// JavaScript Document
//<![CDATA[
	function f_clientHeight() {
		var valor = document.body ? window.document.body.clientHeight : 0;
		var valor2 = window.innerHeight ? window.innerHeight : 0;
		var valor3 = document.documentElement ? document.documentElement.clientHeight:0
		var resultado = valor > valor2 ? valor: valor2;
		if (resultado < valor3) {
			resultado = valor3;
		}
		return resultado;
		//IE document.body ? document.body.clientHeight : 0;
	}
	
	//------------------------------------------

	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_validateForm() { //v4.0
	  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
		if (val) { nm=val.name; if ((val=val.value)!="") {
		  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
		  } else if (test!='R') { num = parseFloat(val);
			if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
			if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
			  min=test.substring(8,p); max=test.substring(p+1);
			  if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é requerido.<br/>'; }
	  } 
	  if (errors) {
		  var obj = document.getElementById("erros");
		  obj.innerHTML = errors;
		  //alert('O(s) seguinte(s) erro(s) ocorreu(am) :\n\n'+errors);
	  } else {
		  var obj = document.getElementById("erros");
		  obj.innerHTML = "<img src='../images/loader.gif' /><font color='#000000'><strong>Aguarde....<\/strong><\/font>";	
	  }
	  document.MM_returnValue = (errors == '');
	}
	
	//--------------------------------------------------
	
	function mascaraTexto(evento, mascara){  
		  
		var campo, valor, i, tam, caracter;  
	  
		if (document.all) // Internet Explorer  
		   campo = evento.srcElement;  
		else // Nestcape, Mozzila  
			campo= evento.target;  
			  
		valor = campo.value;  
		tam = valor.length;  
		  
		for(i=0;i<mascara.length;i++){  
		   caracter = mascara.charAt(i);  
		  if(caracter!="9")   
			  if (i < tam & caracter!=valor.charAt(i))  {
				 campo.value = valor.substring(0,i) + caracter + valor.substring(i,tam);  
			  }
					  
		}  
	   
	}  
	
	function validaData(campo,valor) {
		var date=valor;
		var ardt=new Array;
		var ExpReg=new RegExp("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/[12][0-9]{3}");
		ardt=date.split("/");
		erro=false;
		if ( date.search(ExpReg)==-1){
			erro = true;
			}
		else if (((ardt[1]==4)||(ardt[1]==6)||(ardt[1]==9)||(ardt[1]==11))&&(ardt[0]>30))
			erro = true;
		else if ( ardt[1]==2) {
			if ((ardt[0]>28)&&((ardt[2]%4)!=0))
				erro = true;
			if ((ardt[0]>29)&&((ardt[2]%4)==0))
				erro = true;
		}
		if (erro) {
			alert("\"" + valor + "\" não é uma data válida!!!");
			campo.focus();
			campo.value = "";
			return false;
		}
		return true;
	}
	
	function Move(obj){
		obj.style.backgroundColor = "#FFFFCC";
	}

	function Mout(obj){
		obj.style.backgroundColor = '';
	}


	function swapVisibilidade(param){
		//var list_args = param.split(",");
		//var i;
		//alert(args[0]);
		//for (i = 0; i < (list_args.length); i++) {
			
			var obj = document.getElementById(param);
			if (obj.style.visibility == "hidden"){
				obj.style.visibility = "visible";
				obj.style.display = "block";
			}else{
				obj.style.visibility = "hidden";
				obj.style.display = "none";
			}
	//}
	//swapVisibilidadeSelect(); 
	
}

function post(url, param) {
	if (navigator.appName == "Microsoft Internet Explorer") {
		try {
			 HttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				 HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	} else {
		HttpRequest = new XMLHttpRequest();	
	}
		
	if (!HttpRequest) {
            alert('Não foi possível criar um Obj XMLHTTP');
            return false;
    }
	
	HttpRequest.onreadystatechange =  function() {
											var conteudo = document.getElementById("tela");
											if (HttpRequest.readyState < 4) {
												
												conteudo.innerHTML = "<p>&nbsp;</p>&nbsp;<p></p><div align='center'><strong>Aguarde...</strong></div>";
											}
											if (HttpRequest.readyState == 4) {
												if (HttpRequest.status == 200) {
													conteudo.innerHTML = HttpRequest.responseText;
												} else {
													showMessage('Problema com a requisição!');
												}
											}
										};

		
	HttpRequest.open('POST', url, true);
	HttpRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	//HttpRequest.setRequestHeader('Content-Type','application/x-uuencode');
	//HttpRequest.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
    //HttpRequest.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
    //HttpRequest.setRequestHeader("Pragma", "no-cache");
	HttpRequest.send(param);

}

	
//]]>
