// JavaScript Document
//Tenta criar o objeto xmlHTTP

try{
    xmlhttp = new XMLHttpRequest(); 
	xmlhttp2 = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
			xmlhttp2 = false;
        }
    }
}

//Fila de conexões
fila=[]
ifila=0

//Carrega via XMLHTTP a url recebida e coloca seu valor

//no objeto com o id recebido
function ajaxHTML(id,url){
    //Carregando...
    document.getElementById(id).innerHTML="<span class='carregando'>"+
                                          "Carregando...</span>"
    //Adiciona à fila
    fila[fila.length]=[id,url]
    //Se não há conexões pendentes, executa
    if((ifila+1)==fila.length)ajaxRun()
}

//Executa a próxima conexão da fila
function ajaxRun(){
    //Abre a conexão
    xmlhttp.open("GET",fila[ifila][1],true);
    //Função para tratamento do retorno
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            //Mostra o HTML recebido
            retorno=unescape(xmlhttp.responseText.replace(/\+/g," "))
            document.getElementById(fila[ifila][0]).innerHTML=retorno
            //Roda o próximo
            ifila++
            if(ifila<fila.length)setTimeout("ajaxRun()",20)
        }
    }
    //Executa
    xmlhttp.send(null)
}


function getData(dataSource, divID) {
	if(xmlhttp) {
		document.getElementById(divID).innerHTML="<div align='center'><img src='imagens/ajax-loader.gif' /></div>"
		var obj = document.getElementById(divID);
		xmlhttp.open("GET", dataSource);
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 &&
				xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
		}
	xmlhttp.send(null);
	}
}





















// AJAX DAS FOTOS EM DESTAQUE
function getDataImg(dataSource, divID) {
	if(xmlhttp) {
		document.getElementById(divID).innerHTML="<div align='center' style='width:225px; height:169px;'><table border=0 width='225' height='100%'><tr><td align='center' valign='middle'><img src='imagens/ajax-loader-jpg.gif' /></td></tr></table></div>"
		var obj = document.getElementById(divID);
		xmlhttp.open("GET", dataSource);
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 &&
				xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
		}
	xmlhttp.send(null);
	}
}
function getDataImg2(dataSource, divID) {
	if(xmlhttp2) {
		document.getElementById(divID).innerHTML="<div align='center' style='width:103px; height:78px;'><table border=0 width='100%' height='100%'><tr><td align='center' valign='middle'><img src='imagens/ajax-loader-jpg.gif' /></td></tr></table></div>"
		var obj2 = document.getElementById(divID);
		xmlhttp2.open("GET", dataSource);
		xmlhttp2.onreadystatechange = function(){
			if (xmlhttp2.readyState == 4 &&
				xmlhttp2.status == 200) {
					obj2.innerHTML = xmlhttp2.responseText;
				}
		}
	xmlhttp2.send(null);
	}
}
// FIM AJAX DAS FOTOS EM DESTAQUE
















// AJAX DE MORE INFO
function getDataInfo(dataSource, divID) {
	if(xmlhttp) {
		document.getElementById(divID).innerHTML="<div align='center' style='width:100%; height:400px;'><table border=0 width='100%' height='100%'><tr><td align='center' valign='middle'><img src='imagens/ajax-loader-jpg.gif' /></td></tr></table></div>"
		var obj = document.getElementById(divID);
		xmlhttp.open("GET", dataSource);
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 &&
				xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
		}
	xmlhttp.send(null);
	}
}
// FIM AJAX DE MORE INFO




// AJAX DE CONTACT
function getDataContact(dataSource, divID) {
	if(xmlhttp) {
		document.getElementById(divID).innerHTML="<div align='center'><table border=0 width='100%' height='100%'><tr><td align='center' valign='middle'><img src='imagens/ajax-loader-jpg.gif' /></td></tr></table></div>"
		var obj = document.getElementById(divID);
		xmlhttp.open("GET", dataSource);
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 &&
				xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
		}
	xmlhttp.send(null);
	}
}
// FIM AJAX DE CONTACT









function getCarrinho(dataSource, divID) {
	if(xmlhttp) {
		document.getElementById(divID).innerHTML="<img src='imagens/ajax-loader-car.gif' />"
		var obj = document.getElementById(divID);
		xmlhttp.open("GET", dataSource);
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 &&
				xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
		}
	xmlhttp.send(null);
	}
}


corAD = ''



function getSwf(dataSource, color, divID,lok) {
	if(xmlhttp) {
		document.getElementById(divID).innerHTML="<div align='center' style='width:432px; height:400px;'><img src='imagens/ajax-loader.gif' /></div>"
		var obj = document.getElementById(divID);
		xmlhttp.open("GET", dataSource+color);
		
		if (lok == 1) {
			
			corAD = color;
			
		} else {
			
			cor = color;
			
		}
		
	
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 &&
				xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
				
		
		}
	xmlhttp.send(null);
	}
}

function postData(dataSource, divID, args) {
	if(xmlhttp) {
		document.getElementById(divID).innerHTML="<div align='center' style='padding-top:50px; color:#cccccc'>Carregando...<br><br><img src='imagens/ajax-loader.gif' /></div>"
		var obj = document.getElementById(divID);
		
		xmlhttp.open("POST", dataSource);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(args);
		
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 &&
				xmlhttp.status == 200) {
					obj.innerHTML = xmlhttp.responseText;
				}
		}
	xmlhttp.send(null);
	}
}

function getData2(dataSource, divID) {
	if(xmlhttp2) {
		document.getElementById(divID).innerHTML="<div align='center' style='width:432px; height:400px;'><img src='imagens/ajax-loader.gif' /></div>"
		var obj2 = document.getElementById(divID);
		xmlhttp2.open("GET", dataSource);
		xmlhttp2.onreadystatechange = function(){
			if (xmlhttp2.readyState == 4 &&
				xmlhttp2.status == 200) {
					obj2.innerHTML = xmlhttp2.responseText;
				}
		}
	xmlhttp2.send(null);
	}
}








function insereTAG() {

	var tag = document.getElementById("nome_tag").value;
	getData('tag.asp?tag='+tag,'tag-inset');
	document.getElementById("nome_tag").value = "";
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}






function AvisoCompra(nome,id,corAde) {
	

	var i
    tam = 0
	var erro = 0
	
	for (i=0;i<document.tamanhos.tamanho.length;i++){
       if (document.tamanhos.tamanho[i].checked) {
          tam = document.tamanhos.tamanho[i].value;
		  med = document.getElementById("medida" + i).value;
		  break;
	   }	    
    }
	
	if (tam == 0) {
			alert("ATENÇÃO\n\nFaltou escolher o tamanho do adesivo.")
			erro = 1
	}
	if (corAde != 'Multicor') {
		if (corAD == '') {
				alert("ATENÇÃO\n\nFaltou escolher a cor do adesivo.")
				erro = 1
		}
	}
	
	if (erro == 0) {
	
		document.getElementById("alerta").style.display='';
		document.getElementById("carrinho").style.display='none';
		nomeProd = nome;
		document.getElementById('nome-do-produto').innerHTML = nome;	
		document.getElementById('tamanho-do-produto').innerHTML = tam + " : " + med;
		
		
		
		
		if (corAde == 'Multicor') {
			document.getElementById("link_edit_cor").style.display='none';
			//document.getElementById("titulo_cor").style.display='none';
			document.getElementById('cor-do-produto').innerHTML = 'Multicor';
			//corAD = 'Multicor';
		} else {		
			document.getElementById('cor-do-produto').innerHTML = '<div style="width:100px; height:15px; background-color:#'+corAD+';"></div>';
		}
		
		switch(tam) {
   			case "P":
				document.getElementById('preco-do-produto').innerHTML = 'R$ ' + document.tamanhos.preco_p.value + ',00';
				break;
			
			case "M":
				document.getElementById('preco-do-produto').innerHTML = 'R$ ' + document.tamanhos.preco_m.value + ',00';
				break;
				
			case "G":
				document.getElementById('preco-do-produto').innerHTML = 'R$ ' + document.tamanhos.preco_g.value + ',00';
				break;
		}
		
		
	}
		
		
		
		
		
		// 
		
}









//FUNÇÃO QUE VALIDA CAMPOS NUM FORMULÁRIO
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- O campo não pode estar vazio.\n'; }
    } if (errors) alert('Ocorreram os seguinte(s) erro(s):\n\n'+errors);
    document.MM_returnValue = (errors == '');
} }
//FIM DA FUNÇÃO QUE VALIDA CAMPOS NUM FORMULÁRIO













// FUNÇÃO QUE VERIFICA A ASSINATURA DA NEWSLETTER
function assNews() {
	
	
	
	email = document.getElementById("email_news").value;
	
	
	if (email == '') {
		
		alert('O campo de email está vazio');
	
	} else {
		
		if (email.indexOf("@") == -1) {
			
			alert('Insira um email válido!');
		
		} else {
			
			getData('insert.asp?who=newsletter&email=' + email,'box_newsletter');
			
		}
	
	}	
		
		
}
// FIM DA FUNÇÃO










function MM_jumpMenu(targ,selObj,restore){ //v3.0
	var local = selObj.options[selObj.selectedIndex].value;

	if (local != 0) {
		
		window.location="catalogo.asp?who="+local;
		
		//getData('catalogo.asp?who='+local,'box-catalogo');
	}
	
	if (restore) selObj.selectedIndex=0;
   
}




function checkTam(tam) {
	switch(tam) {
   		case "P":
   			document.getElementById("p").className='alertacompra';
			document.getElementById("pe").className='alertacompra';
			document.getElementById("peq").className='alertacompra';
			
			document.getElementById("m").className='';
			document.getElementById("me").className='';
			document.getElementById("med").className='';
			
			document.getElementById("g").className='';
			document.getElementById("gr").className='';
			document.getElementById("gra").className='';
			
			break;
			
		case "M":
   			document.getElementById("p").className='';
			document.getElementById("pe").className='';
			document.getElementById("peq").className='';
			
			document.getElementById("m").className='alertacompra';
			document.getElementById("me").className='alertacompra';
			document.getElementById("med").className='alertacompra';
			
			document.getElementById("g").className='';
			document.getElementById("gr").className='';
			document.getElementById("gra").className='';
			
			break;
   		case "G":
   			document.getElementById("p").className='';
			document.getElementById("pe").className='';
			document.getElementById("peq").className='';
			
			document.getElementById("m").className='';
			document.getElementById("me").className='';
			document.getElementById("med").className='';
			
			document.getElementById("g").className='alertacompra';
			document.getElementById("gr").className='alertacompra';
			document.getElementById("gra").className='alertacompra';
			
			break;
 }

}














function editProd(id) {
	
	document.getElementById('alerta').style.display='none';
	document.getElementById('carrinho').style.display='';
	//alert("<a href='#Aviso' class='categoria_01' onclick='AvisoCompra('" + nomeProd + "'," + id + ");'>teste</a>");
	if (corAD == '') {
		corAD = 'Multicor';
	}	
	document.getElementById('carrinho').innerHTML = "<a href='#Aviso' class='categoria_01' onclick=\"AvisoCompra('" + nomeProd + "'," + id + ",'" + corAD + "');\"><img src='imagens/botao_atualizar_produto.gif' alt='Atualizar o pedido do seu Adesivo de parede' border='0' /></a>";
}






	function colocaCarrinho(id) {
		//getData('alerta.asp?ct=1','alerta');
		document.getElementById('preview_carrinho').style.display='';
		getData2('preview_carrinho.asp?who=carrinho&id='+id+'&cor='+corAD+'&tam='+tam,'preview_carrinho');
		getData('alerta2.asp?ctrl=1&id='+id,'alerta');
		document.getElementById('alerta').style.display='';
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
function maisUm(id) {
	getData('alerta.asp?id='+id,'alerta');
	document.getElementById('alerta').style.display='none';
	document.getElementById('preview_carrinho').style.display='none';
	document.getElementById("carrinho").style.display='';
}









function revisaPreco(id) {
	
	var qtd = document.getElementById("qtd_" + id).value;
	var preco = document.getElementById("preco_" + id).value;
	var subtotal = document.getElementById("subtotal_input").value;
	var desconto = document.getElementById("desconto_input").value;
	
	document.getElementById('preco_final_' + id).innerHTML = qtd * preco;
		
	var parcial = document.getElementById("preco_parcial_" + id).value;
	
	var subtotal = (subtotal - parcial) + (qtd * preco);
	
	var desconto = (subtotal * desconto) / 100;
	
	document.getElementById("valor_desconto").innerHTML = desconto;
	document.getElementById("subtotal").innerHTML = subtotal;
	document.getElementById("total").innerHTML = subtotal - desconto;
	document.getElementById("total_input").value = subtotal - desconto;
	document.valor_total.total.value = subtotal - desconto;
	
	document.getElementById("subtotal_input").value = subtotal;
	
	document.getElementById("preco_parcial_" + id).value = qtd * preco;
	
	getCarrinho('grava_carrinho.asp?qtd=' + qtd + '&id_carrinho=' + id,'cestinha');
	
		
}










function validaCupom() {
		
		var cupom = document.getElementById("cupom_desc").value;
		
		if (cupom != "") {
		
			getData('cupom.asp?cupom=' + cupom,'cupom_desconto');
			
		}
									
}



function descontaCupom(ref,valor) {

	document.getElementById('tdcupom').style.display='';
	document.getElementById('titulo_cupom').style.display='none';
	document.getElementById('cupom_desconto').style.display='none';
	
	document.getElementById("referencia").innerHTML = ref;
	
	var total = document.getElementById("subtotal_input").value;
	
	var desc = (total * valor) / 100;
	
	document.getElementById("valor_desconto").innerHTML = desc;
	
	
	total = total - desc;
	
	document.getElementById("total").innerHTML = total;
	document.getElementById("total_input").value = total;
	document.valor_total.total.value = total;
	document.getElementById("desconto_input").value = valor;
	

}










function fechaCarrinho() {

	total = document.getElementById("total_input").value;
	displayMessage('autentica.asp?total=' + total);

}



function validaCadastro() {

	var erro = '';
	var cont = 0;
	
	// Nome
	if (document.getElementById("nome").value == '') {		
		erro = erro + '<p>- The field <b>name</b> is empty</p>';
		cont = cont + 1;
		document.getElementById("nome").style.background = '#FFFFCC';
	} else {
		document.getElementById("nome").style.background = '';
	}
	
	//Data Nascimento
	/*if (document.cadastro.dia.selectedIndex  == 0) {		
		erro = erro + '<p>- Faltou o <b>dia</b> do seu nascimento!</p>';	
		cont = cont + 1;
		document.getElementById("dia").style.background = '#FFFFCC';
	} else {
		document.getElementById("dia").style.background = '';
	}
	
	if (document.cadastro.mes.selectedIndex  == 0) {		
		erro = erro + '<p>- Faltou o <b>mês</b> do seu nascimento!</p>';
		cont = cont + 1;
		document.getElementById("mes").style.background = '#FFFFCC';
	} else {
		document.getElementById("mes").style.background = '';
	}
	
	if (document.cadastro.ano.selectedIndex  == 0) {		
		erro = erro + '<p>- Faltou o <b>ano</b> do seu nascimento!</p>';
		cont = cont + 1;
		document.getElementById("ano").style.background = '#FFFFCC';
	} else {
		document.getElementById("ano").style.background = '';
	}*/
	
	
	
	//sexo
	/*var sexo = '';
	for (i=0;i<document.cadastro.sexo.length;i++){
       if (document.cadastro.sexo[i].checked) {
          sexo = document.cadastro.sexo[i].value;
		  //med = document.getElementById("medida" + i).value;
		  break;
	   }	    
    }
		
	if (sexo == '') {
		erro = erro + '<p>- Informe o seu <b>sexo</b>!</p>';
		cont = cont + 1;
		document.getElementById("sexo").style.background = '#FFFFCC';
	} else {
		document.getElementById("sexo").style.background = '';
	}*/
	
	
	
	//CPF
	/*if (document.cadastro.cpf.value == '') {
		
		erro = erro + '<p>- Informe o número do seu <b>CPF</b>.</p>';
		cont = cont + 1;
		document.getElementById("cpf").style.background = '#FFFFCC';
		
	} else {
		
		document.getElementById("cpf").style.background = '';
		
		//CPF
		cpf = document.cadastro.cpf.value;
		var vr = cpf.substring(0,3) + cpf.substring(4,7) + cpf.substring(8,11) + cpf.substring(12);
		cpf = vr;	
		
		    if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n";
                 var nonNumbers = /\D/;
                 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";
                 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
                         
               			erro = erro + '<p>- Numero de <b>CPF</b> invalido!</p>';
						cont = cont + 1;
						document.getElementById("cpf").style.background = '#FFFFCC';
			     }
               
			   var a = [];
               var b = new Number;
               var c = 11;
               for (i=0; i<11; i++){
                       a[i] = cpf.charAt(i);
                       if (i < 9) b += (a[i] * --c);
               }
               if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
               b = 0;
               c = 11;
               for (y=0; y<10; y++) b += (a[y] * c--);
               if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
               if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
				
						erro = erro + '<p>- Digito verificador do <b>CPF</b> está incorreto!</p>';
						cont = cont + 1;
						document.getElementById("cpf").style.background = '#FFFFCC';
               }
               
	
	}*/
	
	
	
	//Endereço
	/*if (document.cadastro.endereco.value == '') {
		
		erro = erro + '<p>- Esqueceu do seu <b>endereço</b>!</p>';
		cont = cont + 1;
		document.getElementById("endereco").style.background = '#FFFFCC';
	} else {
		document.getElementById("endereco").style.background = '';
	}*/
	
	
	
	//Número
	/*if (document.cadastro.numero.value == '') {
		
		erro = erro + '<p>- Esqueceu o <b>número</b> da sua residência!</p>';
		cont = cont + 1;
		document.getElementById("numero").style.background = '#FFFFCC';
	} else {
		document.getElementById("numero").style.background = '';
	}*/
	
	
	//Bairro
	/*if (document.cadastro.bairro.value == '') {
		
		erro = erro + '<p>- Informe o seu <b>bairro</b>.</p>';
		cont = cont + 1;
		document.getElementById("bairro").style.background = '#FFFFCC';
	} else {
		document.getElementById("bairro").style.background = '';
	}*/
	
	
	//CEP
	/*if (document.cadastro.cep.value == '') {
		
		erro = erro + '<p>- Seu <b>CEP</b>!</p>';
		cont = cont + 1;
		document.getElementById("cep").style.background = '#FFFFCC';
	} else {
		document.getElementById("cep").style.background = '';
	}*/
	
	
	//Cidade
	/*if (document.cadastro.cidade.value == '') {
		
		erro = erro + '<p>- Informe sua <b>cidade</b>!</p>';
		cont = cont + 1;
		document.getElementById("cidade").style.background = '#FFFFCC';
	} else {
		document.getElementById("cidade").style.background = '';
	}*/
	
	
	//Estado
	/*var estado = document.cadastro.estado.options[document.cadastro.estado.selectedIndex].value;
	
	if (estado == '') {
		
		erro = erro + '<p>- Informe seu <b>Estado</b>!</p>';
		cont = cont + 1;
		document.getElementById("estado").style.background = '#FFFFCC';
	} else {
		document.getElementById("estado").style.background = '';
	}*/
	
	
	
	//Telefone	
	//ddd
	/*if (document.cadastro.ddd.value == '') {
		
		erro = erro + '<p>- Informe o <b>DDD</b> da sua cidade!</p>';
		cont = cont + 1;
		document.getElementById("ddd").style.background = '#FFFFCC';
	} else {
		document.getElementById("ddd").style.background = '';
	}
	//tel
	if (document.cadastro.telefone.value == '') {
		
		erro = erro + '<p>- Informe um número de <b>telefone</b> para contato.</p>';
		cont = cont + 1;
		document.getElementById("telefone").style.background = '#FFFFCC';
	} else {
		document.getElementById("telefone").style.background = '';
	}*/
	
	
	//email
	 var email = document.getElementById("email").value;
	 re = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	 
	 if(email.search(re) == -1) {
     
	 	erro = erro + '<p>- Enter an <b>e-mail</b> real</p>';
		cont = cont + 1;
		document.getElementById("email").style.background = '#FFFFCC';
	 } else {
		 document.getElementById("email").style.background = '';
	 }
	 
	 
	 
	 
	 //TEXTO
	if (document.getElementById("observacoes").value == '') {
		
		erro = erro + '<p>- What you want to contact us?</p>';
		cont = cont + 1;
		document.getElementById("observacoes").style.background = '#FFFFCC';
	} else {
		document.getElementById("observacoes").style.background = '';
	}
	
	
	
	 
	 //senha
	 /*var senha = document.cadastro.senha.value;
	 if (senha == '') {
		erro = erro + '<p>- Escolha uma <b>senha</b> para acompanhar seu pedido.</p>';
		cont = cont + 1;
		document.getElementById("senha").style.background = '#FFFFCC';
	 } else {
		 document.getElementById("senha").style.background = '';
	 }*/
	 
	 
	 
	 //Politica
	 /*if (document.cadastro.politica.checked) {
		 
		document.getElementById("politica").style.background = ''; 
				 
	 } else {
		 
		erro = erro + '<p>- Aceite a <b>Política de privacidade</b>!</p>';
		cont = cont + 1;
		document.getElementById("politica").style.background = '#FFFFCC';
		
	 }*/
	 
	 
	 //Entrega
	/* if (document.cadastro.endereco_entrega.value == '' || document.cadastro.numero_entrega.value == '' || document.cadastro.bairro_entrega.value == '' || document.cadastro.cep_entrega.value == '' || document.cadastro.cidade_entrega.value == '' || document.cadastro.estado_entrega.value == '') {
		erro = erro + '<p>- Verifique o <b>endereço de entrega</b>!</p>';
		cont = cont + 1;
		document.getElementById("endereco_entrega").style.background = '#FFFFCC';
		document.getElementById("numero_entrega").style.background = '#FFFFCC';
		document.getElementById("bairro_entrega").style.background = '#FFFFCC';
		document.getElementById("cidade_entrega").style.background = '#FFFFCC';
		document.getElementById("estado_entrega").style.background = '#FFFFCC';
		document.getElementById("cep_entrega").style.background = '#FFFFCC';
	 } else {
		document.getElementById("endereco_entrega").style.background = '';
		document.getElementById("numero_entrega").style.background = '';
		document.getElementById("bairro_entrega").style.background = '';
		document.getElementById("cidade_entrega").style.background = '';
		document.getElementById("estado_entrega").style.background = '';
		document.getElementById("cep_entrega").style.background = '';
	 }*/
	 
	 
	//Forma Pagamento
	/*var pg = '';
	for (i=0;i<document.cadastro.pagamento.length;i++){
       if (document.cadastro.pagamento[i].checked) {
          pg = document.cadastro.pagamento[i].value;
		  //med = document.getElementById("medida" + i).value;
		  break;
	   }	    
    }
	if (pg == '') {
		erro = erro + '<p>- Informe uma <b>Forma de Pagamento</b>!</p>';
		cont = cont + 1;
		document.getElementById("tipos_pagamento").style.background = '#FFFFCC';
		
	} else {
		
		document.getElementById("tipos_pagamento").style.background = '';
		
		if (pg == 'AMEX' || pg == 'VISA') {
			var parcelas = '';
			for (i=0;i<document.cadastro.parcelas.length;i++){
			   if (document.cadastro.parcelas[i].checked) {
				  parcelas = document.cadastro.parcelas[i].value;
				  //med = document.getElementById("medida" + i).value;
				  break;
			   }	    
			}
			if (parcelas == '') {
				erro = erro + '<p>- Informe a quantidade de <b>Parcelas</b> para o pagamento.</p>';
				cont = cont + 1;
				document.getElementById("tipos_pagamento").style.background = '#FFFFCC';
			}
		}
	}*/
	
	
	
	
	
	//CONTROLE DE ERROS
	if (cont < 5) {
		
		
	
	
		if (erro != '') {
			
			
			
			var fechar = '<p style=\'padding-top:10px; text-align:center;\' align=\'center\'><a href=\'#Finalizando Compra\' onclick=\'closeMessage();\'><img src=\'imagens/botao_fechar.gif\' alt=\'FECHAR\' border=\'0\' /></a></p>';
			displayStaticAlert(erro + fechar,'modal_alerta');
			retorno = false;
			
			
		} else {
			
			retorno = true;
			getDataContact('grava.asp?who=contato&nome=' + document.getElementById("nome").value + '&email=' + email + '&fone=' + document.getElementById("fone").value + '&texto=' + document.getElementById("observacoes").value,'dv-form');
			
		}
	
	
	} else {
		
		var fechar = '<p style=\'padding-top:10px; text-align:center;\' align=\'center\'><a href=\'#Finalizando Compra\' onclick=\'closeMessage();\'><img src=\'imagens/botao_fechar.gif\' alt=\'FECHAR\' border=\'0\' /></a></p>';
		displayStaticAlert('<p>Os campos são de preenchimento obrigatório!</p>' + fechar,'modal_alerta');
		retorno = false;
	
	}
}






function PulaCPF() {
		if (document.getElementById("cpf").value.length == 14) {
			document.getElementById("endereco").focus();
		}
	}







function PulaCEP() {
		if (document.cadastro.cep.value.length == 8) {
			document.cadastro.cidade.focus();
		}
	}







function PulaDDD() {
		if (document.cadastro.ddd.value.length == 2) {
			document.cadastro.telefone.focus();
		}
	}
	
	
	
	
	
	


function mascaraCPF(campo,xEvent) {
	
    var strCheck = '0123456789';
    var key = '';
    var whichCode = (window.Event) ? xEvent.which : xEvent.keyCode;
    if (whichCode == undefined) whichCode = xEvent.keyCode;
    if (whichCode == 13 || whichCode == 8 || whichCode == 0) return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida 
	
	vr = campo.value;
	if (vr.length == 14) return false;
	if (vr.length == 3 || vr.length == 7) campo.value = vr + ".";
	if (vr.length == 11) campo.value = vr + "-";
}


function mascaraCEP(campo,xEvent) {
	
    var strCheck = '0123456789';
    var key = '';
    var whichCode = (window.Event) ? xEvent.which : xEvent.keyCode;
    if (whichCode == undefined) whichCode = xEvent.keyCode;
    if (whichCode == 9 || whichCode == 6 || whichCode == 0) return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida 
	
	vr = campo.value;
	if (vr.length == 9) return false;
	if (vr.length == 5) campo.value = vr + "-";
}





function tipoPG(total) {
	
	document.getElementById('credito').style.display='none';
	document.getElementById('debito').style.display='none';
	document.getElementById('transferencia').style.display='none';
	document.getElementById('boleto').style.display='none';
	
	var tipo = document.getElementById("tipos_pagamento").value;
	
	document.getElementById(tipo).style.display='';
	
	if (tipo == 'credito') {
		
		document.getElementById('parcelas').style.display='';
		document.getElementById("1p").innerHTML = total.toFixed(2);
		document.getElementById("2p").innerHTML = (total/2).toFixed(2);
		document.getElementById("3p").innerHTML = (total/3).toFixed(2);
		document.getElementById("4p").innerHTML = (total/4).toFixed(2);
		
		
	} else {
		
		document.getElementById('parcelas').style.display='none';
		
	}
	
	
	switch(tipo) {
		
		case "credito":
			document.getElementById("tipo_cobranca").value = 'C';
			break;
		
		case "debito":
			document.getElementById("tipo_cobranca").value = 'D';
			break;
			
		case "transferencia":
			document.getElementById("tipo_cobranca").value = 'T';
			break;
			
		case "boleto":
			document.getElementById("tipo_cobranca").value = 'B';
			break;
	}
		
	
}






function tipoCB(i) {
	if (document.cadastro.pagamento[i].checked) {
		
		document.getElementById('cod_banco').value = document.cadastro.pagamento[i].value;
		
	}
		
}
	//document.getElementById("tipos_pagamento").value;
	
	
	
	
	
	
	
	
	
	
	
	
	
 function Logar() {
	 
	 var email = document.getElementById("email_login").value;
	 var senha = document.getElementById("senha_login").value;
	 getCarrinho('verifica.asp?email=' + email + '&senha=' + senha,'login') ;
	
 }
 
 
 function entrega(campo) {
	 
	 document.getElementById(campo + "_entrega").value = document.getElementById(campo).value;
	 
 }
 
 
 
 function VerificaEmail() {
	 
	 if (document.cadastro.email.value != '') {
		 
		 getCarrinho('verifica.asp?who=email&email=' + document.cadastro.email.value,'vemail');
		 
	 } 		 
	 
 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 function GeraHTM(id,nome) {
	 
	getData('seo.asp','cestinha');
	 
 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 function conclusao() {
		 	
			if (document.valor_total.total.value <= 0) {
				conclusao = false;
			} else {
				conclusao = true;
			}
 }
 
 
 
 
 
 function Faq(id) {

	 var i = 0;
	 
	 for (i=1;i<7;i++){

		document.getElementById(10 + i).style.display = 'none';
		document.getElementById(i).style.fontWeight = 'normal';
	 
	 }
	 	
	document.getElementById(10 + id).style.display = '';
	document.getElementById(id).style.fontWeight = 'bold';
	
		
	
 }
 
 
 
 
 
 
 
 function ValidaContato() {
	 
	 var erro = '';
	var cont = 0;
	
	// Nome
	if (document.getElementById("nome").value == '') {		
		erro = erro + '<p>- O Campo <b>nome</b> está em branco</p>';
		cont = cont + 1;
		document.getElementById("nome").style.background = '#FFFFCC';
	} else {
		document.getElementById("nome").style.background = '';
		nome = document.getElementById("nome").value;
	}
	
	//email
	 var email = document.getElementById("email").value;
	 re = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	 
	 if(email.search(re) == -1) {
     
	 	erro = erro + '<p>- Coloquei um <b>email</b> de verdade!!</p>';
		cont = cont + 1;
		document.getElementById("email").style.background = '#FFFFCC';
	 } else {
		 document.getElementById("email").style.background = '';
	 }
	 
	 
	 // Assunto
	if (document.getElementById("assunto").value == '') {		
		erro = erro + '<p>- O Campo <b>assunto</b> não pode estar vazio</p>';
		cont = cont + 1;
		document.getElementById("assunto").style.background = '#FFFFCC';
	} else {
		document.getElementById("assunto").style.background = '';
		ass = document.getElementById("assunto").value;
	}
	
	
	// Texto
	if (document.getElementById("texto").value == '') {		
		erro = erro + '<p>- Como assim, não vai escrever nada?</p>';
		cont = cont + 1;
		document.getElementById("texto").style.background = '#FFFFCC';
	} else {
		document.getElementById("texto").style.background = '';
		texto = document.getElementById("texto").value;
	}	
	
	
	//CONTROLE DE ERROS
	if (cont < 4) {
		
		
	
	
		if (erro != '') {
			
			
			
			var fechar = '<p style=\'padding-top:10px; text-align:center;\' align=\'center\'><a href=\'#Finalizando Compra\' onclick=\'closeMessage();\'><img src=\'imagens/botao_fechar.gif\' alt=\'FECHAR\' border=\'0\' /></a></p>';
			displayStaticAlert(erro + fechar,'modal_alerta');
			retorno = false;
			
			
		} else {
			
			getCarrinho('enviar_email.asp?who=contato&nome=' + nome + '&email=' + email + '&ass=' + ass + '&texto=' + texto,'faq');
			retorno = true;
		}
	
	
	} else {
		
		var fechar = '<p style=\'padding-top:10px; text-align:center;\' align=\'center\'><a href=\'#Finalizando Compra\' onclick=\'closeMessage();\'><img src=\'imagens/botao_fechar.gif\' alt=\'FECHAR\' border=\'0\' /></a></p>';
		displayStaticAlert('<p>Os campos são de preenchimento obrigatório!</p>' + fechar,'modal_alerta');
		retorno = false;
	
	}
	 
 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 //FOTOS EM DESTAQUE
 function fotoDesq(local,div,local2) {
	 getDataImg('abre_foto.asp?local=' + local + '&largura=225','foto_desq_' + div);
	 getDataImg2('abre_foto.asp?local=' + local2 + '&largura=100','jpgzinho_' + div);
 }
 
 
 
 
 
 
 
 
 
 //LINK DIRETO PARA RENT NOW
 function rentNow(apt) {
	 getDataInfo('box_booking_info.asp?ap=' + apt,'destaque')
 }
 
 
 
 
 
 // LIMPA CAMPO DO BOOKING FORM
 function limpaCampo(nome) {
	 var campo = document.getElementById(nome).value;
	 if (campo.indexOf('your') == 0 || campo.indexOf('repeat') == 0) {
		 document.getElementById(nome).value = '';
	 }
 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 //CALENDARIO
 DHTMLSuite.include("calendar");
	function calendarMonthChange(inputArray)
	{
		var calendarRef = inputArray.calendarRef;
		
		var month = inputArray.month;
		var year = inputArray.year;
		month++;
		if(month>12){
			month=1;
			year++;
		}
		
		var objectToChange = false;
		switch(calendarRef.id)
		{
			case "calendar1":
				objectToChange = myCalendar2;
				break;
			case "calendar2":	
				objectToChange = myCalendar3;
				break;
			case "calendar3":
				month-=3;
				if(month<1){
					month=12 + month;
					year--;	
				}
				objectToChange = myCalendar;
				break;
		}
		objectToChange.setDisplayedMonth(month);
		objectToChange.setDisplayedYear(year);
	}