
function Cambia_img_preferiti(img_name)
{
	if (document.getElementById("img_preferiti"+img_name))
	{
				var img=document.getElementById("img_preferiti"+img_name);
				if (img.src=='http://www.italiainaffitto.it/images/add-preferiti.gif')
					{
						img.src='images/in-preferiti.gif';
						img.setAttribute('title',"Rimuovi dagli annunci che osservi");
					} 
				else
					{
						img.src='images/add-preferiti.gif';
						img.setAttribute('title',"Aggiungi agli annunci che osservi");
					} 
	}
}

function CheckResolution(){ 
if (window.screen){ 
var w = screen.width;  

if(w >= 740 & w < 835) { 
return 800;} 
  
if(w >= 835) { 
return 400; } 
}
}

function Checkheight(){ 
if (window.screen){   
var h = screen.height;

 
return h-200; 


}
} 


function IDSelected(tagselect)
{
	var selObj = document.getElementById(tagselect);
	if (selObj.type=="select"){
		var selIndex = selObj.selectedIndex;
		var id=selObj[selIndex].value;
	}
	else{
		id=selObj.value;
	}
	//var id=selObj.options[selIndex].value;
	
	return id;
}


function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function Chiudi_anteprima(anteprima)
{
	
	 var d = document.getElementById(anteprima);
 	 d.innerHTML='';

}

function NumPostiLetto()
{
	var selObj = document.getElementById('posti');
	if (selObj.type=="select"){
		var selIndex = selObj.selectedIndex;
		var id=selObj[selIndex].value;
	}
	else{
		id=selObj.value;
	}
	//var id=selObj.options[selIndex].value;
	
	return id;
}

function Find_prov(prov)
{
	
	if (prov.checked)
		return 1;
	else
		return 0;

}

function Repleace_accenti(stringa)
{
	stringa=stringa.replace(/ù/g,'u');
	stringa=stringa.replace(/u\'/g,'u');
	stringa=stringa.replace(/è/g,'e');
	stringa=stringa.replace(/e\'/g,'e');
	stringa=stringa.replace(/é/g,'e');
	stringa=stringa.replace(/ì/g,'i');
	stringa=stringa.replace(/ò/g,'o');
	stringa=stringa.replace(/o\'/g,'o');
	stringa=stringa.replace(/à/g,'a');
	stringa=stringa.replace(/a\'/g,'a');
	stringa=stringa.replace(/ /g,'+');
	stringa=stringa.replace(/'/g,'\'\'');
	
	return stringa;
}

function Copia_dal(dal,al)
{
   al.value=dal.value;
}

function ins_periodo(val)
{
	
	var div_periodi=document.getElementById("periodi");
	div_periodi.style.display='block';
	var dal=document.getElementById("dal_disp");
	var al=document.getElementById("al_disp");
	if ((dal.value!=''))
	{
		al.value=val;
	}
	else
	{
		dal.value=val;
	}
	
}


function Del_my_list()
{

	var lista=document.getElementById('list_Advertises');
		lista.innerHTML='&nbsp;';
		

}


 
function Popup(apri) {
				var stile = "top=10, left=10, width=450, height=400, status=no, menubar=no, toolbar=no, scrollbars=yes";
        window.open(apri, "", stile);
        
     }

function MyPopUp(str, titolo, width, height) {

        searchWin = window.open(str,'','scrollbars=yes,resizable=yes,width='+width+',height='+height+',status=no,location=no,toolbar=no');

//        searchWin.refer = self;

}

function ChangeLink(id_link)
{
	var i=1;
	var totlink=5;
	var sw=false;
	
 	while ( i<totlink+1) 
	{
			if (document.getElementById(i))
			{
				    	if ((parseInt(id_link)==i) && (sw==false) )
							{
								document.getElementById(i).style.color="#52AD42";
								document.getElementById(i).style.textDecoration="none";
								sw=true;
								
							} 
						else
							{
								document.getElementById(i).style.color="#cccccc";
								document.getElementById(i).style.textDecoration="underline";
							}
					
						
			}
			i=i+1;
  }
    var annuncifreedue=document.getElementById('adfree2');
    if (id_link==5) 
    	{
    		annuncifreedue.style.display=""; 
    	}
    else
    	{
    		annuncifreedue.style.display="none"; 
    	}

	
}



function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   
   var tasto=document.getElementById("tasto_form");
   /*tasto.click;*/
   return false;
   }
else
   return true;
}

function Show_help(id)
{
	
	var info=document.getElementById('help_'+id);
	info.style.display='';
	
	
}


function Hide_help(id)
{
	
	var info=document.getElementById('help_'+id);
	info.style.display='none';
	
}



google.load('language','1');  
function translate(target_tr,prima, seconda) { 
	
    $$('[rel="'+target_tr+'"]').each( 
    
        function(e) { 
        	
            google.language.translate(e.innerHTML, prima, seconda, 
                function(result) { 
                	if (!result.error) {
                    if (result.translation) { 
                        e.innerHTML = result.translation; 
                    } else { 
                        //alert( 'Translate Error!\n\n' + result.error.message ); 
                    } 
                  }
                } 
            );                                          
        } 
    ); 
   
} 



	
function occorrenze(str)
	{
	var orig=document.getElementById(str).value.length;
	var sost=document.getElementById(str).value.replace(/,/g,'');

	var mod=sost.length;
	return orig-mod;
 } 
 
 
 
 
function showAddress(address) {
	
	var geocoder = null;
				var geocoder = new GClientGeocoder();
			 	
				if (GBrowserIsCompatible()) {
				        geocoder = new GClientGeocoder();
				      }
			
						
	var respo=document.getElementById("response_coordinate");
		  respo.innerHTML='<font color="red">Attendere...</font>';
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        alert(address + " not found");
      } else {
        var lat=document.getElementById("lat");
        var lon=document.getElementById("lon");
  			lat.value=point.lat();
        lon.value= point.lng(); 
        respo.innerHTML='<b>Coordinate acquisite</b>';
      }
    }
  );
  		  
}