var menu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();

function abreHighslide2(url, largura, altura, tipo){
	var link = document.createElement("a");
	link.setAttribute("href",url);
	
	if(!tipo){
		tipo = 'ajax';
	}
	
	hs.htmlExpand(link, {objectType:tipo, width:largura, height:altura, dimmingOpacity: 0.5, outlineType: 'glossy-dark', useControls: false, wrapperClassName: 'draggable-header no-footer'}); 
	
}

function popup(url, width, height, rola){						
	if (rola==""){
		rola="yes"
	}
	window.open(url,"_blank","resizable=no,toolbar=no,status=no,top=" + (window.screen.height - height)/2 + ",left=" + (window.screen.width - width)/2 + ",menubar=no,scrollbars=" + rola + ",width=" + width + ",height=" + height);
}

function validaFrmComentario(form){
	$("#resp").show();
	if(form.nome.value==""){
		$("#resp").html("Por favor, preencha o campo NOME!");
		form.nome.focus();
		return false;
	}
	if(form.email.value==""){
		$("#resp").html( "Por favor, preencha o campo EMAIL!");
		form.email.focus();
		return false;
	}else{
		if(!validaEmail(form.email.value)){
			$("#resp").html("Por favor, informe um EMAIL V&Aacute;LIDO!");
			form.email.focus();
			return false;
		}
	}	
	if(form.comentario.value==""){
		$("#resp").html("Por favor, preencha o campo MENSAGEM!");
		form.comentario.focus();
		return false;
	}

	$("#resp").load('ctrlImplementa.php?'+$("#frmComentario").formSerialize());
	return false;
}
//verifica se o email informada eh valido
function validaEmail(email){
	ER = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]{2,64}(\.[a-z0-9-]{2,64})*\.[a-z]{2,4}$");
	if (ER.test(email)){
		return true;
	}else{
		return false;
	}
}
function validaFrmContato(form){
	scrollTo(0,0);
	document.getElementById("resposta").style.display = "block";
	if(form.txtNome.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";
		form.txtNome.focus();
		return false;
	}
	if(form.txtEmail.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";
		form.txtEmail.focus();
		return false;
	}else{
		if(!validaEmail(form.txtEmail.value)){
			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";
			form.txtEmail.focus();
			return false;
		}
	}	
	if(form.telefone.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo TELEFONE!";
		form.telefone.focus();
		return false;
	}
	if(form.txtAssunto.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, selecione o ASSUNTO!";
		form.txtAssunto.focus();
		return false;
	}
	if(form.txtMensagem.value==""){
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo MENSAGEM!";
		form.txtMensagem.focus();
		return false;
	}
	$("#resposta").load('ctrlImplementa.php?'+$("#frmContato").formSerialize());
}
function validaFrmLigaremos(form){
		if(form.txtNome.value==""){
			alert("Preencha o campo nome!");
			form.txtNome.focus();
			return false;
		}		
		if(form.txtEmail.value==""){
			alert("Preencha o campo email!");
			form.txtEmail.focus();
			return false;
		}else{
			if(!validaEmail(form.txtEmail.value)){
				alert("Preencha um email valido!");
				form.txtEmail.focus();
				return false;
			}
		}
		if(form.txtPais.value==""){
			alert("Preencha o campo telefone!");
			form.txtPais.focus();
			return false;
		}
		if(form.txtFone.value==""){
			alert("Preencha o campo telefone!");
			form.txtFone.focus();
			return false;
		}
		

		return true;		
	}	

