// =======================================================================================================================
// =======================================================================================================================
//																	Fun�es de JavaScript
// =======================================================================================================================
// =======================================================================================================================

// Funcao: passa_selecao
// Autor: Lucas Roxo Mundim (lucas@refazenda.com)
// Finalidade: Passar o valor e o contedo de um campo select para um campo text especificado
// Exemplo: onchange="passa_selecao(this, this.form.grav, this.form.id_grav);"
function passa_selecao(nome_select, campo_texto, campo_id) {
	campo_id.value = nome_select.options[nome_select.selectedIndex].value;
	campo_texto.value = nome_select.options[nome_select.selectedIndex].text;
}
function popup_padrao(w,h,url,wname){

	var descontoH=0;
	var descontoV=0;
	var new_h;
	var new_w;

	// Linux
   	if (navigator.platform.lastIndexOf('Linux')!= -1){
   		if(navigator.appName == "Konqueror"){
   			descontoV = 18;
			descontoH = -1;
   		}

       	 else if (navigator.appName == "Microsoft Internet Explorer"||navigator.appName=="Opera"){
            descontoV = -11;
        }
	}
	new_w = Number(w)+descontoH;
	new_h = Number(h)+descontoV;
	var expRemoteWin = window.open(url,wname,'top=0,left=0,x=0,y=0,width='+new_w+',height='+new_h+',toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,scrollbars=yes');
}

function popup_padrao_no_status(w,h,url,wname){

	var descontoH=0;
	var descontoV=0;
	var new_h;
	var new_w;

	// Linux
   	if (navigator.platform.lastIndexOf('Linux')!= -1){
   		if(navigator.appName == "Konqueror"){
   			descontoV = 1;
			descontoH = -1;
   		}

       	 else if (navigator.appName == "Microsoft Internet Explorer"||navigator.appName=="Opera"){
            descontoV = -15;
        }
	}
	new_w = Number(w)+descontoH;
	new_h = Number(h)+descontoV;
	var expRemoteWin = window.open(url,wname,'top=0,left=0,x=0,y=0,width='+new_w+',height='+new_h+',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes');
}


function popup_incluir(url, wname, sel_name, form_name) {
   popup_padrao(450,200,url+'?interface=0&acao=incluir&sel_name='+sel_name+'&form_name='+form_name,wname);
}

function window_name() {
	window.name = "admin";
}
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_preloadImages() { //v3.0
  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_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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

startList = function() {
        //para cada item do menu
	if (document.all&&document.getElementById) {
          navRoot = document.getElementById("nav");
          for (i=0; i<navRoot.childNodes.length; i++) {
             node = navRoot.childNodes[i];
        if (node.nodeName=="LI") {
          node.onmouseover=function() {
             this.className+=" over";
        }
node.onmouseout=function() {
   this.className=this.className.replace(" over", "");
   }
   }
  }
 }
 //item 1
  if (document.all&&document.getElementById) {
          navRoot1 = document.getElementById("nav1");
          for (i=0; i<navRoot1.childNodes.length; i++) {
             node1 = navRoot1.childNodes[i];
        if (node1.nodeName=="LI") {
          node1.onmouseover=function() {
             this.className+=" over";
        }
node1.onmouseout=function() {
   this.className=this.className.replace(" over", "");
   }
   }
  }
 }
 
 //item 2
 if (document.all&&document.getElementById) {
          navRoot2 = document.getElementById("nav2");
          for (i=0; i<navRoot2.childNodes.length; i++) {
             node2 = navRoot2.childNodes[i];
        if (node2.nodeName=="LI") {
          node2.onmouseover=function() {
             this.className+=" over";
        }
node2.onmouseout=function() {
   this.className=this.className.replace(" over", "");
   }
   }
  }
 }
 
 //item3
 if (document.all&&document.getElementById) {
          navRoot3 = document.getElementById("nav3");
          for (i=0; i<navRoot3.childNodes.length; i++) {
             node3 = navRoot3.childNodes[i];
        if (node3.nodeName=="LI") {
          node3.onmouseover=function() {
             this.className+=" over";
        }
node3.onmouseout=function() {
   this.className=this.className.replace(" over", "");
   }
   }
  }
 }
 
 //item4
 if (document.all&&document.getElementById) {
          navRoot4 = document.getElementById("nav4");
          for (i=0; i<navRoot4.childNodes.length; i++) {
             node4 = navRoot4.childNodes[i];
        if (node4.nodeName=="LI") {
          node4.onmouseover=function() {
             this.className+=" over";
        }
node4.onmouseout=function() {
   this.className=this.className.replace(" over", "");
   }
   }
  }
 }
 //item5
 if (document.all&&document.getElementById) {
          navRoot5 = document.getElementById("nav5");
          for (i=0; i<navRoot5.childNodes.length; i++) {
             node5 = navRoot5.childNodes[i];
        if (node5.nodeName=="LI") {
          node5.onmouseover=function() {
             this.className+=" over";
        }
node5.onmouseout=function() {
   this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;
