function enviar_contacto(){
	
		if (document.getElementById('contacto').raz_soc.value == "") {
			alert("Por favor ingrese su nombre.");
			document.getElementById('contacto').raz_soc.focus();
			return;
		}
		if (document.getElementById('contacto').mail.value == "" && document.getElementById('contacto').tel.value==""){
			alert("Debe ingresar un teléfono o email de contacto.");
			document.getElementById('contacto').mail.focus();
			return;
		}else{
			if(!(document.getElementById('contacto').mail.value=="")){
				if (!((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('contacto').mail.value)))){
					alert("Ha ingresado una dirección de correo electrónico no válida.");
					document.getElementById('contacto').mail.focus();
					return;
				}
			}
		}

	document.getElementById('contacto').submit();
}

function cargar_select(accion,nom_sel1,nom_sel2,str,form){
			
		if(accion){
			cad="document."+form+"."+nom_sel1+".selectedIndex";
			
			nva=eval(cad);
			
			if(nva!=-1){
					cad="document."+form+"."+nom_sel1+".options["+nva+"]";	
					nva=eval(cad).value;
					
					nva_text=eval(cad).text;
					cad="document."+form+"."+str;
					
					cadena=eval(cad).value;
					
					if(cadena.indexOf(nva+"#")==-1)
					{
						
						cad="document."+form+"."+nom_sel2;
						if(eval(cad).length){
							if(eval(cad+'[0]').text.indexOf("...")!=-1){
								eval(cad+"[0]=null");
							}
						}
						val=eval(cad).length;
						val=nva+"-"+val;
						//alert(nva)
						cad="document."+form+"."+nom_sel2+".options[document."+form+"."+nom_sel2+".options.length]=new Option(nva_text,val)";
						//prp_dom.options [document.formulario.prp_dom.options.length]=new Option(nva,val);
						eval(cad);
						cad="document."+form+"."+str;
						eval(cad).value += nva + "#";
						//alert(eval("document.formulario."+str).value)
					}else{
						alert("Revise su sintaxis o asegurese de no estar repitiendo el item");
					}	
			}else{
				alert("Seleccione un Item para agregar")
			}	
				    						
		}else{
			    var cpto_borrar,e,aux,valor=0;
			    cad="document."+form+"."+str;
			    cadena=eval(cad).value;
			   // alert(document.formulario.prp_dom.selectedIndex)
			    cad="document."+form+"."+nom_sel2+".selectedIndex";
			    if(eval(cad)!=-1){
			    		cad="document."+form+"."+nom_sel2+".options[document."+form+"."+nom_sel2+".selectedIndex]";
			    		borrar=eval(cad).text;
						valor=eval(cad).value;
						cpto_borrar=borrar + "#";  
						//alert(cadena.substring(cadena.indexOf(cpto_borrar,0)));
						cadena2=cadena.substring(0,cadena.indexOf(cpto_borrar,0));
					    cadena3=cadena.substring(cadena.indexOf(cpto_borrar,0) + cpto_borrar.length,cadena.length);
					    str_zon=cadena2 + cadena3;
					    cad="document."+form+"."+str+".value=str_zon";
					    eval(cad);
					    cad="document."+form+"."+nom_sel2+".options[document."+form+"."+nom_sel2+".selectedIndex]=null";
					    eval(cad);	
			    }else{
					alert("Seleccione un Item para quitar")
				}
		}
}


function enviar_tasacion(){
	
		if (document.getElementById('contacto').raz_soc.value == "") {
			alert("Por favor ingrese su nombre.");
			document.getElementById('contacto').raz_soc.focus();
			return;
		}
		if (document.getElementById('contacto').mail.value == "" && document.getElementById('contacto').tel.value==""){
			alert("Debe ingresar un teléfono o email de contacto.");
			document.getElementById('tasacion').mail.focus();
			return;
		}else{
			if(!(document.getElementById('contacto').mail.value=="")){
				if (!((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('contacto').mail.value)))){
					alert("Ha ingresado una dirección de correo electrónico no válida.");
					document.getElementById('contacto').mail.focus();
					return;
				}
			}
		}

	document.getElementById('contacto').condicion.value=document.getElementById('contacto').con_id.options[document.getElementById('contacto').con_id.selectedIndex].text;

	document.getElementById('contacto').tipo.value=document.getElementById('contacto').tip_id[document.getElementById('contacto').tip_id.selectedIndex].text;

		
	document.getElementById('contacto').submit();
}


function enviar_buscar(){
	document.getElementById('buscar').submit()
}


function enviar_buscar2(){
	document.getElementById('buscar2').submit()
}

function enviar_buscar3(){
	document.getElementById('buscar3').submit()
}

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

	function checkEnter(event,form)	{ 	
	var code = 0;
	if (isNS4)
		code = event.which;
	else
		code = event.keyCode;
	if (code==13)
		form.submit();
		//eval('document.'+form).submit();
	}

	function abrir(prp_id,usr,usuario){
		window.open("imprimir_ficha.php?usr_id="+usr+"&prp_id="+prp_id+"&usuario="+usuario,"vent","toolsbar=0,width=600,height=600,scrollbars=1");
	}
	function ampliar_foto(dir,foto){
		window.open("includes/ampliar.php?dir="+dir+"&foto="+foto.replace('sw=5&','')+"","Foto_Ampliada","toolsbar=0,width=700,height=500,scrollbars=0");
	}
	function ampliar_foto_ppal(usr_id,prp_id){	
		var nro=eval('document.formulario.nro_foto').value;
		var cadena="http://www.inmoclick.com.ar/ftp_inmohost/fotos/"+prp_id+"-"+usr_id+"-"+nro+".gif";
		window.open("inc/ampliar.php?foto="+cadena+"","Foto_Ampliada","top=0,left=0,toolsbar=0,width=700,height=510,scrollbars=1");
}
	function abrir_ventana(url){
		window.open(url,"vent","toolsbar=0,width=600,height=600,scrollbars=1");
	}

	function enviarConsulta(tipo){
			
		if(tipo!="por_id"){
			
			url="";
			
   			pro=document.getElementById('prov');
			loc=document.getElementById('loc_id');
            tip=document.getElementById('tip_id');
            con=document.getElementById('con_id');
            pre_mi=document.getElementById('pre_min');
            pre_ma=document.getElementById('pre_max'); 
            dom=document.getElementById('prp_dom').value;
            mon=document.getElementById('pesos');
            s1=document.getElementById('ser1');
            s2=document.getElementById('ser2');
            s3=document.getElementById('ser3');
            s4=document.getElementById('ser4');
            cFoto=document.getElementById('conFoto');
            uSemana=document.getElementById('ultSemana');
            uMes=document.getElementById('ultMes');
            pro_la=document.getElementById('pro_lat');
            pro_ln=document.getElementById('pro_lng');
          
           
        	pro_id_=pro[pro.selectedIndex].value;
        	loc_id_=loc[loc.selectedIndex].value;
        	tip_id_=tip[tip.selectedIndex].value;
        	con_id_=con[con.selectedIndex].value;
        	
        	if(pro_id_!=0){
        		url+="?pro_id="+pro[pro.selectedIndex].value;	
        	}
        	
        	if(loc_id_!=0){
        		url+="&loc_id="+loc[loc.selectedIndex].value;
        	}
        	
        	if(tip_id_!=0){
        		url+="&tip_id="+tip[tip.selectedIndex].value;
        	}
        	
        	if(con_id_!=0){
        		url+="&con_id="+con[con.selectedIndex].value;
        	}
        	
            
        	pre_min_=pre_mi[pre_mi.selectedIndex].value;
        	pre_max_=pre_ma[pre_ma.selectedIndex].value;
        	
        	if(pre_min_>0){
        		url+="&pre_min="+pre_min_;
        	}
        	
        	if(pre_max_>0){
        		url+="&pre_max="+pre_max_;
        	}
        	
        	ser1_=s1[s1.selectedIndex].value;
        	ser2_=s2[s2.selectedIndex].value;
        	ser3_=s3[s3.selectedIndex].value;
        	ser4_=s4[s4.selectedIndex].value;
        	
        	if(ser1_!=""&&ser1_!="Indistinto"){
        		url+="&ser1="+ser1_;
        	}
        	if(ser2_&&ser2_!="Indistinto"){
        		url+="&ser2="+ser2_;
        	}
        	if(ser3_&&ser3_!="Indistinto"){
        		url+="&ser3="+ser3_;
        	}
        	if(ser4_&&ser4_!="Indistinto"){
        		url+="&ser4="+ser4_;
        	}
        	
        	cFoto_='';
        	uMes_='';
        	uSemana_='';
        	
        	if(cFoto.checked){
        		url+="&conFoto="+cFoto.value;
        	}
        	
        	if(uMes.checked){
        		url+="&ultMes="+uMes.value;
        	}
        	if(uSemana.checked){
        		url+="&ultSemana="+uSemana.value;
        		
        	}
        	
        	if(dom){
        		url+="&prp_dom="+dom;
        	}
        	
        	if(mon.checked)
        		url+="&pesos=1";
        	else
        		url+="&pesos=2";
        	
      
        		
        	
        	
        	
        	location.href='resultado_busqueda.php'+url;	
		}else{
			$('usr_id').value;
			location.href='ficha.php?usr_id='+$('usr_id').value+'&prp_id='+$('prp_id').value;	
		}
}
function enviar_amigo(){
		if (document.getElementById('enviar_amigo').rNombre.value == "") {
			alert("Por favor ingrese su nombre.");
			document.getElementById('enviar_amigo').rNombre.focus();
			return;
		}
		if (document.getElementById('enviar_amigo').rMail.value == "") {
			alert("Por favor ingrese su e-mail.");
			document.getElementById('enviar_amigo').rMail.focus();
			return;
		}else{
			if(!(document.getElementById('enviar_amigo').rMail.value=="")){
				if (!((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('enviar_amigo').rMail.value)))){
					alert("Ha ingresado una direccion de correo electronico no valida.");
					document.getElementById('enviar_amigo').rMail.focus();
					return;
				}
			}
		}
		if (document.getElementById('enviar_amigo').aNombre.value == "") {
			alert("Por favor ingrese nombre de destinatario.");
			document.getElementById('enviar_amigo').aNombre.focus();
			return;
		}
		if (document.getElementById('enviar_amigo').aMail.value == "") {
			alert("Por favor ingrese e-mail de destinatario.");
			document.getElementById('enviar_amigo').aMail.focus();
			return;
		}else{
			if(!(document.getElementById('enviar_amigo').aMail.value=="")){
				if (!((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('enviar_amigo').aMail.value)))){
					alert("Ha ingresado una direccion de correo electronico no valida.");
					document.getElementById('enviar_amigo').aMail.focus();
					return;
				}
			}
		}
		if (document.getElementById('enviar_amigo').aMensaje.value == "") {
			alert("Por favor ingrese un mensaje.");
			document.getElementById('enviar_amigo').aMensaje.focus();
			return;
		}
		document.getElementById('enviar_amigo').submit();
}
function reloj(){
	momentoActual = new Date();
    hora = momentoActual.getHours();
    minuto = momentoActual.getMinutes();
    segundo = momentoActual.getSeconds();
    dia = momentoActual.getDate();
    mes = momentoActual.getMonth()+1;
    anio = momentoActual.getFullYear();
   	var ampm;
   	
    if(hora > 12){
    	//Para reloj 24 comnetar la siguiente linea
    	//hora -=12;
    	ampm='PM';
    }else{
    	ampm="AM";
    }

    str_segundo = new String (segundo);
    if (str_segundo.length == 1)
       segundo = "0" + segundo;

    str_minuto = new String (minuto);
    if (str_minuto.length == 1)
       minuto = "0" + minuto;

    str_hora = new String (hora);
    if (str_hora.length == 1)
       hora = "0" + hora;
       
    str_dia = new String (dia);
    if (str_dia.length == 1)
       dia = "0" + dia;

    str_mes = new String (mes);
    if (str_mes.length == 1)
       mes = "0" + mes;

    str_anio = new String (anio);
    if (str_anio.length == 1)
       anio = "0" + anio;   

    horaImprimible = dia + "/" + mes + "/" + anio + " " + hora + ":" + minuto + ":" + segundo + " " + ampm;

    document.getElementById('reloj').innerHTML=horaImprimible;

    setTimeout("reloj()",1000); 
}

function iniciarMapa(lat,lng){
	
	if (GBrowserIsCompatible()) {
		//mapa
		map = new GMap2(document.getElementById("ubicacionInmueble"));
		map.setCenter(new GLatLng(lat,lng), 17);
		map.disableDoubleClickZoom();
        map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl());
		
		
		point=new GLatLng(lat,lng);
		marker=new GMarker(point);
		map.clearOverlays(); 
		map.addOverlay(marker);
	
		
	}		
}
