function keepshopping(){ 
document.location = "./default.asp";
} 

function switchMenu(obj){
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function getD(id){ 
document.location = "./detalle.asp?prd=" + id;
} 
function getL(id){ 
document.location = "./listado.asp?cat=" + id;
} 

function popup(url){
WindowObjectReference = window.open(url,'','menu=0,resizable=1,scrollbars=1');
}
		
function openWindow(url, width, height) {
  var win;
  var windowName;
  var params;
  windowName  = "features";
  params = "toolbar=0,";
  params += "location=0,";
  params += "directories=0,";
  params += "status=0,";
  params += "menubar=0,";
  params += "scrollbars=1,";
  params += "resizable=1,";
  params += "top=50,";
  params += "left=50,";
  params += "width="+width+",";
  params += "height="+height;
  win = window.open(url, windowName, params);

  win.focus();

  return;
}
	
function validarEmail(){
var valor = document.formLogin.usu.value

  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
  {    
    return true;
  } else {
    alert("La direccion de email no es valida");
    return false;
  }
}

function validarEmailRegistro(){
var valor = document.formRegistro.mail.value

  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
  {    
    return true;
  } else {
    alert("La direccion de email no es valida");
    return false;
  }
}

function validarPwd2() {
var invalid = " "; // Invalid character is a space
var minLength = 6; // Minimum length
var pw1 = document.formRegistro.pwd1.value;
var pw2 = document.formRegistro.pwd2.value;
// check for a value in both fields.
if (pw1 == '' || pw2 == '') {
alert('Please enter your password twice.');
return false;
}
// check for minimum length
if (pw1.length < minLength) {
alert('Your password must be at least ' + minLength + ' characters long. Try again.');
return false;
}
// check for spaces
if (pw1.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
else {
if (pw1 != pw2) {
alert ("You did not enter the same new password twice. Please re-enter your password.");
return false;
}
else {
alert('Nice job.');
return true;
      }
   }
}

function validarPwd(){
	var p1 = document.formRegistro.pwd1.value;
	var p2 = document.formRegistro.pwd2.value;
	
	if (p1 == p2){		
		return true;
	}else{
		alert("Los passwords no coinciden");
		return false;
	}
}

function isNumberKey(evt,field){  
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
  return false;
  
if(field.style.backgroundColor == "red")
  field.style.backgroundColor = "white"
return true;
}

function foco(){
	document.form1.s.focus();
}

function validarCantidad(){
  if(document.comprar.prdCnt.value.length<1)
  {
    document.comprar.prdCnt.style.backgroundColor = "red";
    return false;
   }
   
  if(document.comprar.prdCnt.value<1)
  {
    document.comprar.prdCnt.style.backgroundColor = "red";
    return false;
   }   
   
   document.comprar.submit();
   //return true;
}

function checkout(){
		if(confirm("Confirma finalizar el pedido?"))
			document.location = "./finalizar.asp";
}

function checkout3(){
	var answer = confirm("Confirma finalizar el pedido?")
	if (answer){
			document.frmCarrito.finalizado.value = 1;
			document.frmCarrito.action = './carrito_3.asp';
			document.frmCarrito.submit();
	}
	else{
		return false;
	}
}

function checkout2(){
	document.location = "./carrito_2.asp";
}

function mostrar(obj,img) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
		document.getElementById(img).src = 'http://stk.fastimport.ws/search_show.gif';
	}
	else {
		el.style.display = '';
		document.getElementById(img).src = 'http://stk.fastimport.ws/search_hide.gif';
	}
}

function createRequestObject() { 

   var req; 

   if(window.XMLHttpRequest){ 
	  // Firefox, Safari, Opera... 
	  req = new XMLHttpRequest(); 
   } else if(window.ActiveXObject) { 
	  // Internet Explorer 5+ 
	  req = new ActiveXObject("Microsoft.XMLHTTP"); 
   } else { 
	  // There is an error creating the object, 
	  // just as an old browser is being used. 
	  alert('Problem creating the XMLHttpRequest object'); 
   } 

   return req; 

} 

// Make the XMLHttpRequest object 
var http = createRequestObject(); 

function sendRequest(q) { 

  if(q=='')
  {
	document.getElementById("searchResults").innerHTML = '';
  }else{

   // Open PHP script for requests 
   http.open('get', 'z.asp?q='+q); 
   http.onreadystatechange = handleResponse; 
   http.send(null); 
   }

} 

function handleResponse() { 
    
       if(http.readyState == 4 && http.status == 200){ 
    
          // Text returned FROM the PHP script 
          var response = http.responseText; 
    
          if(response) { 
             // UPDATE ajaxTest content 
             document.getElementById("searchResults").innerHTML = response; 
          } 
    
       } 
    
    } 
