var caminho = "http://www.planetamedico.com.br/novosite/saude"
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function status(theURL) { //v2.0

		url = theURL
		window.location.href(url);
  	
}
function destino(path){
	if(path.indexOf("?") == -1){
		conteudo.location.href = path + '?res=' + screen.height
	}else{
		conteudo.location.href = path + '&res=' + screen.height
	}	
}
function res(){
	var f = document.getElementById("conteudo");
	var ah = screen.availHeight;
	f.height = (1.0443*ah) - 350;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

// --- Funções Genéricas do MAC. NÃO APAGAR!!!!!!!
try{
xmlhttp = new XMLHttpRequest();}catch(ee){try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
catch(E){xmlhttp = false;}}}

function recuperar(campo, dados, pega, envia, local,params) {
		xmlhttp.open("POST", pega + "?" + campo + "=" + dados + params);
		xmlhttp.onreadystatechange=function() { 
					document.getElementById(local).innerHTML = '<font size="1" face="verdana" color="#FF0000">Aguarde...</font>'
		   if(xmlhttp.readyState == 4){
					document.getElementById(local).innerHTML = xmlhttp.responseText
				}}
			xmlhttp.send(envia) 
}
function enviarAjax(url){
	var params = ""
	var p = new Array()
	b = document.getElementsByTagName("input")
	n = 0
	for(i=0;i<b.length;i++){
		if(b[i].value!="" && b[i].value!=null && b[i].getAttribute("value")!="submit" && b[i].getAttribute("value")!="image"){
			p[n] = params + b[i].getAttribute("name") + "=" + b[i].value  
			n++;
		}
	}
	s = document.getElementsByTagName("select")
	for(j=0;j<s.length;j++){
		if(s[j].value!="" && s[j].value!=null){
			p[n] = params + s[j].getAttribute("name") + "=" + s[j].value
			n++
		}
	}
	params = p.join("&");
	window.location.href = url + "?" + params
}
function mostraPesq(id, img){
	pesq = document.getElementById(id)
	imagem = document.getElementById(img)
	if(imagem.getAttribute("status")=="ir"){
		pesq.style.display = ''
		document.getElementById("td_pesq").style.width = '180'
		imagem.src = caminho + "/images/bot_voltar_barra.gif"
		imagem.setAttribute("status","voltar")
	}else{
		pesq.style.display = 'none'
		document.getElementById("td_pesq").style.width = '0'
		imagem.src = caminho + "/images/bot_ir_barra.gif"
		imagem.setAttribute("status","ir")	
	}
}
function selEx(e){
        var key;
        var isCtrl;	
        if(window.event)
        {
                key = window.event.keyCode;     //IE
                if(window.event.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
				if(window.event.shiftKey)
                        isShift = true;
                else
                        isShift = false;
        }
        else
        {
                key = e.which;     //firefox
                if(e.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
				if(e.shiftKey)
                        isShift = true;
                else
                        isShift = false;
        }
		//alert("CTRL:"+isCtrl+" -Shift: "+isShift)
}
function abreMenu(n){
	var a = 1
	while(document.getElementById("m"+a)){
		if(document.getElementById("mn"+a)){
			document.getElementById("mn"+a).style.display = 'none'
		}
		var img = document.getElementById("img"+a)
		if(img.src.substr(img.src.length-5,5) != "2.gif"){
			i = 4
		}else{
			i = 5
		}
		img.src = img.src.substr(0,img.src.length-i) + img.src.substr(img.src.length-4,4)
		a++;
	}	
	if(document.getElementById("mn"+n)){
		document.getElementById("mn"+n).style.display = '';
		var p = getPosEl("img1").left;
		document.getElementById("mn"+n).style.left = p;
	}
	var img = document.getElementById("img"+n)
	img.src = img.src.substr(0,img.src.length-4) + "2" + img.src.substr(img.src.length-4,4)
}

function getPosEl(elemID){
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
    }
    return {left:offsetLeft};
}

function corSub(path,l,act){
switch(act){
case "entra":
	//document.getElementById(path + "." + l).style.backgroundColor  = "#F5821F"
	document.getElementById(path + "." + l).className = "tp-submenu-item-ativo"
	break;
case "sai":
	//document.getElementById(path + "." + l).style.backgroundColor = ""
	document.getElementById(path + "." + l).className = "tp-submenu-item"
	break;
}
}
function move_i(what){
	what.style.background='#EDEDED';
}
function move_o(what){
	what.style.background='#F3F3F3';
}

function validaMenu(valor){
	v = document.getElementsByName("menu")
	for(i=0;i<v.length;i++){
		if(v[i].getAttribute("value")==valor){
			sm = document.getElementsByName("submenu")
			c = 0
			for(j=0;j<sm.length;j++){
				if(sm[j].getAttribute("valMenu") == valor && sm[j].checked == true){
					c++;
				}
			}
			if(c > 0){
				v[i].checked = true
			}else{
				v[i].checked = false	
			}
		} 	
	}
}
function checaSubMenu(valor,id){
	sm = document.getElementsByName("submenu")
	for(i=0;i<sm.length;i++){
		if(sm[i].getAttribute("valMenu")==valor){
			if(document.getElementById(id).checked==true){
					sm[i].checked=true	
			}else{
					sm[i].checked=false	
			}
		}
	}
}
function fim(){
  	//window.opener.history.go(0)
	opener.location.reload();
	//window.opener.reload();
	//opener.document.execCommand('Refresh');
	window.close();
}
function checa_todos()
{
	for (var i=0;i<document.form.elements.length;i++)
        {
            var e = document.form.elements[i];
        	e.checked=(!e.checked)
        }
 }
function excluir(theURL) {
	if (confirm('O item selecionado será excluído.\nDeseja continuar ?'))
  	{
		url = theURL
		window.location.href = url;
  	}
}
function excluir_um(theURL) { //v2.0
 if (confirm('O item selecionado será excluído.\nDeseja continuar ?'))
  	{
		url = theURL;
		window.location.href(url);
  	}
}
function excluir_varios(theURL,campo) { //v2.0
 if (confirm('O(s) item(ns) selecionado(s) será(ão) excluído(s).\nDeseja continuar ?'))
  	{
		VFormObj = document.form; 
		numero = VFormObj.elements.length; 
		for(i = 0; i < numero; i++) 
		{ 
			var selecionados; 
			if(VFormObj.elements[i].checked == true) 
			{ 
				if (selecionados == null) 
				{ 
					selecionados=VFormObj.elements[i].value; 
				} 
				else 
				{ 
					selecionados=selecionados + "," + VFormObj.elements[i].value; 
				} 
			} 
		} 
		if (theURL.indexOf("?") == -1){
			url = theURL + '?' + campo + '=' + selecionados;
		}else{
			url = theURL + '&' + campo + '=' + selecionados;
		}
		if(selecionados!=undefined){
			window.location.href = url;
		}
  	}
}
function Trim(str){
	while (str.charAt(0) == " ")
	str = str.substr(1,str.length -1);
	
	while (str.charAt(str.length-1) == " ")
	str = str.substr(0,str.length-1);
	
	return str;
} 


function abre_janela(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function resetaPos(){
	var a = 1
	while(document.getElementById("m"+a)){
		if(document.getElementById("mn"+a)){
			document.getElementById("mn"+a).style.display = 'none'
		}
		a++;
	}	
}


function verificacao(nomeForm){

var msgBranco = "Favor preencher o campo";//Mensagem para campos vazios
var msgBrancoRadio = "Favor selecionar o campo";//Mensagem para radio buttons
var msgEmail = "com um e-mail válido";
var msgNumero = "Somente com números";
var msgCPF = "com um CPF válido";
var msgCEP = "com um CEP válido";
var msgCNPJ = "com um CNPJ válido";
var msgFone = "com um telefone válido";
var msgCaracteres = "com no mínimo";
var msgLink = "com um link válido";
var msgData = "com uma data válida";
var msgCkecked = "Favor selecionar ao menos uma opção do campo";
var msgHora = "com uma hora válida";
var msgCompara1 = "O campo";
var msgCompara2 = "deve ser idêntico ao campo";
var msgArquivo1 = "O nome de arquivo no campo"
var msgArquivo2 = "não pode conter espaços ou acentos"
var msgFormato1 = "O formato de arquivo no campo"
var msgFormato2 = "deve ser"
var msgValor1 = "O campo"
var msgValor2 = "deve conter um valor monetário"

fv = document.getElementById(nomeForm);
for(q=0;q<fv.length;q++){
	if(fv[q].id!=""){
	if(fv[q].getAttribute("verificar")!='' && fv[q].getAttribute("verificar")!=undefined ){
		if(fv[q].value==''){
			alert(msgBranco+' "'+fv[q].getAttribute("verificar")+'".');
			fv[q].focus();
			return false;
		}
		if(fv[q].getAttribute("type")=='checkbox' || fv[q].getAttribute("type")=='radio'){
			h=0;
			for(y=1;y<=fv[q].getAttribute("quantCampos");y++){
					if(fv[q+y-1].checked==false){
						h++
					}
			}
			if(h==fv[q].getAttribute("quantCampos")){
				if(fv[q].getAttribute("type")=='checkbox'){
					alert(msgCkecked+' "'+fv[q].getAttribute("verificar")+'".');
				}else{
					alert(msgBrancoRadio+' "'+fv[q].getAttribute("verificar")+'".');
				}
				fv[q].focus();
				return false;	
			}
		}
	}
	if(fv[q].getAttribute("email")!=undefined && fv[q].value!=""){
		formatoEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(fv[q].value)
		if(formatoEmail==false ){
			alert(msgBranco+' "'+fv[q].getAttribute("email")+'" ' + msgEmail+'.');
			fv[q].focus();
			return false;
		}
	}
	if (fv[q].getAttribute("numero")!=undefined && fv[q].value!=""){
		if((fv[q].value * 0)!=0){					
			alert(msgBranco+'"'+fv[q].getAttribute("numero")+'" '+msgNumero+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("cpf")!=undefined && fv[q].value!=""){
		valorCPF = String(fv[q].value).replace(/\D/g,"");
		if(valorCPF.length!=11){
			alert(msgBranco +' "' + fv[q].getAttribute("cpf") + '" '+ msgCPF+'.');
			fv[q].focus();
			return false;
		}
		var i; 
		s = valorCPF; 
		var c = s.substr(0,9); 
		var dv = s.substr(9,2); 
		var d1 = 0; 
		for (i = 0; i < 9; i++){ 
			d1 += c.charAt(i)*(10-i); 
		} 
		if (d1 == 0){ 
			alert(msgBranco +' "' + fv[q].getAttribute("cpf") + '" '+ msgCPF+'.');
			fv[q].focus();
			return false;
		} 
		d1 = 11 - (d1 % 11); 
		if (d1 > 9){d1 = 0}; 
		if (dv.charAt(0) != d1){ 
			alert(msgBranco +' "' + fv[q].getAttribute("cpf") + '" '+ msgCPF+'.');
			fv[q].focus();
			return false;
		}
		d1 *= 2; 
		for (i = 0; i < 9; i++){ 
			d1 += c.charAt(i)*(11-i); 
		} 
		d1 = 11 - (d1 % 11); 
		if (d1 > 9) {d1 = 0}; 
		if (dv.charAt(1) != d1){ 
			alert(msgBranco +' "' + fv[q].getAttribute("cpf") + '" '+ msgCPF+'.');
			fv[q].focus();
			return false; 
		} 
	}
	if(fv[q].getAttribute("cep")!=undefined && fv[q].value!=""){
		valorCEP = String(fv[q].value).replace(/[.-]/g,"");
		if(valorCEP.length!=8){
			alert(msgBranco+' "'+fv[q].getAttribute("cep")+'" '+msgCEP+'.');
			fv[q].focus();
			return false;
		}
		if(valorCEP == "00000000" || valorCEP == "11111111" || valorCEP == "22222222" || valorCEP == "33333333" || valorCEP == "44444444" || valorCEP == "55555555" || valorCEP == "66666666" || valorCEP == "77777777" || valorCEP == "88888888" || valorCEP == "99999999"){
			alert(msgBranco+' "'+fv[q].getAttribute("cep")+'" '+msgCEP+'.');
			fv[q].focus();
			return false;	
		}
		if((valorCEP.charAt(0)==valorCEP.charAt(2) && valorCEP.charAt(1)==valorCEP.charAt(3) && valorCEP.charAt(2)==valorCEP.charAt(4))){
			alert(msgBranco+' "'+fv[q].getAttribute("cep")+'" '+msgCEP+'.');
			fv[q].focus();
			return false;	
		}
	}
	if(fv[q].getAttribute("cnpj")!=undefined && fv[q].value!=""){
		valorCNPJ = String(fv[q].value).replace(/\D/g,"");
		if(valorCNPJ.length!=14){
			alert(msgBranco+' "'+fv[q].getAttribute("cnpj")+'" '+msgCNPJ+'.');
			fv[q].focus();
			return false;
		}
		a = [];
		b = new Number;
		c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
		for (i=0; i<12; i++){
			a[i] = valorCNPJ.charAt(i);
			b += a[i] * c[i+1];
		}
		if ((x = b % 11) < 2){
			a[12] = 0
		}else{ 
			a[12] = 11-x 
		}
		b = 0;
		for (y=0; y<13; y++){
			b += (a[y] * c[y]);
		}
		if ((x = b % 11) < 2){ 
			a[13] = 0; 
		}else{ 
			a[13] = 11-x; 
		}
		if((valorCNPJ.charAt(12) != a[12]) || (valorCNPJ.charAt(13) != a[13])){
			alert(msgBranco+' "'+fv[q].getAttribute("cnpj")+'" '+msgCNPJ+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("fone")!=undefined && fv[q].value!=""){
		valorFone = String(fv[q].value).replace(/\D/g,"");
		if((/[a-z]/g).test(valorFone)==true){
			alert(msgBranco+' "'+fv[q].getAttribute("fone")+'" '+msgFone+'.');
			fv[q].focus();
			return false;	
		}
		if(valorFone == "0000000000" || valorFone == "1111111111" || valorFone == "2222222222"|| valorFone == "3333333333" || valorFone == "4444444444" || valorFone == "5555555555" || valorFone == "6666666666" || valorFone == "7777777777" || valorFone == "8888888888" || valorFone == "9999999999"){
			alert(msgBranco+' "'+fv[q].getAttribute("fone")+'" '+msgFone+'.');
			fv[q].focus();
			return false;	
		}
		if((valorFone.charAt(0)==valorFone.charAt(2) && valorFone.charAt(1)==valorFone.charAt(3) && valorFone.charAt(2)==valorFone.charAt(4) &&valorFone.charAt(3)==valorFone.charAt(5) && valorFone.charAt(4)==valorFone.charAt(6))){
			alert(msgBranco+' "'+fv[q].getAttribute("fone")+'" '+msgFone+'.');
			fv[q].focus();
			return false;	
		}
	}
	if(fv[q].getAttribute("caracteres")!=undefined && fv[q].value!=""){
		numeroCaractere = fv[q].getAttribute("quantCaracteres");
		valorCaractere = String(fv[q].value).replace(/[ ]/g,"");
		if(valorCaractere.length<numeroCaractere){
			alert(msgBranco+' "'+fv[q].getAttribute("caracteres")+'" '+msgCaracteres+' "'+fv[q].getAttribute("quantCaracteres")+'" caracteres.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("link")!=undefined && fv[q].value!=""){
		testeURL_a = /^http:\/\//;
		testeURL_b = /^https:\/\//;
		testeURL_c = /[^a-z:\/\/]/g;
		if(testeURL_a.test(fv[q].value)==false || testeURL_b.test(fv[q].value)==false && testeURL_c.test(fv[q].value)==true){
			alert(msgBranco+' "'+fv[q].getAttribute("link")+'" '+msgLink+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("data")!=undefined && fv[q].value!=""){
		valorData = String(fv[q].value).replace(/\D/g,"");
		dataTeste_a = valorData.charAt(0) + valorData.charAt(1);
		dataTeste_b = valorData.charAt(2) + valorData.charAt(3);
		dataTeste_c = valorData.charAt(4) + valorData.charAt(5) + valorData.charAt(6) + valorData.charAt(7);
		dataTesteBi = dataTeste_c / 4;
		if(dataTeste_b>12){
			alert(msgBranco+' "'+fv[q].getAttribute("data")+'" '+msgData+'.');
			fv[q].focus();
			return false;
		}
		if(dataTeste_b==01 || dataTeste_b==03 || dataTeste_b==05 || dataTeste_b==07 || dataTeste_b==08 || dataTeste_b==10 || dataTeste_b==12){
			valorMes=31
		}
		if(dataTeste_b==04 || dataTeste_b==06 || dataTeste_b==09 || dataTeste_b==11){
			valorMes=30
		}
		if(dataTeste_b==02){
			if((/\D/g).test(dataTesteBi)==false){
				valorMes=29;
			}else{
				valorMes=28;
			}
		}
		dataTeste_c = /-/g;
		if(dataTeste_a>valorMes || dataTeste_c.test(fv[q].value)==true){
			alert(msgBranco+' "'+fv[q].getAttribute("data")+'" '+msgData+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("hora")!=undefined && fv[q].getAttribute("hora")!="" && fv[q].value!=""){//hora
		valorHora = String(fv[q].value).replace(/\D/g,"");
		horaTeste_a = valorHora.charAt(0) + valorHora.charAt(1);
		horaTeste_b = valorHora.charAt(2) + valorHora.charAt(3);
		horaTeste_c = /-/g;
		if(horaTeste_a>24 || horaTeste_b>59 || horaTeste_c.test(fv[q].value)==true){
			alert(msgBranco+' "'+fv[q].getAttribute("hora")+'" '+msgHora+'.');
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("monetario")!=undefined && fv[q].getAttribute("monetario")!="" && fv[q].value != "" ){
		if(/\,\d{2}$/.test(fv[q].value)==false || /\D/.test(fv[q].value.replace(",",""))==true){
			alert(msgValor1 + " " + fv[q].getAttribute("monetario") + " " + msgValor2);
			fv[q].focus();
			return false;
		}
	}
	if(fv[q].getAttribute("verificaNomeArquivo")!=undefined && fv[q].getAttribute("verificaNomeArquivo")!="" && fv[q].value!=""){//hora
		var arq = fv[q].value.split("\\")
		var nome = arq[arq.length-1]
		if(nome.split(" ").length > 1){
			alert(msgArquivo1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgArquivo2 + ".")
			fv[q].focus();
			return false;
		}
		var ext = nome.split(".")
		switch(fv[q].getAttribute("formato")){
			case "audio":
				if(ext[ext.length-1].toLowerCase()!="mp3"){
					alert(msgFormato1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgFormato2 + " mp3.")
					fv[q].focus();
					return false;
				}
				break;
			case "video":
				if(ext[ext.length-1].toLowerCase()!="flv"){
					alert(msgFormato1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgFormato2 + " mp3.")
					fv[q].focus();
					return false;
				}
				break;
			case "arquivo":
				if(ext[ext.length-1].toLowerCase()=="exe" || ext[ext.length-1].toLowerCase()=="bat" || ext[ext.length-1].toLowerCase()=="dll" || ext[ext.length-1].toLowerCase()=="vbs" || ext[ext.length-1].toLowerCase()=="scr"){
					alert(msgFormato1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " não " + msgFormato2 + " " + ext[ext.length-1].toLowerCase() + ".")
					fv[q].focus();
					return false;
				}
				break;
			case "imagem":
				if(ext[ext.length-1].toLowerCase()!="jpg" && ext[ext.length-1].toLowerCase()!="gif"){
					alert(msgFormato1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgFormato2 + " jpg ou gif.")
					fv[q].focus();
					return false;
				}
				break;
			case "divulgacao":
				if(ext[ext.length-1].toLowerCase()!="jpg" && ext[ext.length-1].toLowerCase()!="gif" && ext[ext.length-1].toLowerCase()!="swf"){
					alert(msgFormato1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgFormato2 + " jpg, gif ou swf.")
					fv[q].focus();
					return false;
				}
				break;
		}
		acentos = /[áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÅÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ=+^~&%$#@]/
		if(nome.search(acentos)!=-1){
			alert(msgArquivo1 + " " + fv[q].getAttribute("verificaNomeArquivo") + " " + msgArquivo2 + ".")
			fv[q].focus();
			return false;
		}			
	}
	if(fv[q].getAttribute("comparar")!=undefined && fv[q].getAttribute("comparar")!="" && fv[q].value!=""){
		campoComp = fv[q].getAttribute("campo")
		switch(fv[q].getAttribute("modoComparar")){
		case "maior":
			if(fv[q].value < document.getElementById(campoComp).value){
				alert(msgCompara1+' "'+fv[q].getAttribute("comparar")+'" '+msgCompara2+' "'+document.getElementById(campoComp).getAttribute("nomeComparar")+'".');
				fv[q].focus();
				return false;
			}			
			break;
		case "menor":
			if(fv[q].value > document.getElementById(campoComp).value){
				alert(msgCompara1+' "'+fv[q].getAttribute("comparar")+'" '+msgCompara2+' "'+document.getElementById(campoComp).getAttribute("nomeComparar")+'".');
				fv[q].focus();
				return false;
			}			
			break;
		case "igual":
			if(fv[q].value != document.getElementById(campoComp).value){
				alert(msgCompara1+' "'+fv[q].getAttribute("comparar")+'" '+msgCompara2+' "'+document.getElementById(campoComp).getAttribute("nomeComparar")+'".');
				fv[q].focus();
				return false;
			}		
			break;		
		}

	}
}
}
}


function mascaras(id,tipo,parametro){

campo = document.getElementById(id);
switch(tipo){
	case 'numeros':	
		valorCampoSomenteNumeros = String(campo.value).replace(/\D/g,"");
		if((/\D/g).test(campo.value)==true){
			campo.value = valorCampoSomenteNumeros;
		}
		break;
	case 'naoLetras':
		valorLetras = String(campo.value).replace(/[a-zA-Z]/g,"")
		if(window.event && (/[a-z]/gi).test(campo.value)==true){
				campo.value = valorLetras;
		}
		break;
	case 'cep':
		if(campo.value.length==5){
			campo.value = campo.value+'-';
		}
		break;
	case 'cpf':
		switch(campo.value.length){
			case 3:
				campo.value = campo.value+'.';
				break;
			case 7:
				if(campo.value.charAt(3)=='.'){
					campo.value = campo.value+'.';
				}
				break;
			case 11:
				if(campo.value.charAt(3)=='.' && campo.value.charAt(7)=='.'){
					campo.value = campo.value+'-';
				}else{
					
				}
		}
		break;
	case 'cnpj':
		switch(campo.value.length){
			case 2:
				campo.value = campo.value+'.';
				break;
			case 6:
				if(campo.value.charAt(2)=='.'){
					campo.value = campo.value+'.';
				}				
				break;
			case 10:
				if(campo.value.charAt(2)=='.' && campo.value.charAt(6)=='.'){
					campo.value = campo.value+'.';
				}
				break;
			case 14:
				
				break;
			case 15:
				if(campo.value.charAt(2)=='.' && campo.value.charAt(6)=='.' && campo.value.charAt(10)=='/'){
					campo.value = campo.value+'.';
				}	
				break;
		}
		break;
	case 'fone':
		if(campo.value.length==4){
			campo.value = campo.value+'-';
		}
		break;
	case 'data':
		if(campo.value.length==2){
			campo.value = campo.value+'/';
		}
		if(campo.value.length==5 && campo.value.charAt(2)=='/'){
			campo.value = campo.value+'/';
		}
		break;
	case 'hora':
		if(campo.value.length==2){
			campo.value = campo.value+':';
		}
	case 'pular':
		if(campo.value.length==campo.getAttribute('maxlength')){
			document.getElementById(parametro).focus();
		}
		break;
	case 'monetario':
		alert(campo.value.toString().replace('',''))
		break;
}		
}

function trocaVal(c,nc){
	campo = document.getElementById(c).value
	document.getElementById(nc).value = campo	
}
// --- Funções específicas do Site
function trocaDestaque(){
	window.resizeTo(300,382)
	document.getElementById("div_4").style.display = "none"
	document.getElementById("div_4").setAttribute("verificar","")
	document.getElementById("div_5").style.display = "none"
	document.getElementById("div_5").setAttribute("verificar","")
	document.getElementById("div_1").style.display = "none"
	document.getElementById("div_1").setAttribute("verificar","")
	document.getElementById("div_3").style.display = "none"
	document.getElementById("div_3").setAttribute("verificar","")
	document.getElementById("div_" + document.getElementById("dest_canal").value).style.display = ""
	document.getElementById("div_" + document.getElementById("dest_canal").value).setAttribute("verificar","Local do Destaque")
}

function pegaCidade(idEstado) {
try{xmlhttp = new XMLHttpRequest();}
catch(ee){
	try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
	catch(e){
		try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
		catch(E){xmlhttp = false;}
	}
}
	xmlhttp.open("POST", "troca_cidade.asp?id=" + idEstado + "&cidade=<%=cidade%>");
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf8_encode');
	xmlhttp.onreadystatechange=function() { 
		document.getElementById('boxCidades').innerHTML = '<font size="1" face="verdana" color="#FF0000">Aguarde...</font>'
		if(xmlhttp.readyState == 4){
			document.getElementById('boxCidades').innerHTML = xmlhttp.responseText
		}
	}
		xmlhttp.send('index.asp') 
}

function pegaBairro(idCidade) {
	try{xmlhttp2 = new XMLHttpRequest();}
catch(ee){
	try{xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");}
	catch(e){
		try{xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");}
		catch(E){xmlhttp2 = false;}
	}
}
	
	xmlhttp2.open("POST", "troca_bairro.asp?id=" + idCidade + "&bairro=<%=bairro%>");
	xmlhttp2.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf8_encode');
	xmlhttp2.onreadystatechange=function() { 
		document.getElementById('boxBairros').innerHTML = '<font size="1" face="verdana" color="#FF0000">Aguarde...</font>'
		if(xmlhttp2.readyState == 4){
			document.getElementById('boxBairros').innerHTML = xmlhttp2.responseText
		}
	}
		xmlhttp2.send('index.asp') 
}

function preencheCidade(valor){
	document.getElementById('vlCidade').value= valor
}
function preencheBairro(valor){
	document.getElementById('vlBairro').value= valor
}
function novoBairro(){
	document.getElementById('vlBairro').value = ''
	document.getElementById('bairro').setAttribute('verificar','')
	document.getElementById('bairro').style.display = 'none'
	document.getElementById('digite_novo').style.display = 'none'	
	document.getElementById('outroBairro').style.display = ''
	document.getElementById('outroBairro').setAttribute('verificar','Bairro')
}
function valores(campo,combo){
	document.getElementById(campo).value = document.getElementById(combo).value
}
function verificaCidBar(){
	var res = verificacao('frmCadastro')
	if(res!=false){
		if(document.getElementById('cidade')){
		if(document.getElementById('cidade').value!=''){
			if(document.getElementById('bairro')){
				if(document.getElementById('bairro').value!=""){
					return true;
				}else{
					alert('Favor selecionar seu bairro')
					return false;
				}
			}else{
				alert('Favor selecionar sua cidade e seu bairro.')
				return false;
			}	
		}else{
			alert('Favor selecionar sua cidade.')
			return false;
		}
	}else{
		alert('Favor selecionar seu estado e sua cidade');
		return false;	
	}	
	}else{
		return false;	
	}
}
function adicionaItem(orig,dest) 
{	
	o = document.getElementById(orig)
	d = document.getElementById(dest)
	if (o.value == ""){
		alert('Favor selecionar ao menos um dos itens!');
	}
	var len = d.length;
	for(var i=0;i<o.length;i++){
		if (o.options[i] != null && o.options[i].selected){
			d.options[len] = new Option(o.options[i].text, o.options[i].value); 
			len++;
			o.options[i] = null; 
			i--;
		}
	}
}
function trocaOrdem(dir,cmb){	
	c = document.getElementById(cmb)
	var len = c.length;
	var t = 0
	for(var i=0;i<len;i++){
		if (c.options[i] != null && c.options[i].selected && t == 0){
			switch(dir){
				case "subir":
					if(i>0){
						var vI = new Array(c.options[i-1].text,c.options[i-1].value)
						var vF = new Array(c.options[i].text,c.options[i].value)
						c.options[i-1].text = vF[0]
						c.options[i-1].value = vF[1]
						c.options[i].text = vI[0]
						c.options[i].value = vI[1]
						if(c.selectedIndex > 0){
							c.selectedIndex = c.selectedIndex - 1
						}
					}
					break;
				case "descer":
					if(i < (len-1) && len > 1){
						var vI = new Array(c.options[i].text,c.options[i].value)
						var vF = new Array(c.options[i+1].text,c.options[i+1].value)
						c.options[i].text = vF[0]
						c.options[i].value = vF[1]
						c.options[i+1].text = vI[0]
						c.options[i+1].value = vI[1]
						if(c.selectedIndex < c.length){
							c.selectedIndex = c.selectedIndex + 1
						}
					}
					break;
			}
			t = 1
		}
	}
}
function selCampos(d)
{
	dest = document.getElementById(d)
	for(var i = 0; i < dest.length; i++){
		dest.options[i].selected = true;
	}
}

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-2355013-9");
pageTracker._trackPageview();
} catch(err) {}