// JavaScript Document

function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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.01
  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 && d.getElementById) x=d.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 setBrowserType(){ 
    var aBrowFull = new Array("opera", "msie", "netscape", "gecko", "mozilla"); 
    var aBrowVers = new Array("opera", "msie", "netscape", "rv",    "mozilla"   ); 
    var aBrowAbrv = new Array("op",    "ie",   "ns",       "mo",    "ns"   ); 
    var sInfo = navigator.userAgent.toLowerCase();; 

    sBrowser = ""; 
    for (var i = 0; i < aBrowFull.length; i++){ 
     if ((sBrowser == "") && (sInfo.indexOf(aBrowFull[i]) != -1)){ 
      sBrowser = aBrowAbrv[i]; 
      sVersion = String(parseFloat(sInfo.substr(sInfo.indexOf(aBrowVers[i]) + aBrowVers[i].length + 1))); 
     } 
    } 
	return sBrowser;
}

function abrir_ventana_noscroll(name,ancho,alto){
	ventana2 = window.open(name, "ventana", "width=" + ancho + ",height=" + alto + ",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=no,resizable=no");
}

function abrir_ventana_normal(name,ancho,alto){
	ventana2 = window.open(name, "ventana", "width=" + ancho + ",height=" + alto + ",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no");
}

function muestra(capa){
	menu = document.getElementById(capa);
	menu.style.display = 'block'
}

function oculta(capa){
	menu = document.getElementById(capa);
	menu.style.display = 'none'
}

function cerrar(id) {
	var obj = document.getElementById(id);
	obj.style.display = 'none'
}

function expandir(id,num) {
	var obj = document.getElementById(id);
	
	for (I=1; I<=num ; I++)
	{
		cerrar("capa_"+I);
	}

	cerrar("capa_fija");
	
	if (obj.style.display == "none")
	   obj.style.display = 'block'
	else
	   obj.style.display = 'none'
}

var navega = setBrowserType();

/*
Función Realizada por José Molina
*/

function var_dump(obj) {
   if(typeof obj == "object") {
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}//end function var_dump

function getHTTPObject() {
   var xmlhttp;
			try
			{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
	
			catch (e)
			{
				try
				{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				
				catch (e)
				{
					try
					{
						xmlhttp = new XMLHttpRequest();
					}
					
					catch (e)
					{
						xmlhttp = false;
						alert ('no se pudo obtener al ActiveX requerido');
					}
				}
			}
    
    return xmlhttp;
}

var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest

function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - corrige o bug do InnerHTML em selects no IE
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Versão: 2.1 - 04/09/2007
* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
* @objeto(tipo HTMLobject): o select a ser alterado
* @innerHTML(tipo string): o novo valor do innerHTML
*******/
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.toLowerCase().replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
      
    
    for(var i=0;i<selTemp.childNodes.length;i++){
  var spantemp = selTemp.childNodes[i];
  
        if(spantemp.tagName){     
            opt = document.createElement("OPTION")
    
   if(document.all){ //IE
    objeto.add(opt)
   }else{
    objeto.appendChild(opt)
   }       
    
   //getting attributes
   for(var j=0; j<spantemp.attributes.length ; j++){
    var attrName = spantemp.attributes[j].nodeName;
    var attrVal = spantemp.attributes[j].nodeValue;
    if(attrVal){
     try{
      opt.setAttribute(attrName,attrVal);
      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
     }catch(e){}
    }
   }
   //getting styles
   /*if(spantemp.style){
    for(var y in spantemp.style){
     try{opt.style[y] = spantemp.style[y];}catch(e){}
    }
   }*/
   //value and text
   opt.value = spantemp.getAttribute("value")
   opt.text = spantemp.innerHTML
   //IE
   opt.selected = spantemp.getAttribute('selected');
   //opt.className = spantemp.className;
  } 
 }    
 document.body.removeChild(selTemp)
 selTemp = null
}