
function NovaJanela(URL,NomeJan,parametros) 
{
  window.open(URL,NomeJan,parametros);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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];}}
}

/* flash */

function GerarSWF2($arquivo,$largura,$altura,$id,$bg){
document.writeln('<object id="globalnav-object" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + $largura + '" height="' + $altura + '" id="' + $arquivo + '" name="' + $arquivo + '">');
document.writeln('<param name="movie" value="' + $arquivo + '" />');
document.writeln('<param name="FlashVars" value="loc=en_US&htmlApp=false&gatewayURL=gwurl" />');
document.writeln('<param name="menu" value="false" />');
document.writeln('<param name="quality" value="high" />');
document.writeln('<param name="scale" value="noscale" />');
document.writeln('<param name="wmode" value="transparent" />');
 
document.writeln('<embed id="globalnav-embed" src="' + $arquivo + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl" menu="false" quality="high" scale="noscale" id="' + $id + '" width="' + $largura + '" height="' + $altura + '" TYPE="application/x-shockwave-flash"></embed>');
document.writeln('</object>');
}
/* fim flash */

/* favoritos */


function addFav(){
    var url      = "http://www.praiasonline.com.br";
    var title    = "Praias Online";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}
/* fim favoritos */

$(document).ready(
					
					
					function(){

					$('ul#portfolio2').innerfade({
						speed: 1000,
						timeout: 5000,
						type: 'sequence',
						containerheight: '0px'
					});

});




/* form contato anunciante  */


function verifica_consulta (){
	
         d = document.solicitacao_reservas;

//validar nome
         
		 
		 
		 		 if (document.solicitacao_reservas.ckeck_in.value == ""){
                   alert("O campo data de entrada deve ser preenchido!");
                    d.ckeck_in.focus();
                   return false;
         }
		 
		 		 if (document.solicitacao_reservas.check_out.value == ""){
                   alert("O campo data de saída deve ser preenchido!");
                    d.check_out.focus();
                    return false;
         }
		 
		 
		var data1 = document.solicitacao_reservas.check_in.value;
		var data2 = document.solicitacao_reservas.chek_out.value;
		
		var nova_data1 = parseInt(data1.split("/")[2].toString() + data1.split("/")[1].toString() + data1.split("/")[0].toString());
		var nova_data2 = parseInt(data2.split("/")[2].toString() + data2.split("/")[1].toString() + data2.split("/")[0].toString());
		 
		 if (nova_data2 < nova_data1){
         alert("A data saída é anterior que a data entrada.");
         d.check_out.focus();
		 return false;
         }
      
         if (nova_data1 == nova_data2){
         alert("A data saída não pode ser a mesma que a de entrada.");
		 d.check_in.focus();
          return false;
         }	
		
		
		var estab = false
		for (var i=0;i<document.solicitacao_reservas.elements.length;i++)
		{
		var x = document.solicitacao_reservas.elements[i];
			if (x.name == 'id_cli')
			{
				//alert(x.checked);
				if (x.checked){
					estab = true
				}
			}
		}
		if(!estab){
			alert("Selecione um estabelecimento para o envio de email.")
		return false;
	}	
		 
      return true;

}

/* fim envia form anunciante */









	function createXMLHTTP() 
	{
		var ajax;
		try 
		{
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(e) 
		{
			try 
			{
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
				alert(ajax);
			}
			catch(ex) 
			{
				try 
				{
					ajax = new XMLHttpRequest();
				}
				catch(exc) 
				{
					 alert("Esse browser não tem recursos para uso do Ajax");
					 ajax = null;
				}
			}
			return ajax;
		}
	
	
		   var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
							    "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
							    "Microsoft.XMLHTTP"];
		   for (var i=0; i < arrSignatures.length; i++) 
		   {
				try 
				{
					var oRequest = new ActiveXObject(arrSignatures[i]);
					return oRequest;
				} 
				catch (oError) 
				{
			    }
		   }
		
			   throw new Error("MSXML não instalado.");
	}




function combo(id,proximo)
{
	   var select = createXMLHTTP();
	   select.open("post", "mostra.asp", true);
	   select.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	   select.onreadystatechange=function(){
		   if (select.readyState==4){
			   eval("document.all.div_"+ proximo + ".innerHTML = select.responseText");}}
			   select.send("id=" + id + "&proximo=" + proximo + "&max=<%=nro_depto_loja%>&idioma=<%=idioma%>&dom=<%=dom%>" );
}


function zera(nro,max) {
    var todosSelect = document.getElementsByTagName("select");    
    for( x = nro; x < max; x++ ) {
        todosSelect[x].value = "1";
		todosSelect[x].style.display='none';
    }
}





/* VALIDAÇÃO DE FORMULÁRIOS */


if( jQuery.browser.mozilla ) {
	// do when DOM is ready
	$( function() {
		// search form, hide it, search labels to modify, filter classes nocmx and error
		$( 'form.contato' ).hide().find( '<p>label:not(.nocmx):not(.error)' ).each( function() {
			var $this = $(this);
			var labelContent = $this.html();
			var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
			// create block element with width of label
			var labelSpan = $("<span>")
				.css("display", "block")
				.width(labelWidth)
				.html(labelContent);
			// change display to mozilla specific inline-box
			$this.css("display", "-moz-inline-box")
				// remove children
				.empty()
				// add span element
				.append(labelSpan);
		// show form again
		}).end().show();
	});
};





				//$.validator.setDefaults({
				//	submitHandler: function() { alert("Dados Enviados com sucesso!"); }
				//});





$.metadata.setType("attr", "validate");
$(document).ready(function(){
  
  ///Máscaras

					$("#telefone").mask("(99) 9999.9999");
					$("#check_in").mask("99/99/9999");
					$("#check_out").mask("99/99/9999");
					//$("#check_in").mask("99/99/9999",{placeholder:"_"});  
					//$("#valor").maskMoney({symbol: "", decimal: ",", thousands: "."});


					$('#selectAll').click(function() {
						if(this.checked == true){
							$("input[type=checkbox]").each(function() { 
								this.checked = true; 
							});
						} else {
							$("input[type=checkbox]").each(function() { 
								this.checked = false; 
							});
						}
					});


					function countchecked() {
						// conta check
						  var n = $("input:checked").length;
						 // if (n <= 1) { n==0 } else { n=n-1 } ;
						  $("#anunciantes div.check").text("Estabelecimenos selecionados: (" + n + (n == 1 ? "" : "") + ")");
						}
						countchecked();
					$(":checkbox").click(countchecked);


   $("#google").validate({

      rules: {
         q: {required: true}
      },
      messages: {
         q: {required: ''}
	   }
	   
   });

   $("#whatwhere").validate({

      rules: {
         where: {required: true}
      },
      messages: {
         where: {required: ''}
	   }
	   
   });
				  


	$("#login").validate({

      rules: {
         usuario: {required: true},
		 senha: {required: true}
      },
      messages: {
         usuario: {required: ''},
         senha: {required: ''}
	   }
	   
   });

	

	$("#lembrar_senha").validate({

      rules: {
         usuario: {required: true,minlength:3}
      },
      messages: {
         usuario: {required: '<br>Favor preencher com seu login ou senha!'}
	   }
	   
   });



				
     $("#indique").validate({

      rules: {
         snome: {required: true},
		 smail: {required: true,email: true},
		 anome: {required: true},
		 amail: {required: true,email: true},
	     mensagem: {required: true}
      },
      messages: {
         snome: {required: ''},
		 smail: {required: '',email: ''},
		 anome: {required: ''},
		 amail: {required: '',email: ''},
		 mensagem: {required: ''}
	   }
	   
   });


    $("#contato").validate({

      rules: {
         nome: {required: true},
		 email: {required: true,email: true},
		 assunto: {required: true},
	     mensagem: {required: true}
      },
      messages: {
         nome: {required: ''},
		 email: {required: '',email: ''},
		 assunto: {required: ''},
		 mensagem: {required: ''}
	   }
	   
   });

	
    $("#busca").validate({

      rules: {
         tipo: {required: true},
		 uf: {required: true}
      },
      messages: {
         tipo: {required: ''},
		 uf: {required: '*'}
	   }
	   
   });


	


	$("#anunciantes").validate({
		errorLabelContainer: $("#anunciantes div.error"),
		wrapper: 'li'
		
	});






}); // fim do $(document).ready(function() {	
