function rtclickcheck(keyp){
	var mymessage = "© AndinaReal Peru. Todos los Derechos Reservados.";

  if (navigator.appName == "Netscape" && keyp.which == 3) {

    alert(mymessage);

    return false;

  }

  if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {

    alert(mymessage);
	return false;

  }

  if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {

    alert(mymessage);

    return false;

  }

}
function cargar_departamento(codpais,nivel,anterior,path,form)
{
	/*
if (form.pais.value == "PE000000") 
  {        
  cadena=codpais+","+nivel+","+anterior;  
  jsrsExecute(path+"cargar_ubicacion.php",enviar_dep,"confirmar",cadena);
//if (form.pais.value == "PE000000") 
  //{        
    self.div_nac.style.display='';
//	self.div_nac_ruc.style.display='';
	self.div_ext.style.display='none';
	return;
  } else {
    self.div_nac.style.display='none';
//	self.div_nac_ruc.style.display='none';
	self.div_ext.style.display='';
	return;
  }
  */
  
//document.getElementById('div_frame1').style.display='none';  
//if (form.pais.value == "PE000000") 
//  {        

  cadena=codpais+","+nivel+","+anterior;  
  jsrsExecute(path+"cargar_ubicacion.php",enviar_dep,"confirmar",cadena);
//if (form.pais.value == "PE000000") 
//if (document.getElementById("pais").value == "PE000000") { 

var form_pais = document.frm_opcadd;
if (form_pais.pais.value == "PE000000") { 
    //self.div_nac.style.display='';
	document.getElementById('div_nac').style.display='block';
	//self.div_nac_ruc.style.display='';
	//self.div_ext.style.display='none';
	document.getElementById('div_ext').style.display='none';
	return;
  } else {
    //self.div_nac.style.display='none';
	document.getElementById('div_nac').style.display='none';  
	//self.div_nac_ruc.style.display='none';
	//self.div_ext.style.display='';
	document.getElementById('div_ext').style.display='';  
	return;
  }  
}
function enviar_dep(cadena)
{

 var form = document.frm_opcadd;
 cadena=cadena.split("-");
 
 coddepc=cadena[0].split(",");
 coddepn=cadena[1].split(",");
 
 cantidad=coddepc.length;
 
 form.dpto.options.length=1;
 form.prov.options.length=1;
 form.dist.options.length=1;
 
 opcion=new Option("---- Departamento ----","");
 form.dpto.options[0]= opcion;

 opcion_prov=new Option("---- Provincia ----","");
 form.prov.options[0]= opcion_prov;

 opcion_dist=new Option("---- Distrito ----","");
 form.dist.options[0]= opcion_dist;

 for(x=1;x < cantidad; x++)
 { 
  	otraopcion=new Option(coddepn[x-1],coddepc[x-1]);
	form.dpto.options[x] = otraopcion;
 }
}




function cargar_provincia(coddep,nivel,path,anterior)
{ 
  cadena=coddep+","+nivel;
  jsrsExecute(path+"cargar_ubicacion.php",enviar_prov,"confirmar",cadena);
}

function enviar_prov(cadena)
{
 var form = document.frm_opcadd;
 cadena=cadena.split("-");
 
 coddepc=cadena[0].split(",");
 coddepn=cadena[1].split(",");
 
 cantidad=coddepc.length;
  
 form.prov.options.length=1;
 form.dist.options.length=1;
 
 opcion=new Option("----   Provincia  ----","");
 form.prov.options[0]= opcion;
 
 opcion_dist=new Option("---- Distrito ----","");
 form.dist.options[0]= opcion_dist;

 for(x=1;x < cantidad; x++)
 { 
  	otraopcion=new Option(coddepn[x-1],coddepc[x-1]);
	form.prov.options[x] = otraopcion;
 }
}

function cargar_distrito(codprov,nivel,path,anterior)
{
  cadena=codprov+","+nivel;
  jsrsExecute(path+"cargar_ubicacion.php",enviar_dist,"confirmar",cadena);
}

function enviar_dist(cadena)
{
 var form = document.frm_opcadd;
 cadena=cadena.split("-");
 
 coddepc=cadena[0].split(",");
 coddepn=cadena[1].split(",");
 
 cantidad=coddepc.length;
  
 form.dist.options.length=1;
 
 opcion=new Option("----   Distrito   ----","");
 form.dist.options[0]= opcion;
 
 for(x=1;x < cantidad; x++)
 { 
  	otraopcion=new Option(coddepn[x-1],coddepc[x-1]);
	form.dist.options[x] = otraopcion;
 }
}

function validar_busqueda(form){
	if(form.q.value.length < 3) {
		alert('La búsqueda debe contener 3 caracteres minimo');
		form.q.focus();
		return false;
	}
	return true;
}

function popup_codiciones() {
	window.open('usuario_termcond.php', '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,top=50,left=200,resizable=no,width=560,height=540')
}

function popup_saftpay_banks() {
	window.open('http://www.AndinaReal.com/saftpay_banks.php', '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,top=50,left=200,resizable=no,width=300,height=220')
}

function popup_saftpay_demo() {
	window.open('saftpay_demo.php', '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,top=50,left=200,resizable=no,width=692,height=580')
}

function popup_producto(IDprod) {
	window.open('producto_popup.php?idp=' + IDprod, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,top=50,left=200,resizable=no,width=500,height=470')
}

function popup_productoimg(nomprod,imgprod,ancho,alto) {
	window.open('popup_productoimg.php?nom='+ nomprod +'&img='+imgprod , '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,top=50,left=200,resizable=no,width=' + ancho + ',height=' + alto + '')
}

function valida_numero() 
{
	if (event.keyCode < 46 || event.keyCode > 57 || event.keyCode == 47)
	event.returnValue = false;
}

function valida_numentero() 
{
	if (event.keyCode < 48 || event.keyCode > 57)
	event.returnValue = false;
}
/*********** form boletin **************/
function envia_cod_bol(param,selObj,restore){
	
	var val = selObj.options[selObj.selectedIndex].value;
	window.location = "pe_suscriptores_boletin.php?" + param + "&textsus=" + val;
	if (restore) selObj.selectedIndex=0;
}

function valida_email(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

/******************************************/

/*************************************************/
/************ Funciones añadidas ****************/
/************************************************/
function valid_opcaddusuario_form(form) 
{
	if (form.email.value == "") { alert("Falta ingresar E-mail"); form.email.focus(); return (false); }
		if (form.email.value.length!=0)
		if (form.email.value.indexOf('@', 0) == -1 || form.email.value.indexOf('.', 0) == -1)
			{ alert("Dirección de correo inválida"); form.email.focus(); return (false); }
	if (form.clave.value == "") { alert("Falta ingresar contraseña"); form.clave.focus(); return (false); }
	if (form.rclave.value == "") { alert("Falta ingresar repetir contraseña"); form.rclave.focus(); return (false); }
	if (form.nombre.value == "") { alert("Falta ingresar nombre"); form.nombre.focus(); return (false); }
	if (form.apellido.value == "") { alert("Falta ingresar apellidos"); form.apellido.focus(); return (false); }
	if (form.direc.value == "") { alert("Falta ingresar direccion"); form.direc.focus(); return (false); }
	if (form.postal.value == "") { alert("Falta ingresar codigo postal"); form.postal.focus(); return (false); }	
	if (form.pob.value == "") { alert("Falta ingresar poblacion"); form.pob.focus(); return (false); }
	if (form.prov.value == "") { alert("Falta ingresar provincia/estado"); form.prov.focus(); return (false); }	
	if (form.pais.value == "") { alert("Falta selecionar pais"); form.pais.focus(); return (false); }
	if (form.perfil.value == "") { alert("Falta ingresar perfil de usuario"); form.perfil.focus(); return (false); }
	if (form.clave.value != form.rclave.value) { alert("La contraseña ingresada no coincide"); form.clave.focus(); return (false); }	
}

function valid_frmrecpass_usuario(form)
{
	if (form.email.value == "") { alert("Ingrese su dirección de correo"); form.email.focus(); return (false); }
	if (form.email.value.length!=0)
		if (form.email.value.indexOf('@', 0) == -1 || form.email.value.indexOf('.', 0) == -1)
		{ alert("Dirección de correo inválida"); form.email.focus(); return (false); }
}

function valid_editdir_form(form)
{
	if (form.nombre.value == "") { alert("Falta ingresar nombre"); form.nombre.focus(); return (false); }
	if (form.apellido.value == "") { alert("Falta ingresar apellidos"); form.apellido.focus(); return (false); }
	if (form.direc.value == "") { alert("Falta ingresar direccion"); form.direc.focus(); return (false); }
	if (form.postal.value == "") { alert("Falta ingresar codigo postal"); form.postal.focus(); return (false); }	
	if (form.pob.value == "") { alert("Falta ingresar poblacion"); form.pob.focus(); return (false); }
	if (form.prov.value == "") { alert("Falta ingresar provincia/estado"); form.prov.focus(); return (false); }	
	if (form.pais.value == "") { alert("Falta selecionar pais"); form.pais.focus(); return (false); }
}

function valid_opceditusuario_form(form) {
	if (form.nombre.value == "") { alert("Falta ingresar nombre"); form.nombre.focus(); return (false); }
	if (form.apellido.value == "") { alert("Falta ingresar apellidos"); form.apellido.focus(); return (false); }
	if (form.perfil.value == "") { alert("Falta ingresar perfil de usuario"); form.perfil.focus(); return (false); }
	/*if (form.opcestado.value == "") { alert("Falta seleccionar estado de usuario"); form.opcestado.focus(); return (false); }*/
	/*if (form.opcestado[1].checked=false)  { alert("Falta seleccionar estado de usuario"); form.opcestado.focus(); return (false); }*/
}

/*********** form login de usuarios **************/
function valid_login_form(form){
	if (form.email.value == "") { alert("Ingrese su dirección de correo"); form.email.focus(); return (false); }
	if (form.email.value.length!=0)
		if (form.email.value.indexOf('@', 0) == -1 || form.email.value.indexOf('.', 0) == -1)
			{ alert("Dirección de correo inválida"); form.email.focus(); return (false); }
	if (form.clave.value == "")
	{ alert("Ingrese su contraseña"); form.clave.focus(); return (false); }
 }
function valid_vc_form(form){
	if (form.PAN.value == "") { alert("Ingrese numero de su Tarjeta Visa"); form.PAN.focus(); return false;}
	if(form.PAN.value.length < 16)  { alert("El numero de tarjeta no es valida"); form.PAN.focus(); return false;}
}
function valid_mc_form(form){
	if (form.NUMTARJETA.value == "") { alert("Ingrese numero de su Tarjeta Mastercard"); form.NUMTARJETA.focus(); return false;}
	if(form.NUMTARJETA.value.length < 16)  { alert("El numero de tarjeta no es valida"); form.NUMTARJETA.focus(); return false;}
	if (form.CVC2.value == "") { alert("Ingrese codigo CVC2 de su Tarjeta"); form.CVC2.focus(); return false;}
}
/*************** Hide opc busqueda de ordenes ***************/
function hide_opcbusq_orden(form) {
  if (form.opcbusq.value == "C") 
  {        
    self.div_cod.style.display='';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "M") 
  { 
    self.div_cod.style.display='none';
	self.div_mail.style.display='';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  }
  if (form.opcbusq.value == "E") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "F") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "N") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "P") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "T") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "U") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='';
	return;
  } 
}
/*************** Hide opc busqueda de usuarios ***************/
function hide_opcbusq_usuario(form)
{
  if (form.opcbusq.value == "C") 
  {        
    self.div_cod.style.display='';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "M") 
  { 
    self.div_cod.style.display='none';
	self.div_mail.style.display='';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  }
  if (form.opcbusq.value == "E") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "F") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "N") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "P") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "T") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='';
	self.div_ubic.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "U") 
  {        
    self.div_cod.style.display='none';
	self.div_mail.style.display='none';
	self.div_estado.style.display='none';
	self.div_fecha.style.display='none';
	self.div_nom.style.display='none';
	self.div_perfil.style.display='none';
	self.div_selec.style.display='none';
	self.div_ubic.style.display='';
	return;
  } 
}

/*************** Hide opc busqueda de productos ***************/
function hide_opcbusq_producto(form)
{
  if (form.opcbusq.value == "C") 
  {        
    self.div_cod.style.display='';
	self.div_estado.style.display='none';
	self.div_stock.style.display='none';
	self.div_nom.style.display='none';
	self.div_categ.style.display='none';
	self.div_selec.style.display='none';
	self.div_offer.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "E") 
  {        
    self.div_cod.style.display='none';
	self.div_estado.style.display='';
	self.div_stock.style.display='none';
	self.div_nom.style.display='none';
	self.div_categ.style.display='none';
	self.div_selec.style.display='none';
	self.div_offer.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "S") 
  {        
    self.div_cod.style.display='none';
	self.div_estado.style.display='none';
	self.div_stock.style.display='';
	self.div_nom.style.display='none';
	self.div_categ.style.display='none';
	self.div_selec.style.display='none';
	self.div_offer.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "N") 
  {        
    self.div_cod.style.display='none';
	self.div_estado.style.display='none';
	self.div_stock.style.display='none';
	self.div_nom.style.display='';
	self.div_categ.style.display='none';
	self.div_selec.style.display='none';
	self.div_offer.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "K") 
  {        
    self.div_cod.style.display='none';
	self.div_estado.style.display='none';
	self.div_stock.style.display='none';
	self.div_nom.style.display='none';
	self.div_categ.style.display='';
	self.div_selec.style.display='none';
	self.div_offer.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "T") 
  {        
    self.div_cod.style.display='none';
	self.div_estado.style.display='none';
	self.div_stock.style.display='none';
	self.div_nom.style.display='none';
	self.div_categ.style.display='none';
	self.div_selec.style.display='';
	self.div_offer.style.display='none';
	return;
  } 
  if (form.opcbusq.value == "O") 
  {
    self.div_cod.style.display='none';
	self.div_estado.style.display='none';
	self.div_stock.style.display='none';
	self.div_nom.style.display='none';
	self.div_categ.style.display='none';
	self.div_selec.style.display='none';
	self.div_offer.style.display='';
	return;
  } 
}
/***************** fin hide opc busqueda de prod *******************/

/********** Hide detalles del producto *********/
function hide_infoprodcuto(param) {
	if (param == "frame1")	{
		document.getElementById('div_frame1').style.display='';
		document.getElementById('div_frame2').style.display='none';
		document.getElementById('div_frame3').style.display='none';
		document.getElementById('div_frame4').style.display='none';
		document.getElementById('div_frame5').style.display='none';
		document.getElementById('div_frame6').style.display='none';
	}
	if (param == "frame2")	{
		document.getElementById('div_frame1').style.display='none';
		document.getElementById('div_frame2').style.display='';
		document.getElementById('div_frame3').style.display='none';
		document.getElementById('div_frame4').style.display='none';
		document.getElementById('div_frame5').style.display='none';
		document.getElementById('div_frame6').style.display='none';
	}
	if (param == "frame3")	{
		document.getElementById('div_frame1').style.display='none';
		document.getElementById('div_frame2').style.display='none';
		document.getElementById('div_frame3').style.display='';
		document.getElementById('div_frame4').style.display='none';
		document.getElementById('div_frame5').style.display='none';
		document.getElementById('div_frame6').style.display='none';
	}
	if (param == "frame4")	{
		document.getElementById('div_frame1').style.display='none';
		document.getElementById('div_frame2').style.display='none';
		document.getElementById('div_frame3').style.display='none';
		document.getElementById('div_frame4').style.display='';
		document.getElementById('div_frame5').style.display='';
		document.getElementById('div_frame6').style.display='none';
	}
	if (param == "frame5")	{
		document.getElementById('div_frame1').style.display='none';
		document.getElementById('div_frame2').style.display='none';
		document.getElementById('div_frame3').style.display='none';
		document.getElementById('div_frame4').style.display='';
		document.getElementById('div_frame5').style.display='';
		document.getElementById('div_frame6').style.display='none';
	}
	if (param == "frame6")	{
		document.getElementById('div_frame1').style.display='none';
		document.getElementById('div_frame2').style.display='none';
		document.getElementById('div_frame3').style.display='none';
		document.getElementById('div_frame4').style.display='';
		document.getElementById('div_frame5').style.display='none';
		document.getElementById('div_frame6').style.display='';
	}
}
/********** fin Hide detalles del producto *********/

function valid_miperf_form(form) {
	if (form.nombre.value == "") { alert("Falta ingresar nombre"); form.nombre.focus(); return (false); }
	if (form.apellido.value == "") { alert("Falta ingresar apellidos"); form.apellido.focus(); return (false); }
}

function valid_midirmod_form(form)
{
	if (form.nombre.value == "") { alert("Falta ingresar nombre"); form.nombre.focus(); return (false); }
	if (form.apellido.value == "") { alert("Falta ingresar apellidos"); form.apellido.focus(); return (false); }
	if (form.pais.value == "") { alert("Falta selecionar pais"); form.pais.focus(); return (false); }
	if (form.pais.value == "PE000000") {
		if (form.dpto.value == "") { alert("Falta seleccionar departamento"); form.dpto.focus(); return (false); }	
		if (form.prov.value == "") { alert("Falta seleccionar provincia"); form.prov.focus(); return (false); }	
	} else {
		if (form.provest.value == "") { alert("Falta ingresar provincia/estado"); form.provest.focus(); return (false); }
		if (form.pob.value == "") { alert("Falta ingresar ciudad"); form.pob.focus(); return (false); }
	}
	if (form.direc.value == "") { alert("Falta ingresar direccion"); form.direc.focus(); return (false); }
	if (form.postal.value == "") { alert("Falta ingresar codigo postal"); form.postal.focus(); return (false); }	
}

function valid_mipass_form(form)
{
	if (form.apass.value == "") { alert("Falta ingresar contraseña anterior"); form.apass.focus(); return (false); }
	if (form.npass.value == "") { alert("Falta ingresar nueva contraseña"); form.npass.focus(); return (false); }
	if (form.rnpass.value == "") { alert("Falta ingresar replica de nueva contraseña"); form.rnpass.focus(); return (false); }
	if (form.npass.value != form.rnpass.value) { alert("Las nuevas contraseñas ingresadas no coinciden"); form.npass.focus(); return (false); }
}
function valid_opcadd_form(form)
{
	if (form.nombre.value == "") { alert("Falta ingresar nombre de operacion"); form.nombre.focus(); return (false); }
}
function valid_subadd_form(form)
{
	if (form.nombre.value == "") { alert("Falta ingresar nombre de operacion"); form.nombre.focus(); return (false); }
	if (form.inc.value == "") { alert("Falta ingresar ruta de archivo de la operacion"); form.inc.focus(); return (false); }
	if (form.ico.value == "") { alert("Falta ingresar nombre de archivo del icono"); form.ico.focus(); return (false); }
}
function valid_opcadd_formperfil(form)
{
	if (form.perfil.value == "") { alert("Falta ingresar nombre de perfil"); form.perfil.focus(); return (false); }
}
function valid_opcadd_formparam(form)
{
	if (form.desparam.value == "") {alert("Falta ingrese nombre de parametro"); form.desparam.focus(); return (false); }
}
function valid_subadd_formparam(form) 
{
	if (form.idparam.value == "") {alert("Falta valor de parametro"); form.idparam.focus(); return (false); }
	if (form.desparam.value == "") {alert("Falta ingresar nombre de parametro"); form.desparam.focus(); return (false); }
}
function valid_opcadd_formboletin(form)
{
	if (form.nombre.value == "") {alert("Falta ingresar nombre de boletin"); form.nombre.focus(); return (true); }
}

/****************  funciones de usuario web ***********************/

function valid_addusuario_form(form) 
{
	if (form.email.value == "") { alert("Falta ingresar E-mail"); form.email.focus(); return (false); }
		if (form.email.value.length!=0)
		if (form.email.value.indexOf('@', 0) == -1 || form.email.value.indexOf('.', 0) == -1)
			{ alert("Dirección de correo inválida"); form.email.focus(); return (false); }
	if (form.clave.value == "") { alert("Falta ingresar contraseña"); form.clave.focus(); return (false); }
	if (form.rclave.value == "") { alert("Falta ingresar repetir contraseña"); form.rclave.focus(); return (false); }
	if (form.nombre.value == "") { alert("Falta ingresar nombre"); form.nombre.focus(); return (false); }
	if (form.apellido.value == "") { alert("Falta ingresar apellidos"); form.apellido.focus(); return (false); }
	if (form.telf.value == "") { alert("Falta ingresar teléfono"); form.telf.focus(); return (false); }
	if (form.pais.value == "") { alert("Falta selecionar pais"); form.pais.focus(); return (false); }
	if (form.pais.value == "PE000000") {
		if (form.dpto.value == "") { alert("Falta seleccionar departamento"); form.dpto.focus(); return (false); }	
		if (form.prov.value == "") { alert("Falta seleccionar provincia"); form.prov.focus(); return (false); }	
	} else {
		if (form.provest.value == "") { alert("Falta ingresar provincia/estado"); form.provest.focus(); return (false); }
		if (form.pob.value == "") { alert("Falta ingresar ciudad"); form.pob.focus(); return (false); }
	}
	if (form.direc.value == "") { alert("Falta ingresar direccion"); form.direc.focus(); return (false); }
	if (form.postal.value == "") { alert("Falta ingresar codigo postal"); form.postal.focus(); return (false); }	
	if (form.clave.value != form.rclave.value) { alert("La contraseña ingresada no coincide"); form.clave.focus(); return (false); }
	if (form.condicion.checked == false) { alert("Falta aceptar condiciones de contrato"); form.condicion.focus(); return (false); }
}

function valid_frmpass_recpassword(form)
{
	if (form.npass.value == "") { alert("Falta ingresar nueva contraseña"); form.npass.focus(); return (false); }
	if (form.rnpass.value == "") { alert("Falta ingresar replica de nueva contraseña"); form.rnpass.focus(); return (false); }
	if (form.npass.value != form.rnpass.value) { alert("Las nuevas contraseñas ingresadas no coinciden"); form.npass.focus(); return (false); }
}

function activar_oferta(txtbox)
{
	if (document.frm_opcadd.precioffer.disabled) document.frm_opcadd.precioffer.disabled = false; else document.frm_opcadd.precioffer.disabled = true;
	if (document.frm_opcadd.desoffer.disabled) document.frm_opcadd.desoffer.disabled = false; else document.frm_opcadd.desoffer.disabled = true;
	if (document.frm_opcadd.categoffer.disabled) document.frm_opcadd.categoffer.disabled = false; else document.frm_opcadd.categoffer.disabled = true;
}

function valid_frmopcadd_prod(form) {
	if (form.categ.value == "") { alert("Falta seleccionar categoria"); form.categ.focus(); return (false); }
	if (form.nombre.value == "") { alert("Falta ingresar nombre del producto"); form.nombre.focus(); return (false); }
	//if (form.res.value == "") { alert("Falta ingresar resumen del producto"); form.res.focus(); return (false); }
	if (form.unid.value == "") { alert("Falta seleccionar Unidad de presentacion del producto"); form.unid.focus(); return (false); }
	if (form.factor.value == "") { alert("Falta ingresar factor de unidad"); form.factor.focus(); return (false); }
	if (form.pesobruto.value == "") { alert("Falta ingresar Peso Bruto"); form.pesobruto.focus(); return (false); }
	if (form.pesoneto.value == "") { alert("Falta ingresar Peso Neto"); form.pesoneto.focus(); return (false); }
	if (form.unidpeso.value == "") { alert("Falta seleccionar Unidad de Peso"); form.unidpeso.focus(); return (false); }
	if (form.stock.value == "") { alert("Falta ingresar Stock"); form.stock.focus(); return (false); }
	if (form.precio.value == "") { alert("Falta ingresar precio"); form.precio.focus(); return (false); }
	if (form.inioffer.checked) {
		if (form.precioffer.value == "") { alert("Falta ingresar precio de oferta"); form.precioffer.focus(); return (false); }
		if (eval(form.precioffer.value)==0) { alert("El precio oferta debe ser mayor a cero"); form.precioffer.focus(); return (false); }
	}
	if (eval(form.pesobruto.value) <= eval(form.pesoneto.value)) { alert("El peso neto debe ser menor a peso bruto"); form.pesobruto.focus(); return (false); }
	if (eval(form.factor.value) == 0) { alert("El factor de unidad debe ser diferente de cero"); form.factor.focus(); return (false); }
	if (eval(form.stock.value)==0) { alert("El stock debe ser mayor a cero"); form.stock.focus(); return (false); }
	if (eval(form.precio.value)==0) { alert("El precio debe ser mayor a cero"); form.precio.focus(); return (false); }
}

function valid_frmeditimg_prod(form) {
	if (form.nomimg.value == "") { alert("Falta ingresar nombre de imagen"); form.nomimg.focus(); return (false); }
	if (form.imgprod.value == "") { alert("Falta seleccionar imagen"); form.imgprod.focus(); return (false); }
}

function valid_frmaddunid_prod(form) {
	if (form.unid.value == "") { alert("Falta seleccionar unidad de producto"); form.unid.focus(); return (false); }
	if (form.factor.value == "") { alert("Falta ingresar factor de unidad"); form.factor.focus(); return (false); }
	if (form.pesobruto.value == "") { alert("Falta ingresar peso bruto"); form.pesobruto.focus(); return (false); }
	if (form.pesoneto.value == "") { alert("Falta ingresar peso neto"); form.pesoneto.focus(); return (false); }
	if (form.unidpeso.value == "") { alert("Falta seleccionar unidad de peso del producto"); form.unidpeso.focus(); return (false); }
	if (form.stock.value == "") { alert("Falta ingresar stock del producto"); form.stock.focus(); return (false); }
	if (form.precio.value == "") { alert("Falta precio del producto"); form.precio.focus(); return (false); }
	if (eval(form.pesobruto.value) <= eval(form.pesoneto.value)) { alert("El peso neto debe ser menor a peso bruto"); form.pesobruto.focus(); return (false); }
	if (eval(form.factor.value) == 0) { alert("El factor de unidad debe ser diferente de cero"); form.factor.focus(); return (false); }
	if (eval(form.stock.value)==0) { alert("El stock debe ser mayor a cero"); form.stock.focus(); return (false); }
	if (eval(form.precio.value)==0) { alert("El precio debe ser mayor a cero"); form.precio.focus(); return (false); }
}

function valid_frmeditoffer_prod(form) {
	if (form.inioffer.checked) {
		if (form.precioffer.value == "") { alert("Falta ingresar precio de oferta"); form.precioffer.focus(); return (false); }
		if (eval(form.precioffer.value)==0) { alert("El precio de oferta debe ser mayor a cero"); form.precioffer.focus(); return (false); }
		if (eval(form.precioffer.value) >= eval(form.precio.value)) { alert("El precio de oferta debe ser menor a precio establecido"); form.precioffer.focus(); return (false); }
	}
}

function valid_frmeditprice_prod(form) {
	if (form.stock.value == "") { alert("Falta ingresar stock del producto"); form.stock.focus(); return (false); }
	if (form.precio.value == "") { alert("Falta precio del producto"); form.precio.focus(); return (false); }
	if (eval(form.stock.value)==0) { alert("El stock debe ser mayor a cero"); form.stock.focus(); return (false); }
	if (eval(form.precio.value)==0) { alert("El precio debe ser mayor a cero"); form.precio.focus(); return (false); }
	if (form.precioffer.value!="") {
		if (eval(form.precioffer.value) >= eval(form.precio.value)) { alert("El precio establecido debe ser mayor a precio de oferta"); form.precio.focus(); return (false); }		
	}
}

function valid_frmeditini_prod(form) {
	//if (form.categ.value == "") { alert("Falta seleccionar categoria"); form.categ.focus(); return (false); }
	if (form.nombre.value == "") { alert("Falta ingresar nombre del producto"); form.nombre.focus(); return (false); }
	//if (form.res.value == "") { alert("Falta ingresar resumen del producto"); form.res.focus(); return (false); }
	if (form.des.value == "") { alert("Falta ingresar descripcion del producto"); form.des.focus(); return (false); }	
}

function valid_frmeditlang_prod(form) {
	if (form.nombre.value == "") { alert("Falta ingresar nombre del producto"); form.nombre.focus(); return (false); }
	if (form.res.value == "") { alert("Falta ingresar resumen del producto"); form.res.focus(); return (false); }
}

function valid_shipment_form(form) {
	//if (form.opcCourier.checked == false) { alert("Falta seleccionar metodo de envio"); form.opcCourier.focus(); return (false); }
	//if (document.form1.opcCourier.value = "") { alert("Falta seleccionar metodo de envio"); form.opcCourier.focus(); return (false); }
}

function abre(url,num1,num2) { 
	var hWnd = window.open(url,"","width="+num1+",height="+num2+",resizable=no,scrollbars=no,top=0,left=0"); 
	if (hWnd.focus != null) 
	hWnd.focus(); 
}

function valid_shipment_adress_form(form)
{
	var optAdd = form.groupOpcDir.length;
	
	if (form.groupOpcDir[optAdd-1].checked && form.groupOpcDir[optAdd-1].value == "NUEVO") {
		if (form.nombre.value == "") { alert("Falta ingresar nombre"); form.nombre.focus(); return (false); }
		if (form.apellido.value == "") { alert("Falta ingresar apellidos"); form.apellido.focus(); return (false); }
		if (form.pais.value == "") { alert("Falta selecionar pais"); form.pais.focus(); return (false); }
		if (form.pais.value == "PE000000") {
			if (form.dpto.value == "") { alert("Falta seleccionar departamento"); form.dpto.focus(); return (false); }	
			if (form.prov.value == "") { alert("Falta seleccionar provincia"); form.prov.focus(); return (false); }	
		} else {
			if (form.provest.value == "") { alert("Falta ingresar provincia/estado"); form.provest.focus(); return (false); }
			if (form.pob.value == "") { alert("Falta ingresar ciudad"); form.pob.focus(); return (false); }
		}
		if (form.direc.value == "") { alert("Falta ingresar direccion"); form.direc.focus(); return (false); }
		if (form.postal.value == "") { alert("Falta ingresar codigo postal"); form.postal.focus(); return (false); }	
	}
}

function checkOptNewAddress(form) {
	var optAdd = form.groupOpcDir.length;
	form.groupOpcDir[optAdd-1].checked = true
	return false;
}

function validOrderProcess_form(form) {
	if (form.INC_MSG.checked == true && form.INC_PROCESS.checked == true) {
		if (form.comentario.value == "") { alert("Falta ingresar mensaje"); form.comentario.focus(); return (false); }
		if (form.procOrd.value == "") { alert("Falta seleccionar estado de proceso"); form.procOrd.focus(); return (false); }
		if (form.order.value == "") { alert("Recargar la orden, si persiste el error comuniquese con su proveedor "); form.order.focus(); return (false); }
	} else if (form.INC_MSG.checked == true && form.INC_PROCESS.checked == false) { 
		if (form.comentario.value == "") { alert("Falta ingresar mensaje"); form.comentario.focus(); return (false); }
		if (form.order.value == "") { alert("Recargar la orden, si persiste el error comuniquese con su proveedor "); form.order.focus(); return (false); }
	} else if (form.INC_MSG.checked == false && form.INC_PROCESS.checked == true) { 
		if (form.procOrd.value == "") { alert("Falta seleccionar estado de proceso"); form.procOrd.focus(); return (false); }
		if (form.order.value == "") { alert("Recargar la orden, si persiste el error comuniquese con su proveedor "); form.order.focus(); return (false); }		
	} else {
		alert("Seleccione opciones a ajecutar"); return (false);
	}
}

function swModePrivateSendMsg(form) {
	if (form.MODE.checked == false) {
		document.QForm.SENDMAIL.disabled = false;
		document.QForm.ADDCOMENT.disabled = false;
	} else {
		document.QForm.SENDMAIL.disabled = true;
		document.QForm.ADDCOMENT.disabled = true;
	}
}

function swModeStatusChange(form) {
	if (form.procOrd.value == "") {
		document.QForm.INC_PROCESS.checked = false;
	} else {
		document.QForm.INC_PROCESS.checked = true;
	}
}

function activar_modo_msgorden(txtbox) {
	if (document.frm_opcadd.precioffer.disabled) document.frm_opcadd.precioffer.disabled = false; else document.frm_opcadd.precioffer.disabled = true;
	if (document.frm_opcadd.desoffer.disabled) document.frm_opcadd.desoffer.disabled = false; else document.frm_opcadd.desoffer.disabled = true;
	if (document.frm_opcadd.categoffer.disabled) document.frm_opcadd.categoffer.disabled = false; else document.frm_opcadd.categoffer.disabled = true;
}

function valid_opcadd_msgtemp_form(form) {
	if (form.nombre.value == "") { alert("Falta ingresar titulo de mensaje"); form.nombre.focus(); return (false); }
	if (form.msgtem.value == "") { alert("Falta ingresar template de mensaje"); form.msgtem.focus(); return (false); }
}

function cargar_departamentow(codpais,nivel,anterior,path,form) {
/*
if (form.paisw.value == "PE000000") 
  {
  cadena=codpais+","+nivel+","+anterior;  
  jsrsExecute(path+"cargar_ubicacion.php",enviar_depw,"confirmar",cadena);
//if (form.pais.value == "PE000000") 
  //{        
    self.div_nacw.style.display='';
	self.div_nac_rucw.style.display='';
	self.div_extw.style.display='none';
	return;
  } else {
    self.div_nacw.style.display='none';
	self.div_nac_rucw.style.display='none';
	self.div_extw.style.display='';
	return;
  }
*/
cadena=codpais+","+nivel+","+anterior;  
  jsrsExecute(path+"cargar_ubicacion.php",enviar_depw,"confirmar",cadena);
//if (form.pais.value == "PE000000") 
var form_paisw = document.frm_opcadd_dis;
if (form_paisw.paisw.value == "PE000000") { 
//alert("Hiii"); return;
    //self.div_nac.style.display='';
	document.getElementById('div_nacw').style.display="block";
	//self.div_nac_ruc.style.display='';
	//self.div_ext.style.display='none';
	document.getElementById('div_extw').style.display="none";
	return;
  } else {
    //self.div_nac.style.display='none';
	document.getElementById('div_nacw').style.display='none';  
	//self.div_nac_ruc.style.display='none';
	//self.div_ext.style.display='';
	document.getElementById('div_extw').style.display='';  
	return;
  }  
}
function enviar_depw(cadena)
{

 var form = document.frm_opcadd_dis;
 cadena=cadena.split("-");
 
 coddepc=cadena[0].split(",");
 coddepn=cadena[1].split(",");
 
 cantidad=coddepc.length;
 
 form.dptow.options.length=1;
 form.provw.options.length=1;
 form.distw.options.length=1;
 
 opcion=new Option("---- Departamento ----","");
 form.dptow.options[0]= opcion;

 opcion_prov=new Option("---- Provincia ----","");
 form.provw.options[0]= opcion_prov;

 opcion_dist=new Option("---- Distrito ----","");
 form.distw.options[0]= opcion_dist;

 for(x=1;x < cantidad; x++)
 { 
  	otraopcion=new Option(coddepn[x-1],coddepc[x-1]);
	form.dptow.options[x] = otraopcion;
 }
}

function cargar_provinciaw(coddep,nivel,path,anterior)
{ 
  cadena=coddep+","+nivel;
  jsrsExecute(path+"cargar_ubicacion.php",enviar_provw,"confirmar",cadena);
}

function enviar_provw(cadena)
{
 var form = document.frm_opcadd_dis;
 cadena=cadena.split("-");
 
 coddepc=cadena[0].split(",");
 coddepn=cadena[1].split(",");
 
 cantidad=coddepc.length;
  
 form.provw.options.length=1;
 form.distw.options.length=1;
 
 opcion=new Option("----   Provincia  ----","");
 form.provw.options[0]= opcion;
 
 opcion_dist=new Option("---- Distrito ----","");
 form.distw.options[0]= opcion_dist;

 for(x=1;x < cantidad; x++)
 { 
  	otraopcion=new Option(coddepn[x-1],coddepc[x-1]);
	form.provw.options[x] = otraopcion;
 }
}

function cargar_distritow(codprov,nivel,path,anterior)
{
  cadena=codprov+","+nivel;
  jsrsExecute(path+"cargar_ubicacion.php",enviar_distw,"confirmar",cadena);
}

function enviar_distw(cadena)
{
 var form = document.frm_opcadd_dis;
 cadena=cadena.split("-");
 
 coddepc=cadena[0].split(",");
 coddepn=cadena[1].split(",");
 
 cantidad=coddepc.length;
  
 form.distw.options.length=1;
 
 opcion=new Option("----   Distrito   ----","");
 form.distw.options[0]= opcion;
 
 for(x=1;x < cantidad; x++)
 { 
  	otraopcion=new Option(coddepn[x-1],coddepc[x-1]);
	form.distw.options[x] = otraopcion;
 }
}

function valid_addusuariod_form(form) 
{
	
	if (form.email.value == "") { alert("Falta ingresar E-mail"); form.email.focus(); return (false); }
		if (form.email.value.length!=0)
		if (form.email.value.indexOf('@', 0) == -1 || form.email.value.indexOf('.', 0) == -1)
			{ alert("Dirección de correo inválida"); form.email.focus(); return (false); }
	if (form.clave.value == "") { alert("Falta ingresar contraseña"); form.clave.focus(); return (false); }
	if (form.rclave.value == "") { alert("Falta ingresar repetir contraseña"); form.rclave.focus(); return (false); }
	if (form.clave.value != form.rclave.value) { alert("La contraseña ingresada no coincide"); form.clave.focus(); return (false); }
	if (form.nombre.value == "") { alert("Falta ingresar nombre"); form.nombre.focus(); return (false); }
	if (form.apellido.value == "") { alert("Falta ingresar apellidos"); form.apellido.focus(); return (false); }
	if (form.telf.value == "") { alert("Falta ingresar teléfono"); form.telf.focus(); return (false); }
	
	if (form.pais.value == "") { alert("Falta selecionar pais"); form.pais.focus(); return (false); }

	if (form.pais.value == "PE000000") {
		if (form.dpto.value == "") { alert("Falta seleccionar departamento"); form.dpto.focus(); return (false); }	
		if (form.prov.value == "") { alert("Falta seleccionar provincia"); form.prov.focus(); return (false); }	
		if (form.dist.value == "") { alert("Falta seleccionar distrito"); form.dist.focus(); return (false); }			
	} else {
		if (form.provest.value == "") { alert("Falta ingresar provincia/estado"); form.provest.focus(); return (false); }
		if (form.pob.value == "") { alert("Falta ingresar ciudad"); form.pob.focus(); return (false); }
	}
	if (form.direc.value == "") { alert("Falta ingresar direccion"); form.direc.focus(); return (false); }
	if (form.postal.value == "") { alert("Falta ingresar codigo postal"); form.postal.focus(); return (false); }	


// distribuidores
	if (form.paisw.value == "") { alert("Falta selecionar pais"); form.paisw.focus(); return (false); }

	if (form.paisw.value == "PE000000") {
		if (form.dptow.value == "") { alert("Falta seleccionar departamento"); form.dptow.focus(); return (false); }	
		if (form.provw.value == "") { alert("Falta seleccionar provincia"); form.provw.focus(); return (false); }	
		if (form.distw.value == "") { alert("Falta seleccionar distrito"); form.distw.focus(); return (false); }			
	} else {
		if (form.provestw.value == "") { alert("Falta ingresar provincia/estado"); form.provestw.focus(); return (false); }
		if (form.pobw.value == "") { alert("Falta ingresar ciudad"); form.pobw.focus(); return (false); }
	}

	if (form.direcw.value == "") { alert("Falta ingresar direccion"); form.direcw.focus(); return (false); }
	if (form.telfw.value == "") { alert("Falta ingresar teléfono"); form.telfw.focus(); return (false); }
	if (form.postalw.value == "") { alert("Falta ingresar codigo postal"); form.postalw.focus(); return (false); }	
	if (form.paisw.value == "PE000000") {
		if (form.rucw.value == "") { alert("Falta ingresar R.U.C."); form.rucw.focus(); return (false); }
	}

	if (form.empresaw.value == "") { alert("Falta ingresar razón social"); form.empresaw.focus(); return (false); }
	if (form.personacontactow.value == "") { alert("Falta ingresar persona de contacto"); form.personacontactow.focus(); return (false); }
	if (form.emailw.value == "") { alert("Falta ingresar E-mail"); form.emailw.focus(); return (false); }
		if (form.emailw.value.length!=0)
		if (form.emailw.value.indexOf('@', 0) == -1 || form.emailw.value.indexOf('.', 0) == -1)
			{ alert("Dirección de correo inválida"); form.emailw.focus(); return (false); }

//	if (form.condicion.checked == false) { alert("Falta aceptar condiciones de contrato"); form.condicion.focus(); return (false); }
}
function valid_contacto_form(form) {
	if (form.nombre.value == "") { alert("Falta ingresar nombre"); form.nombre.focus(); return (false); }
	if (form.email.value == "") { alert("Falta ingresar E-mail"); form.email.focus(); return (false); }
		if (form.email.value.length!=0)
		if (form.email.value.indexOf('@', 0) == -1 || form.email.value.indexOf('.', 0) == -1)
			{ alert("Dirección de correo inválida"); form.email.focus(); return (false); }
	if (form.empresa.value == "") { alert("Falta ingresar nombre de empresa"); form.empresa.focus(); return (false); }
	if (form.pais.value == "") { alert("Falta seleccionar país"); form.pais.focus(); return (false); }
	if (form.asunto.value == "") { alert("Falta ingresar asuntoe"); form.asunto.focus(); return (false); }
	if (form.mensaje.value == "") { alert("Falta ingresar mensaje"); form.mensaje.focus(); return (false); }
}
function cambiar_input(id){
	if (document.getElementById(id).value == 'Buscar Productos'){ 
		document.getElementById(id).value = ''; 
		document.getElementById(id).className='txt_search_focus';
	} 
	return false;
}

function restablecer_input(id){
	if (document.getElementById(id).value==''){
		document.getElementById(id).value='Buscar Productos'; 
		document.getElementById(id).className='txt_search'; 
		return false;
	}			
}
function muestra(seleccionado){
	if (seleccionado ==1)	{
		cliente.style.display = "block"; 
		distribuidor.style.display = "none"; 
	}
	if (seleccionado ==2)	{
		cliente.style.display = "none"; 
		distribuidor.style.display = "block"; 
	}
}
