// Lib jcvdesign
function Ajax(valor, urlr, qid, msg)
{
url=urlr+valor;
jcvF(url, qid, msg);
}
function jcvF(url, QID, msg)
{
	this.QID = QID;
	this.msg = msg;
	ajax(url);
}
function extraiScript(texto){
        var ini = 0;
        while (ini!=-1){
                ini = texto.indexOf('<script', ini);
                if (ini >=0){
                        ini = texto.indexOf('>', ini) + 1;
                        var fim = texto.indexOf('</script>', ini);
                        codigo = texto.substring(ini,fim);
                        //eval(codigo);
						novo = document.createElement("script")
                        novo.text = codigo;
                        document.body.appendChild(novo);

                }
        }
}
function ajax(url){
	  req = null;
      if (window.XMLHttpRequest) {
      req = new XMLHttpRequest();
      req.onreadystatechange = processReqChange;
      req.open("GET",url,true);
      req.send(null);
 	  }
	  else if (window.ActiveXObject) {
      req = new ActiveXObject("Microsoft.XMLHTTP");
     	 if (req) {
      	req.onreadystatechange = processReqChange;
		req.setRequestHeader("'Content-Type', 'application/x-www-form-urlencoded'");
  		req.open("GET",url,true);
		req.send();
      	}

      }
}
function processReqChange(){
	document.getElementById(QID).innerHTML = "<div id='loadingAjax'>"+msg+"</div>";
      if (req.readyState == 4) {
		  if (req.status ==200) {
			 document.getElementById(QID).innerHTML = req.responseText;
			 extraiScript(req.responseText);

     		 }
		  else {
		      document.getElementById(QID).innerHTML = "<div id='errorAjax'>ERRO: Falha ao executar a requisi&ccedil;&atilde;o.</div>";
      		}

      }

} 
function searchClick(){
	if(document.getElementById("search").value == 'Procurar pelo site'){
		document.getElementById("search").value = '';
	}
}
function searchBlur(){
	if(document.getElementById("search").value == ''){
		document.getElementById("search").value = 'Procurar pelo site';
	}
}





function verifForm(){

$alert = _$("alerts-form");
$nome = _$("cont_nome");
$email = _$("cont_email");
$estado = _$("cont_estado");
$cidade =  _$("cont_cidade");
$assunto = _$("cont_assunto");
$mensagem = _$("cont_msg");
$type = "";

if($nome.value == ''){
$msg= "Favor informar seu nome";
$nome.focus();
}
else if($email.value == ''){
$msg= "Favor informar seu e-mail";
$email.focus();
}
else if($cidade.value == ''){
$msg= "Favor informar sua cidade";
$cidade.focus();
}
else if($estado.value == ''){
$msg= "Favor informar seu estado";
$estado.focus();
}

else if($assunto.value == ''){
$msg= "Favor informar um assunto";
$assunto.focus();
}
else if($mensagem.value == ''){
$msg= "Favor digitar uma mensagem";
$mensagem.focus();
}
else{
$msg= "Enviando sua Mensagem... Aguarde!";
$type = "ok";
}
	if($type == "ok"){
	$alert.innerHTML= "<div class='ok'>"+$msg+"</div>";
	return true;
	}
	else{
	$alert.innerHTML= "<div class='error'>"+$msg+"</div>";
	return false;
	}
}


function verifDepo(){

$alert = _$("alerts-form");
$nome = _$("nome");
$email = _$("email");
$mensagem = _$("depoimento");
$type = "";

if($nome.value == ''){
$msg= "Favor informar seu nome";
$nome.focus();
}
else if($email.value == ''){
$msg= "Favor informar seu e-mail";
$email.focus();
}

else if($mensagem.value == ''){
$msg= "Favor digitar um depoimento";
$mensagem.focus();
}
else{
$msg= "Enviando seu depoimento... Aguarde!";
$type = "ok";
}
	if($type == "ok"){
	$alert.innerHTML= "<div class='ok'>"+$msg+"</div>";
	return true;
	}
	else{
	$alert.innerHTML= "<div class='error'>"+$msg+"</div>";
	return false;
	}
}


function aprove($url, $msg){
	if(confirm($msg)){
		window.location = $url;
	}
	else{
		return false;
		}
}

// tabbs

$(document).ready(function(){
    
  $("a.tab").click(function () {  
        
     $(".active").removeClass("active");  
        
    $(this).addClass("active");  
	
	      
    $(".tconts").hide();  
     
    var content_show = $(this).attr("title");  
    $("#"+content_show).show();  
      
 });  
 
 });  

// tabbs end

function validasearch(){
	$search = _$('search').value;
	if($search == ""){
		return false;
		// fail form
	}
	else if($search == "Procurar pelo site"){
		return false;
		// fail form
	}
	else{
		return true;
	}
}

function clear($id){
	_$($id).innerHTML = "here";
	alert("here");
}


function comonosconheceu(resp){
	$write = _$("quemlabel");
	if(resp == "indica" || resp == "amigo"){
		$write.innerHTML = "Quem?<br /><input name='quem' type='text' id='quem' />";
	}
	else if(resp == "portal" || resp == "catalogo"){
		$write.innerHTML = "Qual?<br /><input name='quem' type='text' id='quem' />";
	}
	else if(resp == "outro"){
		$write.innerHTML = "Como?<br /><input name='quem' type='text' id='quem' />";
	}
	else{
		$write.innerHTML = "";
	}
	
}


function verifOrc(){

$alert = _$("alerts-form");
$nome = _$("orc_nome");
$sexo = _$("orc_sexo");
$residencial = _$("orc_residencial");
$celular = _$("orc_celular");
$email = _$("orc_email");
$tipoevento = _$("orc_tipoevento");
$dataevento = _$("orc_dataevento");
$orcamento = _$("orc_msg");



$type = "";

if($nome.value == ''){
$msg= "Favor informar seu nome completo";
$nome.focus();
}
else if($sexo.value == ''){
$msg= "Favor informar seu sexo";
$sexo.focus();
}
else if($residencial.value == ''){
$msg= "Favor informar seu telefone residencial";
$residencial.focus();
}
else if($celular.value == ''){
$msg= "Favor informar seu telefone celular";
$celular.focus();
}
else if($email.value == ''){
$msg= "Favor informar seu e-mail";
$email.focus();
}


else if($tipoevento.value == ''){
$msg= "Favor informar o tipo de evento";
$tipoevento.focus();
}
else if($dataevento.value == ''){
$msg= "Favor digitar a data do evento";
$dataevento.focus();
}
else if($orcamento.value == ''){
$msg= "Favor digitar uma mensagem no campo Orçamento";
$orcamento.focus();
}
else{
$msg= "Enviando seu orçamento... Aguarde!";
$type = "ok";
}
	if($type == "ok"){
	$alert.innerHTML= "<div class='ok'>"+$msg+"</div>";
	return true;
	}
	else{
	$alert.innerHTML= "<div class='error'>"+$msg+"</div>";
	return false;
	}
}


$(document).ready(function(){
						   $(".listprod a img").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
						   $(".listprod a img").hover(function(){
						   $(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
						   },function(){
						   $(this).fadeTo("slow", 0.6); // This should set the opacity back to 30% on mouseout
						   });
						   });

$(document).ready(function(){
						   $(".listprod a").hover(function(){
						   $("div", this).slideDown();
						   },function(){
						   $("div", this).slideUp(); 
						   });
						   });

$(document).ready(function(){
						   $(".listsub a img").fadeTo("slow", 0.6);
						   $(".listsub a").hover(function(){
						   $("img", this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
						   $("div", this).slideUp();
						   },function(){
						   $("img", this).fadeTo("slow", 0.6); // This should set the opacity back to 30% on mouseout
						   $("div", this).slideDown(); 
						   });
						   });


$(document).ready(function(){
						   $(".prod-view a").hover(function(){
						   $("div", this).fadeTo("slow", 0.7);
						   },function(){
						   $("div", this).fadeTo("slow", 0);
						   });
						   });


$(document).ready(function(){
						   $("#albuns-list a img").fadeTo("slow", 0.6);
						   $("#albuns-list a").hover(function(){
						   $("img", this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
						   $("div", this).slideUp();
						   },function(){
						   $("img", this).fadeTo("slow", 0.6); // This should set the opacity back to 30% on mouseout
						   $("div", this).slideDown(); 
						   });
						   });