function recuperarClave(base) {
	window.open(base+"/forgotPassword.aspx", "myWindow", "status = 1, height = 163, width = 372, resizable = 0" );
}

function error_alert(errorcode){
	switch(errorcode){
			case 1:
				alert('Usuario o contrasena incorrectos');
			break;
			case 2:
				alert('Hubo un error en la votación. Inténtelo en unos minutos');
			break;
			case 3:
				alert('En este momento no se pueden realizar compras en el portal. Contáctenos para más información.');
			break;
			case 4:
				alert('Se produjo un error en el proceso de pago. Contáctenos para más información.');
			break;
			case 5:
				alert('El producto seleccionado no posee el stock suficiente.');
			break;
			case 6:
				alert('El nombre de usuario ya existe');
			break;
			case 7:
				alert('Hubo un error al intentar actualizar sus datos');
			break;
			case 8:
				alert('Error en el costo de envío');
			break;
			case 9:
				alert('El registro ha sido removido o se encuentra deshabilitado');
			break;
			case 10:
				alert('Su cuenta ha sido desactivada. Contáctenos para más información.');
			break;
			case 666:
				alert('Se ha producido un error');
			break;
	}
	if(errorcode>0){
	document.location.reload();
	}
}

var consultaMode=0;
function showConsulta(){
	var formulario_consulta = document.getElementById('contact_form');
	if(consultaMode==0){
		formulario_consulta.style.display="inline";
		consultaMode=1;
	}else{
		formulario_consulta.style.display="none";
		consultaMode=0;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_setTextOfTextfield(formulario,objId,x,newText,checkText) { //v9.0
  with (document){
	if(getElementById){
		  var obj = document.forms[formulario][objId];
	}
	if(obj && obj.value==checkText){
		obj.value = newText;
	}
  }
}

function desplegar(cual){
	  with (document){
		if(getElementById){	
			//alert(categoriaexpand + " - " + cual);
			if((categoriaexpand!=0 && categoriaexpand!=cual) || categoriaexpand==0){
				var obj2 = getElementById('boton_1_hijos_'+categoriaexpand);
				if(obj2){
					obj2.className = "boton_1_hijos";
				}
				var obj = getElementById('boton_1_hijos_'+cual);
				if(obj){
					obj.className = "boton_1_hijos_on";
					categoriaexpand=cual;
				}
			}else if(categoriaexpand==cual){
				var obj = getElementById('boton_1_hijos_'+cual);
				if(obj){
					obj.className = "boton_1_hijos";
					categoriaexpand=0;
				}	
			}			
		}
	  }
}
function __setKw(){
	document.getElementById('Keywords').value = document.getElementById('Name').value;
}
function setCategoria(valor,nombre){
	document.getElementById('textsearch').innerHTML = nombre;
	document.getElementById('nav').style.display = "none";
	document.getElementById('Id').value = valor;
	setTimeout( function(){	document.getElementById('nav').style.display = "inline";},2);
	//document.buscador.Name.focus();
}
function setHidden(campo,valor,lista,nombre){
	document.getElementById('nav'+lista).style.display = "none";
	document.getElementById(campo).value = valor;
	document.getElementById('textsearch_'+lista).innerHTML = "<font color='#000000'><b>"+nombre+"</b></font>";
	setTimeout( function(){	document.getElementById('nav'+lista).style.display = "inline";},2);
}

function inspector(el) {
var str ="";
for (var i in el){
	str+= i + ": " + el.getAttribute(i) + "<br>";
}
document.write(str);
}

function qty_add(sumar,minStock,stock){
	var cantidad_form = document.getElementById('Quantity');
	var cantidad = parseInt(cantidad_form.value);
	if(sumar > 0){
		if(stock > cantidad){
			cantidad_form.value=cantidad+1;
		}		
	}else{
		if(cantidad > minStock && cantidad > 1){
			cantidad_form.value=cantidad-1;
		}
	}	
}


function MM_validateFormSuscribe() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormSuscribe.arguments;
    for (i=0; i<(args.length-2); i+=3){
		test=args[i+2];
		val=document.forms['susc'].elements[(args[i])];	
		if(val.value=="nombre y apellido" || val.value=="email"){			
			valor="";			
		}else{
			valor=val.value;	
		}
		if (val){
			nm=val.name;
			if(nm=="customerName"){			
				nm="nombre y apellido";	
			}
			if(nm=="customerEmail"){			
				nm="email";	
			}
			if((val=valor)!=""){
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+val+' no es un email válido.\n';
				}else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			}else if(test.charAt(0) == 'R')errors += '- '+nm+' debe estar completo.\n';
		}
    }
	if (errors) alert('Error al enviar el formulario:\n'+errors);
    document.MM_returnValue = (errors == '');
} }



function MM_validateFormContact() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormContact.arguments;
    for (i=0; i<(args.length-2); i+=3){
		test=args[i+2];
		val=document.forms['consulta'].elements[(args[i])];	
		if(val.value=="nombre y apellido" || val.value=="email"){			
			valor="";			
		}else{
			valor=val.value;	
		}
		if (val){
			nm=val.name;
			if(nm=="txtFirstName"){			
				nm="nombre y apellido";	
			}
			if(nm=="txtEmail"){			
				nm="email";	
			}
			if(nm=="Comentario"){			
				nm="consulta";	
			}
			if((val=valor)!=""){
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+val+' no es un email válido.\n';
				}else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			}else if(test.charAt(0) == 'R')errors += '- '+nm+' debe estar completo.\n';
		}
    }
	if (errors) alert('Error al enviar el formulario:\n'+errors);
    document.MM_returnValue = (errors == '');
} }


function MM_validateFormComment() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormComment.arguments;
    for (i=0; i<(args.length-2); i+=3){
		test=args[i+2];
		val=document.forms['myform'].elements[(args[i])];	
		if(val.value=="nombre y apellido" || val.value=="email"){			
			valor="";			
		}else{
			valor=val.value;	
		}
		if (val){
			nm=val.name;
			if(nm=="postName"){			
				nm="nombre";	
			}
			if(nm=="postMail"){			
				nm="email";	
			}
			if(nm=="postText"){			
				nm="comentario";	
			}
			if((val=valor)!=""){
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+val+' no es un email válido.\n';
				}else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':');
						min=test.substring(8,p);
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				}
			}else if(test.charAt(0) == 'R')errors += '- '+nm+' debe estar completo.\n';
		}
    }
	if (errors) alert('Error al enviar el formulario:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

