// JavaScript Document

	function handleHttpResponse() {
		if (http.readyState == 4) {
		   if (http.status == 200) {
			  if (http.responseText.indexOf('invalid') == -1) {
					 // Armamos un array, usando la coma para separar elementos
				 results = http.responseText.split(",");				 
				  if(results[0] == "yes")
				  {	
						document.getElementById("mensaje").innerHTML = "<table width='100%' height='35' border='0' cellpadding='0' cellspacing='0'><tr><td width='3%' align='right'>&nbsp;</td><td width='94%'  class='text_content'>Please Wait</td><td width='3%' class='Contenidos_3eye_blanco'>&nbsp;</td></tr></table>"
						document.frmGaumardLoginq.action = "view_myaccount.asp?idusuario="+results[1];
						document.frmGaumardLoginq.submit();
						//alert(results[1]);
				  }
				   if(results[0] == "Error")
				  {
					  document.getElementById("mensaje").innerHTML ="<table width='100%' height='35' border='0' cellpadding='0' cellspacing='0'><tr><td width='3%' align='right'>&nbsp;</td><td width='94%'  class='text_content' ><strong style='color:red'>Error:</strong> User or Password are incorrect. Try again</td><td width='3%' class='Contenidos_3eye_blanco'>&nbsp;</td></tr></table>"	
				  }			  
				   if(results[0] != "yes")
				  {
					  document.getElementById("mensaje").innerHTML ="<table width='100%' height='35' border='0' cellpadding='0' cellspacing='0'><tr><td width='3%' align='right'>&nbsp;</td><td width='94%'  class='text_content' ><strong style='color:red'>Error:</strong> User or Password are incorrect. Try again</td><td width='3%' class='Contenidos_3eye_blanco'>&nbsp;</td></tr></table>"	
				  }				  
				  
				 enProceso = false;
			  }
		   }
		}
	}


	function Enter()
	{ 
		if(document.getElementById("user_login").value == "")
		{
			alert("Please insert your user");	
			document.getElementById("user_login").focus();
			return false;
		}
		
		if(document.getElementById("password_login").value == "")
		{
			alert("Please insert your password");	
			document.getElementById("password_login").focus();
			return false;
		}	
	
		if (!enProceso && http) {
		   var user = escape(document.getElementById("user_login").value);
		   var pass = escape(document.getElementById("password_login").value);
		   document.getElementById("mensaje").innerHTML = "<table width='100%' height='15' border='0' cellpadding='0' cellspacing='0'><tr><td width='200' align='right'><img src='img/loading.gif' alt='Loading' width='32' height='32' longdesc='Loading - Please Wait'></td><td width='3%' >&nbsp;</td><td width='60%' class='Contenidos_3eye'>Please Wait </td></tr></table>";			   
		   var url = "adminsite/procedure.asp?tipo=16&user="+user+"&password="+pass;
		   http.open("GET", url, true);
		   http.onreadystatechange = handleHttpResponse;
		   enProceso = true;
		   http.send(null);
		   

		   
		}	
		return false;
	}

	function getHTTPObject() {
		var xmlhttp;
		/*@cc_on
		@if (@_jscript_version >= 5)
		   try {
			  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		   } catch (e) {
			  try {
				 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			  } catch (E) { xmlhttp = false; }
		   }
		@else
		xmlhttp = false;
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		   try {
			  xmlhttp = new XMLHttpRequest();
		   } catch (e) { xmlhttp = false; }
		}
		return xmlhttp;
	}


var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest

	function searchProducts()
	{
		if(document.getElementById("textSearch").value=="")
		{
			alert("Please write a product name");
			document.getElementById("textSearch").focus();
			return;
		}
//		document.getElementById("frmGaumardLogin").action = "resultSearchProducts.asp";
//		document.getElementById("frmGaumardLogin").submit();
		
		document.frmGaumardLogin.action = "resultSearchProducts.asp";
		document.frmGaumardLogin.submit();		
		
	}
	
	function Saltar(Campo,event)
	{
		var key
		if(window.event)
			key = window.event.keyCode
		else 
			if(event)
				key = event.which
			else
				return true
			// Si es tecla enter
				
		if(key == 13)
			document.getElementById(Campo).focus()
	}	
	
	function executeEnter(event)
	{
		var key
		if(window.event)
			key = window.event.keyCode
		else 
			if(event)
				key = event.which
			else
				return true
			// Si es tecla enter
				
		if(key == 13)
			Enter();
	}
	
	function executeSearch(event)
	{
		var key
		if(window.event)
			key = window.event.keyCode
		else 
			if(event)
				key = event.which
			else
				return true
			// Si es tecla enter
				
		if(key == 13)
			searchProducts();
	}