estaAnimando=false;
$(document).ready(function(){
	$("span[rel]").overlay({mask: {
		color: '#616161',
		loadSpeed: 200,
		opacity: 0.8
	},closeOnClick: false});
	$('.dvSe').mouseover(function(){
		this.salio=false;
		setTimeout("anima('"+this.id+"')",50);
		$(this).mouseout(function(){
			this.salio=true;
			//if($(this).css('width')=='100px'){
				$(this).animate({width:17});
			//}
		});
	});
	initMenus();
	jquerycssmenu.buildmenu("myjquerymenu", arrowimages)
	//$("a[title]").tooltip({ positionLeft: true });
});
function anima(ob){
	var ob=document.getElementById(ob);
	if(!ob.salio){
		//alert(ob);
		if($(ob).css('width')=='17px'){
			$(ob).animate({width:100});
		}
	}
}
function initMenus() {
	$('ul.menu ul').hide();
	//$.each($('ul.menu  ul'), function(){
		$('ul.menu  ul.expandfirst').show();
		$('a.activado_prod').parent().parent().show();
		$('a.activado_prod').parent().parent().prev().css('color','#0094AB');
		$('a.activado_prod').css('color','#0094AB');
	//});
	$('ul.menu li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;
			//alert(checkElement);

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				$('ul.menu li a').css('color','#000');
				$(this).css('color','#0094AB');
				return false;
			}
		}
	);
}
function des(){
	$('#md').css('display','block');
}
function ocu(){
	$('#md').css('display','none');
}
function des2(){
	$('#md2').css('display','block');
}
function ocu2(){
	$('#md2').css('display','none');
}
function p(lnk){
	document.location=lnk;
}
function setMail(mail,add){
	document.getElementById('mail_dest').value=mail;
	if(add != '' && add != undefined){
		document.getElementById('add_tit').innerHTML=add;
	}
}
function envia_contacto_encabezado(en){
	nombrev = document.getElementById('nombre_enc').value;
	mailv = document.getElementById('mail_enc').value;
	telefonov = document.getElementById('telefono_enc').value;
	comentariov = document.getElementById('comentario_enc').value;
	
	paisv = document.getElementById('pais_enc').value;
	ciudadv = document.getElementById('ciudad_enc').value;
	zonalabv = document.getElementById('zonalab_enc').value;
	
	nombrev = nombrev.replace(/^\s*|\s*$/g,'');
	mailv = mailv.replace(/^\s*|\s*$/g,'');
	telefonov = telefonov.replace(/^\s*|\s*$/g,'');
	comentariov = comentariov.replace(/^\s*|\s*$/g,'');
	ciudadv = ciudadv.replace(/^\s*|\s*$/g,'');
	
	var txt1=(en!=1)?'Complete por favor su comentario':'Please fill your comment';
	var txt2=(en!=1)?'Direción de mail invalida':'Invalid email address';
	var txt3=(en!=1)?'Complete por favor su mail':'Please fill in your email';
	var txt4=(en!=1)?'Complete por favor su nombre':'Please fill in your name';
	var txt5=(en!=1)?'Complete por favor su ciudad':'Please fill in your city';
	
	cancelado=false;
	if(comentariov.length<1){
		document.getElementById('mensaje_enc').innerHTML=txt1;
		cancelado=true;
	}
	if(ciudadv.length<1){
		document.getElementById('mensaje_enc').innerHTML=txt5;
		cancelado=true;
	}
	valormail=document.getElementById('mail_enc').value;
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valormail)){
		
	}else{
		document.getElementById('mensaje_enc').innerHTML=txt2;
		cancelado=true;
	}
	if(mailv.length<1){
		document.getElementById('mensaje_enc').innerHTML=txt3;
		cancelado=true;
	}
	if(nombrev.length<1){
		document.getElementById('mensaje_enc').innerHTML=txt4;
		cancelado=true;
	}
	if(!cancelado){
	document.getElementById('formulario_contacto_enc').style.display='none';
	document.getElementById('enviando_enc').style.display='';
	document.getElementById('comentario_enc').value='';
	document.getElementById('mensaje_enc').innerHTML='';
	mailDest=document.getElementById('mail_dest').value;
		$.ajax({
  url: 'formulario_contacto.php?envia=1&nombre='+nombrev+'&mail='+mailv+'&telefono='+telefonov+'&comentario='+comentariov+"&mailDest="+mailDest+"&pais="+paisv+"&ciudad="+ciudadv+"&zonalab="+zonalabv,
  success: function(data) {
    $('#texto_enviando_enc').html(data);
  }
});
	}
}
function lim_f_con(en){
	if(document.getElementById('form_oculto').style.display!='none'){
		setTimeout("lim_f_con()",700);
	}else{
		
		var txt=(en!=1)?'Enviando Mensaje':'Sending Message';
		
		document.getElementById('formulario_contacto_enc').style.display='';
		document.getElementById('add_tit').innerHTML='';
		document.getElementById('enviando_enc').style.display='none';
		document.getElementById('texto_enviando_enc').innerHTML=txt+'...<br /><img src=\'img/loading.gif\' />';
		document.getElementById('mensaje_enc').innerHTML='';
	}
}
function img(id1,id2){
		document.getElementById(id1).style.display='';
		document.getElementById(id2).style.display='none';
}
