// JavaScript Document

<!--

function CargarFoto(img, ancho, alto){
  derecha=(screen.width-ancho)/2;
  arriba=(screen.height-alto)/2;
  //string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+ancho+",height="+alto+",left="+derecha+",top="+arriba+"";
  string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+200+",height="+200+",left="+derecha+",top="+arriba+"";
  fin=window.open(img,"",string);
}

//Script de la fecha. 

function getdiasemana(fecha){

  var diasemana = fecha.getDay();

  switch(diasemana){

   case 0: return "Domingo";

   case 1: return "Lunes";

   case 2: return "Martes";

   case 3: return "Miércoles";

   case 4: return "Jueves";

   case 5: return "Viernes";

   case 6: return "Sábado";

  }

 }

function getdiasemanai(fecha){

  var diasemana = fecha.getDay();

  switch(diasemana){

   case 0: return "Sunday";

   case 1: return "Monday";

   case 2: return "Tuesday";

   case 3: return "Wednesday";

   case 4: return "Thursday";

   case 5: return "Friday";

   case 6: return "Saturday";

  }

 }
 function getmes(fecha){

  var mes = fecha.getMonth();

  switch(mes){

   case 0: return "enero";

   case 1: return "febrero";

   case 2: return "marzo";

   case 3: return "abril";

   case 4: return "mayo";

   case 5: return "junio"; 

   case 6: return "julio";

   case 7: return "agosto";

   case 8: return "septiembre";

   case 9: return "octubre";

   case 10: return "noviembre";

   case 11: return "diciembre";
  }  
 }

function abre(url){ 

   window.open(url,'','width=580,height=465,,,,,status,,');

 }
 
 function valida_contenido(checkOK,checkStr) //Lo tome de un codig. free en Internet
{
	var allValid = true;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
		if (ch != ",")
			allNum += ch;
	}
	if (!allValid)
		return (false)
	else
		return (true)
}

 
 function validacion(carrito,action) {
 var res=true;
 //alert(document.carrito.elements[2].value);
 //alert("cant de elementos: "+document.carrito.elements.length);
//alert (document.carrito.importe.value);
tam1 = (document.carrito.elements.length-2)/4;
tam = Math.round(tam1);
//alert ("cantidad de elementos del formulario a recorrer"+tam)
var j=0, m=0, n=1;
 for (n = 1;  n <= tam;  n++) {
	       //j=n+1;
		   j++;
           if (n == 1) m=0
		   else m=m+4;
		   //alert("viene el valor del producto "+j+" que es:"+carrito.elements[m].value);
   	       if (carrito.elements[m].value=="0" || carrito.elements[m].value==""){
		     alert("Por favor, escriba un valor para el producto No."+j)
			 res=false;
		    return (false)
	       }
           if (carrito.elements[m].value == "" || carrito.elements[m].value.substring(0,1)==0)
	           {
			alert("Por favor, entre un valor.");
    		carrito.elements[m].value.focus();
			res=false;
    		return (false);
	           }
		   if (carrito.elements[m].value!="") {
	     		var cadena="0123456789";
		        var v=carrito.elements[m].value;
        		if (!valida_contenido(cadena,v)){
		        	alert("Por favor, escriba una cantidad válida para el producto No."+j);
					res=false;
			        return (false)
				}
	       }
		   if (res=true)
		   {
		   cnt=carrito.elements[m].value;
		   ms=carrito.elements[m+1].value;
		   cex=carrito.elements[m+2].value;
		   //alert("ms: "+ms);
		   //alert ("valor de res "+res);
		   if (ms != 0) {
			   resto=cnt%ms;		   
			   if (resto != 0) {
			   alert ('Cantidad errónea para el producto '+j+'. Por favor entre un valor múltiplo de '+ms);
			   carrito.elements[m+1].value=ms;
			   if (carrito.elements[m+1].disabled==true)
			   	carrito.elements[m+1].focus();
			   else
			   	carrito.elements[m].focus();
			   res=false;
    	   	   //return (false)
			   }
		   }
		   var pie=cnt-cex;
		   
		   //alert ("Cantidad del producto: "+cnt);
   		   //alert("cantidad en existencia: "+cex);
		   //alert ("resta: "+pie);
		   if (pie > 0) {
			   alert ('Cantidad errónea para el producto '+j+'. La cantidad será reajustada a la cantidad disponible que es: '+cex);
    		   carrito.elements[m].value=cex;
			   carrito.elements[m].focus();
			   res=false;
    	   	   return (false)
		   }
		   }
		   //n++;
 }
 if (action == 4 && res== true) {
	 if (document.carrito.importe.value) {
	  var dato=document.carrito.importe.value.substr(1);
	          //alert (dato);	
		if (dato=='') dato=0;
		
		if (dato < 40) {
	     if (dato > 0)
		 	alert("No es posible confirmar su pedido, para considerar un pedido válido su importe debe estar en el rango entre 40.00 y 2000.00 USD, usted solo ha comprado productos por un valor de $"+dato+" USD.");
			//alert ("No es posible confirmar su pedido, para considerar un pedido válido su importe debe 35.00 USD, usted solo ha comprado productos por un valor de $"+dato+" USD.");
		 else
		 	alert("No es posible confirmar su pedido, para considerar un pedido válido su importe debe estar en el rango entre 40.00 y 2000.00 USD, usted no ha comprado ningún producto.");
			//alert ("No es posible confirmar su pedido, el importe mínimo para considerar un pedido válido debe ser ser inferior a 500.00 USD y superior a 35.00 USD, usted no ha comprado ningún producto.");

		 res=false;
		 return (false);
		 //window.location="cesta.php?<?=$sid?>&acc=1&idproducto=0&cantidad=0&nombre=''&precio=0&ms=0&cant_existencia=0";
		 //return (false) pepecin de mi amor
		} else {
		if (dato > 2000) {
			alert ("No es posible confirmar su pedido, para considerar un pedido válido su importe debe estar en el rango entre 40.00 y 2000.00 USD, usted ha comprado productos por un valor de $"+dato+" USD. Si Ud. desea hacer compras con un monto superior por favor contacte a nuestro administrador.");
         res=false;
		 return (false);			
		} else {
     	  res=true;
		  return (true);
	
		}	
		  //window.location="confped.php";
		  //return (true)
		  }
	 }
 }
 return (res);
}	  

 function validacioni(carrito,action) {
 var res=true;
 //alert(document.carrito.elements[2].value);
 //alert("cant de elementos: "+document.carrito.elements.length);
//alert (document.carrito.importe.value);
tam1 = (document.carrito.elements.length-2)/4;
tam = Math.round(tam1);
//alert ("cantidad de elementos del formulario a recorrer"+tam)
var j=0, m=0, n=1;
 for (n = 1;  n <= tam;  n++) {
	       //j=n+1;
		   j++;
           if (n == 1) m=0
		   else m=m+4;
		   //alert("viene el valor del producto "+j+" que es:"+carrito.elements[m].value);
   	       if (carrito.elements[m].value=="0" || carrito.elements[m].value==""){
		     alert("Please, write down a value for the product Num."+j)
			 res=false;
		    return (false)
	       }
           if (carrito.elements[m].value == "" || carrito.elements[m].value.substring(0,1)==0)
	           {
			alert("Please, insert a value.");
    		carrito.elements[m].value.focus();
			res=false;
    		return (false);
	           }
		   if (carrito.elements[m].value!="") {
	     		var cadena="0123456789";
		        var v=carrito.elements[m].value;
        		if (!valida_contenido(cadena,v)){
		        	alert("Please, write down a valid quantity for the product Num."+j);
					res=false;
			        return (false)
				}
	       }
		   if (res=true)
		   {
		   cnt=carrito.elements[m].value;
		   ms=carrito.elements[m+1].value;
		   cex=carrito.elements[m+2].value;
		   //alert("ms: "+ms);
		   //alert ("valor de res "+res);
		   if (ms != 0) {
			   resto=cnt%ms;		   
			   if (resto != 0) {
			   alert ('Wrong quantity for the product '+j+'. Please insert a value multiple of  '+ms);
			   carrito.elements[m+1].value=ms;
			   if (carrito.elements[m+1].disabled==true)
			   	carrito.elements[m+1].focus();
			   else
			   	carrito.elements[m].focus();
			   res=false;
    	   	   //return (false)
			   }
		   }
		   var pie=cnt-cex;
		   
		   //alert ("Cantidad del producto: "+cnt);
   		   //alert("cantidad en existencia: "+cex);
		   //alert ("resta: "+pie);
		   if (pie > 0) {
			   alert ('Wrong quantity for the product '+j+'. The quantity will be readjusted to the available quantity that is : '+cex);
    		   carrito.elements[m].value=cex;
			   carrito.elements[m].focus();
			   res=false;
    	   	   return (false)
		   }
		   }
		   //n++;
 }
 if (action == 4 && res== true) {
	 if (document.carrito.importe.value) {
	  var dato=document.carrito.importe.value.substr(1);
		if (dato < 40) {
	     
		 alert ("It is not possible to confirm your order. The minimum amount to consider an order valid should be from $40.00 USD on. You have bought products only for $"+dato+" USD.");
		 res=false;
		 return (false);
		 //window.location="cesta.php?<?=$sid?>&acc=1&idproducto=0&cantidad=0&nombre=''&precio=0&ms=0&cant_existencia=0";
		 //return (false)
		} else {
		  res=true;
		  return (true);
		  //window.location="confped.php";
		  //return (true)
		  }
	 }
 }
 return (res);
}	  


function esDigito(sChr){
var sCod = sChr.charCodeAt(0);
return ((sCod > 47) && (sCod < 58));
}

function valSep(oTxt){
var bOk = false;
bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));
bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
return bOk;
}

function finMesdt(oTxt){
var nMes = parseInt(oTxt.value.substr(5, 2), 10);
var nRes = 0;
switch (nMes){
case 1: nRes = 31; break;
case 2: nRes = 29; break;
case 3: nRes = 31; break;
case 4: nRes = 30; break;
case 5: nRes = 31; break;
case 6: nRes = 30; break;
case 7: nRes = 31; break;
case 8: nRes = 31; break;
case 9: nRes = 30; break;
case 10: nRes = 31; break;
case 11: nRes = 30; break;
case 12: nRes = 31; break;
}
return nRes;
}


function finMes(oTxt){
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
var nRes = 0;
switch (nMes){
case 1: nRes = 31; break;
case 2: nRes = 29; break;
case 3: nRes = 31; break;
case 4: nRes = 30; break;
case 5: nRes = 31; break;
case 6: nRes = 30; break;
case 7: nRes = 31; break;
case 8: nRes = 31; break;
case 9: nRes = 30; break;
case 10: nRes = 31; break;
case 11: nRes = 30; break;
case 12: nRes = 31; break;
}
return nRes;
}

function valDia(oTxt){
var bOk = false;
var nDia = parseInt(oTxt.value.substr(0, 2), 10);
bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
return bOk;
}

function valMes(oTxt){
var bOk = false;
var nMes = parseInt(oTxt.value.substr(3, 2), 10);

bOk = bOk || ((nMes >= 1) && (nMes <= 12));
return bOk;
}

function valAno(oTxt){
var bOk = true;

var nAno =  oTxt.value.substr(6,4);

bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
return bOk;
}



function valAnodt(oTxt){
var bOk = true;
var nAno = oTxt.value.substr(0,4);
bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
return bOk;
}

function valDiadt(oTxt){
var bOk = false;
var nDia = parseInt(oTxt.value.substr(8, 2), 10);
bOk = bOk || ((nDia >= 1) && (nDia <= finMesdt(oTxt)));
return bOk;
}

function valMesdt(oTxt){
var bOk = false;
var nMes = parseInt(oTxt.value.substr(5, 2), 10);
bOk = bOk || ((nMes >= 1) && (nMes <= 12));
return bOk;
}

function valSepdt(oTxt){
var bOk = false;
bOk = bOk || ((oTxt.value.charAt(4) == "-") && (oTxt.value.charAt(7) == "-"));
bOk = bOk || ((oTxt.value.charAt(4) == "/") && (oTxt.value.charAt(7) == "/"));
return bOk;
}

function getmesi(fecha){

  var mes = fecha.getMonth();
  switch(mes){

   case 0: return "January";

   case 1: return "February";

   case 2: return "March";

   case 3: return "April";

   case 4: return "May";

   case 5: return "June"; 

   case 6: return "July";

   case 7: return "August";

   case 8: return "September";

   case 9: return "October";

   case 10: return "November";

   case 11: return "December";
  }  
 }

function getmesin(fecha){
var mes=fecha-1;
  switch(mes){

   case 0: return "January";

   case 1: return "February";

   case 2: return "March";

   case 3: return "April";

   case 4: return "May";

   case 5: return "June"; 

   case 6: return "July";

   case 7: return "August";

   case 8: return "September";

   case 9: return "October";

   case 10: return "November";

   case 11: return "December";
  }  
 }
 
function Delta(oTxt)
{
var bOk = true;
var nDia = parseInt(oTxt.value.substr(0, 2), 10);
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
var nAno = oTxt.value.substr(6);
if (nAno.length == 2)
	nAno="20"+nAno;	//eval("this."+id+".style.display='';");
//alert(nAno);
//alert(nMes);
var cMes=getmesin(nMes);
//alert(cMes);
var fechaentrega=cMes+" "+nDia+", "+nAno;
//alert("fechaentrega: "+fechaentrega);
fechaentrega= new Date(freservaano, freservames-1, freservadia);
//alert(fechaentrega);
today= new Date();
var nDelta=((fechaentrega.getTime()-today.getTime())/1000/60/60/24);
//var cDia=getdiasemana(today);
var cDia=today.getDay();
//alert("cDia: "+cDia);
//alert("nDelta: "+Math.round(nDelta));
switch(cDia){
   case 0: if (Math.round(nDelta) < 12)	bOk = false; //domingo para los 5 dias 5

   case 1: if (Math.round(nDelta) < 12)	bOk = false; // Lunes; para los 5 dias 7

   case 2: if (Math.round(nDelta) < 14)	bOk = false; //Martes; para los 5 dias 7

   case 3: if (Math.round(nDelta) < 14)	bOk = false; //Miércoles; para los 5 dias 7

   case 4: if (Math.round(nDelta) < 14)	bOk = false; //Jueves; para los 5 dias 7

   case 5: if (Math.round(nDelta) < 14)	bOk = false; //Viernes; para los 5 dias 7

   case 6: if (Math.round(nDelta) < 14)	bOk = false; //Sábado; para los 5 dias 6

  }
//alert(bOk);
return bOk;
}

function CheckFecha(oTxt)
{
	var bOk = true;
	if (oTxt.value != "")
	{
		bOk = bOk && (valAno(oTxt));
		bOk = bOk && (valMes(oTxt));
		bOk = bOk && (valDia(oTxt));
		bOk = bOk && (valSep(oTxt));
	}
	else
		{
		//alert("esta vacio");
		bOk = false;
		}
return bOk;
}


function valFecha(oTxt)
{
	var bOk = true;
	if (oTxt.value != "")
	{
		bOk = bOk && (valAno(oTxt));
		bOk = bOk && (valMes(oTxt));
		bOk = bOk && (valDia(oTxt));
		bOk = bOk && (valSep(oTxt));
		if (!bOk)
		{
			alert("Fecha inválida.");
			oTxt.value = "";
			oTxt.focus();
		}
		else
			{
			bOk = bOk && Delta(oTxt);
			if (!bOk){
				alert("Fecha de entrega no válida. La solicitud debe hacerse con al menos 10 días hábiles de antelación a la fecha de entrega.");
				oTxt.value = "";
				oTxt.focus();
				}
			else
				bOk = true;
			}
	}
	else
		{
		//alert("esta vacio");
		bOk = false;
		oTxt.value = "";
		oTxt.focus();
		}
return bOk;
}

function validaFecha(oTxt)
{
	var bOk = true;
	if (oTxt.value != "")
	{
		bOk = bOk && (valAnodt(oTxt));
		bOk = bOk && (valMesdt(oTxt));
		bOk = bOk && (valDiadt(oTxt));
		bOk = bOk && (valSepdt(oTxt));
	}
	else
	{
		//alert("esta vacio");
		bOk = false;
	}
	return bOk;
}

function valHora(oTxt){
var bOk = false;
var nHora = parseInt(oTxt.value.substr(0, 2), 10);
bOk = bOk || ((nHora >= 1) && (nHora <= 12));
return bOk;
}

function valMinutos(oTxt){
var bOk = false;
var nMinutos = parseInt(oTxt.value.substr(3, 2), 10);
bOk = bOk || ((nMinutos >= 0) && (nMinutos <= 59));
return bOk;
}

function valPunto(oTxt){
var bOk = false;
bOk = bOk || (oTxt.value.charAt(2) == ":");
return bOk;
}

function valHorario(oTxt)
{
	var bOk = true;
	if (oTxt.value != "")
	{
		bOk = bOk && (valHora(oTxt));
		bOk = bOk && (valPunto(oTxt));
		bOk = bOk && (valMinutos(oTxt));
		if (!bOk)
		{
			alert("Hora inválida");
			oTxt.value = "";
			oTxt.focus();
		}
	}
}

function valida_busca(buscador)
{
	//alert(document.buscador.busca.value);
	if (document.buscador.busca.value=="")
		return (false);
	else	
		return (true);
}


function DiffDays(S2, S1) {
	alert("entre diff");
 var X = ReadISO8601date(S2) ; if (X<0) return "Date 1 bad"
 var Y = ReadISO8601date(S1) ; if (Y<0) return "Date 2 bad"
 var Z =(Date.UTC(X[0], X[1]-1, X[2])-Date.UTC(Y[0], Y[1]-1, Y[2]))/86400000
 alert("Z="+Z);
 return (Date.UTC(X[0], X[1]-1, X[2])-Date.UTC(Y[0], Y[1]-1, Y[2]))/86400000
 }

function valida_bava(buscava)
{
	if (document.buscava.valor1.value=="" && document.buscava.valor2.value=="" && document.buscava.valor3.value=="" && document.buscava.lbprecio1.selectedIndex==0 && document.buscava.lbprecio2.selectedIndex==0) 
		return (false);
	else	
		return (true);
}
 function Actualiza1()
 {
  	if (document.cestac.numitem.value!=0)
	{
	document.cestac.action="cesta.php";
	document.cestac.submit();
	}
	else
 		 alert ("No es posible editar su pedido. Usted no ha comprado ningún producto.");
 }

function Actualiza1i()
 {
	if (document.cestac.numitem.value!=0)
	{
	document.cestac.action="cesta.php";
	document.cestac.submit();
	}
	else
 		 alert ("It is not possible to edit the order. You have not bought any product.");

 }
 
 function Actualiza2()
 {
	if (document.cestac.numitem.value==0)
 		 alert ("No es posible confirmar su pedido. Usted no ha seleccionado ningún producto.");

	else if (document.cestac.mensajetexto.value=="")
	{

	document.cestac.action='confped.php';
	document.cestac.submit();
	}
	else {
		 //alert ("No es posible confirmar su pedido, el importe mínimo para considerar un pedido válido debe ser de 40.00 USD o superior, usted solo ha comprado productos por un valor de $"+document.cestac.total.value+" USD.");
		 tx=document.cestac.mensajetexto.value;
		 tx=tx.replace("<br>","\n") ;
	 	alert(tx);
	}


 }
 
  function Actualiza2i()
 {
	if (document.cestac.numitem.value==0)
 		 alert ("It is not possible to pay the order. You have not bought any product.");

	else if (document.cestac.total.value >=40)
	{

	document.cestac.action='confped.php';
	document.cestac.submit();
	}
	else
		 alert ("It is not possible to confirm the order. The minimum amount to consider an order valid should be from $40.00 USD on. You have bought products only for $"+document.cestac.total.value+" USD.");

 }

function MuestraFormulario(sLayer)
{
	oDhtml=lNetScape6Used? document.getElementById(sLayer) : eval("document.all." + sLayer);
	if (lExplorerUsed||lNetScape6Used)
	{
			oDhtml.style.top=document.body.scrollTop;
			oDhtml.style.visibility="visible";
	}
	else if (lNetScape4Used)
		{
			eval("document." + sElementID + ".top=document.body.scrollTop;");
			eval("document." + sElementID + ".visibility=visible;");
		}

}

function Oculta(sLayer)
{
	oDhtml=lNetScape6Used? document.getElementById(sLayer) : eval("document.all." + sLayer);
	if (lExplorerUsed||lNetScape6Used)
	{
			oDhtml.style.top=document.body.scrollTop;
			oDhtml.style.visibility="hidden";
	}
	else if (lNetScape4Used)
		{
			eval("document." + sElementID + ".top=document.body.scrollTop;");
			eval("document." + sElementID + ".visibility=hide;");
		}

}

function OcultaFormulario()
{
	if (lExplorerUsed||lNetScape6Used)
			oDhtml.style.visibility="hidden";
	else if (lNetScape4Used)
			eval("document.AddPricePerProvinceLayer.visibility= hide;");
}

function IsAlphaNum( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
	  {	
		return false;
      }
	var isValid = true;
	
	// convert to a string for performing string comparisons.
   	str += "";	

	// Loop through length of string and test for any alpha numeric 
	// characters
   	for (i = 0; i < str.length; i++)
   	{
			// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
      	if (!(((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
      			((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
      			((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ||
				(str.charAt(i) == "-") || (str.charAt(i) == "_") || 
				(str.charAt(i) == "/") || (str.charAt(i) == " ") || (str.charAt(i) == "á")
				|| (str.charAt(i) == "é") || (str.charAt(i) == "í")|| (str.charAt(i) == "ú")
				|| (str.charAt(i) == "ó") || (str.charAt(i) == ".")
				|| (str.charAt(i) == "Á") || (str.charAt(i) == "É")
				|| (str.charAt(i) == "Í") || (str.charAt(i) == "Ó") || (str.charAt(i) == "Ú")
				|| (str.charAt(i) == "ñ") || (str.charAt(i) == "Ñ")))
			{
				isValid = false;
				break;
			}	
   	} // END for   
   	return isValid;
}  // end IsAlphaNum

function IsAlphaNum1( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
	  {	
		return false;
      }
	else return true;  

}  // end IsAlphaNum

function IsAlphaNum2( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
	  {	
		return false;
      }
	var isValid = true;
	
	// convert to a string for performing string comparisons.
   	str += "";	

	// Loop through length of string and test for any alpha numeric 
	// characters
   	for (i = 0; i < str.length; i++)
   	{
			// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
		if (str.charAt(i) == "&") alert("pase");
      	if (!(((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
      			((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
      			((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ||
				(str.charAt(i) == "-") || (str.charAt(i) == "_") || 
				(str.charAt(i) == "/") || (str.charAt(i) == " ") || (str.charAt(i) == "á")
				|| (str.charAt(i) == "é") || (str.charAt(i) == "í")|| (str.charAt(i) == "ú")
				|| (str.charAt(i) == "ó") || (str.charAt(i) == ".")
				|| (str.charAt(i) == "Á") || (str.charAt(i) == "É")
				|| (str.charAt(i) == "Í") || (str.charAt(i) == "Ó") || (str.charAt(i) == "Ú")|| (str.charAt(i) == "")
				|| (str.charAt(i) == "<") || (str.charAt(i) == ">") || (str.charAt(i) == ";")
				|| (str.charAt(i) == "ñ") || (str.charAt(i) == "Ñ")))
			{
				isValid = false;
				break;
			}	
   	} // END for   
   	return isValid;
}  // end IsAlphaNum

function IsNum( numstr ) {
	// Return immediately if an invalid value was passed in
	if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "")	
		return false;

	var isValid = true;
	var decCount = 0;		// number of decimal points in the string

	// convert to a string for performing string comparisons.
	numstr += "";	

	// Loop through string and test each character. If any
	// character is not a number, return a false result.
 	// Include special cases for negative numbers (first char == '-')
	// and a single decimal point (any one char in string == '.').   
	for (i = 0; i < numstr.length; i++) {
		// track number of decimal points
		if (numstr.charAt(i) == ".")
			decCount++;

    	if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || 
				(numstr.charAt(i) == "-") || (numstr.charAt(i) == "."))) {
       	isValid = false;
       	break;
		} else if ((numstr.charAt(i) == "-" && i != 0) ||
				(numstr.charAt(i) == "." && numstr.length == 1) ||
			  (numstr.charAt(i) == "." && decCount > 1)) {
       	isValid = false;
       	break;
      }         	         	       
//if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9")) || 
   } // END for   
   
   	return isValid;
}  // end IsNum

function limpiacaja() {
	document.buscador.busca.value=" ";
}


function openWindow(url)
{
	ancho=(screen.width)-200;
	alto=(screen.height)-300;
	window.open(url,'','width='+ancho+', height='+alto+', left='+((screen.width - ancho)/2)+', top='+(((screen.height - alto)/2)+90)+', menubar,resizable,toolbar,titlebar,status,directories,location,scrollbars=yes');
}
// -->