
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 1,
        wrap: 'last',
        //initCallback: mycarousel_initCallback
    });
	
    jQuery('#mycarouselBanner').jcarousel({
        auto: 1,
        wrap: 'last',
        //initCallback: mycarousel_initCallback
    });	
	
});


function formatText(index, panel) {
		  return index + "";
	    }
    
	
	
	
        $(function () {
					
					
        
            $('.anythingSlider').anythingSlider({
                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 3000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 600,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
        		startText: "Go",             // Start text
		        stopText: "Stop",               // Stop text
		        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
            });
			
    $('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});	
			
			$.superbox();
			
			$.superbox.settings = {
				boxId: "superbox", // Id attribute of the "superbox" element
				boxClasses: "", // Class of the "superbox" element
				overlayOpacity: .8, // Background opaqueness
				boxWidth: "600", // Default width of the box
				boxHeight: "400", // Default height of the box
				loadTxt: "Carregando...", // Loading text
				closeTxt: "Fechar", // "Close" button text
				prevTxt: "Voltar", // "Previous" button text
				nextTxt: "Avançar" // "Next" button text
			};			
            
            $("#slide-jump").click(function(){
                $('.anythingSlider').anythingSlider(6);
            });
            
        });

function SubmitForm(frmProdutos)
{       
if(event.keyCode == 13) // código ASCII da tecla enter    
    {
		document.forms[frmProdutos].submit(); // envia o form       
    }
}

function displayForm(id,state) {
	if(state=='on'){
		document.getElementById(id).style.display = 'block';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}


window.onload = function() {
	
	var objNoivos = document.getElementById('frmNoivos');
	if (objNoivos) {
		objNoivos.onsubmit = function() {return funEnviaFormParametros(this);};
	}
	
	var objUsuarios = document.getElementById('frmUsuarios');
	if (objUsuarios) {
		objUsuarios.onsubmit = function() {return funEnviaFormUsuarios(this);};
	}	
	
	var objConvidados = document.getElementById('frmConvidados');
	if (objConvidados) {
		objConvidados.onsubmit = function() {return funEnviaPesquisa(this);};
	}
	
	
}


function _funcAtualizaQuantidade(valorQuantidade, codProduto) {
	
	if (valorQuantidade != "") {
		location.href='atualizarLista.asp?Quantidade=' + valorQuantidade + '&codProduto=' + codProduto;	
	}
	
}




function funEnviaPesquisa(objFrm) {

	
	return true;
}

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}

function soNumerosBox(v){
    return v.replace(/\D/g,"")
}

function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function data(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/(\d{2})(\d)/,"$1/$2")    //Coloca hífen entre o quarto e o quinto dígitos
	v=v.replace(/(\d{6})(\d)/,"$1/$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function cpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}

function cep(v){
    v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}

function cnpj(v){
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}

function romanos(v){
    v=v.toUpperCase()             //Maiúsculas
    v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
    //Essa é complicada! Copiei daqui: http://www.diveintopython.org/refactoring/refactoring.html
    while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
        v=v.replace(/.$/,"")
    return v
}

function site(v){
    //Esse sem comentarios para que você entenda sozinho ;-)
    v=v.replace(/^http:\/\/?/,"")
    dominio=v
    caminho=""
    if(v.indexOf("/")>-1)
        dominio=v.split("/")[0]
        caminho=v.replace(/[^\/]*/,"")
    dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
    caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
    caminho=caminho.replace(/([\?&])=/,"$1")
    if(caminho!="")dominio=dominio.replace(/\.+$/,"")
    v="http://"+dominio+caminho
    return v
}

function funEnviaFormUsuarios(objFrm) {

	if (objFrm.txtLogin.value == '' ) {
		alert('É obrigatório informar o login.');
		objFrm.txtLogin.focus()
		return false;
	}

	if (objFrm.txtSenha.value == '' ) {
		alert('É obrigatório informar a senha.');
		objFrm.txtSenha.focus()
		return false;
	}
	
	return true;
}

function funEnviaFormParametros(objFrm) {

	if (objFrm.txtEmail.value == '' ) {
		alert('É obrigatório informar o E-mail.');
		objFrm.txtEmail.focus()
		return false;
	}
	
	if 	(!(CheckEmail(objFrm.txtEmail.value)))			
		{
			alert("E-mail informado esta em um formato inválido!");
			objFrm.txtEmail.focus();
			return false;
		}

	if (objFrm.txtSenha.value == '' ) {
		alert('É obrigatório informar a senha.');
		objFrm.txtSenha.focus()
		return false;
	}
	
	return true;
}
function ValidaEnviaSenhaUsuario(objFrm) {

	if (objFrm.txtEmail.value == '' ) {
		alert('É obrigatório informar o E-mail.');
		objFrm.txtEmail.focus()
		return false;
	}
	
	if 	(!(CheckEmail(objFrm.txtEmail.value)))			
		{
			alert("E-mail informado esta em um formato inválido!");
			objFrm.txtEmail.focus();
			return false;
		}

	
	return true;
}

function MascaraNova(strField, sMask) { 
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; 
	objForm = document.RequestForm; 
	
	if(document.all) { // Internet Explorer 
	nTecla = event.keyCode; } 
	else if(document.layers) { // Nestcape 
	nTecla = event.which; 
	} 
	
	if(nTecla == 39) return false; 
	
	sValue = objForm[strField].value; 
	
	// Limpa todos os caracteres de formatação que 
	// já estiverem no campo. 
	sValue = sValue.toString().replace( "-", "" ); 
	sValue = sValue.toString().replace( "-", "" ); 
	sValue = sValue.toString().replace( ".", "" ); 
	sValue = sValue.toString().replace( ".", "" ); 
	sValue = sValue.toString().replace( "/", "" ); 
	sValue = sValue.toString().replace( "/", "" ); 
	sValue = sValue.toString().replace( "(", "" ); 
	sValue = sValue.toString().replace( "(", "" ); 
	sValue = sValue.toString().replace( ")", "" ); 
	sValue = sValue.toString().replace( ")", "" ); 
	sValue = sValue.toString().replace( " ", "" ); 
	sValue = sValue.toString().replace( ":", "" ); 
	sValue = sValue.toString().replace( ",", "" ); 
	sValue = sValue.toString().replace( "$", "" ); 
	sValue = sValue.toString().replace( "R", "" ); 
	fldLen = sValue.length; 
	mskLen = sMask.length; // = 5 
	
	i = 0; 
	nCount = 0; 
	sCod = ""; 
	mskLen = fldLen; 
	
	while (i <= mskLen) { 
	bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/")); 
	bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")); 
	bolMask = bolMask || ((sMask.charAt(i) == ":") || (sMask.charAt(i) == "$") || (sMask.charAt(i) == "R") || (sMask.charAt(i) == ",")); 
	
	if (bolMask) { 
	sCod += sMask.charAt(i); 
	mskLen++; } 
	else { 
	sCod += sValue.charAt(nCount); 
	nCount++; 
	} 
	
	i++; 
	} 
	
	objForm[strField].value = sCod; 
	
	if (nTecla != 8) { // backspace 
	if (sMask.charAt(i-1) == "9") { // apenas números... 
	return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9 
	else { // qualquer caracter... 
	return true; 
	} } 
	else { 
	return true; 
	} 
} 

function SoNumeros(Elem) {
	if (event.keyCode < 48 || event.keyCode > 57){ 
		event.returnValue = false; 
	} 
}


function get_comboSecao(codSecao){
	for (var i=0;i < document.getElementById('cboGrupo').options.length;i++){ 
		
	  if(document.getElementById('cboGrupo').options[i].value == document.getElementById('cboGrupo').value){ 
	  document.getElementById('cboGrupo').options.selectedIndex = i; 
		} 
	}

	
	if (document.getElementById('cboGrupo').value != ""){
		document.getElementById('cboSecao').options[document.getElementById('cboSecao').options.length] = new Option ("Aguarde ...", "", true, true);
		var comboModelos = createXMLHTTP();
	
		comboModelos.open("post", "../xml/xmlSecao.asp?codSecao="+codSecao+"&codGrupo=" + document.getElementById('cboGrupo').value, true);
		comboModelos.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		comboModelos.onreadystatechange=function(){
			if (comboModelos.readyState==4){// abaixo o texto do gerado no arquivo xmlGerenciaRelatorio.asp e colocado no span
				document.getElementById('divmodelos').innerHTML = comboModelos.responseText;
			}
		}
			comboModelos.send("codSecao="+ codSecao +"&codGrupo=" + document.getElementById('cboGrupo').value);
	}
}
	
function CheckEmail(email)
{
   var achou_ponto=false;
   var achou_arroba=false;
   var nao_achou_espaco=false;

   for (var i=0; i < email.length; i++)
   {
      if (email.charAt(i)=="@")
      { 
         if (email.charAt(i+1)==".") achou_arroba=false;
         else achou_arroba=true;
      }
      else if (email.charAt(i)==".") achou_ponto=true;
      else if (email.charAt(i)!=" ") nao_achou_espaco=true;
   }
   if(email.charAt(email.length-1)==".") achou_ponto=false;
   if (achou_ponto && achou_arroba && nao_achou_espaco) return true;
   else
   {      
      return false;  
   }
}

function RetirarItem(codSequencia, codProduto){
	
	if (!confirm('Deseja realmente excluir este produto do seu carrinho?'))return;
		location.href='excluirProduto.asp?Codigo='+codProduto+'&codSequencia='+codSequencia;
	
	return;
}

function RetirarItemLista(codProduto){
	
	if (!confirm('Deseja realmente excluir este produto da sua lista?'))return;
		location.href='excluirProdutoLista.asp?Codigo='+codProduto;
	
	return;
}



function OnLoad() {
	document.getElementById("carregando").style.display="none";
	document.getElementById("galeriaFotos").style.display="inline";		
	
}

function populaBairro(txtCidade, codBairro){
	
		document.getElementById("divBairro").innerHTML = "<img src='_imagens/circulo.gif' border='0'> Buscando bairros ...";
		
		   var buscandoRegiao = createXMLHTTP();
			buscandoRegiao.open("get", "http://www.personaleimoveis.com.br/v2/buscaBairro.asp?codCidade=" + txtCidade + "&codBairro="+codBairro, true);
            buscandoRegiao.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			buscandoRegiao.setRequestHeader("charset","ISO-8859-1");
			buscandoRegiao.setRequestHeader("Encoding","ISO-8859-1");			
            buscandoRegiao.onreadystatechange=function(){
		  
		   if (buscandoRegiao.readyState==4){
						document.getElementById("divBairro").innerHTML = buscandoRegiao.responseText;				
				}
			}
			buscandoRegiao.send("txtCidade=" + txtCidade + "&codBairro="+codBairro);

}

function EnviaContact(theForm)
{
	
		
	
	if(theForm.nome_first.value=="")
	{
		alert("Name is required.");
		theForm.nome_first.focus();
		return false;
	}
	
	if(CampoBranco552(theForm.telefone)==true)
	{
		alert("Telephone is required.");
		theForm.telefone.focus();
		return false;
	}

	if(theForm.Best_Time.value=="")
	{
		alert("Best time to contact is required.");
		theForm.Best_Time.focus();
		return false;
	}
		

	if(CampoBranco552(theForm.Email_Address)==true)
	{
		alert("Email must be present and valid.");
		theForm.Email_Address.focus();
		return false;
	}	
	
	if 	(!(CheckEmail(theForm.Email_Address.value)))			
		{
			alert("Informed email this in an invalid format!");
			theForm.Email_Address.focus();
			return false;
		}	
	
	if(CampoBranco552(theForm.Service_Request)==true)
	{
		alert("Service Request is required.");
		theForm.Service_Request.focus();
		return false;
	}	

	
	
	if (document.theForm.valorBot.value == ""){
		alert("You answered the bot check incorrectly.");
		document.theForm.valorBot.focus();
		return false;
	}
	
	var Resultado = parseInt(document.theForm.n1.value) + parseInt(document.theForm.n2.value);
	var Informado = parseInt(document.theForm.valorBot.value);
	
	if (Resultado != Informado){
		alert("You answered the bot check incorrectly.");
		document.theForm.valorBot.focus();
		return false;
	}		

}

function EnviaClick(theForm)
{
	
		
	
	if(theForm.first_name.value=="")
	{
		alert("Name is required.");
		theForm.first_name.focus();
		return false;
	}
		

	if(CampoBranco552(theForm.emailClick)==true)
	{
		alert("Email must be present and valid.");
		theForm.emailClick.focus();
		return false;
	}	
	
	if 	(!(CheckEmail(theForm.emailClick.value)))			
		{
			alert("Informed email this in an invalid format!");
			theForm.emailClick.focus();
			return false;
		}	
	
	if(CampoBranco552(theForm.phone)==true)
	{
		alert("Phone is required.");
		theForm.phone.focus();
		return false;
	}	

	if (theForm.valorBotClick.value == ""){
		alert("You answered the bot check incorrectly.");
		theForm.valorBotClick.focus();
		return false;
	}
	
	var Resultado = parseInt(theForm.n1Click.value) + parseInt(theForm.n2Click.value);
	var Informado = parseInt(theForm.valorBotClick.value);
	
	if (Resultado != Informado){
		alert("You answered the bot check incorrectly.");
		theForm.valorBotClick.focus();
		return false;
	}		

}

function EnviaFree(theForm)
{
	

	if(theForm.Street.value=="")
	{
		alert("Street to contact is required.");
		theForm.Street.focus();
		return false;
	}
	
	if(theForm.City.value=="")
	{
		alert("City to contact is required.");
		theForm.City.focus();
		return false;
	}	
		
		
	if(theForm.State.value=="")
	{
		alert("State to contact is required.");
		theForm.State.focus();
		return false;
	}	
	
	if(theForm.Zip.value=="")
	{
		alert("Zip Code to contact is required.");
		theForm.Zip.focus();
		return false;
	}	
	
	if(theForm.Service_Request.value=="")
	{
		alert("Service Request to contact is required.");
		theForm.Service_Request.focus();
		return false;
	}	

	
	if (document.theForm.valorBot.value == ""){
		alert("You answered the bot check incorrectly.");
		document.theForm.valorBot.focus();
		return false;
	}
	
	var Resultado = parseInt(document.theForm.n1.value) + parseInt(document.theForm.n2.value);
	var Informado = parseInt(document.theForm.valorBot.value);
	
	if (Resultado != Informado){
		alert("You answered the bot check incorrectly.");
		document.theForm.valorBot.focus();
		return false;
	}		

}

function CampoBranco552(campo)
{
	if (campo.value == "")
		return true;
	else
		return false;
}

function CheckEmail(email)
{
   var achou_ponto=false;
   var achou_arroba=false;
   var nao_achou_espaco=false;

   for (var i=0; i < email.length; i++)
   {
      if (email.charAt(i)=="@")
      { 
         if (email.charAt(i+1)==".") achou_arroba=false;
         else achou_arroba=true;
      }
      else if (email.charAt(i)==".") achou_ponto=true;
      else if (email.charAt(i)!=" ") nao_achou_espaco=true;
   }
   if(email.charAt(email.length-1)==".") achou_ponto=false;
   if (achou_ponto && achou_arroba && nao_achou_espaco) return true;
   else
   {      
      return false;  
   }
}

function MascaraTexto(strField, sMask) { 
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; 
	objForm = document.theForm; 
	
	if(document.all) { // Internet Explorer 
	nTecla = event.keyCode; } 
	else if(document.layers) { // Nestcape 
	nTecla = event.which; 
	} 
	
	if(nTecla == 39) return false; 
	
	sValue = objForm[strField].value; 
	
	// Limpa todos os caracteres de formatação que 
	// já estiverem no campo. 
	sValue = sValue.toString().replace( "-", "" ); 
	sValue = sValue.toString().replace( "-", "" ); 
	sValue = sValue.toString().replace( ".", "" ); 
	sValue = sValue.toString().replace( ".", "" ); 
	sValue = sValue.toString().replace( "/", "" ); 
	sValue = sValue.toString().replace( "/", "" ); 
	sValue = sValue.toString().replace( "(", "" ); 
	sValue = sValue.toString().replace( "(", "" ); 
	sValue = sValue.toString().replace( ")", "" ); 
	sValue = sValue.toString().replace( ")", "" ); 
	sValue = sValue.toString().replace( " ", "" ); 
	sValue = sValue.toString().replace( ":", "" ); 
	sValue = sValue.toString().replace( ",", "" ); 
	sValue = sValue.toString().replace( "$", "" ); 
	sValue = sValue.toString().replace( "R", "" ); 
	fldLen = sValue.length; 
	mskLen = sMask.length; // = 5 
	
	i = 0; 
	nCount = 0; 
	sCod = ""; 
	mskLen = fldLen; 
	
	while (i <= mskLen) { 
	bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/")); 
	bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")); 
	bolMask = bolMask || ((sMask.charAt(i) == ":") || (sMask.charAt(i) == "$") || (sMask.charAt(i) == "R") || (sMask.charAt(i) == ",")); 
	
	if (bolMask) { 
	sCod += sMask.charAt(i); 
	mskLen++; } 
	else { 
	sCod += sValue.charAt(nCount); 
	nCount++; 
	} 
	
	i++; 
	} 
	
	objForm[strField].value = sCod; 
	
	if (nTecla != 8) { // backspace 
	if (sMask.charAt(i-1) == "9") { // apenas números... 
	return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9 
	else { // qualquer caracter... 
	return true; 
	} } 
	else { 
	return true; 
	} 
} 

function SoNumeros(Elem) {
	if (event.keyCode < 48 || event.keyCode > 57){ 
		event.returnValue = false; 
	} 
}



