function focusField(Field) {
	var f = document.getElementById(Field);
	f.focus();
}

function copyStreet(Field, Strada) {
	//Field.value = Strada;
	//Field.focus();
	var f = document.getElementById(Field);
	f.value = Strada;
	f.focus();
	
	var blocco = document.getElementById("proponiVie");
	if (blocco)
	{
		blocco.style.display="none";
		blocco.style.visibility="hidden";
	}
}

var isNS4 = (navigator.appName=="Netscape")?1:0;
function control() {
	if(!isNS4){ 
		if (event.keyCode==34 || event.keyCode==92) event.returnValue = false;
	}else{
		if (event.which==34 || event.keyCode==92) return false;
	}
}

function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}

function evalScript(scripts)
{	try
	{	if(scripts != '')	
		{	
			var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
	       	                         if (scripts !== null) script += arguments[1] + '\n';
 	        	                        return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}
	catch(e)
	{	alert(e)
	}
}

function CreateXmlHttpReq(handler) 
{
  var xmlhttp = null;
  try 
  {
    xmlhttp = new XMLHttpRequest();
  } 
  catch(e) 
  {
    try 
    {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch(e) 
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
}

function ajaxGet(url,handler) 
{
	var ajax_req = null;
	
    var a = new Array("placeholder");
    for (var j=2; j<arguments.length; j++) 
    {
        a[a.length] = arguments[j];
    }
    
    var myhandler = function() 
    {
    	var content = false;
    	if (ajax_req.readyState == 4 && ajax_req.status == 200) 
	    {
	        content = ajax_req.responseText;	        
	    } 
	    
        if (content != false) 
        {
            a[0] = content;
            return handler.apply(this, a);
        }
    }
    
    ajax_req = CreateXmlHttpReq(myhandler);
    ajax_req.open("GET",url);
    ajax_req.send(null);
}

function myHandler(content,elementid) 
{
	var e = document.getElementById(elementid);
    e.innerHTML = content;
    evalScript( content );
}

function focusami(element)
{
	window.element.focus();
}


function setHomePage(link, txt1, txt2)
{	
	if (document.all)
	{ 
		document.write('<A HREF="javascript:history.go(0);" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\''+link+'\');">');	
		document.write(''+txt1+'</a>');
	}
	else if (document.getElementById)
	{ 
		document.write('<a href="'+link+'">'+txt2+'</a>');
	}		
}
