	window.onload = init;
	var y;
	
	function init() 
	{
		if (window.Event) 
			document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = getXY;
	}

	function getXY(e) 
	{
		y = (window.Event) ? e.pageY : event.clientY;

		nLanguageBarOffsetDown = document.getElementById("head").offsetTop + document.getElementById("head").clientHeight
		lYisOverLanguageBar = y < nLanguageBarOffsetDown

		nBottomDivOffsetTop = document.getElementById("bottomDiv").offsetTop
		lYisOverBottomDiv = y > nBottomDivOffsetTop

		if (navigator.appName=="Microsoft Internet Explorer")
		{
			document.getElementById("head").style.zIndex = (lYisOverLanguageBar) ? 1 : -1;
			document.getElementById("bottomDiv").style.zIndex = (lYisOverBottomDiv) ? 1 : -1;
		}
		else
		{
			document.getElementById("head").style.zIndex = (lYisOverLanguageBar) ? 2 : 0;
			document.getElementById("bottomDiv").style.zIndex = (lYisOverBottomDiv) ? 2 : 0;
		}
	}
	

	function ClearList(elemName)
	{
		var elem = document.getElementById(elemName);
		while(elem.length > 0)
		{
			elem.remove(0);
		}
	}


	function CheckSelected(id1, id2)
	{				
		return id1==id2;
	}


	function AddElementOnList(cList, oOption)
	{
		try
		{
			document.getElementById(cList).add(oOption, null);
		}
		catch(ex)
		{
			document.getElementById(cList).add(oOption);
		}
	}

	
	function ChangeLanguage(tnLanguage)
	{
		document.getElementById("hdnLanguage").value = tnLanguage
		var x = document.getElementById("form1");
		var txt = document.URL;
		if (txt.charAt(txt.length-1) == "/")
			txt = txt + "index.asp";
		x.action = txt;
		x.submit();
	}


	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 setCookie(c_name,value)
	{
		document.cookie=c_name+ "=" +escape(value);
	}


	function emailCheck (emailStr) 
	{
		/* Verificar si el email tiene el formato user@dominio. */
		var emailPat=/^(.+)@(.+)$/
		
		/* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		
		/* Verifica los caracteres que son válidos en una dirección de email */
		var validChars="\[^\\s" + specialChars + "\]"
		
		var quotedUser="(\"[^\"]*\")"
		
		/* Verifica si la dirección de email está representada con una dirección IP Válida */
		
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

		/* Verificar caracteres inválidos */
		
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		// domain, as opposed to ipDomainPat, shown above. */
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) 
		{
			//alert("Email address seems incorrect (check @ and .'s)")
			return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]

		// Si el user "user" es valido 
		if (user.match(userPat)==null) 
		{
			// Si no alert("El nombre de usuario no es válido.")
			return false
		}

		/* Si la dirección IP es válida */
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) 
		{
			for (var i=1;i<=4;i++) 
			{
				if (IPArray[i]>255) 
				{
					// alert("IP de destino inválida")
					return false
				}
			}
			return true
		}

		var domainArray=domain.match(domainPat)
		if (domainArray==null) 
		{
			//alert("El dominio parece no ser válido.")
			return false
		}

		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
		{
			//alert("La dicrección debe tener 3 letras si es ."com" o 2 si en de algún pais.")
			return false
		}

		if (len<2) 
		{
			//alert("La dirección es erronea")
			return false
		}
		
		// La dirección de email ingresada es Válida
		return true;
	}	

	function JustNumbers(e)
	{
		lnPressedKey = (document.all) ? e.keyCode : e.which;
	
		//Tecla de retroceso para borrar o Tab, siempre la permite
		if (lnPressedKey == 8 || lnPressedKey == 0)
		{
			return true;
		}
			
		// Patron de entrada, en este caso solo acepta numeros
		lnPattern =/[0-9]/;
		
		lnFinalKey = String.fromCharCode(lnPressedKey);
		
		return lnPattern.test(lnFinalKey);
	}


