// JavaScript Document
//===================================================================================================
//	FORMULÁRIOS
//===================================================================================================
	function check_form(frmString, frmCampoValidar){
				
		var TstringCompara = frmCampoValidar.split(",").length;
		var StringElement = frmCampoValidar.split(",");
		var i;
		for (i=0;i<=(TstringCompara-1);i++){		
			var NomeCampo = StringElement[i];
			if(document.getElementById(NomeCampo).type == 'text' || document.getElementById(NomeCampo).type == 'textarea'){
				if(document.getElementById(NomeCampo).value==''){
					alert('Preencha: ' + document.getElementById(NomeCampo).title);
					document.getElementById(NomeCampo).style.borderColor='red';
					document.getElementById(NomeCampo).focus();				
					return false;
					break		
				}else{document.getElementById(NomeCampo).style.border = "solid #CCCCCC 1px";}
			}else if(document.getElementById(NomeCampo).type == 'checkbox'){
				if(!document.getElementById(NomeCampo).checked){
					alert('Selecione: ' + document.getElementById(NomeCampo).title);
					document.getElementById(NomeCampo).focus();				
					return false;
					break		
				}							
			}
		}
		return true;
	}
//===================================================================================================
//	FORMULÁRIOS AJAX
//===================================================================================================
	function AjaxSubmit(frm, Nfunc){
		return Spry.Utils.submitForm(frm, Nfunc);					
	}
	function MySuccessCallbackExc(req){
		location.href = req.xhRequest.responseText;
	}	
	function MyErrorCallbackExc(req){
		document.getElementById('ZoupFitLoader').style.display = 'none';
		alert('Ocorreu um erro na exclusao');
	}
	function Excluir(strNuId,strUrl){
		if(confirm('Tem certeza que deseja excluir?')){	
			var req = Spry.Utils.loadURL("POST", "zoup.fit-global-salvar.asp?acao=excluir_texto&ZoupFitPaginaConteudo="+strNuId+"&url_page="+strUrl, true, MySuccessCallbackExc, { postData: "action=update&genre=fiction", headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" }, errorCallback: MyErrorCallbackExc });
		}else{
			return false;
		}		
	}
	function EnviarEmail(req) 
	{
		if(req.xhRequest.responseText == 'false'){
			Spry.Utils.setInnerHTML('RequeryResposta', 'Ocorreu um erro no cadastro');
		}else if(req.xhRequest.responseText == 'true'){
			document.getElementById("ZoupFitLoader").style.display='none';	
			alert('e-mail enviado com sucesso!');
			window.location.replace('Default.asp');
		}						
	}	
	function SelecionarRoteiros(strObj){
		var obj = strObj;		
		for(var i = 0;i < obj.options.length;i++){
			obj.options[i].selected = true;
		}
	} 	
//===================================================================================================
//	POP UPS
//===================================================================================================	
	function AbrePopUp(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}	
	function AbreCidade(theURL) { //v2.0
	  window.opener.location ='zoup.fit-cidade.asp?ZoupFitPagina='+theURL+'&ZoupFitPaginaConteudo='+theURL;
	}		
	
//===================================================================================================
//	ANUNCIOS 
//===================================================================================================	
	function mostraLayer(Nlayer, Hlayer, FLayer, HFLayer){
		var NomeLayer = Nlayer;
		var NomeLayerAnterior = Hlayer;
		var BackGround = FLayer;
		var BackGroundAnterior = HFLayer;
		
		if(document.getElementById(NomeLayer).style.display=='none'){
			document.getElementById(NomeLayer).style.display='block';
			document.getElementById(FLayer+'b').style.display='block';
			document.getElementById(BackGround).style.backgroundColor='#F5F4E7';
			document.getElementById(BackGround).style.borderTop = "dashed #ccc 1px";
			document.getElementById(BackGround).style.borderLeft = "dashed #ccc 1px";
			document.getElementById(BackGround).style.borderRight = "dashed #ccc 1px";			
			
			if(document.getElementById(NomeLayerAnterior).value!='' && document.getElementById(NomeLayerAnterior).value!=NomeLayer){				
				document.getElementById(document.getElementById(NomeLayerAnterior).value).style.display='none';
				document.getElementById(document.getElementById(BackGroundAnterior).value).style.backgroundColor='#F4F5F0';
				document.getElementById(document.getElementById(BackGroundAnterior).value).style.borderTop = "dashed #ccc 0px";
				document.getElementById(document.getElementById(BackGroundAnterior).value).style.borderLeft = "dashed #ccc 0px";
				document.getElementById(document.getElementById(BackGroundAnterior).value).style.borderRight = "dashed #ccc 0px";
				document.getElementById(document.getElementById(BackGroundAnterior).value+'b').style.display='none';
			}

			document.getElementById('BackGroundAnterior').value=BackGround;
			document.getElementById('LayerAnterior').value=NomeLayer;			
		}else{
			document.getElementById(BackGround).style.backgroundColor='#F4F5F0';
			document.getElementById(BackGround).style.borderTop = "dashed #ccc 0px";
			document.getElementById(BackGround).style.borderLeft = "dashed #ccc 0px";
			document.getElementById(BackGround).style.borderRight = "dashed #ccc 0px";							
			document.getElementById(NomeLayer).style.display='none';
			document.getElementById(BackGround+'b').style.display='none';
		}
	}
	function fecharAnuncio(Nlayer, FLayer){
			document.getElementById(FLayer+'b').style.display='none';
			document.getElementById(FLayer).style.backgroundColor='#F4F5F0';
			document.getElementById(FLayer).style.borderTop = "dashed #ccc 0px";
			document.getElementById(FLayer).style.borderLeft = "dashed #ccc 0px";
			document.getElementById(FLayer).style.borderRight = "dashed #ccc 0px";							
			document.getElementById(Nlayer).style.display='none';			
	}		