function setLocation(url){
    window.location.href = url;
}

function expand_nav(link)
{
	var ul = find_enclosing_ul(link)
	if (ul.style.display == 'none')
	{
		ul.style.display = 'block'
	}
	else
	{
		ul.style.display = 'none'
	}
	if (link.className == 'down')
	{
		link.className='down_open'
	}
	else
	{
		link.className='down'
	}
}
		
function find_enclosing_ul(link)
{
	var search_node = link
	while (true)
	{
		var node = search_node.nextSibling
		if (node && node.nodeName == 'UL')
		{
			break
		}
		else
		{
			search_node = node
		}
	}
	return node	
}

function validaRUC(campo) {          
   
      numero = campo;
	  /* alert(numero); */

      var suma = 0;      
      var residuo = 0;      
      var pri = false;      
      var pub = false;            
      var nat = false;      
      var numeroProvincias = 22;                  
      var modulo = 11;
                  
      /* Verifico que el campo no contenga letras */                  
      var ok=1;
      for (i=0; i<numero.length && ok==1 ; i++){
         var n = parseInt(numero.charAt(i));
         if (isNaN(n)) ok=0;
      }
      if (ok==0){
         return false;
      }
                  
      if (numero.length < 10 ){              
         return false;
      }
     
      /* Los primeros dos digitos corresponden al codigo de la provincia */
      provincia = numero.substr(0,2);      
      if (provincia < 1 || provincia > numeroProvincias){           
		 return false;       
      }

      /* Aqui almacenamos los digitos de la cedula en variables. */
      d1  = numero.substr(0,1);         
      d2  = numero.substr(1,1);         
      d3  = numero.substr(2,1);         
      d4  = numero.substr(3,1);         
      d5  = numero.substr(4,1);         
      d6  = numero.substr(5,1);         
      d7  = numero.substr(6,1);         
      d8  = numero.substr(7,1);         
      d9  = numero.substr(8,1);         
      d10 = numero.substr(9,1);                
         
      /* El tercer digito es: */                           
      /* 9 para sociedades privadas y extranjeros   */         
      /* 6 para sociedades publicas */         
      /* menor que 6 (0,1,2,3,4,5) para personas naturales */ 

      if (d3==7 || d3==8){           
         return false;
      }         
         
      /* Solo para personas naturales (modulo 10) */         
      if (d3 < 6){           
         nat = true;            
         p1 = d1 * 2;  if (p1 >= 10) p1 -= 9;
         p2 = d2 * 1;  if (p2 >= 10) p2 -= 9;
         p3 = d3 * 2;  if (p3 >= 10) p3 -= 9;
         p4 = d4 * 1;  if (p4 >= 10) p4 -= 9;
         p5 = d5 * 2;  if (p5 >= 10) p5 -= 9;
         p6 = d6 * 1;  if (p6 >= 10) p6 -= 9; 
         p7 = d7 * 2;  if (p7 >= 10) p7 -= 9;
         p8 = d8 * 1;  if (p8 >= 10) p8 -= 9;
         p9 = d9 * 2;  if (p9 >= 10) p9 -= 9;             
         modulo = 10;
      }         

      /* Solo para sociedades publicas (modulo 11) */                  
      /* Aqui el digito verficador esta en la posicion 9, en las otras 2 en la pos. 10 */
      else if(d3 == 6){           
         pub = true;             
         p1 = d1 * 3;
         p2 = d2 * 2;
         p3 = d3 * 7;
         p4 = d4 * 6;
         p5 = d5 * 5;
         p6 = d6 * 4;
         p7 = d7 * 3;
         p8 = d8 * 2;            
         p9 = 0;            
      }         
         
      /* Solo para entidades privadas (modulo 11) */         
      else if(d3 == 9) {           
         pri = true;                                   
         p1 = d1 * 4;
         p2 = d2 * 3;
         p3 = d3 * 2;
         p4 = d4 * 7;
         p5 = d5 * 6;
         p6 = d6 * 5;
         p7 = d7 * 4;
         p8 = d8 * 3;
         p9 = d9 * 2;            
      }
                
      suma = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;                
      residuo = suma % modulo;                                         

      /* Si residuo=0, dig.ver.=0, caso contrario 10 - residuo*/
      digitoVerificador = residuo==0 ? 0: modulo - residuo;                

      /* ahora comparamos el elemento de la posicion 10 con el dig. ver.*/                         
      if (pub==true){           
         if (digitoVerificador != d9){                          
            return false;
         }                  
         /* El ruc de las empresas del sector publico terminan con 0001*/         
         if ( numero.substr(9,4) != '0001' ){                    
            return false;
         }
      }         
      else if(pri == true){         
         if (digitoVerificador != d10){                          
            return false;
         }         
         if ( numero.substr(10,3) != '001' ){                    
            return false;
         }
      }      

      else if(nat == true){         
         if (digitoVerificador != d10){                          
            return false;
         }         
         if (numero.length >10 && numero.substr(10,3) != '001' ){                    
            return false;
         }
      }      
      return true;   
   }

var confirmMsg  = 'Realmente desea';

function confirmLink(theLink, theSqlQuery)
{
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg + ':\n\n' + theSqlQuery);
    if (is_confirmed) {
        if ( typeof(theLink.href) != 'undefined' ) {
            theLink.href += '&is_js_confirmed=1';
        } else if ( typeof(theLink.form) != 'undefined' ) {
            theLink.form.action += '?is_js_confirmed=1';
        }
    }

    return is_confirmed;
}

function validarEmail(email)
{
	var d;
  	d  = email.indexOf("@"), 
	d2 = email.lastIndexOf(".");
  	if((d<=0)||(email.indexOf(" ")!=-1)||(d>=email.length-1)||(d2<=d)||(d2>=email.length-1))
  	{
    	return false;
  	}
  	return true;
}

function valida_ingreso_general(){
	var theForm = document.form_entrar;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['contrasenia'].value == "" || theForm['contrasenia'].value == "Contraseña"){
		errMsg = "Contraseña es un campo obligatotio";
		theForm['contrasenia'].className='text_rojo';
		setfocus = "['contrasenia']";
	}

	if (!validarEmail(theForm['email'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['email'].className='text_rojo';
		setfocus = "['email']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['entrar'].disabled = true;
		theForm['entrar'].value = "PROCESANDO...";
		theForm.submit();
	}
}

function valida_busca_palabra(){
	var theForm = document.form_palabra;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['Palabra'].value == "" || theForm['Palabra'].value == "Buscar Productos..."){
		errMsg = "Debe ingresar una Palabra a Buscar\n\nPuede escribir:\nCódigos de Productos SAZ, # de Parte de Productos,\nNombres de Categorías, Nombres de SubCategorías, Nombres de Marcas o cualquier Palabra";
		setfocus = "['Palabra']";
	}

	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm.submit();
	}
}

function valida_ingreso(){
	var theForm = document.form_crea_cuenta;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]{2,3}-? ?[0-9]{6,7}$/;
	var telfRE1 = /^[0-9]+$/;
	var telfRE2 = /^[0-9]*$/;
	var conRE = /^(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$/;
	var errMsg = "";
	var setfocus = "";
	
	if (!theForm['Acepta'].checked){
		errMsg = "Debe aceptar los Términos de Uso del Sitio";
	}
	
	if (theForm['captchacode'].value == ""){
		errMsg = "Caracteres es un campo obligatotio";
		theForm['captchacode'].className='text_rojo';
		setfocus = "['captchacode']";
	}

	if (!conRE.test(theForm['CPassword'].value)){
		errMsg = "Repita su Contraseña es un campo obligatotio";
		theForm['CPassword'].className='text_rojo';
		setfocus = "['CPassword']";
	}
	
	if (!conRE.test(theForm['Password2'].value)){
		errMsg = "Contraseña es un campo obligatotio\n y debe cumplir con la forma del ejemplo";
		theForm['Password2'].className='text_rojo';
		setfocus = "['Password2']";
	}
	
	if (!telfRE2.test(theForm['Fax'].value)){
		errMsg = "Fax sólo permite ingreso de números";
		setfocus = "['Fax']";
	}
	
	if (!telfRE2.test(theForm['Telefono2'].value)){
		errMsg = "Celular sólo permite ingreso de números";
		setfocus = "['Telefono2']";
	}
	
	if (!telfRE1.test(theForm['Telefono1'].value)){
		errMsg = "Teléfono es un campo obligatorio y sólo permite ingreso de números";
		theForm['Telefono1'].className='text_rojo';
		setfocus = "['Telefono1']";
	}
	
	if (theForm['Direccion'].value == ""){
		errMsg = "Dirección es un campo obligatotio";
		theForm['Direccion'].className='text_rojo';
		setfocus = "['Direccion']";
	}
	
	if (theForm['Sector'].value == ""){
		errMsg = "Sector es un campo obligatotio";
		theForm['Sector'].className='text_rojo';
		setfocus = "['Sector']";
	}
	
	if (theForm['Ciudad'].value == ""){
		errMsg = "Ciudad es un campo obligatotio";
		theForm['Ciudad'].className='text_rojo';
		setfocus = "['Ciudad']";
	}
	
	if (theForm['Provincia'].value == ""){
		errMsg = "Provincia es un campo obligatotio";
		theForm['Provincia'].className='text_rojo';
		setfocus = "['Provincia']";
	}
		
	if (!validarEmail(theForm['E-Mail'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['E-Mail'].className='text_rojo';
		setfocus = "['E-Mail']";
	}
	
	if (theForm['Apellido'].value == ""){
		errMsg = "Apellido es un campo obligatotio";
		theForm['Apellido'].className='text_rojo';
		setfocus = "['Apellido']";
	}
	
	if (theForm['Nombre'].value == ""){
		errMsg = "Nombre es un campo obligatotio";
		theForm['Nombre'].className='text_rojo';
		setfocus = "['Nombre']";
	}
	
	if (!validaRUC(theForm['RUC'].value)){
		errMsg = "Debe ingresar un RUC o No. de Cédula válido (sólo números)";
		theForm['RUC'].className='text_rojo';
		setfocus = "['RUC']";
	}
	
	if (theForm['Password2'].value != theForm['CPassword'].value){
		errMsg = "Contraseña y Repita su Contraseña No Coinciden";
		setfocus = "['Password2']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['Enviar'].disabled = true;
		theForm['Enviar'].value = "PROCESANDO...";
		theForm.submit();
	}
}

function recuerda_contrasenia(){
	var theForm = document.form_recuerda;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var errMsg = "";
	var setfocus = "";
	
	if (!validarEmail(theForm['E-Mail'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['E-Mail'].className='text_rojo';
		setfocus = "['E-Mail']";
	}

	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['consultar'].disabled = true;
		theForm['consultar'].value = "PROCESANDO...";
		theForm.submit();
	}
}

function valida_ingresar(){
	var theForm = document.form_login;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['contrasenia1'].value == ""){
		errMsg = "Contraseña es un campo obligatotio";
		theForm['contrasenia1'].className='text_rojo';
		setfocus = "['contrasenia1']";
	}

	if (!validarEmail(theForm['email2'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['email2'].className='text_rojo';
		setfocus = "['email2']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['ingresar1'].disabled = true;
		theForm['ingresar1'].value = "VERIFICANDO...";
		theForm.submit();
	}
}

function valida_ingresar_arriba(){
	var theForm = document.form_login_arriba;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['contrasenia'].value == ""){
		errMsg = "Contraseña es un campo obligatotio";
		theForm['contrasenia'].className='fieldrojo';
		setfocus = "['contrasenia']";
	}

	if (!validarEmail(theForm['email'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['email'].className='fieldrojo';
		setfocus = "['email']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['ingresar'].disabled = true;
		theForm['ingresar'].value = "VERIFICANDO...";
		theForm.submit();
	}
}

function valida_contacto(){
	var theForm = document.form_contactos;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]{2,3}-? ?[0-9]{6,7}$/;
	var telfRE1 = /^[0-9]+$/;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['Mensaje'].value == ""){
		errMsg = "Mensaje es un campo obligatotio";
		theForm['Mensaje'].className='text_rojo';
		setfocus = "['Mensaje']";
	}
		
	if (!validarEmail(theForm['E-Mail'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['E-Mail'].className='text_rojo';
		setfocus = "['E-Mail']";
	}
	
	if (!telfRE1.test(theForm['Telefono'].value)){
		errMsg = "Teléfono es un campo obligatotio y solo permite ingreso de números";
		theForm['Telefono'].className='text_rojo';
		setfocus = "['Telefono']";
	}
	
	if (theForm['Nombres'].value == ""){
		errMsg = "Nombres es un campo obligatotio";
		theForm['Nombres'].className='text_rojo';
		setfocus = "['Nombres']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['Enviar'].disabled = true;
		theForm['Enviar'].value = "PROCESANDO...";
		theForm.submit();
	}
}

function valida_ingreso_hoja(){
	var theForm = document.form_trabaja;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]{2,3}-? ?[0-9]{6,7}$/;
	var telfRE1 = /^[0-9]{9}$/;
	var telfRE2 = /^[0-9]{2}$/;
	var telfRE3 = /^[0-9]{3,4}$/;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['hojavida'].value == ""){
		errMsg = "Ingrese su Hoja de Vida en Archivo de Word (.doc) y el nombre del archivo será hojadevida_numerocedula.doc,\nejem: hojadevia_0401373674.doc";
		theForm['hojavida'].className='text_rojo';
		setfocus = "['hojavida']";
	}
	
	if (!telfRE3.test(theForm['salario'].value)){
		errMsg = "Aspiración Salarial es un campo obligatotio y solo permite ingreso de números\nDebe contener máximo 4 dígitos";
		theForm['salario'].className='text_rojo';
		setfocus = "['salario']";
	}
	
	if (theForm['areaaplica'].value == ""){
		errMsg = "Área a la que aplica es un campo obligatotio";
		theForm['areaaplica'].className='text_rojo';
		setfocus = "['areaaplica']";
	}
	
	if (theForm['anios'].value == ""){
		errMsg = "Años de Experiencia es un campo obligatotio";
		theForm['anios'].className='text_rojo';
		setfocus = "['anios']";
	}
	
	if (theForm['area'].value == ""){
		errMsg = "Area de Estudio es un campo obligatotio";
		theForm['area'].className='text_rojo';
		setfocus = "['area']";
	}
	
	if (theForm['nivel'].value == ""){
		errMsg = "Nivel Educativo es un campo obligatotio";
		theForm['nivel'].className='text_rojo';
		setfocus = "['nivel']";
	}
	
	if (!validarEmail(theForm['email1'].value)){
		errMsg = "Ingrese un E-Mail Válido, campo obligatorio";
		theForm['email1'].className='text_rojo';
		setfocus = "['email1']";
	}
	
	if (!telfRE1.test(theForm['celular'].value)){
		errMsg = "Celular es un campo obligatotio y solo permite ingreso de números\nDebe contener 9 dígitos";
		theForm['celular'].className='text_rojo';
		setfocus = "['celular']";
	}
	
	if (!telfRE1.test(theForm['telefono'].value)){
		errMsg = "Teléfono es un campo obligatotio y solo permite ingreso de números\nDebe contener 9 dígitos";
		theForm['telefono'].className='text_rojo';
		setfocus = "['telefono']";
	}
	
	if (theForm['sector'].value == ""){
		errMsg = "Sector es un campo obligatotio";
		theForm['sector'].className='text_rojo';
		setfocus = "['sector']";
	}
	
	if (theForm['direccion'].value == ""){
		errMsg = "Dirección es un campo obligatotio";
		theForm['direccion'].className='text_rojo';
		setfocus = "['direccion']";
	}
	
	if (theForm['ciudad'].value == ""){
		errMsg = "Ciudad es un campo obligatotio";
		theForm['ciudad'].className='text_rojo';
		setfocus = "['ciudad']";
	}
	
	if (theForm['provincia'].value == ""){
		errMsg = "Provincia es un campo obligatotio";
		theForm['provincia'].className='text_rojo';
		setfocus = "['provincia']";
	}
	
	if (theForm['sangre'].value == ""){
		errMsg = "Tipo de Sangre es un campo obligatotio";
		theForm['sangre'].className='text_rojo';
		setfocus = "['sangre']";
	}
	
	if (theForm['cargas'].value == ""){
		errMsg = "Cargas Familiares es un campo obligatotio";
		theForm['cargas'].className='text_rojo';
		setfocus = "['cargas']";
	}
	
	if (theForm['estadocivil'].value == ""){
		errMsg = "Estado Civil es un campo obligatotio";
		theForm['estadocivil'].className='text_rojo';
		setfocus = "['estadocivil']";
	}
	
	if (!validaRUC(theForm['cedula'].value)){
		errMsg = "Cédula es un campo obligatotio y solo permite números\nIngrese una Cédula válida";
		theForm['cedula'].className='text_rojo';
		setfocus = "['cedula']";
	}
	
	if (theForm['fecha'].value == ""){
		errMsg = "Fecha de Nacimiento es un campo obligatotio";
		theForm['fecha'].className='text_rojo';
		setfocus = "['fecha']";
	}


	if (theForm['apellidos'].value == ""){
		errMsg = "Apellidos es un campo obligatotio";
		theForm['apellidos'].className='text_rojo';
		setfocus = "['apellidos']";
	}

	if (theForm['nombres'].value == ""){
		errMsg = "Nombres es un campo obligatotio";
		theForm['nombres'].className='text_rojo';
		setfocus = "['nombres']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['enviar'].disabled = true;
		theForm['enviar'].value = "PROCESANDO...";
		theForm.submit();
	}
}

function valida_editamisdatos(){
	var theForm = document.form_misdatos;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]{2,3}-? ?[0-9]{6,7}$/;
	var telfRE1 = /^[0-9]+$/;
	var telfRE2 = /^[0-9]*$/;
	var conRE = /^(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$/;
	var errMsg = "";
	var setfocus = "";

	if (!theForm['Acepta'].checked){
		errMsg = "Debe aceptar los Términos de Uso del Sitio";
	}
	
	if (!telfRE2.test(theForm['Fax'].value)){
		errMsg = "Fax sólo permite ingreso de números";
		theForm['Fax'].className='text_rojo';
		setfocus = "['Fax']";
	}
	
	if (!telfRE2.test(theForm['Telefono2'].value)){
		errMsg = "Celular sólo permite ingreso de números";
		theForm['Telefono2'].className='text_rojo';
		setfocus = "['Telefono2']";
	}

	if (!telfRE1.test(theForm['Telefono1'].value)){
		errMsg = "Debe escribir un Telefono1 válido";
		theForm['Telefono1'].className='text_rojo';
		setfocus = "['Telefono1']";
	}
	
	if (theForm['Direccion'].value == ""){
		errMsg = "Direccion es un campo obligatotio";
		theForm['Direccion'].className='text_rojo';
		setfocus = "['Direccion']";
	}
	
	if (theForm['Sector'].value == ""){
		errMsg = "Sector es un campo obligatotio";
		theForm['Sector'].className='text_rojo';
		setfocus = "['Sector']";
	}
	
	if (theForm['Ciudad'].value == ""){
		errMsg = "Ciudad es un campo obligatotio";
		theForm['Ciudad'].className='text_rojo';
		setfocus = "['Ciudad']";
	}
	
	if (theForm['Provincia'].value == ""){
		errMsg = "Provincia es un campo obligatotio";
		theForm['Provincia'].className='text_rojo';
		setfocus = "['Provincia']";
	}
		
	if (!validarEmail(theForm['E-Mail'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['E-Mail'].className='text_rojo';
		setfocus = "['E-Mail']";
	}
	
	if (theForm['Apellido'].value == ""){
		errMsg = "Apellido es un campo obligatotio";
		theForm['Apellido'].className='text_rojo';
		setfocus = "['Apellido']";
	}
	
	if (theForm['Nombre'].value == ""){
		errMsg = "Nombre es un campo obligatotio";
		theForm['Nombre'].className='text_rojo';
		setfocus = "['Nombre']";
	}
	
	if (!validaRUC(theForm['RUC'].value)){
		errMsg = "Debe ingresar un RUC o No. de Cédula válido (sólo números)";
		theForm['RUC'].className='text_rojo';
		setfocus = "['RUC']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['Enviar'].disabled = true;
		theForm['Enviar'].value = "PROCESANDO...";
		theForm['cancelar'].disabled = true;
		theForm.submit();
	}
}

function valida_ingresocredito(){
	var theForm = document.form_misdatos;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]{2,3}-? ?[0-9]{6,7}$/;
	var telfRE1 = /^[0-9]+$/;
	var telfRE2 = /^[0-9]*$/;
	var conRE = /^(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$/;
	var errMsg = "";
	var setfocus = "";

	if (!theForm['Acepta'].checked){
		errMsg = "Debe aceptar los Términos de Uso del Sitio";
	}
	
	if (!telfRE1.test(theForm['billingPhone'].value)){
		errMsg = "Debe escribir un Teléfono válido";
		theForm['billingPhone'].className='text_rojo';
		setfocus = "['billingPhone']";
	}
	
	if (theForm['billingAddress'].value == ""){
		errMsg = "Dirección es un campo obligatotio";
		theForm['billingAddress'].className='text_rojo';
		setfocus = "['billingAddress']";
	}
	
	if (theForm['billingCity'].value == ""){
		errMsg = "Ciudad es un campo obligatotio";
		theForm['billingCity'].className='text_rojo';
		setfocus = "['billingCity']";
	}
	
	if (theForm['billingState'].value == ""){
		errMsg = "Provincia es un campo obligatotio";
		theForm['billingState'].className='text_rojo';
		setfocus = "['billingState']";
	}
		
	if (!validarEmail(theForm['billingEMail'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['billingEMail'].className='text_rojo';
		setfocus = "['billingEMail']";
	}
	
	if (theForm['billingLastName'].value == ""){
		errMsg = "Apellido es un campo obligatotio";
		theForm['billingLastName'].className='text_rojo';
		setfocus = "['billingLastName']";
	}
	
	if (theForm['billingFirstName'].value == ""){
		errMsg = "Nombre es un campo obligatotio";
		theForm['billingFirstName'].className='text_rojo';
		setfocus = "['billingFirstName']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['Enviar'].disabled = true;
		theForm['Enviar'].value = "INGRESANDO...";
		theForm['cancelar'].disabled = true;
		theForm.submit();
	}
}

function valida_ingresoDINERS(){
	var theForm = document.form_misdatos;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]{2,3}-? ?[0-9]{6,7}$/;
	var telfRE1 = /^[0-9]+$/;
	var telfRE2 = /^[0-9]*$/;
	var conRE = /^(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$/;
	var errMsg = "";
	var setfocus = "";

	if (!theForm['Acepta'].checked){
		errMsg = "Debe aceptar los Términos de Uso del Sitio";
	}
	
	if (theForm['txtReferencia5'].value == ""){
		errMsg = "Ciudad es un campo obligatotio";
		theForm['txtReferencia5'].className='text_rojo';
		setfocus = "['txtReferencia5']";
	}
	
	if (theForm['txtReferencia4'].value == ""){
		errMsg = "Provincia es un campo obligatotio";
		theForm['txtReferencia4'].className='text_rojo';
		setfocus = "['txtReferencia4']";
	}
	
	if (!telfRE1.test(theForm['txtReferencia3'].value)){
		errMsg = "Debe escribir un Teléfono válido";
		theForm['txtReferencia3'].className='text_rojo';
		setfocus = "['txtReferencia3']";
	}
	
	if (theForm['txtReferencia2'].value == ""){
		errMsg = "Apellidos es un campo obligatotio";
		theForm['txtReferencia2'].className='text_rojo';
		setfocus = "['txtReferencia2']";
	}
		
	if (theForm['txtReferencia1'].value == ""){
		errMsg = "Nombres es un campo obligatotio";
		theForm['txtReferencia1'].className='text_rojo';
		setfocus = "['txtReferencia1']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['Enviar'].disabled = true;
		theForm['Enviar'].value = "INGRESANDO...";
		theForm['cancelar'].disabled = true;
		theForm.submit();
	}
}

function verifica_clave(){
	var theForm = document.form_cambia_clave;
	var conRE = /^(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$/;
	var errMsg = "";
	var setfocus = "";
	
	if (!conRE.test(theForm['Confirma'].value)){
		errMsg = "Repita Contraseña es un campo obligatotio\n y debe cumplir con la forma del ejemplo";
		theForm['Confirma'].className='text_rojo';
		setfocus = "['Confirma']";
	}
	
	if (!conRE.test(theForm['Nueva'].value)){
		errMsg = "Nueva Contraseña es un campo obligatotio\n y debe cumplir con la forma del ejemplo";
		theForm['Nueva'].className='text_rojo';
		setfocus = "['Nueva']";
	}
	
	if (theForm['Actual'].value == ""){
		errMsg = "Contraseña Actual es un campo obligatorio";
		theForm['Actual'].className='text_rojo';
		setfocus = "['Actual']";
	}
	
	if (theForm['Confirma'].value != theForm['Nueva'].value){
		errMsg = "No coincide Nueva Contraseña y Repita Contraseña";
		setfocus = "['Nueva']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['Enviar'].disabled = true;
		theForm['Enviar'].value = "PROCESANDO...";
		theForm['cancelar'].disabled = true;
		theForm.submit();
	}
}

function valida_direcciones(){
	var theForm = document.form_direccion;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]{2,3}-? ?[0-9]{6,7}$/;
	var telfRE1 = /^[0-9]+$/;
	var telfRE2 = /^[0-9]*$/;
	var conRE = /^(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$/;
	var errMsg = "";
	var setfocus = "";

	if (theForm['DIRDIRECCION'].value == ""){
		errMsg = "Direccion es un campo obligatotio";
		theForm['DIRDIRECCION'].className='text_rojo';
		setfocus = "['DIRDIRECCION']";
	}
	
	if (theForm['DIRSECTOR'].value == ""){
		errMsg = "Sector es un campo obligatotio";
		theForm['DIRSECTOR'].className='text_rojo';
		setfocus = "['DIRSECTOR']";
	}
	
	if (theForm['DIRCIUDAD'].value == ""){
		errMsg = "Ciudad es un campo obligatotio";
		theForm['DIRCIUDAD'].className='text_rojo';
		setfocus = "['DIRCIUDAD']";
	}
	
	if (theForm['DIRPROVINCIA'].value == ""){
		errMsg = "Provincia es un campo obligatotio";
		theForm['DIRPROVINCIA'].className='text_rojo';
		setfocus = "['DIRPROVINCIA']";
	}

	if (!telfRE1.test(theForm['DIRTELEFONO'].value)){
		errMsg = "Debe escribir un Telefono1 válido";
		theForm['DIRTELEFONO'].className='text_rojo';
		setfocus = "['DIRTELEFONO']";
	}
		
	if (theForm['DIRAPELLIDO'].value == ""){
		errMsg = "Apellido es un campo obligatotio";
		theForm['DIRAPELLIDO'].className='text_rojo';
		setfocus = "['DIRAPELLIDO']";
	}
	
	if (theForm['DIRNOMBRE'].value == ""){
		errMsg = "Nombre es un campo obligatotio";
		theForm['DIRNOMBRE'].className='text_rojo';
		setfocus = "['DIRNOMBRE']";
	}
		
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['ingresar'].disabled = true;
		theForm['ingresar'].value = "PROCESANDO...";
		theForm.submit();
	}
}

function valida_local(){
	var theForm = document.form_opciones_envio;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['local'].value == ""){
		errMsg = "Por favor escoja el local donde desea retirar los productos de su compra";
		theForm['local'].className='text_rojo';
		setfocus = "['local']";
	}
			
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm.submit();
	}
}

function valida_cotizaciones(){
	var theForm = document.form_cotizaciones;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]{2,3}-? ?[0-9]{6,7}$/;
	var telfRE1 = /^[0-9]+$/;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['Contenido'].value == ""){
		errMsg = "Contenido es un campo obligatotio";
		theForm['Contenido'].className='text_rojo';
		setfocus = "['Contenido']";
	}
	
	if (theForm['Forma'].value == ""){
		errMsg = "Forma de Cotización es un campo obligatotio";
		theForm['Forma'].className='text_rojo';
		setfocus = "['Forma']";
	}
		
	if (!validarEmail(theForm['E-Mail'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['E-Mail'].className='text_rojo';
		setfocus = "['E-Mail']";
	}
	
	if (!telfRE1.test(theForm['Telefono'].value)){
		errMsg = "Teléfono es un campo obligatotio y solo permite ingreso de números";
		theForm['Telefono'].className='text_rojo';
		setfocus = "['Telefono']";
	}
	
	if (theForm['Apellidos'].value == ""){
		errMsg = "Apellidos es un campo obligatotio";
		theForm['Apellidos'].className='text_rojo';
		setfocus = "['Apellidos']";
	}
	
	if (theForm['Nombres'].value == ""){
		errMsg = "Nombres es un campo obligatotio";
		theForm['Nombres'].className='text_rojo';
		setfocus = "['Nombres']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['Enviar'].disabled = true;
		theForm['Enviar'].value = "PROCESANDO...";
		theForm.submit();
	}
}

function valida_corporativo(){
	var theForm = document.form_corporativo;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]{2,3}-? ?[0-9]{6,7}$/;
	var telfRE1 = /^[0-9]+$/;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['Observaciones'].value == ""){
		errMsg = "Observaciones es un campo obligatotio";
		theForm['Observaciones'].className='text_rojo';
		setfocus = "['Observaciones']";
	}
		
	if (!validarEmail(theForm['Email'].value)){
		errMsg = "Debe ingresar un E-mail válido, es un campo obligatotio";
		theForm['Email'].className='text_rojo';
		setfocus = "['Email']";
	}
	
	if (!telfRE1.test(theForm['Telefono'].value)){
		errMsg = "Teléfono es un campo obligatotio y solo permite ingreso de números";
		theForm['Telefono'].className='text_rojo';
		setfocus = "['Telefono']";
	}
	
	if (theForm['Contacto'].value == ""){
		errMsg = "Contacto es un campo obligatotio";
		theForm['Contacto'].className='text_rojo';
		setfocus = "['Contacto']";
	}
	
	if (theForm['Empresa'].value == ""){
		errMsg = "Empresa es un campo obligatotio";
		theForm['Empresa'].className='text_rojo';
		setfocus = "['Empresa']";
	}
	
	if (!validaRUC(theForm['Ruc'].value)){
		errMsg = "Debe ingresar un RUC válido (sólo números)";
		theForm['Ruc'].className='text_rojo';
		setfocus = "['Ruc']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['Enviar'].disabled = true;
		theForm['Enviar'].value = "PROCESANDO...";
		theForm.submit();
	}
}
