function borraForma(obj){if(obj!=null){obj.reset();};};
function marcaError(pid,message){$(".men_"+pid).html(message).css("display","block");};
function showDD(controlName,arrayObj,retValue,widthValue,className){if(retValue==null){retValue="";};if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};if(widthValue==null){widthValue="";};if(widthValue!=""){widthValue=" style=\"width:"+widthValue+";\" ";};var html="<select"+widthValue+className+" id=\""+controlName+"\" name=\""+controlName+"\" size=\"1\">";html+="<option value=\"\">- - -</option>";for(var i=0;i<arrayObj.length;i++){html+="<option ";if(retValue==arrayObj[i][0]){html+="selected ";};html+="value=\""+arrayObj[i][0]+"\">"+arrayObj[i][1]+"</option>";};html+="</select>";document.write(html);};
function showCheckBox(controlName,controlValor,valorOn,className){if(className==null){className="";};if(className!=""){className="class=\""+className+"\" ";};if(valorOn==null){valorOn="-1";};var html="<input "+className+"type=\"checkbox\" id=\""+controlName+"\" name=\""+controlName+"\" value=\""+valorOn+"\"";if(valorOn==controlValor){html+="checked>";}else{html+=">";};document.write(html);};
function showRadio(controlName,retValue,defValue,className){if(retValue==null){retValue="";};if(defValue==null){defValue=="";};if(className==null){className="";};if(className!=""){className="class=\""+className+"\" ";};var html="<input "+className+"type=\"radio\" name=\""+controlName+"\" id=\""+controlName+"\" value=\""+defValue+"\" ";if(retValue==defValue){html+="checked >";}else{html+=">";};document.write(html);html=null;};

function getSiNoT(controlNombre, retValue, toAdd, className) { if (className == null) { className = ""; }; if (className != "") { className = " class=\"" + className + "\" "; }; if (toAdd == null) { toAdd = ""; }; var sino = new Array(["Si", "S"], ["No", "N"]); var html = "<select " + className + " id=\"" + controlNombre + "\"  name=\"" + controlNombre + "\" size=1 " + toAdd + ">"; html += "<option value=\"\">- -</option>"; for (var i = 0; i < sino.length; i++) { html += "<option "; if (retValue == sino[i][1]) { html += "selected "; }; html += "value=\"" + sino[i][1] + "\">" + sino[i][0] + "</option>"; }; html += "</select>"; document.write(html); html = null; };

function showDocTipo(dt,className){if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};var html="<select "+className+" name=\"usu_doctipo\" id=\"usu_doctipo\" size=1 style=\"width:98%;\">";for(var i=0;i<tipdoc.length;i++){if(dt==tipdoc[i][0]){html+="<option selected value=\""+tipdoc[i][0]+"\">"+tipdoc[i][1]+"</option>";};};html+="</selected>";document.write(html);html=null;};
function showDocumento(doc,className){if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};if(doc==null){doc="";};var html="<div "+className+" style=\"width:205px;padding:2px;\" title=\"si deseas cambiar el número\ndebes reiniciar el proceso de registro...\"><b>"+doc+"</div>";document.write(html);html=null;};
function showDepartamento(retValue,className){if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};var html = "<select "+className+" style=\"width:98%;\" name=usu_departamento id=usu_departamento size=1 onchange=\"showProvincia(null,null,this);showDistrito(null,null,this);\">";html+="<option value=\"\">-- seleccione el departamento --</option>";for (var i=0;i<ubigeo.length;i++){if((ubigeo[i][1]=="00")&&(ubigeo[i][2]=="00")){html+="<option ";if(retValue==ubigeo[i][0]){html+="selected ";};html+="value=\""+ubigeo[i][0]+"\">"+ubigeo[i][3]+"</option>";};};html+="</select>";if(!document.getElementById("usu_departamento_div")){document.write("<div id=\"usu_departamento_div\"></div>");};document.getElementById("usu_departamento_div").innerHTML=html;html=null;};
function showProvincia(retValue,className,obj){if(obj!=null){className=$(obj).attr("class");};if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};cDepartamento = document.getElementById("usu_departamento").value;var html = "<select "+className+" style=\"width:98%;\" name=usu_provincia id=usu_provincia size=1 onchange=\"showDistrito(null,null,this);\">";html+="<option value=\"\">-- seleccione la provincia --</option>";for (var i=0;i<ubigeo.length;i++){if((ubigeo[i][0]==cDepartamento)&&(ubigeo[i][1]!="00")&&(ubigeo[i][2]=="00")){html+="<option ";if(retValue==ubigeo[i][1]){html+="selected ";};html+="value=\""+ubigeo[i][1]+"\">"+ubigeo[i][3]+"</option>";};};html+="</select>";if(!document.getElementById("usu_provincia_div")){document.write("<div id=\"usu_provincia_div\"></div>");};document.getElementById("usu_provincia_div").innerHTML=html;html=null;};	
function showDistrito(retValue,className,obj){if(obj!=null){className=$(obj).attr("class");};if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};cDepartamento = document.getElementById("usu_departamento").value;cProvincia = document.getElementById("usu_provincia").value;var html = "<select "+className+" style=\"width:98%;\" name=usu_distrito id=usu_distrito size=1>";html+="<option value=\"\">-- seleccione el distrito --</option>";for (var i=0;i<ubigeo.length;i++){if((ubigeo[i][0]==cDepartamento)&&(ubigeo[i][1]==cProvincia)&&(ubigeo[i][2]!="00")){html+="<option ";if(retValue==ubigeo[i][2]){html+="selected ";};html+="value=\""+ubigeo[i][2]+"\">"+ubigeo[i][3]+"</option>";};};html+="</select>";if(!document.getElementById("usu_distrito_div")){document.write("<div id=\"usu_distrito_div\"></div>");};document.getElementById("usu_distrito_div").innerHTML=html;html=null;};
function showYears(controlName,retValue,iniYear,widthValue,className){if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};if(retValue==null){retValue="";};if(widthValue==null){widthValue="";};var html="<select "+className+" id=\""+controlName+"\" name=\""+controlName+"\" size=\"1\">";html+="<option value=\"\">- - -</option>";for(var i=cYear;i>iniYear;i--){html+="<option ";if(retValue==i.toString()){html+="selected ";};html+="value=\""+i+"\">"+i+"</option>";};html+="</select>";document.write(html);html=null;};
function showI(controlName,retValue,iniI,lastI,widthValue,className){if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};if(retValue==null){retValue="";};if(widthValue==null){widthValue="";};var html="<select "+className+" id=\""+controlName+"\" name=\""+controlName+"\" size=\"1\">";html+="<option value=\"\">- - -</option>";for(var i=iniI;i<lastI;i++){html+="<option ";if(retValue==i.toString()){html+="selected ";};html+="value=\""+i+"\">"+i+"</option>";};html+="</select>";document.write(html);html=null;};	
function expPrevia(obj){if(obj==null){return;};if((obj.value=="")||(obj.value=="N")){$(".expPrevia").css("display","none");}else{$(".expPrevia").css("display","block");};};
function showPerfil(controlName,retValue,obj,toDisplay,className){
	if(obj!=null){className=$(obj).attr("class");};
	if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};if(retValue==null){retValue="";};
	var index=-1;
	if(!document.getElementById(controlName+"_container")){
		var html="<div id=\""+controlName+"_container\">";
		html+="<table width=\"98%\" cellpadding=0 cellspsacing=0 border=0 style=\"table-layout:fixed;\">";
		html+="<col width=\"50%\"><col width=\"50%\">";
		html+="<tr align=left valign=top>";
		html+="<td align=left valign=top>";
		html+="<select "+className+"style=\"width:98%;\" name=\""+controlName+"\" id=\""+controlName+"\" size=\"1\" onchange=\"showPerfil('"+controlName+"',null,this,'"+toDisplay+"');\">";
		html+="<option value=\"0\"> - - selecciona tu perfil - -</option>";
		for(var i=0;i<perfil.length;i++){
			html+="<option ";if(retValue==perfil[i][0]){html+="selected ";index=i;};
			html+="value=\""+perfil[i][0]+"\">"+perfil[i][1]+"</option>";
		};
		html+="</select>";
		html+="</td><td></td></tr>";
		html+="<tr align=left valign=top>";
		html+="<td colspan=2 align=left valign=top>";
		html+="<div id=\""+controlName+"_titulo\"></div>";
		html+="<div id=\""+controlName+"_descripcion\"></div>";
		html+="</td>";
		html+="</tr>";
		html+="</table>";
		html+="</div>";
		document.write(html);html=null;		
	}else{
		if(obj!=null){if(obj.value>0){for(var i=0;i<perfil.length;i++){if(obj.value==perfil[i][0]){index=i;break;};};};};
	}
	if(index!=-1){
		document.getElementById(controlName+"_titulo").innerHTML="<b>"+perfil[index][1]+"</b>";
		document.getElementById(controlName+"_descripcion").innerHTML=perfil[index][2].toString().replace(javaBrs,"<br>");
		if(index==1){displayTiendas=true;}else{displayTiendas=false;};
		if(document.getElementById(toDisplay)){
			if(index==1){document.getElementById(toDisplay).style.display="block";}else{document.getElementById(toDisplay).style.display="none";};
		};
	};	
};
function showLocales(controlName,retValue,thisValue,toDo,formName,className){
	if(formName==null){return;};if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};
	if(!document.getElementById("div_"+controlName)){
		if(!displayTiendas){
			var html="<div style=\"display:none;\" id=\""+controlName+"_container\">";
		}else{
			var html="<div style=\"display:block;\" id=\""+controlName+"_container\">";
		};
		html+="<input type=hidden value=\"\" name=\""+controlName+"_hidden\">";
		html+="<table width=\"600\" cellpadding=0 cellspsacing=0 border=0 style=\"table-layout:fixed;\">";
		html+="<col width=\"300\"><col width=\"100\"><col width=\"200\">";
		html+="<tr align=left valign=top><td colspan=3 align=left valign=top><b>";
		html+="Por favor selecciona las tres (3) tiendas que te resulten de más fácil acceso:";
		html+"</b></td></tr>";
		html+="<tr align=left valign=top>";
			html+="<td align=left valign=top><div id=\"div_"+controlName+"\"></div></td>";
			html+="<td align=left valign=top><input style=\"width:80px;\" title=\"pulsa aquí para agregar una tienda...\" onclick=\"showLocales('"+controlName+"',null,null,'+','"+formName+"');\" type=\"button\" class=botonGris value=\"[+] Agregar\" name=\"addLocal\"></td>";
			html+="<td align=left valign=top><span title=\"pulse aquí para ver el mapa de ubicación de la tienda...\" class=\"erLink\" onclick=\"showLocales('"+controlName+"',null,null,'m','"+formName+"');\">Ver el mapa</span></td>";
		html+="</tr>";
		html+="<tr align=left valign=top><td height=1 colspan=3 bgcolor=\"#ff0000\"></td></tr>";
		html+="<tr align=left valign=top><td colspan=3 align=left valign=top><div id=\"div_2_"+controlName+"\"></div></td></tr>";
		html+="</table>";
		html+="</div>";
		document.write(html);html=null;
	};
	if(toDo==null){toDo="";}
	if(toDo==""){if(retValue==null){retValue="";}if(retValue==""){retValue=",";};if(document.all){document.all[controlName+"_hidden"].value=retValue;}else{document.forms[formName][controlName+"_hidden"].value=retValue;};}else{retValue=document.forms[formName][controlName+"_hidden"].value;if(toDo=="+"){if(thisValue==null){thisValue=document.getElementById(controlName).value;};if(retValue.indexOf((","+thisValue+","))!=-1){return;};retValue+=thisValue+",";document.forms[formName][controlName+"_hidden"].value=retValue;}else if (toDo=="-"){if(thisValue==null){return;};if(thisValue==""){return;};if (retValue.indexOf((","+thisValue+","))==-1){return;};retValue = retValue.replace(","+thisValue+",",",");document.forms[formName][controlName+"_hidden"].value=retValue;}else{if(thisValue==null){thisValue=document.getElementById(controlName).value;};var index=-1;for(var x=0;x<locales.length;x++){if(thisValue==locales[x][0]){index=x;break;}};if(index==-1){alert("por favor selecciona primero la tienda...");return;};window.open("/popup/vermapa.asp?file="+locales[index][2]+"&idLocal="+locales[index][0],"_blank","directories=no,height=370,width=320,titlebar=no,status=no,scrollbars=no,menubar=no");return;};};
	var selLocales = retValue.split(",");
	if(document.getElementById(controlName)){className=$(document.getElementById(controlName)).attr("class");if(className!=""){className=" class=\""+className+"\" ";};};
	var html = "<select "+className+" style=\"width:99%;\" name=\""+controlName+"\" id=\""+controlName+"\" size=1>";html+="<option style=\"color:#606060;\" value=\"\">- - seleccione la tienda - -</option>";for(var i=0;i<locales.length;i++){if (retValue.indexOf(","+(locales[i][0]+","))==-1){html+="<option value=\""+locales[i][0]+"\">- "+locales[i][1]+"</option>";};};html+="</select>";
	document.getElementById("div_"+controlName).innerHTML=html;html=null;
	var html="<table width=\"98%\" cellpadding=0 cellspsacing=0 border=0 style=\"table-layout:fixed;\">";
	html+="<col width=\"50%\"><col width=\"45%\">";
	var countLocales = 0;var tempValues="";
	for(var i=0;i<selLocales.length;i++){
		var index=-1;
		if(selLocales[i]!=""){
			for(var x=0;x<locales.length;x++){if(selLocales[i]==locales[x][0]){index=x;break;}};
			if(index>-1){
				countLocales+=1;
				if(countLocales<4){
					tempValues+=selLocales[i]+","; 
					html+="<tr align=left valign=top>";
					html+="<td align=left valign=top>";
					html+="<b>- "+locales[x][1]+"</b>";
					html+="</td>";
					html+="<td align=left valign=top>";
					html+="<span onmouseover=\"this.style.color='#ff0000';\" onmouseout=\"this.style.color='#0000ff';\" ";
					html+="title=\"pulse aquí para remover este local de la lista...\" onclick=\"showLocales('"+controlName+"',null,'"+locales[x][0]+"','-','"+formName+"');\" ";
					html+="style=\"cursor:pointer;color:#0000ff;\">&nbsp;[&nbsp;x&nbsp;]&nbsp;remover</span>";
					html+="</td>";		
					html+="</tr>";
					html+="<tr align=left valign=top><td height=1 colspan=2 bgcolor=\"#909090\"></td></tr>";
				}else{
					alert("Solo debes seleccionar un máximo de tres locales. El resto será ignorado.");
				};					
			};
		};
	};
	if(tempValues!=""){retValue=","+tempValues;	document.forms[formName][controlName+"_hidden"].value=retValue;};
	if(countLocales==0){
		html+="<tr align=left valign=top>";
		html+="<td colspan=2 align=left valign=top>";
		html+="- - -";
		html+="</td>";
		html+="</tr>";			
	};
	html+="</table>";
	document.getElementById("div_2_"+controlName).innerHTML=html;html=null;
};

function codeRefresh(dest){
	if(document.getElementById("usu_docnumero")){var usu_docnumero=document.getElementById("usu_docnumero").value;}else{var usu_docnumero="";}
	if(document.getElementById("usu_doctipo")){var usu_doctipo=document.getElementById("usu_doctipo").value;}else{var usu_doctipo="";}
	if(document.getElementById("usu_email")){var usu_email=document.getElementById("usu_email").value;}else{var usu_email="";}
	if(document.getElementById("remitir")){var bot=document.getElementById("remitir").disabled=true;}
	document.step1.action = dest;
	document.step1.pag.value = "";
	document.step1.submit();		      
  };
function registra_step1(obj){
	$(".formError").html("").css("display","none");
	obj.remitir.disabled=true;var textErr="";var errCount=0;var men="";
	if(obj.usu_email.value==""){
		errCount+=1; men="No has ingresado ninguna dirección de e-mail.\n"; textErr+="- "+men;marcaError("usu_email",men);
	}else if(!isValidMail(obj.usu_email.value.trim())){
		errCount+=1; men="La dirección de e-mail que has ingresado No parece válida.\n"; textErr+="- "+men;marcaError("usu_email",men);
	};
	if(document.getElementById("usu_doctipo").value==""){errCount+=1; men="No has seleccionado el tipo de documento!\n"; textErr+="- "+men; marcaError("usu_doctipo",men);};	
	if(document.getElementById("usu_docnumero").value==""){errCount+=1; men="No has ingresado tu número de documento!\n"; textErr+="- "+men; marcaError("usu_docnumero",men);};
	if(obj.codigo.value.length!=5){errCount+=1; men="No has ingresado el código de verificación exactamente como aparece en la imagen mostrada!\n"; textErr+="- "+men; marcaError("codigo",men);};
	if (!obj.terminos.checked){errCount+=1;men="Debes marcar la casilla de aceptación de los \"Términos y Condiciones\" en las que se brinda el servicio para poder registrarte!\n";textErr+="- "+men; marcaError("terminos",men);};
	if (textErr!=""){textErr =	"Hay " + errCount + " errores u omisiones en el formulario de registro que deseas remitir:\n"+
								"\n"+textErr;alert(textErr);obj.remitir.disabled=false;return false;
	};	
	return true;
};  
function showCargos(controlName,retValue,controlName1,retValue1,obj,className){
	if(className==null){className="";};if(className!=""){className=" class=\""+className+"\" ";};
	if(retValue==null){retValue="";}if(retValue1==null){retValue1="";}
	if(obj==null){var objValue=retValue;}else{objValue=obj.value;};
	if (!document.getElementById(controlName+"_div")){
		var html="<table cellpadding=0 cellspasing=0 border=0 width=\"100%\" style=\"table-layout:fixed;\">";
		html+="<tr align=left valign=top><td align=left valign=top><span class=\"erRegPregunta\">Seleccione el área:<sup class=req>1</sup></span>";
		html+="<div id=\""+controlName+"_div\">";
		var cCargo = "";
		html+="<select "+className+" style=\"width:99%;\" name=\""+controlName+"\" id=\""+controlName+"\" size=1 onchange=\"showCargos('"+controlName+"','"+retValue+"','"+controlName1+"','"+retValue1+"',this);\">";
		html+="<option value=\"\"> -- seleccione el área --</option>";
		for (var i=0;i<acargos.length;i++){
			if(cCargo!=acargos[i][0]){
				cCargo=acargos[i][0];
				html+="<option ";if(retValue==acargos[i][0]){html+="selected ";};
				html+="value=\""+acargos[i][0]+"\">"+acargos[i][1]+"</option>";
			};
		};
		html+="</select></div>";
		html+=men_idArea+"</td><td align=left valign=top><span class=\"erRegPregunta\">Seleccione el cargo:<sup class=req>1</sup></span>";
		html+="<div id=\""+controlName1+"_div\"></div>";
		html+=men_idCargo+"</td></tr>";	
		html+="</table>";
		document.write(html);html=null;
	};
	var html="<select "+className+" style=\"width:99%;\" name=\""+controlName1+"\" id=\""+controlName1+"\" size=1>";
	html+="<option value=\"\"> -- seleccione el cargo --</option>";
	for (var i=0;i<acargos.length;i++){
		if(objValue==acargos[i][0]){
			html+="<option ";if(retValue1==acargos[i][2]){html+="selected ";};
			html+="value=\""+acargos[i][2]+"\">"+acargos[i][3]+"</option>";
		};
	};
	html+="</select>";		
	document.getElementById(controlName1+"_div").innerHTML=html;html=null;
};
function registra_step2(obj,objForm){
	var objValue = obj.value;
	var objTitle = obj.title;
	obj.value = "espere...";
	obj.title = "por favor espere unos segundo mientras se válida su registro...";
	obj.disabled = true;
	objForm.submit();
};
function verMapa(idRef) {
    return;
	if(idRef==null){return;}
	if(!document.getElementById(idRef)){return;};
	html="</b>&nbsp; <span title=\"pulse aquí para ver el mapa de ubicación de este local...\" class=verMapa onmouseover=\"this.style.color='#FF0000';\" onmouseout=\"this.style.color='#0000FF';\" onclick=\"viewMap('"+idRef+"');\">[ver mapa]</span>";
	document.write(html);html=null;
};
function viewMap(id){
	var idLocal = document.getElementById(id).value;
	var index = -1;
	for(var i=0;i<locales.length;i++){if(locales[i][0]==idLocal){index=i;break;}};
	if(index==-1){alert("por favor seleccione el local...");return;};
	window.open("/popup/vermapa.asp?file="+locales[index][2]+"&idLocal="+idLocal,"_blank","directories=no,height=370,width=320,titlebar=no,status=no,scrollbars=no,menubar=no");
};




	

    function showCheckBox(controlName,controlValor,valorOn){
		if(valorOn==null){valorOn="-1";};
		var html="<input type=\"checkbox\" id=\""+controlName+"\" name=\""+controlName+"\" value=\""+valorOn+"\"";
		if(valorOn==controlValor){html+="checked>";}else{html+=">";}
		document.write(html);html=null;
    };
    function showRadio(controlName,retValue,defValue){
		if(retValue==null){retValue="";};
		if(defValue==null){defValue=="";};
		var html="<input type=\"radio\" name=\""+controlName+"\" id=\""+controlName+"\" value=\""+defValue+"\" ";
		if(retValue==defValue){html+="checked >";}else{html+=">";}
		document.write(html);html=null;
	};
    function showTipoCargo(controlName,retValue){
		var html="";
		for(var i=0;i<tCargos.length;i++){
			html+="<div><input type=radio name=\""+controlName+"\" id=\""+controlName+"\" value=\""+tCargos[i][0]+"\" onclick=\"viewCargos(this);\"";
			if(retValue==tCargos[i][0]){html+="checked> <b>";}else{html+="> <b>";};
			html+=tCargos[i][1]+"</b> ("+tCargos[i][2]+")</div>";
		};
		document.write(html);html=null;
    };
	function viewCargos(obj){
		if((!document.getElementById("cargoTipo_1"))||(!document.getElementById("cargoTipo_2"))){return;};
		if (obj.value=="1"){
			document.getElementById("cargoTipo_1").style.display="block";
			document.getElementById("cargoTipo_2").style.display="none";
		}else{
			document.getElementById("cargoTipo_2").style.display="block";
			document.getElementById("cargoTipo_1").style.display="none";
		};
	} ; 
	//["21","1","ADMINISTRADOR BASE DATOS"]
	function showcargos(controlName,arrayObj,retValue,index,widthValue){
	  if(retValue==null){retValue="";};
	  if(index==null){index=="0";};
	  if(widthValue==null){widthValue="";}else{widthValue=" style=\"width:"+widthValue+";\" ";};
	  var html="<select"+widthValue+"id=\""+controlName+"\" class=\"inputText\" name=\""+controlName+"\" size=\"1\">";
	  html+="<option value=\"\">- - -</option>";
	  for(var i=0;i<arrayObj.length;i++){
		if(index==arrayObj[i][1]){
	  		html+="<option ";if(retValue==arrayObj[i][0]){html+="selected ";};
	  		html+="value=\""+arrayObj[i][0]+"\">"+arrayObj[i][2]+"</option>";
		};
	  };
	  html+="</select>";
	  document.write(html);html=null;
    };
    function setCargo(){
		var t = document.getElementsByName("pex_cargo_tipo");
		if (t[0].value=="1"){
			document.getElementById("cargoTipo_1").style.display="block";
			document.getElementById("cargoTipo_2").style.display="none";
		}else if (t[1].value=="2"){
			document.getElementById("cargoTipo_2").style.display="block";
			document.getElementById("cargoTipo_1").style.display="none";
		};		
    };

	
