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.buscar_productos;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['txt_buscar'].value == "" || theForm['txt_buscar'].value == "Buscar Productos..."){
		errMsg = "Debe ingresar una Palabra a Buscar\n\nPuede escribir:\nCódigos de Productos XPC, # de Parte de Productos,\nNombres de Categorías, Nombres de SubCategorías, Nombres de Marcas o cualquier Palabra";
		setfocus = "['txt_buscar']";
	}

	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 (theForm['Sucursal'].value == ""){
		errMsg = "Sucursal es un campo obligatotio";
		theForm['Sucursal'].className='text_rojo';
		setfocus = "['Sucursal']";
	}

	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 (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['contrasenia'].value == ""){
		errMsg = "Contraseña es un campo obligatotio";
		theForm['contrasenia'].className='text_rojo';
		setfocus = "['contrasenia']";
	}

	if (theForm['codigo'].value == ""){
		errMsg = "Código es un campo obligatorio";
		theForm['codigo'].className='text_rojo';
		setfocus = "['codigo']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['ingresar'].disabled = true;
		theForm['ingresar'].value = "INGRESANDO...";
		theForm.submit();
	}
}

function valida_ingresar_todos(){
	var theForm = document.form_login_todos;
	var errMsg = "";
	var setfocus = "";
	
	if (theForm['contrasenia'].value == ""){
		errMsg = "Contraseña es un campo obligatotio";
		theForm['contrasenia'].className='text_rojo';
		setfocus = "['contrasenia']";
	}

	if (theForm['codigo'].value == ""){
		errMsg = "Código es un campo obligatorio";
		theForm['codigo'].className='text_rojo';
		setfocus = "['codigo']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['ingresar'].disabled = true;
		theForm['ingresar'].value = "INGRESANDO...";
		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 = "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 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 (!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 (!validaRUC(theForm['Ruc'].value)){
		errMsg = "Debe ingresar un RUC válido (sólo números)";
		theForm['Ruc'].className='text_rojo';
		setfocus = "['Ruc']";
	}
	
	if (theForm['Codigo'].value == ""){
		errMsg = "Código de Distribuidor XPC es un campo obligatotio";
		theForm['Codigo'].className='text_rojo';
		setfocus = "['Codigo']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['Enviar'].disabled = true;
		theForm['Enviar'].value = "ENVIANDO...";
		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();
	}
}

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 (theForm['vendedor'].value == ""){
		errMsg = "Vendedor es un campo obligatotio";
		theForm['vendedor'].className='text_rojo';
		setfocus = "['vendedor']";
	}

	if (!validarEmail(theForm['email'].value)){
		errMsg = "Ingrese un E-Mail Válido, campo obligatorio";
		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['provincia'].value == ""){
		errMsg = "Provincia es un campo obligatotio";
		theForm['provincia'].className='text_rojo';
		setfocus = "['provincia']";
	}
	
	if (theForm['ciudad'].value == ""){
		errMsg = "Ciudad es un campo obligatotio";
		theForm['ciudad'].className='text_rojo';
		setfocus = "['ciudad']";
	}
	
	if (theForm['nombres'].value == ""){
		errMsg = "Nombres es un campo obligatotio";
		theForm['nombres'].className='text_rojo';
		setfocus = "['nombres']";
	}
	
	if (!validaRUC(theForm['ruc'].value)){
		errMsg = "RUC o Cédula es un campo obligatotio y solo permite números\nIngrese un RUC o Cédula válido";
		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();
	}
}

function valida_editcuenta(){
	var theForm = document.form1;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var telfRE = /^[0-9]*$/;
	var telfRE1 = /^[0-9]{7}$/;
	var telfRE2 = /^[0-9]{2}$/;
	var conRE = /^(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$/;
	var errMsg = "";
	var setfocus = "";

	if (!telfRE.test(theForm['CLIFAX'].value)){
		errMsg = "FAX sólo permite ingreso de números";
		theForm['CLIFAX'].className='text_rojo';
		setfocus = "['CLIFAX']";
	}
	
	if (!telfRE1.test(theForm['telefono1'].value)){
		errMsg = "Teléfono es un campo obligatotio y solo permite ingreso de números\nDebe contener 7 dígitos";
		theForm['telefono1'].className='text_rojo';
		setfocus = "['telefono1']";
	}
	
	if (!telfRE2.test(theForm['codtelefono1'].value)){
		errMsg = "Código de Provincia es un campo obligatotio y solo permite ingreso de números\nDebe contener 2 dígitos";
		theForm['codtelefono1'].className='text_rojo';
		setfocus = "['codtelefono1']";
	}
	
	if (theForm['sector'].value == ""){
		errMsg = "Sector es un campo obligatotio";
		theForm['sector'].className='text_rojo';
		setfocus = "['sector']";
	}
	
	if (theForm['sector'].value == "otro" && theForm['otrosector'].value == ""){
		errMsg = "Sector es un campo obligatotio";
		theForm['otrosector'].className='text_rojo';
		theForm['sector'].className='text_rojo';
		setfocus = "['otrosector']";
	}
	
	if (theForm['secundaria'].value == "" || theForm['secundaria'].value == "Calle Secundaria"){
		errMsg = "Calle Secundaria es un campo obligatotio";
		theForm['secundaria'].className='text_rojo';
		setfocus = "['secundaria']";
	}
	
	if (theForm['numero'].value == "" || theForm['numero'].value == "Número"){
		errMsg = "Número es un campo obligatotio";
		theForm['numero'].className='text_rojo';
		setfocus = "['numero']";
	}
	
	if (theForm['principal'].value == "" || theForm['principal'].value == "Calle Principal"){
		errMsg = "Calle Principal es un campo obligatotio";
		theForm['principal'].className='text_rojo';
		setfocus = "['principal']";
	}
		
	if (theForm['CLICIUDAD'].value == ""){
		errMsg = "CIUDAD es un campo obligatotio";
		theForm['CLICIUDAD'].className='text_rojo';
		setfocus = "['CLICIUDAD']";
	}
	
	if (theForm['CLIPROVINCIA'].value == ""){
		errMsg = "PROVINCIA es un campo obligatotio";
		theForm['CLIPROVINCIA'].className='text_rojo';
		setfocus = "['CLIPROVINCIA']";
	}
	
	if (!validarEmail(theForm['CLIEMAIL2'].value)){
		errMsg = "Debe escribir un EMAIL SECUNDARIO válido";
		theForm['CLIEMAIL2'].className='text_rojo';
		setfocus = "['CLIEMAIL2']";
	}
	
	if (!validarEmail(theForm['CLIEMAIL'].value)){
		errMsg = "Debe escribir un EMAIL PRINCIPAL válido";
		theForm['CLIEMAIL'].className='text_rojo';
		setfocus = "['CLIEMAIL']";
	}
	
	if (theForm['CLIAPELLIDO'].value == ""){
		errMsg = "APELLIDO es un campo obligatotio";
		theForm['CLIAPELLIDO'].className='text_rojo';
		setfocus = "['CLIAPELLIDO']";
	}
	
	if (theForm['CLINOMBRE'].value == ""){
		errMsg = "NOMBRE es un campo obligatotio";
		theForm['CLINOMBRE'].className='text_rojo';
		setfocus = "['CLINOMBRE']";
	}
	
	if (theForm['CLICONTACTO'].value == ""){
		errMsg = "CONTACTO es un campo obligatotio";
		theForm['CLICONTACTO'].className='text_rojo';
		setfocus = "['CLICONTACTO']";
	}
	
	if (theForm['CLIEMPRESA'].value == ""){
		errMsg = "EMPRESA es un campo obligatotio";
		theForm['CLIEMPRESA'].className='text_rojo';
		setfocus = "['CLIEMPRESA']";
	}
	
	if (!validaRUC(theForm['CLIRUC'].value)){
		errMsg = "Debe ingresar un RUC válido (sólo números)";
		theForm['CLIRUC'].className='text_rojo';
		setfocus = "['CLIRUC']";
	}
	
	if (theForm['CLICODIGO'].value == ""){
		errMsg = "CÓDIGO es un campo obligatorio";
		theForm['CLICODIGO'].className='text_rojo';
		setfocus = "['CLICODIGO']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	
	else {
		theForm['guardar'].disabled = true;
		theForm['guardar'].value = "PROCESANDO...";
		theForm['cancelar'].disabled = true;
		theForm.submit();
	}
}

function valida_ruc_consulta(){
	var theForm = document.form_contrasenia;
	var errMsg = "";
	var setfocus = "";
	
	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['consultar'].disabled = true;
		theForm['consultar'].value = "VERIFICANDO...";
		theForm.submit();
	}
}

function ocultar () {
	document.getElementById ("box_ingresar").style.display = "none";
}

function showBanner() {
	document.getElementById ("box_ingresar").style.display = "block";
}