<!--//
if (navigator.appName.indexOf('Microsoft') != -1){   
    clientNavigator = "IE";   
}else{   
    clientNavigator = "Other";   
}

function SwapImg(org, over){
	var tmp = over.split(".");
	eval("document." + org + ".src = 'imagens/layout/" + tmp[0] + "_over." + tmp[1] + "'");
}
function desSwap(org, over){
	eval("document." + org + ".src = 'imagens/layout/" + over + "'");
}

function AbrePopUp(sPagina,sNome,sParametros){
	window.open(sPagina,sNome,sParametros);
}

function Confirma(sMsg){
	var tmp = confirm(sMsg);
	if (!tmp) return false;
}

function AbrePopUpFotoTexto(foto){
	window.open('popupimg.php?caminho=' + foto.src.replace("_peq","") + '&','Visualizador','toolbar=0, location=0, directories=0, status=1, menubar=0, scrollbars=0, resizable=1, width=10, height=10, top=10, left=10');
}

function AbrePopUpGaleria(varPathFotos,raiz){
	window.open(raiz + 'g_popupimg.php?img=' + varPathFotos + '&','Visualizador','toolbar=0, location=0, directories=0, status=1, menubar=0, scrollbars=0, resizable=1, width=10, height=10, top=10, left=10');
}

function AbrePopUpFoto(caminho, download, raiz){
	window.open(raiz + 'popupimg.php?caminho=' + caminho + '&download=' + download + '&','Visualizador','toolbar=0, location=0, directories=0, status=1, menubar=0, scrollbars=0, resizable=1, width=10, height=10, top=10, left=10');
}

function Obrigatorios(sForm){
	var obrigatorios = eval("sForm._obrigatorios.value");
	if (obrigatorios != ""){
		obrigatorios = obrigatorios.split(",");
		for (var i = 0; i < obrigatorios.length; i++){
			if (eval("sForm." + obrigatorios[i] + ".value") == ""){
				alert("Campo obrigatorio nao preenchido!");
				eval("sForm." + obrigatorios[i] + ".focus();");
				return false;
				break;
			}
		}
	}
}

function ValidaEmail(Wparam){
	if (Wparam.value != ""){
		if (Wparam.value.indexOf('@', 0) == -1 || Wparam.value.indexOf('.', 0) == -1) { 
			alert("E-mail invalido!");
			Wparam.focus()
			return false;
		}
	}
}

function SoNumeros(){
		if (document.all)
			var Tecla = event.keyCode;
		else 
			if (document.layers)
				var Tecla = e.which;
		if ((Tecla > 47 && Tecla < 58) || (Tecla > 95 && Tecla < 106)){
			return true;
		}else{
			if (Tecla != 8 && Tecla != 46 && Tecla != 37 && Tecla != 39 && Tecla != 36 && Tecla != 35 && Tecla != 9)
				return false;
			else
				return true;
		}
	}
	
function retornaCampo(valorPadrao,valorReal){
	if (valorReal.value == ""){
		valorReal.value = valorPadrao;
	}
}

function limpaCampo(valorPadrao,valorReal){
	if (valorReal.value == valorPadrao){
		valorReal.value = "";
	}
}

function somenteNumeros(evnt,permitidos){ 
	/****************************************************************************************
	* Função para permitir somente digitação de número                                      *
	* sintaxe: somenteNumeros(event, [caracteres não numéricos permitidos])                 *
	* ex:  onKeyPress="return somenteNumeros(event,',.;');"                                 *
	****************************************************************************************/
	
	if (evnt.charCode == undefined){
		var tecla = evnt.keyCode;
	}else{
		var tecla = evnt.charCode;
	}
	
	var teste = false;
	if (permitidos != undefined && permitidos != ""){
		if (permitidos.indexOf(String.fromCharCode(tecla)) != -1) teste = true;
	}
	
    if (clientNavigator == "IE"){ 
        if (tecla < 48 || tecla > 57){   
            return teste;   
        }   
    }else{
        if ((tecla < 48 || tecla > 57) && evnt.keyCode == 0){
            return teste;
        }
    }   
}   

function mascaraFone(campo, evnt){
	if (somenteNumeros(evnt) == false){
		return false;
	}
	
	if (campo.value.length == 0) campo.value = "(" + campo.value;
	if (campo.value.length == 3) campo.value = campo.value + ") ";
	if (campo.value.length == 9) campo.value = campo.value + "-";
}

function mascaraCep(campo, evnt){
	if (somenteNumeros(evnt) == false){
		return false;
	}
	
	if (campo.value.length == 5) campo.value = campo.value + "-";
}
//-->
