

function cambiar_fondo(celda1,color1,color2,img){

		if(color1){
			if(color1=="none"){
				 celda1.style.background='';
			}else{
				 celda1.style.background=color1;
				 celda1.style.color=color1;
			}
			
			 celda1.style.color=color2;
			 celda1.style.cursor='pointer';
		}else{
			celda1.style.backgroundImage="url('"+img+"')";
			celda1.style.cursor='pointer';
		}
			 
}

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 agregarSitio(url,titulo){
	if (document.all){
		window.external.AddFavorite(url,titulo);
	}else{ 
		alert("Para Agregar en Favoritas presione Ctrl + D");
	}
}

function editarSeleccion(accion,usr_id){
		cad="";
		
		if(accion=="modificar"){
		
			for(i=0;i<10;i++){
				
				if($('prop'+i)){
					if($('prop'+i).checked){
						location.href="../propiedades/edit/usr_id/"+usr_id+"/prp_id/"+$('prop'+i).value+".html";
						return 1;
					}
				}
			}
	
		}else{

			for(i=0;i<10;i++){
				
				if($('prop'+i)){
					if($('prop'+i).checked){
						cad+=$('prop'+i).value+"-";		
					}
				}
			}
		
		}
		
		if(cad){
			if(confirm("żEsta seguro q desea eliminar las propiedades seleccionadas?")){
				location.href="../propiedades/delete/usr_id/"+usr_id+"/prps/"+cad+".html";
				return 1;	
			}
		}else{
		
			alert('Seleccione un Item')	
		}		
		
}

function checkEnter(event,form)	{ 	
	var code = 0;

	code = event.keyCode;
		
	if (code==13){
		eval('document.'+form).submit();
	}	
}

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="menu" value="false" />\n');
	document.write('</object>\n');
}

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_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_desc/"+pro[pro.selectedIndex].text;	
        	}
        	
        	if(loc_id_!=0){
        		url+="/loc_desc/"+loc[loc.selectedIndex].text;
        	}
        	
        	if(tip_id_!=0){
        		url+="/tip_desc/"+tip[tip.selectedIndex].text;
        	}
        	
        	if(con_id_!=0){
        		url+="/con_desc/"+con[con.selectedIndex].text;
        	}
        	
            
        	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_desc/en-pesos";
        	else
        		url+="/pesos_desc/en-dolares";
        	
        	location.href='/es/propiedades/consultaGeneral/'+url+'.html';	
		}else{
			$('usr_id').value;
			location.href='/es/propiedades/fichaGeneral.html?usr='+$('usr_id').value+'&prp='+$('prp_id').value;	
		}
}

function ver_datos_vendedor(usr_id,prp_id,url){
	  
	  nombre_contacto=document.getElementById('nombre_contacto').value; 
	  mail_contacto=document.getElementById('mail_contacto').value; 
	  
	  
	  if(nombre_contacto&&mail_contacto){
	  	
	  	if(echeck(mail_contacto)){
		
					new Ajax.Updater('datos_vendedor',
						url,
						 {asynchronous:true, 
						  evalScripts:false, 
						  onComplete:function(request, json){
						  						Element.hide('cargando_datos_vendedor');
						  						Element.show(divIdName)}, 
						  onLoading:function(request, json){
						  						Element.show('cargando_datos_vendedor');
						  						Element.hide(divIdName)}, 
						  parameters:'nombre_contacto=' + nombre_contacto + '&mail_contacto=' + mail_contacto+ '&usr_id='+usr_id+'&prp_id='+prp_id }
						  );
	  	}else{
	  		alert('Debe ingresar un E-mail Valido');
	  	}
	  	
	  }else{
	  		alert('Debe completar los datos del Formulario');
	  }
	  
	 
	
}
function echeck(str) 
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var dir_mal=0;
		if (str.indexOf(at)==-1){
		   dir_mal=1;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   dir_mal=1;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   dir_mal=1;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   dir_mal=1;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   dir_mal=1;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   dir_mal=1;
		 }
		
		 if (str.indexOf(" ")!=-1){
		   dir_mal=1;
		 }
		if (dir_mal==1)
		{
			return false;
		}
		else
		{
			return true;
		}
}
 