// Valida si es un email
function validaEmail(emailad) {
	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,4}$/;
	
		if (emailad.value == "")
		{
			//alert("Debe introducir el email");
			//emailad.focus()
			//return false
			return true
			//Si esta vacio, el valor introducido en valido porque es un dato opcional.
		}	
	
	
		if(((emailad.value.search(exclude) != -1)||(emailad.value.search(check)) == -1)||(emailad.value.search(checkend) == -1))
		{
			//alert("Debe introducir un email correcto");
			//emailad.focus()
			return false;
		} else return true
}

function muestra(linea,obj){
	ver=document.getElementById(linea);
	ver.style.display=(ver.style.display == "none" ) ? "block" : "none";
	if (obj){
		cambio = document.getElementById(obj)
		cambio.src = (ver.style.display == "none" ) ? "imagenes/mas.gif" : "imagenes/menos.gif";
	}
	
}

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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function IsDigit()
{
	return (((event.keyCode >= 48) && (event.keyCode <= 57)) ||  (event.keyCode == 37))
}

function AbrirVentanaMantener(pageURL,title,features,w,h)
{
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}

function AbrirVentana(theURL,winName,features)
{
	var camb = features;
	if (camb.indexOf('top',0) < 0) {
		camb = camb + ',top=216';
	} 
	if (camb.indexOf('left',0) < 0) {
		camb = camb + ',left=159';
	} 
	if (camb.indexOf('width',0) < 0) {
		camb = camb + ',width=500';
	} 
	if (camb.indexOf('height',0) < 0) {
		camb = camb + ',height=350';
	} 
	
	neu=window.open(theURL,winName,camb);
	neu.focus()
	
}

 function Arroba(sString)
{
	var str = sString.value
	
	if (str != ''){
		// Return false if e-mail field does not contain a '@' and '.' .   
		if (str.indexOf ('@',0) == -1 || str.indexOf ('.',0) == -1)
		{
			//alert('Introduzca correctamente el E-mail')
			sString.focus()
			return false;     
		}else{
			return true;      
		}
	}else{
		return true;
	}
}

	function NuevoAjax(){
		
	var xmlhttp=false; 
		try { 
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
		} 
		catch (e) { 
			try { 
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
			} 
			catch (E) { 
				xmlhttp = false; 
			} 
		}
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
	
	//------ Inicio Total Usuarios Online
	var miTimerTotalOnline;
	function totalOnline(){
		http = NuevoAjax();
		var q = 'controlUsuarios/inc_usuarios.cfm?idcache=' + aleatorio(1,9999999);
		http.open("GET", q, true);
		http.onreadystatechange = ResultadototalOnline;
		http.send(null);
	}

	function aleatorio(inferior,superior){ 
		numPosibilidades = superior - inferior 
		aleat = Math.random() * numPosibilidades 
		aleat = Math.round(aleat) 
		return parseInt(inferior) + aleat 
	} 
	
	function posicionaCapa(nombre_capa){
	
	if (window.pageYOffset)
	{
		scrollTop = window.pageYOffset;
	}
	else
	{
		scrollTop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
	}
	obj_capa = eval("document.getElementById(\""+nombre_capa+"\")");
	var ancho_array = obj_capa.style.width.split("p");
	var left_temp = 0;
	obj_capa.style.top = scrollTop+'px';
	obj_capa.style.left = left_temp + 'px';
	}
	


//LLamada: VentanaCentradaParametros("contacto_aviso_legal.cfm", {width:820,height:50,scrollbars:0}, "AVISO_LEGAL");
function VentanaCentradaParametros(URL)
	{
	  
	  var opciones = arguments[1] || {};
	  var titulo = arguments[2] || 'VENTANA_CENTRADA';
	   
	  var width = opciones.width || 500;
	  var height = opciones.height || 400;
	  var toolbar = opciones.toolbar || 0;
	  var location = opciones.location || 0;
	  var directories = opciones.directories || 0;
	  var status = opciones.status || 0;
	  var menubar = opciones.menubar || 0;
	  var scrollbars = opciones.scrollbars || 0;
	  var resizable = opciones.resizable || 0;
	  var copyhistory = opciones.copyhistory || 1;
	
			 
	  var left = (screen.width/2) - width/2;
	  var top = (screen.height/2) - height/2;
	 
	  
	  var styleStr = 'toolbar='+toolbar+',location='+location+',directories='+directories+',status='+status+',menubar='+menubar+',scrollbars='+scrollbars+',resizable='+resizable+',copyhistory='+copyhistory+',width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;  
	  var msgWindow = window.open(URL, titulo, styleStr); 
	   msgWindow.focus();		
	}
	
	