// JavaScript Document
 function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
   return (true)
  } else {
   alert("La dirección de email es incorrecta.");
   return (false);
  }
 }
function sendContactF(){
		if(
		   (GetId('frmContactF').Nombre.value=='')||
		   (GetId('frmContactF').Email.value=='')||
		   (GetId('frmContactF').Mensaje.value=='')
		   ){
			alert('Por favor complete todos los campos.');
			}else{
				if (validarEmail(GetId('frmContactF').Email.value)){
					var xP=akiSfrm('frmContactF');
					goAJAX('ContactF','ajax/contact.form.php', xP);
				}
				}
		}
function showContactF(){
		winajax('Cont&aacute;ctenos:','400','400','ajax.php','control=contact.form');
		}
		
function OcultarVtna(){
	var objDiv = GetId("sOverlay");
	objDiv.style.display = "none";
	var objDiv = GetId("sVentana");
	objDiv.style.display = "none";
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
  		if (c_start!=-1){
		    c_start=c_start + c_name.length+1;
		    c_end=document.cookie.indexOf(";",c_start);
		    if (c_end==-1) c_end=document.cookie.length;
   		 return unescape(document.cookie.substring(c_start,c_end));
    	}
  	}
	return "";
}

function checkCookie(usuario){
	username=getCookie('arbolito');
	if (username!=null && username!=""){
	    setCookie('arbolito','click',1); //volvemos a setera la cookie si sigue navegando 
  		return true;
	}else{
		return false;	
	}
}


function iecompattest(){
return (document.compatMode && document.compatMode!='BackCompat')? document.documentElement : document.body
}	
function posicionar(){
	var startX = document.body.clientWidth - document.body.scrollLeft - 200; // Tamaño horizontal de la barra en pixeles
	var startY = 30; // Tamaño vertical de la barra en pixeles   
	var verticalpos='frombottom' // 'fromtop' o 'frombottom' para definir si va arriba o abajo.
	barheight=GetId('Arbolito').offsetHeight
	var ns = (navigator.appName.indexOf('Netscape') != -1) || window.opera;
	var d = document;
	function ml(id){
		var el=d.getElementById(id);
		el.style.visibility='visible'
		if(d.layers){el.style=el;}
		el.sP=function(x,y){this.style.left=x+'px';this.style.top=y+'px';};
		el.x = startX;
		if (verticalpos=='fromtop'){
			el.y = startY;
		}else{
			el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
			el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function(){
		if (verticalpos=='fromtop'){
			var pY = ns ? pageYOffset : iecompattest().scrollTop;
			ftlObj.y += (pY + startY - ftlObj.y)/20;
		}else{
			var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
			ftlObj.y += (pY - startY - ftlObj.y)/20;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout('stayTopLeft()', 1);
	}
	ftlObj = ml('Arbolito');
	stayTopLeft();
	if(checkCookie('click')){
	  GetId('Arbolito').style.visibility = 'hidden';
      GetId('contenarbolito').style.display = '';
	}else{
		 GetId('contenarbolito').style.display = 'none';
	}
}	

function cerrarPopup(pid){
      GetId(pid).style.visibility = 'hidden';    
	  setCookie('arbolito','click',1);  
      GetId('contenarbolito').style.display = '';
}
