// JavaScript Document
<!--
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MudaLigua(ling){	
	form_index.FLing.value =  ling;	
	form_index.action = "index.php";
	form_index.target = "_self";
	form_index.submit();
}

function AbrePagina(pag){
	form_index.action = pag;
	form_index.target = "_self";
	form_index.submit();
}

function mostrafoto(local,foto){
	local.src = foto;	
}

function JanelaAjuda(pag){
	
	window.open(pag,'Ajuda','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');
}

function ValidaPedido(pag){
	aux="";	
	if (form_index.FCliente.value == 0)
	{
		aux= aux + "\n Selecione um Cliente";
	}
	if (aux != "")
	{
		alert(aux);
	}
	else
	{		
		form_index.action = pag;
		form_index.target = "_self";
		form_index.submit();
	}
}

function ValidaPedidoPagto(pag){
	form_index.action = pag;
	form_index.target = "_self";
	form_index.submit();
}

function TeclaEnterSubmit(pag){
	//pega o código da tecla pressionada
	var tecla=event.keyCode;
	//se for a tecla Enter (cód 13)	
	if (tecla==13) 
	{
		form_index.action = pag;
		form_index.target = "_self";
		form_index.submit();
	}
}

function SoNumero(){

	//pega o código da tecla pressionada
	var tecla=event.keyCode;
	//se a tecla não for número cancela a digitação (cód dos números vai de 48 a 57
	if (tecla < 48 | tecla > 57)
	{		
		event.keyCode=0;
		event.returnValue=false;
	}
	
}

function FormataData(campo){
	var aux = campo.value;
	//o indexOf retorna a posição da string, se não achar a string retorna -1
	while (aux.indexOf("/") != -1) {
		aux = aux.replace("/","");
	}//fim do while
	if (aux.length >= 5)
	{
		aux = ( aux.substr(0,2) + "/" + aux.substr(2,2) + "/" + aux.substr(4,aux.length) );
	}
	else
	{
		if (aux.length >= 3)
		{
			aux = ( aux.substr(0,2) + "/" + aux.substr(2,aux.length) );
		}
	}
	campo.value = aux;
}

function FormataValor(campo){
	var aux = campo.value;
	//o indexOf retorna a posição da string, se não achar a string retorna -1
	while (aux.indexOf(",") != -1) {
		aux = aux.replace(",","");
	}//fim do while
	while (aux.indexOf(".") != -1) {
		aux = aux.replace(".","");
	}//fim do while
	
	if (aux.length >= 6){
		aux = ( aux.substr(0,aux.length - 5) +"."+ aux.substr(aux.length-5,3) +","+ aux.substr(aux.length-2,2) );		
	}
	else
	{
		if (aux.length >= 3)
		{			
			aux = ( aux.substr(0,aux.length - 2) +","+ aux.substr(aux.length-2,2) );		
		}//fim do if
	}
	campo.value = aux;
}

function FormataCpf(campo){
	var aux = campo.value;
	//o indexOf retorna a posição da string, se não achar a string retorna -1
	while (aux.indexOf(".") != -1) {
		aux = aux.replace(".","");
	}//fim do while
	while (aux.indexOf("-") != -1) {
		aux = aux.replace("-","");
	}//fim do while
	while (aux.indexOf("/") != -1) {
		aux = aux.replace("/","");
	}//fim do while
	
	if (aux.length >= 13)
	{
			aux = ( aux.substr(0,2) + "." + aux.substr(2,3) + "." + aux.substr(5,3) + "/" + aux.substr(8,4) + "-" + aux.substr(12,aux.length) );
			
	}
	else 
	{
		if ( aux.length >=10)
		{
			aux = ( aux.substr(0,3) + "." + aux.substr(3,3) + "." + aux.substr(6,3) + "-" + aux.substr(9,aux.length) )
		}
	}	
	campo.value = aux;
}

function FormataCep(campo){
	var aux = campo.value;
	//o indexOf retorna a posição da string, se não achar a string retorna -1
	while (aux.indexOf("-") != -1) {
		aux = aux.replace("-","");
	}//fim do while
	while (aux.indexOf(".") != -1) {
		aux = aux.replace(".","");
	}//fim do while
	
	if (aux.length >= 6)
	{
			aux = ( aux.substr(0,2) + "." + aux.substr(2,3) + "-" + aux.substr(5,aux.length) );
			
	}	
	campo.value = aux;
}

function AbreFecha(tbl){
	if (tbl.style.display=='none')
	{
		tbl.style.display='';
	}
	else
	{
		tbl.style.display = 'none';
	}
}

function escondetexto(campo,texto){	
	var aux = texto;
	if (form_index.campo.value ==  aux) {
			form_index.campo.value = "";
	}
}
//-->
