// JavaScript Document

	var funcoes = {
		limparcampos: function(theForm, ids){
			if (ids != ''){
				if(document.getElementById(ids).type == 'text')
					document.getElementById(ids).value = '';
				
				if(document.getElementById(ids).type == 'checkbox')
					document.getElementById(ids).checked = false;
					
				if(document.getElementById(ids).type == 'radio')
					document.getElementById(ids).checked = false;
					
				if(document.getElementById(ids).type == 'password')
					document.getElementById(ids).value = '';
					
				if(document.getElementById(ids).type == 'select-one')
					document.getElementById(ids).selectIndex = -1;
			}
			else{
				for (var i=0; i < theForm.elements.length; i++) {
					if(theForm.elements[i].type == 'text')
						theForm.elements[i].value = '';
					
					if(theForm.elements[i].type == 'checkbox')
						theForm.elements[i].checked = false;
						
					if(theForm.elements[i].type == 'radio')
						theForm.elements[i].checked = false;
						
					if(theForm.elements[i].type == 'password')
						theForm.elements[i].value = '';
						
					if(theForm.elements[i].type == 'select-one')
						theForm.elements[i].selectIndex = -1;
				}
			}
		}
	}


	function FormataCPF(Campo, teclapres){
		if(navigator.appName=="Microsoft Internet Explorer"){
			var tecla = teclapres.keyCode;
			
			var vr = new String(Campo.value);
			vr = vr.replace(".", "");
			vr = vr.replace(".", "");
			vr = vr.replace("-", "");
			
			tam = vr.length + 1;
			
			if (tecla != 9 && tecla != 8){
				if (tam > 3 && tam < 7)
					Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);
				if (tam >= 7 && tam <10)
					Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
				if (tam >= 10 && tam < 12)
					Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
			}
		}
		else if (navigator.appName=="Netscape"){
			var tecla = teclapres.charCode;
			
			var vr = new String(Campo.value);
			vr = vr.replace(".", "");
			vr = vr.replace(".", "");
			vr = vr.replace("-", "");
			
			tam = vr.length + 1;
			
			if (tecla != 9 && tecla != 8){
				if (tam > 3 && tam < 7)
					Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);
				if (tam >= 7 && tam <10)
					Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
				if (tam >= 10 && tam < 12)
					Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
			}
		}
	}




	function FormataCNPJ(Campo, teclapres){
		if(navigator.appName=="Microsoft Internet Explorer"){
			var tecla = teclapres.keyCode;
			var vr = new String(Campo.value);
			if (vr != ''){
				vr = vr.replace(".", "");
				vr = vr.replace(".", "");
				vr = vr.replace("/", "");
				vr = vr.replace("-", "");
				tam = vr.length + 1 ;
				if (tecla != 9 && tecla != 8){
					if (tam > 2 && tam < 6)
					 Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
					if (tam >= 6 && tam < 9)
					 Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
					if (tam >= 9 && tam < 13)
					 Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
					if (tam >= 13 && tam < 15)
					 Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12, tam-12);
				}
			}
		}
		else if (navigator.appName=="Netscape"){
			var tecla = teclapres.charCode;
			var vr = new String(Campo.value);
			if (vr != ''){
				vr = vr.replace(".", "");
				vr = vr.replace(".", "");
				vr = vr.replace("/", "");
				vr = vr.replace("-", "");
				tam = vr.length + 1 ;
				if (tecla != 9 && tecla != 8){
					if (tam > 2 && tam < 6)
					 Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
					if (tam >= 6 && tam < 9)
					 Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
					if (tam >= 9 && tam < 13)
					 Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
					if (tam >= 13 && tam < 15)
					 Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
				}
			}
		}
	}
	
	function FormataCEP(campo, teclaPress){
		var tecla = teclaPress.charCode;
		var vr = new String(campo.value);
    	// Remove todos os caracteres ŕ seguir: ( ) / - . e espaço, para tratar a string denovo.
   		vr = vr.replace(".", "");
		vr = vr.replace(".", "");
		vr = vr.replace("/", "");
		vr = vr.replace("-", "");
		tam = vr.length + 1 ;
		if (tecla != 9 && tecla != 8) {
			if (tam > 5 && tam < 7)
                campo.value = vr.substr(0, 5) + '-' + vr.substr(5, tam);
		}
	}



//==========================================================================================================================
// Função Ajax 
//==========================================================================================================================
function ajaxInit()  //Inicia a biblioteca para funcionar o AJAX
{
	var req;
	try
    {
	    req = new ActiveXObject("Microsoft.XMLHTTP");
	}

        catch(e)
        {
  	        try
            {
	            req = new ActiveXObject("Msxml2.XMLHTTP");
	        }

            catch(ex)
            {
	            try
                {
		            req = new XMLHttpRequest();
		        }

                catch(exc)
		        {
		            alert("Esse Navegador não tem recursos para uso do Ajax! Atualize seu Navegador!");
		            req = null;
		        }
            }
        }

	return req;
}

function CarregaCampo(campo, resposta, pagina){
	ajax = ajaxInit();
	var valor = campo.value;
	var n = campo.name;
	ajax.open("post", pagina, true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	ajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	ajax.setRequestHeader("Pragma", "no-cache");
	ajax.send("'" + n + "'=" + valor);
	
	ajax.onreadystatechange = function() {
		if (ajax.readyState == 1){
			resposta.innerHTML="Carregando...";}
		else if(ajax.readyState == 4){
				if(ajax.status == 200){
					document.getElementById(resposta).innerHTML = ajax.responseText;
				}
				else{alert('Problemas ao consultar as ocorrências! Por favor, contate o T.I. do Freeshop - (11) 3723-5200');}
		}
	}
}

//==========================================================================================================================
// Função Ajax - Nova
//==========================================================================================================================
function createXMLHTTP(){
	try{
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	catch(e){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
			alert(ajax);
		}
	catch(ex){
		try{
			ajax = new XMLHttpRequest();
		}
	catch(exc){
		alert("Esse browser não tem recursos para uso do Ajax");
		ajax = null;
		}
	}
	return ajax;
}

var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
for (var i=0; i < arrSignatures.length; i++){
	try{
		var oRequest = new ActiveXObject(arrSignatures[i]);
		return oRequest;
	} 
	catch (oError){}
	}
	throw new Error("MSXML is not installed on your system.");
}
//==========================================================================================================================


/*
  jsDOMenuBar Version 1.1.1
  Copyright (C) 2004 - 2005 Toh Zhiqiang
  Released on 12 February 2005
  jsDOMenuBar is distributed under the terms of the GNU GPL license
  Refer to license.txt for more informatiom

*/

/*
Get the left position of the menu bar menu.
*/
function getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) { // Private method
  if (x + menuObj.offsetWidth <= getClientWidth()) {
    return x;
  }
  else {
    return x + menuBarItemObj.offsetWidth - menuObj.offsetWidth + getPropIntVal(menuObj, blw) + getPropIntVal(menuObj, brw);
  }
}

/*
Get the top position of the menu bar menu.
*/
function getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) { // Private method
  if (y + menuObj.offsetHeight <= getClientHeight()) {
    return y;
  }
  else {
    if ((ie55 || ie6) && menuBarObj.mode == "static" && pageMode == 0) {
      y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop();
    }
    if ((ie55 || ie6) && menuBarObj.mode == "static" && pageMode == 1) {
      return menuBarItemObj.offsetTop 
           - menuObj.offsetHeight 
           - getPropIntVal(menuBarObj, pt) 
           + getPropIntVal(menuBarItemObj, pt) 
           + getPropIntVal(menuBarItemObj, btw) 
           - getScrollTop();
    }
    else {
      return y - menuObj.offsetHeight - menuBarObj.offsetHeight;
    }
  }
}

/*
Pop up the menu bar menu.
*/
function popUpMenuBarMenu(menuBarObj, menuBarItemObj, menuObj) { // Private method
  var x;
  var y;
  if (menuBarObj.style.position == "fixed") {
    x = menuBarObj.offsetLeft + menuBarItemObj.offsetLeft + getPropIntVal(menuBarObj, blw) - getPropIntVal(menuObj, blw);
    y = menuBarObj.offsetTop + menuBarObj.offsetHeight;
    if (opera || safari) {
      x -= getPropIntVal(menuBarObj, blw);
    }
    menuObj.style.position = "absolute";
    menuObj.style.left = getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + px;
    menuObj.style.top = getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) + px;
    menuObj.style.position = "fixed";
  }
  else {
    if (menuBarObj.mode == "static") {
      x = menuBarItemObj.offsetLeft - getPropIntVal(menuObj, blw) - getScrollLeft();
      y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop();
      if (ie55 || ie6) {
        x += getPropIntVal(menuBarObj, blw);
        y = menuBarItemObj.offsetTop + menuBarItemObj.offsetHeight 
          + getPropIntVal(menuBarObj, bbw) 
          + getPropIntVal(menuBarObj, pb) 
          - getPropIntVal(menuBarItemObj, bbw) 
          - getScrollTop();
      }
      if (safari) {
        x += 8;
        y += 13;
      }
      menuObj.style.left = (getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + getScrollLeft()) + px;
      menuObj.style.top = (getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) + getScrollTop()) + px;
    }
    else {
      x = menuBarObj.offsetLeft + menuBarItemObj.offsetLeft + getPropIntVal(menuBarObj, blw) - getPropIntVal(menuObj, blw) - getScrollLeft();
      y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop();
      if (opera || safari) {
        x -= getPropIntVal(menuBarObj, blw);
      }
      menuObj.style.left = (getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + getScrollLeft()) + px;
      menuObj.style.top = (getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) + getScrollTop()) + px;
    }
  }
  if (ie && menuObj.mode == "fixed") {
    menuObj.initialLeft = parseInt(menuObj.style.left) - getScrollLeft();
    menuObj.initialTop = parseInt(menuObj.style.top) - getScrollTop();
  }
  menuObj.style.visibility = "visible";
}

/*
Refresh the menu bar items.
*/
function refreshMenuBarItems(menuBarObj) { // Private method
  for (var i = 0, len = menuBarObj.childNodes.length; i < len; i++) {
    if (menuBarObj.childNodes[i].enabled && menuBarObj.childNodes[i].clicked) {
      menuBarObj.childNodes[i].className = menuBarObj.childNodes[i].itemClassName;
      if (menuBarObj.childNodes[i].iconObj) {
        menuBarObj.childNodes[i].iconObj.className = menuBarObj.childNodes[i].iconClassName;
      }
      menuBarObj.childNodes[i].clicked = false;
      if (menuBarObj.childNodes[i].menu) {
        hideMenus(menuBarObj.childNodes[i].menu.menuObj);
      }
      break;
    }
  }
  menuBarObj.activated = false;
}

/*
Event handler that handles onmouseover event of the menu bar item.
*/
function menuBarItemOver(e) { // Private method
  if (this.parent.menuBarObj.activated) {
    if (!this.clicked) {
      var menuBarObj = this.parent.menuBarObj;
      for (var i = 0, len = menuBarObj.childNodes.length; i < len; i++) {
        if (menuBarObj.childNodes[i].enabled && menuBarObj.childNodes[i].clicked) {
          menuBarObj.childNodes[i].className = menuBarObj.childNodes[i].itemClassName;
          if (menuBarObj.childNodes[i].iconObj) {
            menuBarObj.childNodes[i].iconObj.className = menuBarObj.childNodes[i].iconClassName;
          }
          menuBarObj.childNodes[i].clicked = false;
          if (menuBarObj.childNodes[i].menu) {
            hideMenus(menuBarObj.childNodes[i].menu.menuObj);
          }
          break;
        }
      }
      if (this.enabled) {
        if (this.menu) {
          this.onclick(e);
        }
        else {
          if (this.actionOnClick) {
            this.className = this.itemClassNameClick;
            if (this.iconObj && this.iconClassNameClick) {
              this.iconObj.className = this.iconClassNameClick;
            }
            this.clicked = true;
          }
        }
      }
    }
  }
  else {
    var menuBarObj = this.parent.menuBarObj;
    for (var i = 0, len = menuBarObj.childNodes.length; i < len; i++) {
      if (menuBarObj.childNodes[i].enabled) {
        menuBarObj.childNodes[i].className = menuBarObj.childNodes[i].itemClassName;
        if (menuBarObj.childNodes[i].iconObj) {
          menuBarObj.childNodes[i].iconObj.className = menuBarObj.childNodes[i].iconClassName;
        }
      }
    }
    if (this.enabled && (this.menu || this.actionOnClick)) {
      switch (menuBarObj.activateMode) {
        case "click":
          this.className = this.itemClassNameOver;
          break;
        case "over":
          if (this.menu) {
            this.onclick(e);
          }
          else {
            this.className = this.itemClassNameOver;
          }
          break;
      }
      if (this.iconObj && this.iconClassNameOver) {
        this.iconObj.className = this.iconClassNameOver;
      }
    }
  }
}

/*
Event handler that handles onclick event of the menu bar item.
*/
function menuBarItemClick(e) { // Private method
  if (this.enabled) {
    if (this.menu) {
      if (this.clicked) {
        this.className = this.itemClassNameOver;
        if (this.iconObj) {
          this.iconObj.className = this.iconClassNameOver;
        }
        hideMenus(this.menu.menuObj);
        this.clicked = false;
        this.parent.menuBarObj.activated = false;
      }
      else {
        this.className = this.itemClassNameClick;
        if (this.iconObj && this.iconClassNameClick) {
          this.iconObj.className = this.iconClassNameClick;
        }
        popUpMenuBarMenu(this.parent.menuBarObj, this, this.menu.menuObj);
        this.clicked = true;
        this.parent.menuBarObj.activated = true;
      }
    }
    else {
      if (this.actionOnClick) {
        var action = this.actionOnClick;
        if (action.indexOf("link:") == 0) {
          location.href = action.substr(5);
        }
        else {
          if (action.indexOf("code:") == 0) {
            eval(action.substr(5));
          }
          else {
            location.href = action;
          }
        }
        this.className = this.itemClassName;
        if (this.iconObj) {
          this.iconObj.className = this.iconClassName;
        }
        this.clicked = false;
        this.parent.menuBarObj.activated = false;
      }
    }
  }
  if (!e) {
    var e = window.event;
    e.cancelBubble = true;
  }
  if (e.stopPropagation) {
    e.stopPropagation();
  }
}

/*
Event handler that handles onmouseout event of the menu bar item.
*/
function menuBarItemOut() { // Private method
  if (!this.parent.menuBarObj.activated) {
    this.className = this.itemClassName;
    if (this.iconObj) {
      this.iconObj.className = this.iconClassName;
    }
  }
}

/*
Event handler that handles onmousedown event of the menu bar.
*/
function menuBarDown(e) { // Private method
  draggingObj = this.parent.menuBarObj;
  var menuBarObj = this.parent.menuBarObj;
  menuBarObj.differenceLeft = getX(e) - menuBarObj.offsetLeft;
  menuBarObj.differenceTop = getY(e) - menuBarObj.offsetTop;
  hideMenuBarMenus();
  document.onmousemove = mouseMoveHandler;
}

/*
Event handler that handles onmouseup event of the menu bar.
*/
function menuBarUp() { // Private method
  draggingObj = null;
  var menuBarObj = this.parent.menuBarObj;
  menuBarObj.differenceLeft = 0;
  menuBarObj.differenceTop = 0;
  menuBarObj.initialLeft = menuBarObj.offsetLeft - getScrollLeft();
  menuBarObj.initialTop = menuBarObj.offsetTop - getScrollTop();
  document.onmousemove = null;
}

/*
Event handler that handles mouse move event.
*/
function mouseMoveHandler(e) { // Private method
  if (draggingObj) {
    draggingObj.style.left = (getX(e) - draggingObj.differenceLeft) + px;
    draggingObj.style.top = (getY(e) - draggingObj.differenceTop) + px;
  }
}

/*
Event handler that handles scroll event.
*/
function menuBarScrollHandler() { // Private method
  for (var i = 1; i <= menuBarCount; i++) {
    var menuBarObj = getElmId("DOMenuBar" + i);
    if (ie && menuBarObj.mode == "fixed") {
      menuBarObj.style.left = (menuBarObj.initialLeft + getScrollLeft()) + px;
      menuBarObj.style.top = (menuBarObj.initialTop + getScrollTop()) + px;
    }
  }
}

/*
Hide all menu bar menus.
*/
function hideMenuBarMenus() { // Public method
  for (var i = 1; i <= menuBarCount; i++) {
    refreshMenuBarItems(getElmId("DOMenuBar" + i));
  }
}

/*
Show the icon before the display text.
Arguments:
className          : Required. String that specifies the CSS class selector for the icon.
classNameOver      : Optional. String that specifies the CSS class selector for the icon when 
                     the cursor is over the menu bar item.
classNameClick     : Optional. String that specifies the CSS class selector for the icon when 
                     the cursor is clicked on the menu bar item.
*/
function showMenuBarItemIcon() { // Public method
  var iconElm = createElm("span");
  var textNode = document.createTextNode("");
  iconElm.appendChild(textNode);
  iconElm.id = this.id + "Icon";
  iconElm.className = arguments[0];
  this.insertBefore(iconElm, this.firstChild);
  var height;
  var offsetHeight;
  var menuBarObj = this.parent.menuBarObj;
  var offset = getPropIntVal(menuBarObj, btw)  
             + getPropIntVal(this, pt) 
             - getPropIntVal(menuBarObj, pb) 
             - getPropIntVal(menuBarObj, bbw) 
             - getPropIntVal(this, pb);
  if (ie55 || ie6) {
    height = getPropIntVal(iconElm, "height");
    offsetHeight = (menuBarObj.mode == "static") ? menuBarObj.offsetHeight + offset : this.offsetHeight + getPropIntVal(this, pt) - getPropIntVal(this, pb);
  }
  else {
    height = iconElm.offsetHeight;
    offsetHeight = this.offsetHeight;
  }
  iconElm.style.top = Math.floor((offsetHeight - height) / 2) + px;
  if (opera && this.parent.menuBarObj.mode != "static") {
    iconElm.style.display = "none";
  }
  this.iconClassName = iconElm.className;
  var len = arguments.length;
  if (len > 1 && arguments[1].length > 0) {
    this.iconClassNameOver = arguments[1];
  }
  if (len > 2 && arguments[2].length > 0) {
    this.iconClassNameClick = arguments[2];
  }
  this.iconObj = iconElm;
  this.setIconClassName = function(className) { // Public method
    if (opera && this.parent.menuBarObj.mode != "static") {
      return;
    }
    this.iconClassName = className;
    this.iconObj.className = this.iconClassName;
  };
  this.setIconClassNameOver = function(classNameOver) { // Public method
    if (opera && this.parent.menuBarObj.mode != "static") {
      return;
    }
    this.iconClassNameOver = classNameOver;
  };
  this.setIconClassNameClick = function(classNameClick) { // Public method
    if (opera && this.parent.menuBarObj.mode != "static") {
      return;
    }
    this.iconClassNameClick = classNameClick;
  };
}

/*
Add a new menu bar item to the menu bar.
Argument:
menuBarItemObj     : Required. Menu bar item object that is going to be added to the menu bar 
                     object.
*/
function addMenuBarItem(menuBarItemObj) { // Public method
  var itemElm = createElm("span");
  itemElm.id = menuBarItemObj.id;
  itemElm.menu = menuBarItemObj.menu;
  itemElm.enabled = menuBarItemObj.enabled;
  itemElm.clicked = false;
  itemElm.actionOnClick = menuBarItemObj.actionOnClick;
  itemElm.itemClassName = menuBarItemObj.className;
  itemElm.itemClassNameOver = menuBarItemObj.classNameOver;
  itemElm.itemClassNameClick = menuBarItemObj.classNameClick;
  itemElm.className = itemElm.itemClassName;
  if (ie50) {
    itemElm.style.height = "1%";
  }
  if (ie55) {
    itemElm.style.width = "auto";
  }
  var textNode = document.createTextNode(menuBarItemObj.displayText);
  itemElm.appendChild(textNode);
  this.menuBarObj.appendChild(itemElm);
  itemElm.parent = this;
  itemElm.setClassName = function(className) { // Public method
    this.itemClassName = className;
    this.className = this.itemClassName;
  };
  itemElm.setClassNameOver = function(classNameOver) { // Public method
    this.itemClassNameOver = classNameOver;
  };
  itemElm.setClassNameClick = function(classNameClick) { // Public method
    this.itemClassNameClick = classNameClick;
  };
  itemElm.setDisplayText = function(text) { // Public method
    if (this.childNodes[0].nodeType == 3) {
      this.childNodes[0].nodeValue = text;
    }
    else {
      this.childNodes[1].nodeValue = text;
    }
  };
  itemElm.setMenu = function(menu) { // Public method
    this.menu = menu;
  };
  itemElm.showIcon = showMenuBarItemIcon;
  itemElm.onmouseover = menuBarItemOver;
  itemElm.onclick = menuBarItemClick;
  itemElm.onmouseout = menuBarItemOut;
  if (menuBarItemObj.itemName.length > 0) {
    this.items[menuBarItemObj.itemName] = itemElm;
  }
  else {
    this.items[this.items.length] = itemElm;
  }
  var len = 0;
  for (var x in this.items) {
    ++len;
  }
  if (len == 1 && opera && pageMode == 0) {
    this.dragObj.style.height = (this.dragObj.offsetTop - itemElm.offsetTop) + px;
  }
}

/*
Create a new menu bar item object.
Arguments:
displayText        : Required. String that specifies the text to be displayed on the menu bar item.
menuObj            : Optional. Menu object that is going to be the main menu for the menu bar item. 
                     Defaults to null (no menu).
itemName           : Optional. String that specifies the name of the menu bar item. Defaults to "" 
                     (no name).
enabled            : Optional. Boolean that specifies whether the menu bar item is enabled/disabled. 
                     Defaults to true.
actionOnClick      : Optional. String that specifies the action to be done when the menu item is 
                     being clicked if no main menu has been set for the menu bar item. Defaults to 
                     "" (no action).
className          : Optional. String that specifies the CSS class selector for the menu bar item. 
                     Defaults to "jsdomenubaritem".
classNameOver      : Optional. String that specifies the CSS class selector for the menu item when 
                     the cursor is over it. Defaults to "jsdomenubaritemover".
classNameClick     : Optional. String that specifies the CSS class selector for the menu item when 
                     the cursor is clicked on it. Defaults to "jsdomenubaritemclick".
*/
function menuBarItem() { // Public method
  this.displayText = arguments[0];
  this.id = "menuBarItem" + (++menuBarItemCount);
  this.itemName = "";
  this.menu = null;
  this.enabled = true;
  this.actionOnClick = "";
  this.className = menuBarItemClassName;
  this.classNameOver = menuBarItemClassNameOver;
  this.classNameClick = menuBarItemClassNameClick;
  var len = arguments.length;
  if (len > 1 && typeof(arguments[1]) == "object") {
    this.menu = arguments[1];
  }
  if (len > 2 && arguments[2].length > 0) {
    this.itemName = arguments[2];
  }
  if (len > 3 && typeof(arguments[3]) == "boolean") {
    this.enabled = arguments[3];
  }
  if (len > 4 && arguments[4].length > 0) {
    this.actionOnClick = arguments[4];
  }
  if (len > 5 && arguments[5].length > 0) {
    this.className = arguments[5];
  }
  if (len > 6 && arguments[6].length > 0) {
    this.classNameOver = arguments[6];
  }
  if (len > 7 && arguments[7].length > 0) {
    this.classNameClick = arguments[7];
  }
}

/*
Create a new menu bar object.
Arguments:
mode               : Optional. String that specifies the mode of the menu bar. Defaults to "absolute".
id                 : Optional, except when mode = "static". String that specifies the id of 
                     the element that will contain the menu bar. This argument is required when 
                     mode = "static".
draggable          : Optional. Boolean that specifies whether the menu bar is draggable. Defaults to 
                     false.
className          : Optional. String that specifies the CSS class selector for the menu bar. Defaults 
                     to "jsdomenubardiv".
width              : Optional. Integer that specifies the width of the menu bar. Defaults to "auto".
height             : Optional. Integer that specifies the height of the menu bar. Defaults to "auto".
*/
function jsDOMenuBar() { // Public method
  this.items = new Array();
  var dragElm = createElm("span");
  dragElm.className = menuBarDragClassName;
  var textNode = document.createTextNode("");
  dragElm.appendChild(textNode);
  var menuBarElm;
  var len = arguments.length;
  if (len > 1 && arguments[1].length > 0 && arguments[0] == "static") {
    menuBarElm = getElmId(arguments[1]);
    if (!menuBarElm) {
      return;
    }
    staticMenuBarId[staticMenuBarId.length] = arguments[1];
    menuBarElm.appendChild(dragElm);
  }
  else {
    menuBarElm = createElm("div");
    menuBarElm.appendChild(dragElm);
    menuBarElm.id = "DOMenuBar" + (++menuBarCount);
  }
  menuBarElm.mode = menuBarMode;
  menuBarElm.activateMode = menuBarActivateMode;
  menuBarElm.draggable = false;
  menuBarElm.className = menuBarClassName;
  menuBarElm.activated = false;
  menuBarElm.initialLeft = 0;
  menuBarElm.initialTop = 0;
  menuBarElm.differenceLeft = 0;
  menuBarElm.differenceTop = 0;
  if (len > 0 && arguments[0].length > 0) {
    switch (arguments[0]) {
      case "absolute":
        menuBarElm.style.position = "absolute";
        menuBarElm.mode = "absolute";
        break;
      case "fixed":
        if (ie) {
          menuBarElm.style.position = "absolute";
        }
        else {
          menuBarElm.style.position = "fixed";
        }
        menuBarElm.mode = "fixed";
        break;
      case "static":
        menuBarElm.style.position = "static";
        menuBarElm.mode = "static";
        break;
    }
  }
  if (len > 2 && typeof(arguments[2]) == "boolean") {
    menuBarElm.draggable = arguments[2];
    if (menuBarElm.draggable) {
      dragElm.style.visibility = "visible";
    }
    else {
      dragElm.style.visibility = "hidden";
    }
  }
  if (len > 3 && arguments[3].length > 0) {
    menuBarElm.className = arguments[3];
  }
  if (len > 4 && typeof(arguments[4]) == "number" && arguments[4] > 0) {
    menuBarElm.style.width = arguments[4] + px;
  }
  if (len > 5 && typeof(arguments[5]) == "number" && arguments[5] > 0) {
    menuBarElm.style.height = arguments[5] + px;
  }
  menuBarElm.style.left = "0px";
  menuBarElm.style.top = "0px";
  if (ie50) {
    menuBarElm.style.height = "1%";
  }
  
  if (menuBarElm.mode != "static") {
    document.body.appendChild(menuBarElm);
  }
  else {
    if (ie) {
      menuBarElm.style.height = "1%";
    }
  }
  if (!getPropVal(menuBarElm, blw)) {
    menuBarElm.style.borderWidth = menuBarBorderWidth + px;
  }
  this.menuBarObj = menuBarElm;
  this.dragObj = dragElm;
  dragElm.parent = this;
  this.addMenuBarItem = addMenuBarItem;
  this.menuBarObj.onclick = function(e) { // Private method
    if (!e) {
      var e = window.event;
      e.cancelBubble = true;
    }
    if (e.stopPropagation) {
      e.stopPropagation();
    }
  };
  dragElm.onmousedown = menuBarDown;
  dragElm.onmouseup = menuBarUp;
  this.setMode = function(mode) { // Public method
    switch (mode) {
      case "absolute":
        this.menuBarObj.style.position = "absolute";
        this.menuBarObj.mode = "absolute";
        this.menuBarObj.initialLeft = parseInt(this.menuBarObj.style.left);
        this.menuBarObj.initialTop = parseInt(this.menuBarObj.style.top);
        break;
      case "fixed":
        if (ie) {
          this.menuBarObj.style.position = "absolute";
          this.menuBarObj.initialLeft = parseInt(this.menuBarObj.style.left);
          this.menuBarObj.initialTop = parseInt(this.menuBarObj.style.top);
        }
        else {
          this.menuBarObj.style.position = "fixed";
        }
        this.menuBarObj.mode = "fixed";
        break;
    }
  };
  this.setActivateMode = function(activateMode) { // Public method
    this.menuBarObj.activateMode = activateMode;
  };
  this.setDraggable = function(draggable) { // Public method
    if (typeof(draggable) == "boolean" && this.menuBarObj.mode != "static") {
      this.menuBarObj.draggable = draggable;
      if (this.menuBarObj.draggable) {
        this.dragObj.style.visibility = "visible";
      }
      else {
        this.dragObj.style.visibility = "hidden";
      }
    }
  };
  this.setClassName = function(className) { // Public method
    this.menuBarObj.className = className;
  };
  this.setDragClassName = function(className) { // Public method
    this.dragObj.className = className;
  };
  this.show = function() { // Public method
    this.menuBarObj.style.visibility = "visible";
  };
  this.hide = function() { // Public method
    this.menuBarObj.style.visibility = "hidden";
  };
  this.setX = function(x) { // Public method
    this.menuBarObj.initialLeft = x;
    this.menuBarObj.style.left = x + px;
  };
  this.setY = function(y) { // Public method
    this.menuBarObj.initialTop = y;
    this.menuBarObj.style.top = y + px;
  };
  this.moveTo = function(x, y) { // Public method
    this.menuBarObj.initialLeft = x;
    this.menuBarObj.initialTop = y;
    this.menuBarObj.style.left = x + px;
    this.menuBarObj.style.top = y + px;
  };
  this.moveBy = function(x, y) { // Public method
    var left = parseInt(this.menuBarObj.style.left);
    var top = parseInt(this.menuBarObj.style.top);
    this.menuBarObj.initialLeft = left + x;
    this.menuBarObj.initialTop = top + y;
    this.menuBarObj.style.left = (left + x) + px;
    this.menuBarObj.style.top = (top + y) + px;
  };
  this.setBorderWidth = function(width) { // Public method
    this.menuBarObj.style.borderWidth = width + px;
  };
}

if (typeof(menuBarClassName) == "undefined") {
  var menuBarClassName = "jsdomenubardiv"; // Public field
}

if (typeof(menuBarItemClassName) == "undefined") {
  var menuBarItemClassName = "jsdomenubaritem"; // Public field
}

if (typeof(menuBarItemClassNameOver) == "undefined") {
  var menuBarItemClassNameOver = "jsdomenubaritemover"; // Public field
}

if (typeof(menuBarItemClassNameClick) == "undefined") {
  var menuBarItemClassNameClick = "jsdomenubaritemclick"; // Public field
}

if (typeof(menuBarDragClassName) == "undefined") {
  var menuBarDragClassName = "jsdomenubardragdiv"; // Public field
}

if (typeof(menuBarMode) == "undefined") {
  var menuBarMode = "absolute"; // Public field
}

if (typeof(menuBarActivateMode) == "undefined") {
  //var menuBarActivateMode = "click"; // Public field
  var menuBarActivateMode = "over"; // Public field
}

if (typeof(menuBarBorderWidth) == "undefined") {
  var menuBarBorderWidth = 2; // Public field
}

var pt = "padding-top"; // Private field
var pb = "padding-bottom"; // Private field
var menuBarCount = 0; // Private field
var menuBarItemCount = 0; // Private field
var draggingObj = null; // Private field
var staticMenuBarId = new Array(); // Private field


/*

  jsDOMenu Version 1.3.1
  Copyright (C) 2003 - 2005 Toh Zhiqiang
  Released on 12 February 2005
  jsDOMenu is distributed under the terms of the GNU GPL license
  Refer to license.txt for more informatiom

*/

/*
Determine whether the browser is IE5.0.
*/
function isIE50() { // Private method
  return isIE5() && !isIE55();
}

/*
Determine whether the browser is IE5.5.
*/
function isIE55() { // Private method
  return navigator.userAgent.indexOf("MSIE 5.5") > -1;
}

/*
Determine whether the browser is IE5.0 or IE5.5.
*/
function isIE5() { // Private method
  return navigator.userAgent.indexOf("MSIE 5") > -1;
}

/*
Determine whether the browser is IE6.
*/
function isIE6() { // Private method
  return navigator.userAgent.indexOf("MSIE 6") > -1 && navigator.userAgent.indexOf("Opera") == -1;
}

/*
Determine whether the browser is IE.
*/
function isIE() { // Private method
  return isIE5() || isIE6();
}

/*
Determine whether the browser is Opera.
*/
function isOpera() { // Private method
  return navigator.userAgent.indexOf("Opera") > -1;
}

/* 
Determine whether the browser is Safari.
*/
function isSafari() { // Private method
  return navigator.userAgent.indexOf("Safari") > -1;
}

/*
Determine the page render mode.

0: Quirks mode.
1: Strict mode.
*/
function getPageMode() { // Private method
  if (document.compatMode) {
    switch (document.compatMode) {
      case "BackCompat":
        return 0;
      case "CSS1Compat":
        return 1;
      case "QuirksMode":
        return 0;
    }
  }
  else {
    if (ie5) {
      return 0;
    }
    if (safari) {
      return 1;
    }
  }
  return 0;
}

/*
Alias for document.getElementById().
*/
function getElmId(id) { // Private method
  return document.getElementById(id);
}

/*
Alias for document.createElement().
*/
function createElm(tagName) { // Private method
  return document.createElement(tagName);
}

/*
Get the x-coordinate of the cursor position relative to the window.
*/
function getX(e) { // Private method
  if (!e) {
    var e = window.event;
  }
  if (safari) {
    return e.clientX - getScrollLeft();
  }
  else {
    return e.clientX;
  }
}

/*
Get the y-coordinate of the cursor position relative to the window.
*/
function getY(e) { // Private method
  if (!e) {
    var e = window.event;
  }
  if (safari) {
    return e.clientY - getScrollTop();
  }
  else {
    return e.clientY;
  }
}

/*
Get the scrollLeft property.
*/
function getScrollLeft() { // Private method
  switch (pageMode) {
    case 0:
      return document.body.scrollLeft;
    case 1:
      if (document.documentElement && document.documentElement.scrollLeft > 0) {
        return document.documentElement.scrollLeft;
      }
      else {
        return document.body.scrollLeft;
      }
  }
}

/*
Get the scrollTop property.
*/
function getScrollTop() { // Private method
  switch (pageMode) {
    case 0:
      return document.body.scrollTop;
    case 1:
      if (document.documentElement && document.documentElement.scrollTop > 0) {
        return document.documentElement.scrollTop;
      }
      else {
        return document.body.scrollTop;
      }
  }
}

/*
Get the clientHeight property.
*/
function getClientHeight() { // Private method
  switch (pageMode) {
    case 0:
      return document.body.clientHeight;
    case 1:
      if (safari) {
        return self.innerHeight;
      }
      else {
        if (!opera && document.documentElement && document.documentElement.clientHeight > 0) {
          return document.documentElement.clientHeight;
        }
        else {
          return document.body.clientHeight;
        }
      }
  }
}

/*
Get the clientWidth property.
*/
function getClientWidth() { // Private method
  switch (pageMode) {
    case 0:
      return document.body.clientWidth;
    case 1:
      if (safari) {
        return self.innerWidth;
      }
      else {
        if (!opera && document.documentElement && document.documentElement.clientWidth > 0) {
          return document.documentElement.clientWidth;
        }
        else {
          return document.body.clientWidth;
        }
      }
  }
}

/*
Convert the string into lower camel case.
*/
function toCamelCase(input) { // Private method
  var inputArray = input.split("-");
  if (inputArray.length == 1) {
    return inputArray[0];
  }
  else {
    var camelCase = inputArray[0];
    for (var i = 1, len = inputArray.length; i < len; i++) {
      camelCase += inputArray[i].charAt(0).toUpperCase() + inputArray[i].substring(1);
    }
    return camelCase;
  }
}

/*
Get the value of the property of the object.
*/
function getPropVal(obj, propertyName) { // Private method
  var propertyValue = obj.style[toCamelCase(propertyName)];
  if (propertyValue) {
    return propertyValue;
  }
  else {
    if (document.defaultView && document.defaultView.getComputedStyle) {
      return document.defaultView.getComputedStyle(obj, null).getPropertyValue(propertyName);
    }
    else {
      if (obj.currentStyle) {
        return obj.currentStyle[toCamelCase(propertyName)];
      }
      else {
        return null;
      }
    }
  }
}

/*
Get the integer value of the property of the object.
*/
function getPropIntVal(obj, propertyName) { // Private method
  return parseInt(getPropVal(obj, propertyName));
}

/*
Get the left position of the pop-up menu.
*/
function getMainMenuLeftPos(menuObj, x) { // Private method
  if (x + menuObj.offsetWidth <= getClientWidth()) {
    return x;
  }
  else {
    return x - menuObj.offsetWidth;
  }
}

/*
Get the top position of the pop-up menu.
*/
function getMainMenuTopPos(menuObj, y) { // Private method
  if (y + menuObj.offsetHeight <= getClientHeight()) {
    return y;
  }
  else {
    return y - menuObj.offsetHeight;
  }
}

/*
Get the left position of the submenu.
*/
function getSubMenuLeftPos(menuObj, x, offset) { // Private method
  if (x + menuObj.offsetWidth - 2 <= getClientWidth()) {
    return x - 2;
  }
  else {
    return x - menuObj.offsetWidth - offset;
  }
}

/*
Get the top position of the submenu.
*/
function getSubMenuTopPos(menuObj, y, offset) { // Private method
  var top = getPropIntVal(menuObj, btw);
  var bottom = getPropIntVal(menuObj, bbw);
  if (y + menuObj.offsetHeight <= getClientHeight()) {
    if (safari) {
      return y - top;
    }
    else {
      return y;
    }
  }
  else {
    if (safari) {
      return y - menuObj.offsetHeight + offset + bottom;
    }
    else {
      return y - menuObj.offsetHeight + offset + top + bottom;
    }
  }
}

/*
Pop up the submenu.
*/
function popUpSubMenu(menuItemObj) { // Private method
  var parentMenuObj = menuItemObj.parent.menuObj;
  var menuObj = menuItemObj.subMenu.menuObj;
  var x;
  var y;
  if (parentMenuObj.style.position == "fixed") {
    x = parentMenuObj.offsetLeft + parentMenuObj.offsetWidth - getPropIntVal(parentMenuObj, brw);
    y = parentMenuObj.offsetTop + menuItemObj.offsetTop + getPropIntVal(parentMenuObj, btw) - getPropIntVal(menuObj, btw);
    menuObj.style.position = "absolute";
    menuObj.style.left = getSubMenuLeftPos(menuObj, x, menuItemObj.offsetWidth) + px;
    menuObj.style.top = getSubMenuTopPos(menuObj, y, menuItemObj.offsetHeight) + px;
    menuObj.style.position = "fixed";
  }
  else {
    if (parentMenuObj.mode == "static" && !ie50) {
      x = menuItemObj.offsetLeft + parentMenuObj.offsetWidth - getPropIntVal(parentMenuObj, blw) - getPropIntVal(parentMenuObj, brw) - getScrollLeft();
      y = menuItemObj.offsetTop - getPropIntVal(menuObj, btw) - getScrollTop();
      if (ie55 || ie6) {
          x += getPropIntVal(parentMenuObj, blw);
          y += getPropIntVal(parentMenuObj, btw);
      }
      if (safari) {
        x += 8;
        y += getPropIntVal(menuObj, btw) + 13;
      }
      menuObj.style.left = (getSubMenuLeftPos(menuObj, x, menuItemObj.offsetWidth) + getScrollLeft()) + px;
      menuObj.style.top = (getSubMenuTopPos(menuObj, y, menuItemObj.offsetHeight) + getScrollTop()) + px;
    }
    else {
      x = parentMenuObj.offsetLeft + parentMenuObj.offsetWidth - getPropIntVal(parentMenuObj, brw) - getScrollLeft();
      y = parentMenuObj.offsetTop + menuItemObj.offsetTop + getPropIntVal(parentMenuObj, btw) - getPropIntVal(menuObj, btw) - getScrollTop();
      menuObj.style.left = (getSubMenuLeftPos(menuObj, x, menuItemObj.offsetWidth) + getScrollLeft()) + px;
      menuObj.style.top = (getSubMenuTopPos(menuObj, y, menuItemObj.offsetHeight) + getScrollTop()) + px;
    }
  }
  if (ie && menuObj.mode == "fixed") {
    menuObj.initialLeft = parseInt(menuObj.style.left) - getScrollLeft();
    menuObj.initialTop = parseInt(menuObj.style.top) - getScrollTop();
  }
  menuObj.style.visibility = "visible";
}

/*
Pop up the main menu.
*/
function popUpMainMenu(menuObj, e) { // Private method
  menuObj.style.left = (getMainMenuLeftPos(menuObj, getX(e)) + getScrollLeft()) + px;
  menuObj.style.top = (getMainMenuTopPos(menuObj, getY(e)) + getScrollTop()) + px;
  var display = popUpMenuObj.menuObj.style.display;
  popUpMenuObj.menuObj.style.display = "none";
  popUpMenuObj.menuObj.style.visibility = "visible";
  popUpMenuObj.menuObj.style.display = display;
}

/*
Refresh the menu items.
*/
function refreshMenuItems(menuObj) { // Private method
  for (var i = 0, len = menuObj.childNodes.length; i < len; i++) {
    if (menuObj.childNodes[i].enabled) {
      menuObj.childNodes[i].className = menuObj.childNodes[i].itemClassName;
      if (menuObj.childNodes[i].subMenu) {
        menuObj.childNodes[i].arrowObj.className = menuObj.childNodes[i].arrowClassName;
      }
      if (menuObj.childNodes[i].iconObj) {
        menuObj.childNodes[i].iconObj.className = menuObj.childNodes[i].iconClassName;
      }
    }
  }
}

/*
Event handler that handles onmouseover event of the menu item.
*/
function menuItemOver(e) { // Private method
  var previousItem = this.parent.previousItem;
  if (previousItem) {
    if (previousItem.className == previousItem.itemClassNameOver) {
      previousItem.className = previousItem.itemClassName;
    }
    if (previousItem.subMenu) {
      previousItem.className = previousItem.itemClassName;
      previousItem.arrowObj.className = previousItem.arrowClassName;
      if (previousItem.iconObj) {
        previousItem.iconObj.className = previousItem.iconClassName;
      }
    }
    var menuObj = getElmId(this.parent.menuObj.id);
    for (var i = 0, len = menuObj.childNodes.length; i < len; i++) {
      if (menuObj.childNodes[i].enabled && menuObj.childNodes[i].subMenu) {
        hideMenus(menuObj.childNodes[i].subMenu.menuObj);
      }
    }
  }
  if (this.enabled) {
    this.className = this.itemClassNameOver;
    if (this.subMenu) {
      this.arrowObj.className = this.arrowClassNameOver;
      popUpSubMenu(this);
    }
    if (this.iconObj && this.iconClassNameOver) {
      this.iconObj.className = this.iconClassNameOver;
    }
  }
  this.parent.previousItem = this;
}

/*
Event handler that handles onclick event of the menu item.
*/
function menuItemClick(e) { // Private method
  if (this.enabled && this.actionOnClick) {
    var action = this.actionOnClick;
    if (action.indexOf("link:") == 0) {
      location.href = action.substr(5);
    }
    else {
      if (action.indexOf("code:") == 0) {
        eval(action.substr(5));
      }
      else {
        location.href = action;
      }
    }
  }
  if (!e) {
    var e = window.event;
    e.cancelBubble = true;
  }
  if (e.stopPropagation) {
    e.stopPropagation();
  }
  if (this.parent.menuObj.mode == "cursor") {
    hideCursorMenus();
  }
  if (this.parent.menuObj.mode == "absolute" || this.parent.menuObj.mode == "fixed") {
    hideVisibleMenus();
    if (typeof(hideMenuBarMenus) == "function") {
      hideMenuBarMenus();
    }
  }
}

/*
Event handler that handles onmouseout event of the menu item.
*/
function menuItemOut() { // Private method
  if (this.enabled) {
    if (!(this.subMenu && this.subMenu.menuObj.style.visibility == "visible")) {
      this.className = this.itemClassName;
    }
    if (this.subMenu) {
      if (this.subMenu.menuObj.style.visibility == "visible") {
        this.arrowObj.className = this.arrowClassNameOver;
        if (this.iconObj) {
          this.iconObj.className = this.iconClassNameOver;
        }
      }
    }
    else {
      if (this.iconObj) {
        this.iconObj.className = this.iconClassName;
      }
    }
  }
}

/*
Determine whether any of the tag name/tag id pair in the filter matches the tagName/tagId pair.
*/
function findMatch(tagName, tagId, filter) { // Private method
  for (var i = 0, len = filter.length; i < len; i++) {
    var filterArray = filter[i].toLowerCase().split(".");
    if ((filterArray[0] == "*" && filterArray[1] == "*") || 
        (filterArray[0] == "*" && filterArray[1] == tagId) || 
        (filterArray[0] == tagName && filterArray[1] == "*") || 
        (filterArray[0] == tagName && filterArray[1] == tagId)) {
      return true;
    }
  }
  return false;
}

/*
Determine whether to show or hide the menu.
*/
function canShowMenu(tagName, tagId, allExcept, noneExcept) { // Private method
  if (allExcept.length > 0) {
    return (!findMatch(tagName.toLowerCase(), tagId.toLowerCase(), allExcept));
  }
  else {
    if (noneExcept.length > 0) {
      return findMatch(tagName.toLowerCase(), tagId.toLowerCase(), noneExcept);
    }
    else {
      return true;
    }
  }
}

/*
Shows/Hides the pop-up menu.
*/
function activatePopUpMenu(e) { // Private method
  if (!popUpMenuObj) {
    return;
  }
  var state = popUpMenuObj.menuObj.style.visibility;
  if (state == "visible") {
    for (var i = 1; i <= menuCount; i++) {
      var menuObj = getElmId("DOMenu" + i);
      if (menuObj.mode == "cursor") {
        menuObj.style.visibility = "hidden";
        menuObj.style.left = "0px";
        menuObj.style.top = "0px";
        menuObj.initialLeft = 0;
        menuObj.initialTop = 0;
        refreshMenuItems(menuObj);
      }
    }
  }
  else {
    if (!e) {
      var e = window.event;
    }
    var targetElm = (e.target) ? e.target : e.srcElement;
    if (targetElm.nodeType == 3) {
      targetElm = targetElm.parentNode;
    }
    if (canShowMenu(targetElm.tagName, targetElm.id, popUpMenuObj.menuObj.allExceptFilter, popUpMenuObj.menuObj.noneExceptFilter)) {
      popUpMainMenu(popUpMenuObj.menuObj, e);
    }
  }
}

/*
Event handler that handles left click event.
*/
function leftClickHandler(e) { // Private method
  if (getX(e) > getClientWidth() || getY(e) > getClientHeight()) {
    return;
  }
  if (!e) {
    var e = window.event;
  }
  if (e.button && e.button == 2) {
    return;
  }
  hideVisibleMenus();
  if (typeof(hideMenuBarMenus) == "function") {
    hideMenuBarMenus();
  }
  if (popUpMenuObj) {
    var state = popUpMenuObj.menuObj.style.visibility;
    if (state == "visible" && (hideValue == 0 || hideValue == 2)) {
      activatePopUpMenu(e);
    }
    if ((state == "hidden" || state == "") && (showValue == 0 || showValue == 2)) {
      activatePopUpMenu(e);
    }
  }
}

/*
Event handler that handles right click event.
*/
function rightClickHandler(e) { // Private method
  if (getX(e) > getClientWidth() || getY(e) > getClientHeight()) {
    return;
  }
  hideVisibleMenus();
  if (typeof(hideMenuBarMenus) == "function") {
    hideMenuBarMenus();
  }
  if (popUpMenuObj) {
    var state = popUpMenuObj.menuObj.style.visibility;
    if (state == "visible" && (hideValue == 1 || hideValue == 2)) {
      activatePopUpMenu(e);
      return false;
    }
    if ((state == "hidden" || state == "") && (showValue == 1 || showValue == 2)) {
      activatePopUpMenu(e);
      return false;
    }
  }
}

/*
Event handler that handles scroll event.
*/
function scrollHandler() { // Private method
  for (var i = 1; i <= menuCount; i++) {
      var menuObj = getElmId("DOMenu" + i);
      if (ie && menuObj.mode == "fixed") {
        menuObj.style.left = (menuObj.initialLeft + getScrollLeft()) + px;
        menuObj.style.top = (menuObj.initialTop + getScrollTop()) + px;
      }
  }
  if (typeof(menuBarScrollHandler) == "function") {
    menuBarScrollHandler();
  }
}

/*
Show the icon before the display text.
Arguments:
className          : Required. String that specifies the CSS class selector for the icon.
classNameOver      : Optional. String that specifies the CSS class selector for the icon when 
                     the cursor is over the menu item.
*/
function showMenuItemIcon() { // Public method
  var iconElm = createElm("span");
  iconElm.id = this.id + "Icon";
  iconElm.className = arguments[0];
  this.insertBefore(iconElm, this.firstChild);
  var height;
  if (ie) {
    height = getPropIntVal(iconElm, "height");
  }
  else {
    height = iconElm.offsetHeight;
  }
  iconElm.style.top = Math.floor((this.offsetHeight - height) / 2) + px;
  if (ie) {
    var left = getPropIntVal(iconElm, "left");
    if (ie55 || ie6) {
      iconElm.style.left = (left - getPropIntVal(this, "padding-left")) + px;
    }
    else {
      iconElm.style.left = left + px;
    }
  }
  this.iconClassName = iconElm.className;
  if (arguments.length > 1 && arguments[1].length > 0) {
    this.iconClassNameOver = arguments[1];
  }
  this.iconObj = iconElm;
  this.setIconClassName = function(className) { // Public method
    this.iconClassName = className;
    this.iconObj.className = this.iconClassName;
  };
  this.setIconClassNameOver = function(classNameOver) { // Public method
    this.iconClassNameOver = classNameOver;
  };
}

/*
Set the menu object that will show up when the cursor is over the menu item object.
Argument:
menuObj            : Required. Menu object that will show up when the cursor is over the 
                     menu item object.
*/
function setSubMenu(menuObj) { // Public method
  var arrowElm = createElm("div");
  arrowElm.id = this.id + "Arrow";
  arrowElm.className = this.arrowClassName;
  this.appendChild(arrowElm);
  var height;
  if (ie) {
    height = getPropIntVal(arrowElm, "height");
  }
  else {
    height = arrowElm.offsetHeight;
  }
  arrowElm.style.top = Math.floor((this.offsetHeight - height) / 2) + px;
  this.subMenu = menuObj;
  this.arrowObj = arrowElm;
  this.setArrowClassName = function(className) { // Public method
    this.arrowClassName = className;
    this.arrowObj.className = this.arrowClassName;
  };
  this.setArrowClassNameOver = function(classNameOver) { // Public method
    this.arrowClassNameOver = classNameOver;
  };
  menuObj.menuObj.style.zIndex = this.parent.menuObj.level + 1;
  menuObj.menuObj.level = this.parent.menuObj.level + 1;
}

/*
Add a new menu item to the menu.
Argument:
menuItemObj        : Required. Menu item object that is going to be added to the menu object.
*/
function addMenuItem(menuItemObj) { // Public method
  if (menuItemObj.displayText == "-") {
    var hrElm = createElm("hr");
    var itemElm = createElm("div");
    itemElm.appendChild(hrElm);
    itemElm.id = menuItemObj.id;
    if (menuItemObj.className.length > 0) {
      itemElm.sepClassName = menuItemObj.className;
    }
    else {
      itemElm.sepClassName = menuItemObj.sepClassName;
    }
    itemElm.className = itemElm.sepClassName;
    this.menuObj.appendChild(itemElm);
    itemElm.parent = this;
    itemElm.setClassName = function(className) { // Public method
      this.sepClassName = className;
      this.className = this.sepClassName;
    };
    itemElm.onclick = function(e) { // Private method
      if (!e) {
        var e = window.event;
        e.cancelBubble = true;
      }
      if (e.stopPropagation) {
        e.stopPropagation();
      }
    };
    itemElm.onmouseover = menuItemOver;
    if (menuItemObj.itemName.length > 0) {
      this.items[menuItemObj.itemName] = itemElm;
    }
    else {
      this.items[this.items.length] = itemElm;
    }
  }
  else {
    var itemElm = createElm("div");
    itemElm.id = menuItemObj.id;
    itemElm.actionOnClick = menuItemObj.actionOnClick;
    itemElm.enabled = menuItemObj.enabled;
    itemElm.itemClassName = menuItemObj.className;
    itemElm.itemClassNameOver = menuItemObj.classNameOver;
    itemElm.className = itemElm.itemClassName;
    itemElm.subMenu = null;
    itemElm.arrowClassName = arrowClassName;
    itemElm.arrowClassNameOver = arrowClassNameOver;
    var textNode = document.createTextNode(menuItemObj.displayText);
    itemElm.appendChild(textNode);
    this.menuObj.appendChild(itemElm);
    itemElm.parent = this;
    itemElm.setClassName = function(className) { // Public method
      this.itemClassName = className;
      this.className = this.itemClassName;
    };
    itemElm.setClassNameOver = function(classNameOver) { // Public method
      this.itemClassNameOver = classNameOver;
    };
    itemElm.setDisplayText = function(text) { // Public method
      if (this.childNodes[0].nodeType == 3) {
        this.childNodes[0].nodeValue = text;
      }
      else {
        this.childNodes[1].nodeValue = text;
      }
    };
    itemElm.setSubMenu = setSubMenu;
    itemElm.showIcon = showMenuItemIcon;
    itemElm.onmouseover = menuItemOver;
    itemElm.onclick = menuItemClick;
    itemElm.onmouseout = menuItemOut;
    if (menuItemObj.itemName.length > 0) {
      this.items[menuItemObj.itemName] = itemElm;
    }
    else {
      this.items[this.items.length] = itemElm;
    }
  }
}

/*
Create a new menu item object.
Arguments:
displayText        : Required. String that specifies the text to be displayed on the menu item. If 
                     displayText = "-", a menu separator will be created instead.
itemName           : Optional. String that specifies the name of the menu item. Defaults to "" (no 
                     name).
actionOnClick      : Optional. String that specifies the action to be done when the menu item is 
                     being clicked. Defaults to "" (no action).
enabled            : Optional. Boolean that specifies whether the menu item is enabled/disabled. 
                     Defaults to true.
className          : Optional. String that specifies the CSS class selector for the menu item. 
                     Defaults to "jsdomenuitem".
classNameOver      : Optional. String that specifies the CSS class selector for the menu item when 
                     the cursor is over it. Defaults to "jsdomenuitemover".
*/
function menuItem() { // Public method
  this.displayText = arguments[0];
  if (this.displayText == "-") {
    this.id = "menuSep" + (++sepCount);
    this.className = sepClassName;
  }
  else {
    this.id = "menuItem" + (++menuItemCount);
    this.className = menuItemClassName;
  }
  this.itemName = "";
  this.actionOnClick = "";
  this.enabled = true;
  this.classNameOver = menuItemClassNameOver;
  this.sepClassName = sepClassName;
  var len = arguments.length;
  if (len > 1 && arguments[1].length > 0) {
    this.itemName = arguments[1];
  }
  if (len > 2 && arguments[2].length > 0) {
    this.actionOnClick = arguments[2];
  }
  if (len > 3 && typeof(arguments[3]) == "boolean") {
    this.enabled = arguments[3];
  }
  if (len > 4 && arguments[4].length > 0) {
    if (arguments[4] == "-") {
      this.className = arguments[4];
      this.sepClassName = arguments[4];
    }
    else {
      this.className = arguments[4];
    }
  }
  if (len > 5 && arguments[5].length > 0) {
    this.classNameOver = arguments[5];
  }
}

/*
Create a new menu object.
Arguments:
width              : Required. Integer that specifies the width of the menu.
mode               : Optional. String that specifies the mode of the menu. Defaults to "cursor".
id                 : Optional, except when mode = "static". String that specifies the id of 
                     the element that will contain the menu. This argument is required when 
                     mode = "static".
alwaysVisible      : Optional. Boolean that specifies whether the menu is always visible. Defaults 
                     to false.
className          : Optional. String that specifies the CSS class selector for the menu. Defaults 
                     to "jsdomenudiv".
*/
function jsDOMenu() { // Public method
  this.items = new Array();
  var menuElm;
  var len = arguments.length;
  if (len > 2 && arguments[2].length > 0 && arguments[1] == "static") {
    menuElm = getElmId(arguments[2]);
    if (!menuElm) {
      return;
    }
    staticMenuId[staticMenuId.length] = arguments[2];
  }
  else {
    menuElm = createElm("div");
    menuElm.id = "DOMenu" + (++menuCount);
  }
  menuElm.level = 10;
  menuElm.previousItem = null;
  menuElm.allExceptFilter = allExceptFilter;
  menuElm.noneExceptFilter = noneExceptFilter;
  menuElm.className = menuClassName;
  menuElm.mode = menuMode;
  menuElm.alwaysVisible = false;
  menuElm.initialLeft = 0;
  menuElm.initialTop = 0;
  if (len > 1 && arguments[1].length > 0) {
    switch (arguments[1]) {
      case "cursor":
        menuElm.style.position = "absolute";
        menuMode.mode = "cursor";
        break;
      case "absolute":
        menuElm.style.position = "absolute";
        menuElm.mode = "absolute";
        break;
      case "fixed":
        if (ie) {
          menuElm.style.position = "absolute";
        }
        else {
          menuElm.style.position = "fixed";
        }
        menuElm.mode = "fixed";
        break;
      case "static":
        menuElm.style.position = "static";
        menuElm.mode = "static";
        break;
    }
  }
  if (len > 3 && typeof(arguments[3]) == "boolean") {
    menuElm.alwaysVisible = arguments[3];
  }
  if (len > 4 && arguments[4].length > 0) {
    menuElm.className = arguments[4];
  }
  menuElm.style.width = arguments[0] + px;
  menuElm.style.left = "0px";
  menuElm.style.top = "0px";
  if (menuElm.mode != "static") {
    document.body.appendChild(menuElm);
  }
  if (!getPropVal(menuElm, blw)) {
    menuElm.style.borderWidth = menuBorderWidth + px;
  }
  this.menuObj = menuElm;
  this.addMenuItem = addMenuItem;
  this.setClassName = function(className) { // Public method
    this.menuObj.className = className;
  };
  this.setMode = function(mode) { // Public method
    switch (mode) {
      case "cursor":
        this.menuObj.style.position = "absolute";
        this.menuObj.mode = "cursor";
        break;
      case "absolute":
        this.menuObj.style.position = "absolute";
        this.menuObj.mode = "absolute";
        this.menuObj.initialLeft = parseInt(this.menuObj.style.left);
        this.menuObj.initialTop = parseInt(this.menuObj.style.top);
        break;
      case "fixed":
        if (ie) {
          this.menuObj.style.position = "absolute";
          this.menuObj.initialLeft = parseInt(this.menuObj.style.left);
          this.menuObj.initialTop = parseInt(this.menuObj.style.top);
        }
        else {
          this.menuObj.style.position = "fixed";
        }
        this.menuObj.mode = "fixed";
        break;
    }
  };
  this.setAlwaysVisible = function(alwaysVisible) { // Public method
    if (typeof(alwaysVisible) == "boolean") {
      this.menuObj.alwaysVisible = alwaysVisible;
    }
  };
  this.show = function() { // Public method
    this.menuObj.style.visibility = "visible";
  };
  this.hide = function() { // Public method
    this.menuObj.style.visibility = "hidden";
    if (this.menuObj.mode == "cursor") {
      this.menuObj.style.left = "0px";
      this.menuObj.style.top = "0px";
      this.menuObj.initialLeft = 0;
      this.menuObj.initialTop = 0;
    }
  };
  this.setX = function(x) { // Public method
    this.menuObj.initialLeft = x;
    this.menuObj.style.left = x + px;
  };
  this.setY = function(y) { // Public method
    this.menuObj.initialTop = y;
    this.menuObj.style.top = y + px;
  };
  this.moveTo = function(x, y) { // Public method
    this.menuObj.initialLeft = x;
    this.menuObj.initialTop = y;
    this.menuObj.style.left = x + px;
    this.menuObj.style.top = y + px;
  };
  this.moveBy = function(x, y) { // Public method
    var left = parseInt(this.menuObj.style.left);
    var top = parseInt(this.menuObj.style.top);
    this.menuObj.initialLeft = left + x;
    this.menuObj.initialTop = top + y;
    this.menuObj.style.left = (left + x) + px;
    this.menuObj.style.top = (top + y) + px;
  };
  this.setAllExceptFilter = function(filter) { // Public method
    this.menuObj.allExceptFilter = filter;
    this.menuObj.noneExceptFilter = new Array();
  };
  this.setNoneExceptFilter = function(filter) { // Public method
    this.menuObj.noneExceptFilter = filter;
    this.menuObj.allExceptFilter = new Array();
  };
  this.setBorderWidth = function(width) { // Public method
    this.menuObj.style.borderWidth = width + px;
  };
}

/*
Specifies how the pop-up menu shows/hide.
Arguments:
showValue          : Required. Integer that specifies how the menu shows.
hideValue          : Optional. Integer that specifies how the menu hides. If not specified, the 
                     menu shows/hides in the same manner.

0: Shows/Hides the menu by left click only.
1: Shows/Hides the menu by right click only.
2: Shows/Hides the menu by left or right click.
*/
function activatePopUpMenuBy() { // Public method
  showValue = typeof(arguments[0]) == "number" && arguments[0] > -1 ? arguments[0] : 0;
  if (arguments.length > 1) {
    hideValue = typeof(arguments[1]) == "number" && arguments[1] > -1 ? arguments[1] : 0;
  }
  else {
    hideValue = showValue;
  }
  if (showValue == 1 || showValue == 2 || hideValue == 1 || hideValue == 2) {
    document.oncontextmenu = rightClickHandler;
  }
}

/*
Hide all menus, except those with alwaysVisible = true.
*/
function hideAllMenus() { // Public method
  for (var i = 1; i <= menuCount; i++) {
    var menuObj = getElmId("DOMenu" + i);
    if (!menuObj.alwaysVisible) {
      if (menuObj.style.position == "fixed") {
        menuObj.style.position == "absolute";
        menuObj.style.visibility = "hidden";
        menuObj.style.position == "fixed";
      }
      else {
        menuObj.style.visibility = "hidden";
        if (menuObj.mode == "cursor") {
          menuObj.style.left = "0px";
          menuObj.style.top = "0px";
          menuObj.initialLeft = 0;
          menuObj.initialTop = 0;
        }
      }
    }
    refreshMenuItems(menuObj);
  }
  for (var i = 0, len = staticMenuId.length; i < len; i++) {
    refreshMenuItems(getElmId(staticMenuId[i]));
  }
}

/*
Hide all menus with mode = "cursor", except those with alwaysVisible = true.
*/
function hideCursorMenus() { // Public method
  for (var i = 1; i <= menuCount; i++) {
    var menuObj = getElmId("DOMenu" + i);
    if (menuObj.mode == "cursor" && !menuObj.alwaysVisible) {
      menuObj.style.visibility = "hidden";
      menuObj.style.left = "0px";
      menuObj.style.top = "0px";
      menuObj.initialLeft = 0;
      menuObj.initialTop = 0;
    }
    if (menuObj.mode == "cursor") {
      refreshMenuItems(menuObj);
    }
  }
}

/*
Hide all menus with mode = "absolute" or mode = "fixed" or mode = "static", except those with 
alwaysVisible = true.
*/
function hideVisibleMenus() { // Public method
  for (var i = 1; i <= menuCount; i++) {
    var menuObj = getElmId("DOMenu" + i);
    if ((menuObj.mode == "absolute" || menuObj.mode == "fixed") && !menuObj.alwaysVisible) {
      if (menuObj.style.position == "fixed") {
        menuObj.style.position = "absolute";
        menuObj.style.visibility = "hidden";
        menuObj.style.position = "fixed";
      }
      else {
        menuObj.style.visibility = "hidden";
        menuObj.style.left = "0px";
        menuObj.style.top = "0px";
        menuObj.initialLeft = 0;
        menuObj.initialTop = 0;
      }
    }
    if (menuObj.mode == "absolute" || menuObj.mode == "fixed") {
      refreshMenuItems(menuObj);
    }
  }
  for (var i = 0, len = staticMenuId.length; i < len; i++) {
    refreshMenuItems(getElmId(staticMenuId[i]));
  }
  if (typeof(staticMenuBarId) == "object") {
    for (var i = 0, len = staticMenuBarId.length; i < len; i++) {
      refreshMenuBarItems(getElmId(staticMenuBarId[i]));
    }
  }
}

/*
Hide the menu and all its submenus.
Argument:
menuObj            : Required. Menu object that specifies the menu and all its submenus to 
                     be hidden.
*/
function hideMenus(menuObj) { // Public method
  refreshMenuItems(menuObj);
  for (var i = 0, len = menuObj.childNodes.length; i < len; i++) {
    if (menuObj.childNodes[i].enabled && menuObj.childNodes[i].subMenu) {
      hideMenus(menuObj.childNodes[i].subMenu.menuObj);
    }
  }
  if (menuObj.style.position == "fixed") {
    menuObj.style.position = "absolute";
    menuObj.style.visibility = "hidden";
    menuObj.style.position = "fixed";
  }
  else {
    menuObj.style.visibility = "hidden";
    menuObj.style.left = "0px";
    menuObj.style.top = "0px";
    menuObj.initialLeft = 0;
    menuObj.initialTop = 0;
  }
}

/*
Set the menu object to be the pop-up menu.
Argument:
menuObj            : Required. Menu object that specifies the pop-up menu.
*/
function setPopUpMenu(menuObj) { // Public method
  popUpMenuObj = menuObj;
}

/*
Check browser compatibility and create the menus.
*/
function initjsDOMenu() { // Public method
  if (document.createElement && document.getElementById) {
    createjsDOMenu();
  }
}

if (typeof(allExceptFilter) == "undefined") {
  var allExceptFilter = new Array("A.*", 
                                  "BUTTON.*", 
                                  "IMG.*", 
                                  "INPUT.*", 
                                  "OBJECT.*", 
                                  "OPTION.*", 
                                  "SELECT.*", 
                                  "TEXTAREA.*"); // Public field
}

if (typeof(noneExceptFilter) == "undefined") {
  var noneExceptFilter = new Array(); // Public field
}

if (typeof(menuClassName) == "undefined") {
  var menuClassName = "jsdomenudiv"; // Public field
}

if (typeof(menuItemClassName) == "undefined") {
  var menuItemClassName = "jsdomenuitem"; // Public field
}

if (typeof(menuItemClassNameOver) == "undefined") {
  var menuItemClassNameOver = "jsdomenuitemover"; // Public field
}

if (typeof(sepClassName) == "undefined") {
  var sepClassName = "jsdomenusep"; // Public field
}

if (typeof(arrowClassName) == "undefined") {
  var arrowClassName = "jsdomenuarrow"; // Public field
}

if (typeof(arrowClassNameOver) == "undefined") {
  var arrowClassNameOver = "jsdomenuarrowover"; // Public field
}

if (typeof(menuMode == "undefined")) {
  var menuMode = "cursor"; // Public field
}

if (typeof(menuBorderWidth) == "undefined") {
  var menuBorderWidth = 2; // Public field
}

var ie50 = isIE50(); // Private field
var ie55 = isIE55(); // Private field
var ie5 = isIE5(); // Private field
var ie6 = isIE6(); // Private field
var ie = isIE(); // Private field
var opera = isOpera(); // Private field
var safari = isSafari(); // Private field
var pageMode = getPageMode(); // Private field
var px = "px"; // Private field
var btw = "border-top-width"; // Private field
var bbw = "border-bottom-width"; // Private field
var blw = "border-left-width"; // Private field
var brw = "border-right-width"; // Private field
var menuCount = 0; // Private field
var menuItemCount = 0; // Private field
var sepCount = 0; // Private field
var popUpMenuObj = null; // Private field
var showValue = 0; // Private field
var hideValue = 0; // Private field
var staticMenuId = new Array(); // Private field
document.onclick = leftClickHandler;
window.onscroll = scrollHandler;

//** Ajax Tabs Content script v2.0- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Updated Oct 21st, 07 to version 2.0. Contains numerous improvements

var ddajaxtabssettings = {}
ddajaxtabssettings.bustcachevar = 1  //bust potential caching of external pages after initial request? (1=yes, 0=no)
ddajaxtabssettings.loadstatustext = "<img src='ajaxtabs/loading.gif' /> Carregando, aguarde..." 


////NO NEED TO EDIT BELOW////////////////////////

function ddajaxtabs(tabinterfaceid, contentdivid){
	this.tabinterfaceid = tabinterfaceid //ID of Tab Menu main container
	this.tabs = document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
	this.enabletabpersistence = true
	this.hottabspositions = [] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
	this.contentdivid = contentdivid
	this.defaultHTML = ""
	this.defaultIframe = '<iframe src="about:blank" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" class="tabcontentiframe" style="width:100%; height:auto; min-height: 100px"></iframe>'
	this.defaultIframe = this.defaultIframe.replace(/<iframe/i, '<iframe name="'+"_ddajaxtabsiframe-" + contentdivid + '" ')
	this.revcontentids = [] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
	this.selectedClassTarget = "link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}

ddajaxtabs.connect=function(pageurl, tabinstance){
	var page_request = false
	var bustcacheparameter =""
	if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE6 or below
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	var ajaxfriendlyurl = pageurl.replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/") 
	page_request.onreadystatechange = function(){ddajaxtabs.loadpage(page_request, pageurl, tabinstance)}
	if (ddajaxtabssettings.bustcachevar) //if bust caching of external page
		bustcacheparameter = (ajaxfriendlyurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', ajaxfriendlyurl+bustcacheparameter, true)
	page_request.send(null)
}

ddajaxtabs.loadpage=function(page_request, pageurl, tabinstance){
	var divId = tabinstance.contentdivid
	document.getElementById(divId).innerHTML = ddajaxtabssettings.loadstatustext //Display "fetching page message"
	if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1)){
		document.getElementById(divId).innerHTML = page_request.responseText
		ddajaxtabs.ajaxpageloadaction(pageurl, tabinstance)
	}
}

ddajaxtabs.ajaxpageloadaction=function(pageurl, tabinstance){
	tabinstance.onajaxpageload(pageurl) //call user customized onajaxpageload() function when an ajax page is fetched/ loaded
}

ddajaxtabs.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

ddajaxtabs.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}

ddajaxtabs.prototype={

	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
		this.cancelautorun() //stop auto cycling of tabs (if running)
		var tabref=""
		try{
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=document.getElementById(tabid_or_position)
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=this.tabs[tabid_or_position]
		}
		catch(err){alert("Invalid Tab ID or position entered!")}
		if (tabref!="") //if a valid tab is found based on function parameter
			this.expandtab(tabref) //expand this tab
	},

	setpersist:function(bool){ //PUBLIC function to toggle persistence feature
			this.enabletabpersistence=bool
	},

	loadajaxpage:function(pageurl){ //PUBLIC function to fetch a page via Ajax and display it within the Tab Content instance's container
		ddajaxtabs.connect(pageurl, this)
	},

	loadiframepage:function(pageurl){ //PUBLIC function to fetch a page and load it into the IFRAME of the Tab Content instance's container
		this.iframedisplay(pageurl, this.contentdivid)
	},

	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
		this.selectedClassTarget=objstr || "link"
	},

	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
	},

	onajaxpageload:function(pageurl){ //PUBLIC Event handler that can invoke custom code whenever an Ajax page has been fetched and displayed
		//do nothing by default
	},

	expandtab:function(tabref){
		var relattrvalue=tabref.getAttribute("rel")
		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easy searching through
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
		if (relattrvalue=="#default")
			document.getElementById(this.contentdivid).innerHTML=this.defaultHTML
		else if (relattrvalue=="#iframe")
			this.iframedisplay(tabref.getAttribute("href"), this.contentdivid)
		else
			ddajaxtabs.connect(tabref.getAttribute("href"), this)
		this.expandrevcontent(associatedrevids)
		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("href")==tabref.getAttribute("href"))? "selected" : ""
		}
		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
			ddajaxtabs.setCookie(this.tabinterfaceid, tabref.tabposition)
	},

	iframedisplay:function(pageurl, contentdivid){
		if (typeof window.frames["_ddajaxtabsiframe-"+contentdivid]!="undefined"){
			try{delete window.frames["_ddajaxtabsiframe-"+contentdivid]} //delete iframe within Tab content container if it exists (due to bug in Firefox)
			catch(err){}
		}
		document.getElementById(contentdivid).innerHTML=this.defaultIframe
		window.frames["_ddajaxtabsiframe-"+contentdivid].location.replace(pageurl) //load desired page into iframe
	},


	expandrevcontent:function(associatedrevids){
		var allrevids=this.revcontentids
		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
		}
	},

	autorun:function(){ //function to auto cycle through and select tabs based on a set interval
		var currentTabIndex=this.automode_currentTabIndex //index within this.hottabspositions to begin
		var hottabspositions=this.hottabspositions //Array containing position numbers of "hot" tabs (those with a "rel" attr)
		this.expandtab(this.tabs[hottabspositions[currentTabIndex]])
		this.automode_currentTabIndex=(currentTabIndex<hottabspositions.length-1)? currentTabIndex+1 : 0 //increment currentTabIndex
	},

	cancelautorun:function(){
		if (typeof this.autoruntimer!="undefined")
			clearInterval(this.autoruntimer)
	},

	init:function(automodeperiod){
		var persistedtab=ddajaxtabs.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
		var persisterror=true //Bool variable to check whether persisted tab position is valid (can become invalid if user has modified tab structure)
		this.automodeperiod=automodeperiod || 0
		this.defaultHTML=document.getElementById(this.contentdivid).innerHTML
		for (var i=0; i<this.tabs.length; i++){
			this.tabs[i].tabposition=i //remember position of tab relative to its peers
			if (this.tabs[i].getAttribute("rel")){
				var tabinstance=this
				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
				this.tabs[i].onclick=function(){
					tabinstance.expandtab(this)
					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
					return false
				}
				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
				}
				if (this.enabletabpersistence && parseInt(persistedtab)==i || !this.enabletabpersistence && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
					this.expandtab(this.tabs[i]) //expand current tab if it's the persisted tab, or if persist=off, carries the "selected" CSS class
					persisterror=false //Persisted tab (if applicable) was found, so set "persisterror" to false
					//If currently selected tab's index(i) is greater than 0, this means its not the 1st tab, so set the tab to begin in automode to 1st tab:
					this.automode_currentTabIndex=(i>0)? 0 : 1
				}
			}
		} //END for loop
		if (persisterror) //if an error has occured while trying to retrieve persisted tab (based on its position within its peers)
			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
			this.automode_currentTabIndex=this.automode_currentTabIndex || 0
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
		}
	} //END int() function

} //END Prototype assignment


//=======================================================================================
// Função para mudar a imagem
//=======================================================================================
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//===================================================================================


function mostraxml(string, tipo)
{
	var encode = "&lt;|&gt;|&amp;|&quot;|&nbsp;|&iexcl;|&cent;|&pound;|&yen;|&sect;|&uml;|&copy;|&laquo;|&not;|&reg;|&deg;|&plusmn;|&acute;|&micro;|&para;|&middot;|&cedil;|&raquo;|&iquest;|&Agrave;|&Aacute;|&Acirc;|&Atilde;|&Auml;|&Aring;|&AElig;|&Ccedil;|&Egrave;|&Eacute;|&Ecirc;|&Igrave;|&Iacute;|&Icirc;|&Iuml;|&Ntilde;|&Ograve;|&Oacute;|&Ocirc;|&Otilde;|&Ouml;|&Oslash;|&Ugrave;|&Uacute;|&Ucirc;|&Uuml;|&szlig;|&agrave;|&aacute;|&acirc;|&atilde;|&auml;|&aring;|&aelig;|&ccedil;|&egrave;|&eacute;|&ecirc;|&euml;|&igrave;|&iacute;|&icirc;|&iuml;|&ntilde;|&ograve;|&oacute;|&ocirc;|&otilde;|&ouml;|&divide;|&oslash;|&ugrave;|&uacute;|&ucirc;|&uuml;|&yuml;|&#130;|&#131;|&#132;|&#133;|&#134;|&#135;|&#136;|&#137;|&#139;|&#140;|&#145;|&#146;|&#147;|&#148;|&#149;|&#150;|&#151;|&#152;|&#153;|&#155;|&#156;|&#159;|<br>|"
	var decode = "<|>|&|Chr(34)|Space(1)|¡|¢|£|¥|§|¨|©|«|¬|®|°|±|´|µ|¶|·|¸|»|¿|À|Á|Â|Ã|Ä|Å|Æ|Ç|È|É|Ê|Ì|Í|Î|Ï|Ñ|Ò|Ó|Ô|Õ|Ö|Ø|Ù|Ú|Û|Ü|ß|à|á|â|ã|ä|å|æ|ç|è|é|ê|ë|ì|í|î|ï|ñ|ò|ó|ô|õ|ö|÷|ø|ù|ú|û|ü|ÿ|‚|ƒ|„|…|†|‡|ˆ|‰|‹|Œ|‘|’|“|”|•|–|—||™|›|œ|Ÿ|vbCrLf|";
	
	var arrayencode = encode.split("|");
	var arraydecode = decode.split("|");
	
	for(i = 0; i < arrayencode.length; i++)
	{
		if (tipo == 1) // converte de &amp; para &
		{
			string.replace(arrayencode[i], arraydecode[i]);
		}
		else if (tipo = 2) // coverte de & para &amp;
		{
			string.replace(arraydecode[i], arrayencode[i]);		
		}	
	}
	var mostraxml = string;
	return mostraxml;

}

//=================================================================================================================
//Funções para marcar a linha ou a coluna de uma table
//
//Como utilizar:
//	- Incluir na pagina as seguintes variaveis:
//		var highlightbehavior = "TR" //(Caso queria marcar somente a coluna, substituir o "TR" por "TD")
//		var ns6 = document.getElementById&&!document.all
//		var ie = document.all
//
//	- Utilizar o exemplo abaixo no table que vc quer utiliar o recurso
//		<table onMouseover="changeto(event, '#XXXXX')" onMouseout="changeback(event, '#YYYYYY')">
//			- #XXXXXX : será a cor da linha quando passar o mouse
//			- #YYYYYY : a cor original da linha, quando o cursor do mouse sair da linha
//
//	- Caso queira que a linha não seja marcada colocar na tag tr o seguinte: <tr id="ignore">
//=================================================================================================================

/***********************************************
* Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

function changeto(e, highlightcolor){
	source=ie? event.srcElement : e.target
	if (source.tagName == "TABLE")
		return
		while(source.tagName!=highlightbehavior && source.tagName!="HTML")
		source=ns6? source.parentNode : source.parentElement
		if (source.style.backgroundColor != highlightcolor && source.id != "ignore"){
			source.style.backgroundColor = highlightcolor;
			source.style.cursor = "default";
			source.style.color = "#000000";} //cor da fonte quando marcar a linha
}

function contains_ns6(master, slave) { //check if slave is contained by master
	while (slave.parentNode)
	if ((slave = slave.parentNode) == master)
		return true;
		return false;
}

function changeback(e, originalcolor){
	if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
		return
	else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
		return
	if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source){
		source.style.backgroundColor = originalcolor;
		source.style.color = "#000000";} //cor original da fonte
}

//===================================================================================
function ltrim(ptexto) {
    var i = 0;
    while (i < ptexto.length && (ptexto.charAt(i)== " ")) {
        i++;
    }
    return (ptexto.substring(i,ptexto.length));
}
//=================================================================================== 
function rtrim(ptexto) {
	var i = ptexto.length - 1;
	while (i > 0 && (ptexto.charAt(i) == " ")) {
	    i--;
    }
	return (ptexto.substring(0,i+1));
}
//===================================================================================    
function trim(ptexto) {
    return ltrim(rtrim(ptexto));
}

//=================================================================================== 

//Funçao para todas as buscas do site
//Funçao para todas as buscas do site
function TrataBusca(texto){
	var pos;
	pos = texto.value.substring(0, 1);
	
	alert(pos.charCodeAt(pos));
	
	campo = texto.value.toLowerCase() 
	campo = campo.replace("á", "a"); 
	campo = campo.replace("à", "a"); 
	campo = campo.replace("â", "a"); 
	campo = campo.replace("ã", "a"); 
	campo = campo.replace("ä", "a"); 
	campo = campo.replace("é", "e"); 
	campo = campo.replace("è", "e"); 
	campo = campo.replace("ê", "e"); 
	campo = campo.replace("ë", "e"); 
	campo = campo.replace("í", "i"); 
	campo = campo.replace("ì", "i"); 
	campo = campo.replace("î", "i"); 
	campo = campo.replace("ï", "i"); 
	campo = campo.replace("ó", "o"); 
	campo = campo.replace("ò", "o"); 
	campo = campo.replace("ô", "o"); 
	campo = campo.replace("ő", "o"); 
	campo = campo.replace("ö", "o"); 
	campo = campo.replace("ú", "u"); 
	campo = campo.replace("ů", "u");
	campo = campo.replace("ű", "u"); 
	campo = campo.replace("ü", "u"); 
	campo = campo.replace("ú", "u"); 
	campo = campo.replace("ç", "c");
	campo = campo.replace("'", "");
	campo = campo.replace(";", "");
	campo = campo.replace("%", "");
	campo = campo.replace("*", "");
	campo = campo.replace("!", "");
	campo = campo.replace("&", "");
	campo = campo.replace("|", "");
	campo = campo.replace("´", "");
	campo = campo.replace("`", "");
	campo = campo.replace("<!--post box-->", "");
	campo = campo.replace("0x", "");
	campo = campo.replace("x0", "");
	campo = campo.replace("x20", "");
	campo = campo.replace("x1b", "");
	campo = campo.replace("x7f", "");
	campo = campo.replace("~", "");
	campo = campo.replace("?", "");
	campo = campo.replace("+", "");
	campo = campo.replace("$", "");
	campo = campo.replace(":", "");
	campo = campo.replace("(", "");
	campo = campo.replace(")", "");
	campo = campo.replace("[", "");
	campo = campo.replace("]", "");
	campo = campo.replace("{", "");
	campo = campo.replace("}", "");
	campo = campo.replace("/", "");
	campo = campo.replace("<", "");
	campo = campo.replace(">", "");
	campo = campo.replace("?", "");
	campo = campo.replace("´", "");
	campo = campo.replace("`", "");
	campo = campo.replace("¨", "");
	campo = campo.replace("--",	"");
	campo = campo.replace("..", "");
	campo = campo.replace("select ", "");
	campo = campo.replace("update ", "");
	campo = campo.replace("delete ", "");
	campo = campo.replace("insert ", "");
	campo = campo.replace("drop ", "");
	campo = campo.replace("exec ", "");
	campo = campo.replace("create ", "");
	campo = campo.replace("script ", "");
	texto.value = campo;
}

//funçao para tratar todos os campos do site. Usar em formulario de cadastro
function TrataForm(){
	/*campo = campo.replace("'", "");
	campo = campo.replace(";", "");
	campo = campo.replace("%", "");
	campo = campo.replace("*", "");
	campo = campo.replace("!", "");
	campo = campo.replace("|", "");
	campo = campo.replace("´", "");
	campo = campo.replace("`", "");
	campo = campo.replace("<!--post box-->", "");
	campo = campo.replace("<!--POST BOX-->", "");
	campo = campo.replace("0x", "");
	campo = campo.replace("x0", "");
	campo = campo.replace("x20", "");
	campo = campo.replace("x1b", "");
	campo = campo.replace("x7f", "");
	campo = campo.replace("~", "");
	campo = campo.replace("?", "");
	campo = campo.replace("+", "");
	campo = campo.replace("$", "");
	campo = campo.replace(":", "");
	campo = campo.replace("(", "");
	campo = campo.replace(")", "");
	campo = campo.replace("[", "");
	campo = campo.replace("]", "");
	campo = campo.replace("{", "");
	campo = campo.replace("}", "");
	campo = campo.replace("/", "");
	campo = campo.replace("<", "");
	campo = campo.replace(">", "");
	campo = campo.replace("?", "");
	campo = campo.replace("´", "");
	campo = campo.replace("`", "");
	campo = campo.replace("¨", "");
	campo = campo.replace("--",	"");
	campo = campo.replace("..", "");
	
	campo = campo.replace("select ", "");
	campo = campo.replace("update ", "");
	campo = campo.replace("delete ", "");
	campo = campo.replace("insert ", "");
	campo = campo.replace("drop ", "");
	campo = campo.replace("exec ", "");
	campo = campo.replace("create ", "");
	campo = campo.replace("script ", "");
	
	campo = campo.replace("Select ", "");
	campo = campo.replace("Update ", "");
	campo = campo.replace("Delete ", "");
	campo = campo.replace("Insert ", "");
	campo = campo.replace("Drop ", "");
	campo = campo.replace("Exec ", "");
	campo = campo.replace("Create ", "");
	campo = campo.replace("Script ", "");
	
	campo = campo.replace("SELECT ", "");
	campo = campo.replace("UPDATE ", "");
	campo = campo.replace("DELETE ", "");
	campo = campo.replace("INSERT ", "");
	campo = campo.replace("DROP ", "");
	campo = campo.replace("EXEC ", "");
	campo = campo.replace("CREATE ", "");
	campo = campo.replace("SCRIPT ", "");*/
}



function CharSpecial(str)   {

	var pos, i, ok, tamanho, numeros;
	if (!CheckAspas(str)){
		return false;
	}

	ok = true;
	numeros = '0123456789';
	//str = trim(str);
	str = retiraEspacos(str);
	tamanho = str.length;
	
	for(i=0; i < tamanho; i++){
		pos = str.substring(i, i+1);
		
		if (!((numeros.indexOf(pos) >= 0) || (pos.charCodeAt(pos) >= 65 && pos.charCodeAt(pos) <= 90) || (pos.charCodeAt(pos) >= 97 && pos.charCodeAt(pos) <= 122 ) || (pos.charCodeAt(pos) == 45) || (pos.charCodeAt(pos) == 32 ))){
			ok = false;
			break;
		}	
	}	

	if (ok == true){
		return true;				
	}
	else{
		return false;
	}
	return true;
}
//===================================================================================


//===================================================================================
//Função para verificar se o caracter é numérico ou não.
//===================================================================================
function IsNumeric(sText){
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++){ 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1){
         IsNumber = false;
	 }
  }
   return IsNumber;
}
//===================================================================================

function CheckAspas(str)
{
	ok = true;
	//str = trim(str);
	str = retiraEspacos(str);
	tamanho = str.length;
	for(i=0; i < tamanho; i++)
	{
		pos = str.substr(i, i+1);
		if ( (pos == "'") || (pos == '"') )
		{
			ok = false;
			break;
		}
	}
	
	if (ok == true) 
	{
		return true;
	}
	else
	{
		return false;
	}
	
}

//======================================================================
//Função para retirar os espaços do inicio e do fim da String
//======================================================================
function retiraEspacos(string) {
    var i = 0;
    var final = '';
    while (i < string.length) {
        if (string.charAt(i) == ' ') {
            final += string.substr(0, i);
            string = string.substr(i+1, string.length - (i+1));
            i = 0;
        }
        else {
            i++;
        }
    }
    return final + string;
}


//======================================================================
//Função para retirar caracteres especiais de uma string.
//======================================================================
function ConvertString(campo){
		var id = campo.id;
		var valor = campo.value;
		var meuArray = valor.split('');
		for (var i = 0; i <= meuArray.length - 1; i++){
			var letra = meuArray[i];
			if (letra != ''){
				var intKeyCode = letra.charCodeAt(letra);
				switch (intKeyCode){
					case	33	:  //	!
						meuArray[i] = '';
						break;
					case	34	:  //	"
						meuArray[i] = '';
						break;
					case	35	:  //	#
						meuArray[i] = '';
						break;
					case	36	:  //	$
						meuArray[i] = '';
						break;
					case	37	:  //	%
						meuArray[i] = '';
						break;
					case	38	:  //	&
						meuArray[i] = '';
						break;
					case	39	:  //	'
						meuArray[i] = '';
						break;
					case	40	:  //	(
						meuArray[i] = '';
						break;
					case	41	:  //	-
						meuArray[i] = '';
						break;
					case	42	:  //	*
						meuArray[i] = '';
						break;
					case	43	:  //	+
						meuArray[i] = '';
						break;
					case	44	:  //	,
						meuArray[i] = '';
						break;
					case	45	:  //	)
						meuArray[i] = '';
						break;
					case	46	:  //	.
						meuArray[i] = '';
						break;
					case	47	:  //	/
						meuArray[i] = '';
						break;
					case	58	:  //	:
						meuArray[i] = '';
						break;
					case	59	:  //	;
						meuArray[i] = '';
						break;
					case	60	:  //	<
						meuArray[i] = '';
						break;
					case	61	:  //	]
						meuArray[i] = '';
						break;
					case	62	:  //	>
						meuArray[i] = '';
						break;
					case	63	:  //	?
						meuArray[i] = '';
						break;
					case	64	:  //	@
						meuArray[i] = '';
						break;
					case	91	:  //	_
						meuArray[i] = '';
						break;
					case	92	:  //	\
						meuArray[i] = '';
						break;
					case	93	:  //	[
						meuArray[i] = '';
						break;
					case	94	:  //	^
						meuArray[i] = '';
						break;
					case	95	:  //	=
						meuArray[i] = '';
						break;
					case	96	:  //	`
						meuArray[i] = '';
						break;
					case	123	:  //	{
						meuArray[i] = '';
						break;
					case	124	:  //	|
						meuArray[i] = '';
						break;
					case	125	:  //	}
						meuArray[i] = '';
						break;
					case	126	:  //	~
						meuArray[i] = '';
						break;
					case	168	:  //	¨
						meuArray[i] = '';
						break;
					case	180	:  //	´
						meuArray[i] = '';
						break;
					case	224	:  //	à
						meuArray[i] = String.fromCharCode(97);
						break;
					case	225	:  //	á
						meuArray[i] = String.fromCharCode(97);
						break;
					case	226	:  //	â
						meuArray[i] = String.fromCharCode(97);
						break;
					case	227	:  //	ã
						meuArray[i] = String.fromCharCode(97);
						break;
					case	228	:  //	ä
						meuArray[i] = String.fromCharCode(97);
						break;
					case	231	:  //	ç
						meuArray[i] = String.fromCharCode(99);
						break;
					case	232	:  //	è
						meuArray[i] = String.fromCharCode(101);
						break;
					case	233	:  //	é
						meuArray[i] = String.fromCharCode(101);
						break;
					case	234	:  //	ê
						meuArray[i] = String.fromCharCode(101);
						break;
					case	235	:  //	ë
						meuArray[i] = String.fromCharCode(101);
						break;
					case	236	:  //	ì
						meuArray[i] = String.fromCharCode(105);
						break;
					case	237	:  //	í
						meuArray[i] = String.fromCharCode(105);
						break;
					case	238	:  //	î
						meuArray[i] = String.fromCharCode(105);
						break;
					case	239	:  //	ï
						meuArray[i] = String.fromCharCode(105);
						break;
					case	242	:  //	ò
						meuArray[i] = String.fromCharCode(111);
						break;
					case	243	:  //	ó
						meuArray[i] = String.fromCharCode(111);
						break;
					case	244	:  //	ô
						meuArray[i] = String.fromCharCode(111);
						break;
					case	245	:  //	õ
						meuArray[i] = String.fromCharCode(111);
						break;
					case	246	:  //	ö
						meuArray[i] = String.fromCharCode(111);
						break;
					case	249	:  //	ù
						meuArray[i] = String.fromCharCode(117);
						break;
					case	250	:  //	ú
						meuArray[i] = String.fromCharCode(117);
						break;
					case	251	:  //	û
						meuArray[i] = String.fromCharCode(117);
						break;
					case	252	:  //	ü
						meuArray[i] = String.fromCharCode(117);
						break;
				}
			}
		}
			
		var texto = '';
		for (var x = 0; x < meuArray.length; x ++){
			if (meuArray[x] != ''){
				texto += meuArray[x];}
		}
		document.getElementById(id).value = texto;
	}


//========================================================================================
//Converte caracteres especiais para sintaxe HTML
//========================================================================================
	function ConvertStringHTML(valor){
		var texto_pronto = '';
		valor = valor.split('');
		for (var x = 0; x < valor.length; x++){
			//A
			valor[x] = valor[x].replace("á", "&aacute;");
			valor[x] = valor[x].replace("â", "&acirc;");
			valor[x] = valor[x].replace("à", "&agrave;");
			valor[x] = valor[x].replace("å", "&aring;");
			valor[x] = valor[x].replace("ã", "&atilde;");
			valor[x] = valor[x].replace("ä", "&auml;");
			valor[x] = valor[x].replace("Á", "&Aacute;");
			valor[x] = valor[x].replace("Â", "&Acirc;");
			valor[x] = valor[x].replace("À", "&Agrave;");
			valor[x] = valor[x].replace("Å", "&Aring;");
			valor[x] = valor[x].replace("Ä", "&Auml;");
			valor[x] = valor[x].replace("Ã", "&Atilde;");
			
			//E
			valor[x] = valor[x].replace("è", "&egrave;");
			valor[x] = valor[x].replace("ë", "&euml;");
			valor[x] = valor[x].replace("é", "&eacute;");
			valor[x] = valor[x].replace("ê", "&ecirc;");
			valor[x] = valor[x].replace("È", "&Egrave;");
			valor[x] = valor[x].replace("Ë", "&Euml;");
			valor[x] = valor[x].replace("Ê", "&Ecirc;");
			valor[x] = valor[x].replace("É", "&Eacute;");
			
			//I
			valor[x] = valor[x].replace("î", "&icirc;");
			valor[x] = valor[x].replace("ï", "&iuml;");
			valor[x] = valor[x].replace("ì", "&igrave;");
			valor[x] = valor[x].replace("í", "&iacute;");
			valor[x] = valor[x].replace("Î", "&Icirc;");
			valor[x] = valor[x].replace("Ì", "&Igrave;");
			valor[x] = valor[x].replace("Ï", "&Iuml;");
			valor[x] = valor[x].replace("Í", "&Iacute;");
			
			//O
			valor[x] = valor[x].replace("ô", "&ocirc;");
			valor[x] = valor[x].replace("ò", "&ograve;");
			valor[x] = valor[x].replace("ö", "&ouml;");
			valor[x] = valor[x].replace("ó", "&oacute;");
			valor[x] = valor[x].replace("õ", "&otilde;");
			valor[x] = valor[x].replace("Ó", "&Oacute;");
			valor[x] = valor[x].replace("Ô", "&Ocirc;");
			valor[x] = valor[x].replace("Ö", "&Ouml;");
			valor[x] = valor[x].replace("Ò", "&Ograve;");
			valor[x] = valor[x].replace("Õ", "&Otilde;");
			
			//U
			valor[x] = valor[x].replace("ú", "&uacute;");
			valor[x] = valor[x].replace("û", "&ucirc;");
			valor[x] = valor[x].replace("ü", "&uuml;");
			valor[x] = valor[x].replace("ù", "&ugrave;");
			valor[x] = valor[x].replace("Ù", "&Ugrave;");
			valor[x] = valor[x].replace("Û", "&Ucirc;");
			valor[x] = valor[x].replace("Ú", "&Uacute;");
			valor[x] = valor[x].replace("Ü", "&Uuml;");
			
			//Outros
			valor[x] = valor[x].replace("Ç", "&Ccedil;");
			valor[x] = valor[x].replace("ç", "&ccedil;");
			
			valor[x] = valor[x].replace("Ø", "&Oslash;");
			valor[x] = valor[x].replace("Ñ", "&Ntilde;");
			valor[x] = valor[x].replace("Ð", "&ETH;");
			valor[x] = valor[x].replace("ø", "&oslash;");
			valor[x] = valor[x].replace("ñ", "&ntilde;");
			valor[x] = valor[x].replace("ð", "&eth;");
			valor[x] = valor[x].replace("Ý", "&Yacute;");
			valor[x] = valor[x].replace("ý", "&yacute;");
			valor[x] = valor[x].replace("<", "&lt;");
			valor[x] = valor[x].replace(">", "&gt;");
			valor[x] = valor[x].replace("Æ", "&AElig;");
			//valor[x] = valor[x].replace("&", "&amp;");
			valor[x] = valor[x].replace("æ", "&aelig;");
			valor[x] = valor[x].replace("®", "&reg;");
			valor[x] = valor[x].replace("© ", "&copy;");
			valor[x] = valor[x].replace("Þ", "&THORN;");
			valor[x] = valor[x].replace("þ", "&thorn;");
			valor[x] = valor[x].replace("ß", "&szlig;");
			
			texto_pronto += valor[x];

			/*if (texto_pronto != '')
				texto_pronto = texto_pronto & " " & valor[x];
			else
				texto_pronto = valor[x];*/
		}
		return texto_pronto;
	}
/**********************************************************************************************/
