$(document).ready(function(){
	$("#ubicate").hide();
	if(chreultados==1){
		$("#ubicate").show();
	}


	var strbsqavanzada=false;
	jQuery.ajaxSettings.async=false;
	var chreultados= $('#bta_resultados').val();
	var valor;
	if(chreultados==0)
	{
		var pestana='';
				if(pestana=='')
				{
					document.getElementById('pestana').value=1;
				}else{
					pestana=pestana;
				}
	}else{
		pestana=pestana;
		//$("#vn").attr('disabled','disabled');
	}
	/*Inicia Nuevo Diseño de Buscador*/
       /*Div de Adjudicados Bancomer*/

       $("#adjudicados_inm").hide();

			 $("#buscar1").hide();
			 $("#buscar3").hide();
			 $("#buscar2").hide();
			 $("#buscar4").hide();

       $("#ad_ban").click(function(){
								 pestana=2;

						//$("#vn").attr('disabled','disabled');
						$("#back").attr('background','img_buscador/backcompleto.jpg')
						$("#to_in").attr('src', 'img_buscador/todos_claro.jpg');
						$("#ad_ban").attr('src', 'img_buscador/adjudicados_oscuro.jpg');

						$("#todos_inm").hide();
						$("#adjudicados_inm").show();

							 $("#buscar1").hide();
							 $("#buscar3").hide();
							 $("#buscar2").hide();
							 $("#buscar4").hide();
							 $("#bus_a").hide();

							$('#vu').removeAttr('checked');
							$('#vn').removeAttr('checked');
							$('#idtipoinmueble2').hide();
							$('#estado').hide();
							$('#idmunicipio').hide();
							$('#idcolonia').hide();
							$('#ubicate').hide();
							document.getElementById('pestana').value=pestana;
       });
       $("#to_in").click(function(){
				 		pestana=1;
            $("#back").attr('background','img_buscador/backtodos.jpg')
            $("#to_in").attr('src', 'img_buscador/todos_obs.jpg');
            $("#ad_ban").attr('src', 'img_buscador/adjudicados_claro.jpg');
            $("#adjudicados_inm").hide();
            $("#todos_inm").show();
            $("#bus_a").hide();

					 $("#buscar1").hide();
					 $("#buscar3").hide();
					 $("#buscar2").hide();
					 $("#buscar4").hide();

            	//$('#vn').removeAttr('disabled');
				$('#vn').removeAttr('checked');
				$('#vu').removeAttr('checked');
            	$('#idtipoinmueble2').hide();
            	$('#estado').hide();
            	$('#idmunicipio').hide();
            	$('#idcolonia').hide();
				$('#ubicate').hide();


							document.getElementById('pestana').value=pestana;
        });

/*Listado de propieades*/

			$("#to_in2").click(function(){
				pestana=1;
				$('#pestana').val(1);
				$("#to_in2").attr('src', '/img_buscador/btn_lis1.jpg');
				$("#ad_ban2").attr('src', '/img_buscador/btn_lis2.jpg');
				$("#bakkend").attr('background', '/img_buscador/back_listado1.jpg');
				validagobsq();
			});
			$("#ad_ban2").click(function(){
				pestana=2;
				$("#to_in2").attr('src', '/img_buscador/btn_lis3.jpg');
				$("#ad_ban2").attr('src', '/img_buscador/btn_lis4.jpg');
				$("#bakkend").attr('background', '/img_buscador/back_listado22.jpg');
				$('#pestana').val(2);
				validagobsq();
			});

        $("#btnavanzax").click(function(){
							strbsqavanzada=true;
							$("#bus_a").show();
				});

		/*Fin Nuevo Buscador*/

	if( (chreultados==1)){
		valor=$('#jsopcion').val();
		if($('#vn').attr('checked')==true)
		{
			$('#imgbavanz').attr({'src':'/imgs/btnbuscar21.jpg'});
		}else{
			$('#imgbavanz').attr({'src':'/imgs/btn_todosinmuebles.jpg'});
		}
		if (valor==1){
			$("#idtipoinmueble2").hide();
			$("#desimagen").hide();
		}else{
			$('#idtipoinmueble2').show();
			$("#desimagen").show();
		}
		$('#estado').show();
		$('#idmunicipio').show();
		$('#idcolonia').show();
		$('#imgubica').show();
		$('#busqavanzada').show();
		$("#desimagen2").show();
	}else{
		$('#idtipoinmueble2').hide();
		$('#estado').hide();
		$('#idmunicipio').hide();
		$('#idcolonia').hide();
		$('#imgubica').hide();
		$('#busqavanzada').hide();
		$("#desimagen").hide();
		$("#desimagen2").hide();
	}

	$("#vn").click(function(){
	$("#ubicate").hide();
		if(pestana==2)
		{
			noadjudicadosn();
		}else{
			strbsqavanzada=false;
			valor = $(this).val();
			if(valor==1)
			{
				$('#imgbavanz').attr({'src':'/imgs/btnbuscar21.jpg'});
				$('#idtipoinmueble2').hide();
				$('#imgubica').show();
				$('#buscar1').hide();
				$('#buscar3').hide();
				$('#buscar2').hide();
				$('#buscar4').hide();

				a2(valor);
				mostrar_controles();
				$("#ubicate").show();
				$('#estado').show();
			}
		}
	});
	$("#vu").click(function(){
		strbsqavanzada=false;
		$("#ubicate").hide();
		valor = $(this).val();
		if(valor==2)
		{
			$('#idtipoinmueble2').show();
			$('#imgubica').hide();
		 	$('#buscar1').hide();
		 	$('#buscar3').hide();
		 	$('#buscar2').hide();
		 	$('#buscar4').hide();

			a2(valor);
			mostrar_controles();
		}
	});

	$('#idtipoinmueble2').change(function(){
		 idtipoinmueble3=$(this).val();
		 a5();
		$("#ubicate").show();
		 $('#estado').show();
		 $('#idmunicipio').hide();
		 $('#idcolonia').hide();
		 $('#imgubica').show();
		 
	});

	$('#idmunicipio').change(function(){
		a4();
		$('#idcolonia').show();
	});

	$('#estado').change(function(){
		valor2=$('#idtipoinmueble2').val();
		a3();
		$('#idmunicipio').show();
		if(pestana==1){
				$('#buscar1').show();
					//if(valor2==4 || valor2==8 || valor2==14){
				if(valor2<=14){
						$('#buscar3').show();
					}else{
						$('#buscar3').hide();
					}
				}
				else{
					$('#buscar2').show();
					//if(valor2==4 || valor2==8 || valor2==14){
					if(valor2<=14){
						$('#buscar4').show();
					}else{
						$('#buscar4').hide();
					}
			}

		$('#idcolonia').hide();
		if(valor==1){
			$("#desimagen").hide();
		}else{
			if (!strbsqavanzada)
				$("#desimagen").show();
		}

		if (!strbsqavanzada){
			$("#desimagen2").show();
			if(valor==1)
				$('#imgbavanz').attr({'src':'/imgs/btnbuscar21.jpg'});
			else
				$('#imgbavanz').attr({'src':'/imgs/btn_todosinmuebles.jpg'});
			$('#busqavanzada').show();
		}

	});

	$("#btnavanzax1").click(function(){
		strbsqavanzada=true;
		$("#buscar1").hide();
		$("#buscar3").hide();
		$("#bus_a").show();
	});

	$("#btnavanzax2").click(function(){
		pestana=document.getElementById('pestana').value;
		strbsqavanzada=true;
		$("#buscar2").hide();
		$("#buscar4").hide();
		$("#bus_a").show();
		if(pestana==1){
			$('#imgbuscaravanzados').hide();
			$("#urlavavza").attr('href','javascript:validago();');
		}else{
			$('#imgbuscaravanzados').hide();
			$("#urlavavza").attr('href','javascript:validago2();');
		}

	});

	$("#busqavanzada").click(function(){
		strbsqavanzada=true;
		$("#bus_a").show();
		$("#busqavanzada").hide();
			$("#bus_a").show(function(){
				if(valor==1){
					$("#desimagen").hide();
					$("#desimagen2").hide();
					$("#imgbuscaravanzados").hide();
					$('#imgjrbusca').attr({'src':'/imgs/btnbuscar21.jpg'});
				}else{
					$("#desimagen").hide();
					$("#desimagen2").hide();
					$("#imgbuscaravanzados").show();
					$('#imgjrbusca').attr({'src':'/imgs/btn_todosinmuebles.jpg'});
				}
			});
	});

});
	function mostrar_controles(){
		$("#busqavanzada").hide();
		$("#desimagen").hide();
		$("#desimagen2").hide();
		$('#estado').hide();
		$('#idmunicipio').hide();
		$('#idcolonia').hide();
		$("#bus_a").hide();
		$("#bus_a input").val('');
		$("#bus_a select").val('0');
	}


var nav4 = window.Event ? true : false;
function acceptNum(evt){
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key>= 48 && key <= 57));
}

function validaTerminos(obj)
{
	if(obj.checked)
	{
		obj.value=1;
	}else{
		obj.value=0;
	}
}

function valida_contban(){
	if(document.frmconban.nombre_alp.value!="")
	{
		if(document.frmconban.lada_alp.value!="")
		{
			if(document.frmconban.tel_alp.value!="")
			{
				if(validateEmail(document.frmconban.email_alp.value))
				{
   var i
    for (i=0;i<document.frmconban.ent.length;i++){
       if (document.frmconban.ent[i].checked)
          break;
    }
    document.frmconban.ent.value= document.frmconban.ent[i].value;
		strlinea="inserconta.m3?idcanal="+document.frmconban.idcanal.value+"&nombre="+document.frmconban.nombre_alp.value+"&lada="+document.frmconban.lada_alp.value+"&tel="+document.frmconban.tel_alp.value+"&email1="+document.frmconban.email_alp.value+"&coment="+document.frmconban.comentariosp.value+"&ent="+document.frmconban.ent.value;
								makeRequest(strlinea, modulo2);
				}else{
					alert("El mail no puede ir en blanco");
				}
			}else{
				alert("El Telefono no puede ir en blanco");
			}
		}else{
			alert("El lada no puede ir en blanco");
		}
	}else{
		alert("El nombre no puede ir en blanco");
	}

}
function valida_reganun()
{
	if(document.frman_reg.chk1.value==1)
	{
		a=document.frman_reg.an_nombre.value;b=document.frman_reg.an_paterno.value;c=document.frman_reg.an_materno.value;
		d=document.frman_reg.an_estado.value;e=document.frman_reg.an_municipio.value;f=document.frman_reg.an_colonia.value;
		g=document.frman_reg.an_calle.value;h=document.frman_reg.an_calle.value;i=document.frman_reg.an_numext.value;j=document.frman_reg.an_numint.value;
		k=document.frman_reg.an_lada1.value;l=document.frman_reg.an_tel1.value;m=document.frman_reg.an_lada2.value;n=document.frman_reg.an_tel2.value;
		o=document.frman_reg.crm_email.value;p=document.frman_reg.crm_pass.value;q=document.frman_reg.crm_pass2.value;
		if (document.frman_reg.an_nombre.value != '')
		{
			if (document.frman_reg.an_paterno.value != '')
			{
				if (document.frman_reg.an_materno.value != '')
				{
					if(document.frman_reg.an_estado.selectedIndex>0)
					{
						if(document.frman_reg.an_municipio.selectedIndex>0)
						{
							if(document.frman_reg.an_colonia.selectedIndex>0)
							{
								if (document.frman_reg.an_calle.value != '')
								{
										if(document.frman_reg.an_numext.value != '')
										{
												if(document.frman_reg.an_lada1.value != '')
												{
													if(document.frman_reg.an_tel1.value != '')
													{
																if (validateEmail(document.frman_reg.crm_email.value))
																{
																	if(document.frman_reg.crm_pass.value != '')
																	{
																		if(document.frman_reg.crm_pass2.value != '')
																				{
												if(document.frman_reg.crm_pass.value==document.frman_reg.crm_pass2.value){
				makeRequest("anunciate/inserta_p.m3?a="+a+"&b="+b+"&c="+c+"&d="+d+"&e="+e+"&f="+f+"&g="+g+"&h="+h+"&i="+i+"&j="+j+"&k="+k+"&l="+l+"&m="+m+"&n="+n+"&o="+o+"&p="+p+"&q="+q, regpart);}else{
				alert("La contraseña y confirmacion de contraseñas son diferentes");
				}
								//document.frman_reg.submit();

																		}else{
																		alert("Debe proporcionar nuevamente sus contraseña para verificación");
																		document.frman_reg.crm_pass2.focus();
																		}
																	}else{
																	alert("Debe proporcionar una Contraseña");
																	document.frman_reg.crm_pass.focus();
																	}
																}else{
																alert("Debe proporcionar un E-mail");
																	document.frman_reg.crm_email.focus();
																}

															}else{
														alert("Debe proporcionar un teléfono");
														document.frman_reg.an_tel1.focus();
														}
												}else{
												alert("Debe proporcionar una lada");
												document.frman_reg.an_lada1.focus();
												}
										}else{
										alert("Debe proporcionae un numero Exterior");
										document.frman_reg.an_numext.focus();
										}
										}else{
									alert("Debe proporcionar una calle");
									document.frman_reg.an_calle.focus();
								}
							}else{
							alert("Debe seleccionar una Colonia");
							}
						}else{
						alert("Debe seleccionar un Municipio");
						}
					}else{
					alert("Debe seleccionar un Estado");
					}
				}else{

					alert("Debe de proporsionar su Apellido materno");
					document.frman_reg.an_materno.focus();
				}
			}else{

				alert("Debe de proporsionar su Apellido paterno");
				document.frman_reg.an_paterno.focus();
			}
		}else{

			alert("Debe de proporsionar su nombre");
			document.frman_reg.an_nombre.focus();
		}
	}else{
		alert("Debe aceptar los términos y condiciones de uso para continuar");
		document.frman_reg.chk1.focus();
	}
}
function regpart(){
	if (http_request.readyState == 4){
		if (http_request.status == 200){
			datos=http_request.responseText;
			eval(datos);
		}else{
			alert("no se encontraron datos");
		}
	}
}
function muestraf(){
	document.getElementById("flashc").style.visibility='visible';
}
function muestraf2(){
	document.getElementById("flashc").style.visibility='visible';
	$('#vu').attr('checked','checked')
	valor = $('#vu').val();
	$('#idtipoinmueble2').show();
	a2(valor);
	mostrar_controles();
}
function iniciando(valSesion){
	if(valSesion==0){
		document.getElementById("flashc").style.visibility='hidden';
		sw(200,200,1);
		ss='<div id="carga_sec"><table bgcolor="#FFFFFF" width="250" height="175" border="0" cellpadding="0" cellspacing="0"><tr><td align="right" valign="top" height="10"><a class="tsess1" href="javascript:closewin(); muestraf();">Cerrar&nbsp;<img border="0" src="http://www.metroscubicos.com/m3/usuweb/close.png"></a></td></tr><tr><td height="120" valign="top"><form name="frmusl"><div id="logns"><table border="0" cellpadding="0" cellspacing="0" height="100"><tr><td colspan="3" class="tsess1" height="40">&nbsp;&nbsp;&nbsp;Inicia sesión</td></tr><tr><td colspan="3" class="tsess1">&nbsp;&nbsp;&nbsp;No eres usuario registrado, <a class="tsess1" href="/metros/bancomer/index.m3?idcanal=1&idsubcanal=1&pinta=0">regístrate</a><br><br></td></tr><td height="10"></td><td class="tsess1">Correo electrónico&nbsp;</td><td><input style="width:100px" name="l_usr" class="campos" type="text"></td></tr><tr><td width="10"></td><td class="tsess1">Contraseña&nbsp;</td><td><input style="width:100px" name="l_pw" class="campos" type="password"></td></tr><input type="hidden" name="idcanal" value="5"><input type="hidden" name="presenta" value="21"></div></form><tr><td height=10></td></tr><tr><td colspan="3" align="right" height="20"><a href="javascript:accsoBncmr(10058)"><img src="/imgs/enviargen2.jpg" border=0></a><br></td></tr></table></td></tr></table>';
		document.getElementById(idFillbox).innerHTML=ss;
	}else{
		window.location.href='/usuweb/index.m3';
	}
}
function noadjudicadosn(){
		document.getElementById("flashc").style.visibility='hidden';
		sw(200,200,1);
		ss='<table bgcolor="#FFFFFF" width="250" height="129" border="0" cellpadding="0" cellspacing="0"><tr><td align="right" valign="middle" height="10"><table><tr><td><a class="tsess1" href="javascript:closewin(); muestraf2();">Cerrar&nbsp;<img border="0" src="http://www.metroscubicos.com/m3/usuweb/close.png"></a></td>&nbsp;<td></td></tr></table></td></tr><tr><td height="104" valign="top"><div id="logns"><table border="0" cellpadding="0" cellspacing="0" height="81" width="250"><tr><td class="tsess1" width="10">&nbsp;&nbsp;&nbsp;<br><br></td><td class="tsess1" width="218">	<p align="center">Estimado cliente por el momento no contamos con vivienda adjudicada nueva, le invitamos a consultar nuestra oferta de segundo uso</td><td class="tsess1" width="16">&nbsp;</td></tr><input type="hidden" name="idcanal" value="5"><input type="hidden" name="presenta" value="21"></div></table></td></tr></table>';
		document.getElementById(idFillbox).innerHTML=ss;
}
ptaule=0;
function ptaul(idregion){
	if (ptaule==0){
		document.getElementById('carga_sec').innerHTML='<div id=carga_sec><table bgcolor="#FFFFFF" width="250" height="175" border="0" cellpadding="0" cellspacing="0"><tr><td align="right" valign="top" height="10"><a class=tsess1 href="javascript:closewin(); muestraf();">Cerrar &nbsp;<img border=0 src=http://www.metroscubicos.com/m3/usuweb/close.png></a></td></tr><tr><td height="120" valign=top><form name="frmusl"><div id=logns><table border=0 cellpadding=0 cellspacing=0 height="100"><tr><td colspan=3 class="tsess1" height=40>&nbsp;&nbsp;&nbsp;Inicia sesión</td></tr><tr><td colspan=3 class="tsess1">&nbsp;&nbsp;&nbsp;No eres usuario registrado, <a class=tsess1 href="/metros/bancomer/index.m3?idcanal=1&idsubcanal=1&pinta=0">regístrate</a><br><br></td></tr><td height="10"></td><td class="tsess1">Correo electrónico&nbsp;</td><td><input style="width:100px" name="l_usr" class="campos" type="text"></td></tr><tr><td width="10"></td><td class="tsess1">Contraseña&nbsp;</td><td><input style="width:100px" name="l_pw" class="campos" type="password"></td></tr><input type=hidden name=idcanal value=5><input type=hidden name=presenta value=21></div></form><tr><td height=10></td></tr><tr><td colspan="3" align="right" height="20"><a href="javascript:accsoBncmr(10058)"><img src="/imgs/enviargen2.jpg" border=0></a><br></td></tr></table></td></tr></table>';
		ptaule=1;
		document.frmusl.l_usr.focus();
	}else{
		document.getElementById('carga_sec').innerHTML="";
		ptaule=0;
	}
}
function accsoBncmr(idregion){
	us=document.frmusl.l_usr.value;
	up=document.frmusl.l_pw.value;
	ub=pasoa5("" + us + up);
	document.getElementById('carga_sec').innerHTML="<center><img src=/m3/images/spinner.gif></center>";
	us=Clase64.shadow(DespN(us));
	up=Clase64.shadow(DespN(up));
	strlinea="/valida.m3?us=" + us + "&up=" + up +"&ub=" + ub +"&idregion=10058";
	makeRequest(strlinea, modulo3_b)
	if (us!="" && up!=""){
		document.getElementById('carga_sec').innerHTML='<table bgcolor="#FFFFFF" width="200" height="200" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle" class="tsess1" style="color: #ff0000">Validando usuario...<img src=/m3/images/spinner.gif></td></tr></table>';
	}else{
		document.getElementById('carga_sec').innerHTML='<table bgcolor="#FFFFFF" width="200" height="200" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle" class="tsess1">Datos incorrectos!!!<br>Espere un momento...<img src=/m3/images/spinner.gif></td></tr></table>';
		setTimeout("ptaule=0;ptaul();",1000);
	}
}
function modulo3_b(){
	if (http_request.readyState == 4){
		if (http_request.status == 200){
			datos=http_request.responseText;
			eval(datos);
		}else{
			alert("no se encontraron datos");
		}
	}
}
function val_promo(){
	if(document.frmpromueve.nombre_alp.value!=""){
		if(document.frmpromueve.lada_alp.value!=""){
			if(document.frmpromueve.tel_alp.value!=""){
				if(validateEmail(document.frmpromueve.email_alp.value)){
					if (document.frmpromueve.estado_alp.selectedIndex>0){
						if (document.frmpromueve.Municipio_alp.selectedIndex>0){
							if (document.frmpromueve.colonia_alp.selectedIndex>0){
								if(document.frmpromueve.comentariosp.value!=""){
											var s ="no";
											for ( var i = 0; i < document.frmpromueve.ent.length; i++ ){
												if (document.frmpromueve.ent[i].checked){
													s= "si";
													document.frmpromueve.ent.value= document.frmpromueve.ent[i].value;
													break;
												}
											}
											if (s=="no"){
												document.frmpromueve.ent.value=0;
											}
											strlinea="/promotores/insertpromo.m3?idcanal="+document.frmpromueve.idcanal.value+"&nombre="+document.frmpromueve.nombre_alp.value+"&lada="+document.frmpromueve.lada_alp.value+"&tel="+document.frmpromueve.tel_alp.value+"&email1="+document.frmpromueve.email_alp.value+"&email2="+document.frmpromueve.email_alp2.value+"&idestado="+document.frmpromueve.estado_alp.value+"&idmunicipio="+document.frmpromueve.Municipio_alp.value+"&idcolonia="+document.frmpromueve.colonia_alp.value+"&cp="+document.frmpromueve.CPp.value+"&coment="+document.frmpromueve.comentariosp.value+"&ent="+document.frmpromueve.ent.value+"&otra="+document.frmpromueve.otra.value;
											makeRequest(strlinea, modulo2);
								}else{
										alert("Por favor escriba su mensaje");
								}
							}else{
								alert("Debe Seleccionar una Colonia");
							}
						}else{
							alert("Debe Seleccionar un Municipio");
						}
					}else{
						alert("Debe Seleccionar un Estado");
					}
				}else{
					alert("El mail no puede ir en blanco");
				}
			}else{
				alert("El Telefono no puede ir en blanco");
			}
		}else{
			alert("El lada no puede ir en blanco");
		}
	}else{
		alert("El nombre no puede ir en blanco");
	}
}
function anmun(){
	makeRequest("anunciate/cargacomboxa.m3?idopcion=1&idestado="+document.frman_reg.an_estado.value, modulo2);
}
function ancol(){
	makeRequest("anunciate/cargacomboxa.m3?idopcion=2&idestado="+document.frman_reg.an_estado.value+"&idmunicipio="+document.frman_reg.an_municipio.value, modulo2);
}
function ancp(){
	makeRequest("anunciate/cargacomboxa.m3?idopcion=3&idestado="+document.frman_reg.an_estado.value+"&idmunicipio="+document.frman_reg.an_municipio.value+"&idcolonia="+document.frman_reg.an_colonia.value, modulo2);
}
function ancpp(){
	makeRequest("promotores/cargacombos.m3?idopcion=3&idestado="+document.frmpromueve.estado_alp.value+"&idmunicipio="+document.frmpromueve.Municipio_alp.value+"&idcolonia="+document.frmpromueve.colonia_alp.value, modulo2);
}
function municipio(){
	makeRequest("alarma/cargacombos.m3?idopcion=1&idestado="+document.frmalarma.estado_al.value, modulo2);
}
function colonia(){
	makeRequest("alarma/cargacombos.m3?idopcion=2&idestado="+document.frmalarma.estado_al.value+"&idmunicipio="+document.frmalarma.Municipio_al.value, modulo2);
}
function municipiop(){
	makeRequest("promotores/cargacombos.m3?idopcion=1&idestado="+document.frmpromueve.estado_alp.value, modulo2);
}
function coloniap(){
	makeRequest("promotores/cargacombos.m3?idopcion=2&idestado="+document.frmpromueve.estado_alp.value+"&idmunicipio="+document.frmpromueve.Municipio_alp.value, modulo2);
}
function valida_encuesta(){
	var val = "";
	var val1 = "";
	var val2 = "";
	var val3 = "";
	var val4 = "";
	var val5 = "";
	var rad = document.frmsalida.motivo;
	for (i = 0; i < rad.length; i ++){
		if (rad[i].checked) {
			val = rad[i].value;
		}
	}
	var rad1 = document.frmsalida.motivo_1;
	for (i = 0; i < rad1.length; i ++){
		if (rad1[i].checked) {
			val1 = rad1[i].value;
		}
	}
	var rad2 = document.frmsalida.calificas;
	for (i = 0; i < rad2.length; i ++){
		if (rad2[i].checked) {
			val2 = rad2[i].value;
		}
	}
	var rad3 = document.frmsalida.uso;
	for (i = 0; i < rad3.length; i ++)
	{
		if (rad3[i].checked){
			val3 = rad3[i].value;
		}
	}
	var rad4 = document.frmsalida.info_mostrada;
	for (i = 0; i < rad4.length; i ++){
		if (rad4[i].checked){
			val4 = rad4[i].value;
		}
	}
	var rad5 = document.frmsalida.contactado;
	for (i = 0; i < rad5.length; i ++)
	{
		if (rad5[i].checked) {
			val5 = rad5[i].value;

		}
	}
	strlinea="/alarma/encuesta.m3?idalarma="+document.frmsalida.idalarma.value+"&reactivo1="+val+"&reactivo11="+val1+"&reactivo2="+val2+"&reactivo3="+val3+"&reactivo4="+val4+"&reactivo5="+val5+"&comentarios="+document.frmsalida.comentarios.value;
	makeRequest(strlinea, modulo2);
}
function push_motivo(){
	var val = "";
	var rad = document.frmsalida.motivo;
	for (i = 0; i < rad.length; i ++)
	{
		if (rad[i].checked)
		{
			val = rad[i].value;
			if (val != 2){
				var elemento = document.getElementById('motivo1');
				elemento.style.display = "none";
				document.frmsalida.motivo_1.value="";
			}
		}
	}
}
function regresaFloat(valPrecio){
	var newCad="";
	for(i=0;i<valPrecio.length;i++){
		var char1=valPrecio.charAt(i);
		if(char1!=',' && char1!='$' && char1!=' '){
			newCad=newCad+char1;
		}
	}
	valPrecio=newCad;
	return parseFloat(valPrecio);
}
function valida_alarma(){
	if (document.frmalarma.nombre_al.value != ""){
		if (document.frmalarma.email_al.value != ""){
			if (validateEmail(document.frmalarma.email_al.value)){
				if (document.frmalarma.tel_al.value != ""){
					if (document.frmalarma.idcanal.selectedIndex>0){
						if (document.frmalarma.idtipoinmueble.selectedIndex>0){
							if (document.frmalarma.estado_al.selectedIndex>0){
								if (document.frmalarma.Municipio_al.selectedIndex>0){
									if (document.frmalarma.colonia_al.selectedIndex>0){
										if ((document.frmalarma.precioinf.value != 0 || document.frmalarma.precioinf.value != null) && (document.frmalarma.preciosup.value != 0 || document.frmalarma.preciosup.value != null)){
											var a=regresaFloat(document.frmalarma.precioinf.value);
											var b=regresaFloat(document.frmalarma.preciosup.value);
											if ((a<=b) && (b>=a)){
												strlinea="/alarma/alarma.m3?lada="+document.frmalarma.lada_al.value+"&idcanal="+document.frmalarma.idcanal[document.frmalarma.idcanal.selectedIndex].value+"&nombre="+document.frmalarma.nombre_al.value+"&mail="+document.frmalarma.email_al.value+"&telefono="+document.frmalarma.tel_al.value+"&idtipoinmueble=" + document.frmalarma.idtipoinmueble[document.frmalarma.idtipoinmueble.selectedIndex].value+"&idestado="+document.frmalarma.estado_al.value+"&idmunicipio="+document.frmalarma.Municipio_al.value+"&idcolonia="+document.frmalarma.colonia_al.value+"&precioinf="+a+"&preciosup="+b+"&rec="+document.frmalarma.rec.value+"&ban="+document.frmalarma.ban.value+"&esta="+document.frmalarma.esta.value+"&id_ins=1";
												makeRequest(strlinea, modulo2);
											}else{
												alert("Debe escribir una cantidad menor en Precio Desde");
												document.frmalarma.precioinf.focus();
											}
										}else{
											strlinea="/alarma/alarma.m3?idcanal="+document.frmalarma.idcanal.value+"&nombre="+document.frmalarma.nombre_al.value+"&mail="+document.frmalarma.email_al.value+"&telefono="+document.frmalarma.tel_al.value+"&idtipoinmueble=" + document.frmalarma.idtipoinmueble[document.frmalarma.idtipoinmueble.selectedIndex].value+"&idestado="+document.frmalarma.estado_al.value+"&idmunicipio="+document.frmalarma.Municipio_al.value+"&idcolonia="+document.frmalarma.colonia_al.value+"&precioinf="+document.frmalarma.precioinf.value+"&preciosup="+document.frmalarma.preciosup.value+"&rec="+document.frmalarma.rec.value+"&ban="+document.frmalarma.ban.value+"&esta="+document.frmalarma.esta.value+"&id_ins=1";
											makeRequest(strlinea, modulo2);
										}
									}else{
										alert("Debe seleccionar una Colonia");
									}
								}else{
									alert("Debe seleccionar un Municipio");
								}
							}else{
								alert("Debe seleccionar un Estado");
							}
						}else{
							alert("Debe seleccionar un tipo de inmueble");
						}
					}else{
						alert("Debe seleccionar un tipo de vivienda");
					}
				}else{
					alert("Debe de proporcionar un télefono");
					document.frmalarma.tel_al.focus();
				}
			}else{
				alert("Debe proporcionar una dirección de correo electrónico válida!...");
				document.frmalarma.email_al.focus();
			}
		}else{
			alert("Debe de proporcionar una dirección de correo");
			document.frmalarma.email_al.focus();
		}
	}else{
		alert("Debe de proporcionar un Nombre");
		document.frmalarma.nombre_al.focus();
	}
}
function modulo2(){
	if (http_request.readyState == 4){
		if (http_request.status == 200){
			datos=http_request.responseText;
			eval(datos);
		}else{
			alert("no se encontraron datos");
		}
	}
}
function redireccionar(){
	location.href="/index.m3";
}
function modulo2_alarma(){
	if (http_request.readyState==4){
		alarma2.innerHTML=http_request.responseText;
		alarma3.innerHTML="<img src=/imgs/linea_alarma.jpg border=0>";
	}
}
function validateEmail(emailAddress) {
   var match = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/.test(emailAddress);
   return match;
}
function closecess(){
	makeRequest("/cerrar.m3", modulo3_b)

}
function solonumeroscarga(e){
	var key;
	if(window.event){
		key = e.keyCode;
	}else if(e.which){
		key = e.which;
	}
	if (key < 48 || key > 57){
		return false;
	}
	return true;
}

var tooltip=function(){
	var id = 'tt';
	var top = 100;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		border:function(obj){


			var id_ajax=obj.id;

			document.getElementById(id_ajax).border="2 px";
			document.getElementById(id_ajax).borderStyle="solid";
			document.getElementById(id_ajax).style.borderColor="red";


		},
		hide_border:function(obj){

					obj.setAttribute("border", "0px ");


		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

var theObj="";
var theObj2="";
function toolTip(text,me) {
       theObj=me;
       theObj.onmousemove=updatePos;
       document.getElementById('toolTipBox').innerHTML=text;
       document.getElementById('toolTipBox').style.display="block";
       window.onscroll=updatePos;
}
function updatePos() {
       var ev=arguments[0]?arguments[0]:event;
       var x=ev.clientX;
       var y=ev.clientY;
       diffX=24;
       diffY=0;
       document.getElementById('toolTipBox').style.top  = y-2+diffY+document.body.scrollTop+ "px";
       document.getElementById('toolTipBox').style.left = x-2+diffX+document.body.scrollLeft+"px";
       //theObj.onmouseout=hideMe();
}
function hideMe() {
       document.getElementById('toolTipBox').style.display="none";
}
function toolTip2(text,me2) {

       theObj2=me2;
       theObj2.onmousemove=updatePos2;
       document.getElementById('toolTipBox2').innerHTML=text;
       document.getElementById('toolTipBox2').style.display="block";
       window.onscroll=updatePos2;
}
function updatePos2() {
       var ev=arguments[0]?arguments[0]:event;
       var x=ev.clientX;
       var y=ev.clientY;
       diffX=24;
       diffY=0;
       document.getElementById('toolTipBox2').style.top  = y-2+diffY+document.body.scrollTop+ "px";
       document.getElementById('toolTipBox2').style.left = x-2+diffX+document.body.scrollLeft+"px";
       //theObj.onmouseout=hideMe();
}
function hideMe2() {
       document.getElementById('toolTipBox2').style.display="none";
}
function toolTip3(text,me3) {

       theObj3=me3;
       theObj3.onmousemove=updatePos3;
       document.getElementById('toolTipBox3').innerHTML=text;
       document.getElementById('toolTipBox3').style.display="block";
       window.onscroll=updatePos3;
}
function updatePos3() {
       var ev=arguments[0]?arguments[0]:event;
       var x=ev.clientX;
       var y=ev.clientY;
       diffX=24;
       diffY=0;
       document.getElementById('toolTipBox3').style.top  = y-2+diffY+document.body.scrollTop+ "px";
       document.getElementById('toolTipBox3').style.left = x-2+diffX+document.body.scrollLeft+"px";
       //theObj.onmouseout=hideMe();
}
function hideMe3() {
       document.getElementById('toolTipBox3').style.display="none";
}
function letras(texto, contador, limite){
	if(texto.value.length>limite){
		texto.value=texto.value.substring(0, limite);
	}else{
		contador.value=limite-texto.value.length;
	}
}
function cambiacolor(a){
	document.getElementById(a).style.color="#7895C1";
}
function regresacolor(a){
	document.getElementById(a).style.color="#064F8a";
}
function inseralabsq(){
	if(document.frmbsqavanala.nombre.value != ""){
		if(validateEmail(document.frmbsqavanala.email.value) != ""){
			if(document.frmbsqavanala.telefono.value != ""){
				a=regresaFloat(document.frmbsqavanala.precioinf.value);
				b=regresaFloat(document.frmbsqavanala.preciosup.value);
				if ((a <= b) && (b >= a) || (a==0) || (b==0)){
					//if(document.frmbusca.idmunicipio.value!=0 ||  document.frmbsqavanala.idmunicipio21.value !=0)
					if(document.frmbsqavanala.idmunicipio.value >0){
						strlinea="alarma/alarma.m3?idcanal="+document.frmbsqavanala.idcanal.value+"&nombre="+document.frmbsqavanala.nombre.value+"&mail="+document.frmbsqavanala.email.value+"&telefono="+document.frmbsqavanala.telefono.value+"&idtipoinmueble=" + document.frmbsqavanala.idtipoinmueble.value+"&idestado="+document.frmbsqavanala.idestado.value+"&idmunicipio="+document.frmbsqavanala.idmunicipio.value+"&idcolonia="+document.frmbsqavanala.idcolonia.value+"&precioinf="+a+"&preciosup="+b+"&rec="+document.frmbsqavanala.rec.value+"&ban="+document.frmbsqavanala.ban.value+"&esta="+document.frmbsqavanala.esta.value+"&id_ins=1";		makeRequest(strlinea, modulo2);
					}else{
						alert("Debe de seleccionar un Municipio");
					}
				}
			}else{
				alert("Debe de proporcionar un telefono");
			}
		}else{
			alert("Debe de proporcionar un correo electrónico");
		}
	}else{
		alert("Debe de proporcionar su nombre")
	}
}
function cargatipinm(obj){
	if(obj.selectedIndex>0){
		var txtHTML=makeRequestSync("alarma/cargatipoinm.m3?idopcion="+obj.value);
		eval(txtHTML);
	}
}
function validarEmailBancomer(emailAddress){
   var match = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/.test(emailAddress);
   return match;
}
function registra(idcanal, idsubcanal, idtipo, enviado){
	var insertaesta=makeRequestSync("estadisticas/insertaesta.m3?otro=1&idcanal="+idcanal+"&idsubcanal="+idsubcanal+"&idtipoacceso="+idtipo+"&enviado="+enviado);
	datos=http_request.responseText;
}
function ajusta(){
	var nom = navigator.appName;
	var obj2=document.getElementById(idConcep);
	if (obj2.style.visibility=="visible"){
		obj2.style.top=document.body.scrollTop;
		obj2.style.width=document.body.offsetWidth;
		if (nom=="Netscape"){
			obj2.style.height=document.body.clientHeight;
		}else{
			obj2.style.height=document.body.offsetHeight;
		}
		var obj3=document.getElementById(idFillbox);
		if (obj3.style.visibility=="visible") openwin()
	}
}
