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 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('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').condicion.value=document.getElementById('contacto').con_idPedido[document.getElementById('contacto').con_idPedido.selectedIndex].text;

	document.getElementById('contacto').tipo.value=document.getElementById('contacto').tip_idPedido[document.getElementById('contacto').tip_idPedido.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)
		document.getElementById(form).submit();
		//eval('document.'+form).submit();
	}

	function imprimir_ficha(prp_id,usr){
		window.open("imprimir_ficha.php?usr_id="+usr+"&prp_id="+prp_id,"vent","toolsbar=0,width=600,height=600,scrollbars=0");
	}
	function ampliar_foto(dir,foto){
		window.open("includes/ampliar.php?dir="+dir+"&foto="+foto+"","Foto_Ampliada","toolsbar=0,width=700,height=500,scrollbars=0");
	}
	function abrir_ventana(url){
		window.open(url,"vent","toolsbar=0,width=600,height=600,scrollbars=1");
	}
	

function cambiar_foto(nro_foto,fo_desc,src){
	var nro,nro_desc,celda_actual,src;
	ob_foto=document.getElementById('foto_ppal');
	ob_input=document.getElementById('fo_desc_ppal');
	ob_foto.src=src;
	ob_input.value=fo_desc;
}

function flash(pelicula,width,height){
document.write('<object type="application/x-shockwave-flash" data="' + pelicula + '" width="' + width + '" height="' + height + '">\n');
document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
document.write('<param name="movie" value="' + pelicula + '" />\n');
document.write('<param name="quality" value="high" />\n');
document.write('<param name="bgcolor" value="#ffffff" />\n');
//document.write('<param name="menu" value="false" />\n');
document.write('<param name="wmode" value="transparent" />\n');
document.write('</object>\n');
}

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 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='listado.php'+url;
		}else{
			$('usr_id').value;
			location.href='ficha.php?usr_id='+$('usr_id').value+'&prp_id='+$('prp_id').value;
		}
}

function iniciarMapa(){
    var lat = $('#prp_lat').val();
	var lng = $('#prp_lng').val();
    
    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);
    }
}



