// JavaScript Document


function vaiURL(url){
	window.open(url);	
	}



function regione(valore){
	
	document.getElementById('frmRegione2').value = valore;
	
	}

function inviaRicerca(){
	document.getElementById('frmRicerca').submit();

	}





function cambiaValore(val,tipologia){
	
	switch (tipologia) { 

  case 'Nome':
  document.getElementById('frmNome').value = val; 
  break;
	
  case 'Reg': 
   //alert(val);
    document.getElementById('frmRegione').value = val; 
	cambiaRegione(val);
  break; 

  case 'Prov': 
   //alert(val);
    document.getElementById('frmProvincia').value = val; 
	document.getElementById('listaProvince').disabled = false;
  break; 

  case 'loc':
   //alert(val);
    document.getElementById('frmLocalita').value = val;  
  break; 

  case 'FasciaP':
  // alert(val);
    document.getElementById('frmFascia').value = val; 
  break; 

 case 'Tipo':
 //alert(val);
    document.getElementById('frmTipologia').value = val;  
  break; 
	}
	
	
}

function cambia (valore,tipo,controllo){   
			var query = 'tipo='+tipo+'&valore='+valore;
			var frmTipo = 'frm'+tipo;
			$j.ajax({
				type: "GET",
				url: "immobiliare/XML_selezioneGeografica.asp",
				dataType: "xml",
				data: query,			
				success: function(xml) {
					
					$j('#'+controllo+' option').remove();
					$j(xml).find('item').each(function(){
														  
						var id = $j(this).attr('id');
						var nodo = $j(this).text();
						
						
  						$j('#'+controllo).append($j("<option></option>").attr("value",id).text(nodo)); 
			
					});
					$j('#'+controllo).append($j("<option value=\"\" selected=\"selected\">seleziona</option>")); 
				}
			});
			
	document.getElementById(controllo).disabled = false;
		if (tipo == 'Regione'){
			$j('#listaLocalita option').remove();
			document.getElementById('listaLocalita').disabled = true;
			document.getElementById("frmProvincia").value = '';
			document.getElementById("frmLocalita").value = '';
			
	}
	document.getElementById(frmTipo).value = valore; 
	
}

var map = null;
var geocoder = null;

    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GLargeMapControl);

  		geocoder = new GClientGeocoder();
		
		
		
		
      }
    }

    function showAddress(address,fumetto,zoom) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 12);
			  
	  
			 // Create our "tiny" marker icon
			var blueIcon = new GIcon();
			blueIcon.image = "img/ico1.png";
            blueIcon.iconSize = new GSize(90,45);  
			blueIcon.shadowSize=new GSize(22,20);
			blueIcon.iconAnchor=new GPoint(6,20); 
			blueIcon.infoWindowAnchor=new GPoint(5,1); 
			// Set up our GMarkerOptions object
			markerOptions = { icon:blueIcon };

			  
              var marker = new GMarker(point, markerOptions);
              map.addOverlay(marker);
			  var mapControl = new GMapTypeControl();
				map.addControl(mapControl);
				map.addControl(new GLargeMapControl());
              	marker.openInfoWindowHtml(fumetto);
            }
          }
        );
      }
    }

	function FirstPage(formz)
	{
		//alert('first');
		var el = document.getElementById("offset");
		el.value = 0;
		document.getElementById(formz).submit();
	}
	function PrevPage(offsetPrev,formz)
	{
		//alert('prev');
		var el = document.getElementById("offset");
		el.value = offsetPrev;
		document.getElementById(formz).submit();
	}
	function NextPage(offsetNext,formz)
	{
		
		var el = document.getElementById("offset");
		el.value = offsetNext;
		//alert(el.value);
		document.getElementById(formz).submit();
	}
	function LastPage(offSetLast,formz)
	{
		//alert('last');
		var el = document.getElementById("offset");
		el.value = offSetLast;
		document.getElementById(formz).submit();
	}

	function keypressed(e){
	var evtobj=window.event? event : e 
	var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode

	//var KeyID=e.keyCode? e.keyCode : e.charCode
	//var KeyID = (window.event) ? event.keyCode : e.charCode;
		
	if(unicode=='13'){
		inviaRicerca();
		}
	//alert(unicode);
	}

