var a

function addresstopointnew(id,address,cliente) {
		xlongitudine = null
		ylatitudine = null
        var geocoder = new GClientGeocoder();
        geocoder.getLatLng(address,function(point){
        try {
        xlongitudine = point.x; 
        ylatitudine = point.y;
        SendQuerynew(id,xlongitudine,ylatitudine,address,cliente);
        } catch(e) {
       xlongitudine = "0";
       ylatitudine = "0";
       SendQuerynew(id,xlongitudine,ylatitudine,address,cliente);
}       
    }
        );
}

function SendQuerynew(id,xlongitudine,ylatitudine,address,cliente){
if(cliente == ''){
query = ("ID=" + id + '&Latitudine=' + ylatitudine + '&Longitudine=' + xlongitudine);
}else{
query = ("ID=" + id + '&Latitudine=' + ylatitudine + '&Longitudine=' + xlongitudine + '&cliente=citta');
}
//query = escape(query);
var xmlDoc = getXMLHttpRequestInstance();
xmlDoc.open("GET" , "http://www.regioneliguria.info/geocoding/updatecoord.asp?" + query, true);
xmlDoc.send("");
} 

function getXMLHttpRequestInstance() {
        var xmlhttp;
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
     
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
            try {
                xmlhttp = new XMLHttpRequest();
            } catch (e) {
                xmlhttp = false;
            }
        }
        //alert(e)
    return xmlhttp;
}

function apriinviomail(){
document.getElementById('sendmail').style.display='inline';
document.getElementById('sendmail').focus();
a=5;
return(false);
}

function crealink(url2){
window.location.href='http://www.regioneliguria.info/public/'+(url2)
}

function insertpatrocini(){
document.write('<img src="http://www.regioneliguria.info/immagini/patrocini2.jpg" border=0 usemap="#mappatrocini">')
document.write('<map name="mappatrocini">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="amiat torino" href="http://www.amiat.it/" coords="118,0,148,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="cna torino" href="http://www.cna.to.it/" coords="175,0,206,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="smat torino" href="http://www.smatorino.it/" coords="235,0,282,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="turismo torino" href="http://www.turismotorino.org/" coords="308,0,341,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="anfia" href="http://www.anfia.it/" coords="367,0,417,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="gtt torino" href="http://www.comune.torino.it/gtt/" coords="441,0,483,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="confesercenti torino" href="http://www.www.confesercenti-to.it/" coords="506,0,574,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="federfarma piemonte" href="http://www.farmapiemonte.it/" coords="599,0,652,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="api torino" href="http://www.apito.it/" coords="677,0,730,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="federalberghi torino" href="http://www.federalberghi.com/" coords="754,0,796,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="confagricoltura torino" href="http://www.torino.confagricoltura.it/" coords="869,0,952,34">')
document.write('<area shape="rect" rel="nofollow" target="_blank" alt="coldiretti torino" href="http://www.torino.coldiretti.it/" coords="820,0,850,34">')
document.write('</map>')
}

function insertflash(){
document.write('<img src="http://www.regioneliguria.info/immagini/header.jpg" border=0 usemap="#mapimg">')
document.write('<map name="mapimg">')
document.write('<area shape="rect" rel="nofollow" alt="italian version" target="_top" href="http://www.regioneliguria.info/" coords="425,59,448,73">')
document.write('<area shape="rect" rel="nofollow" alt="russian version" target="_top" href="http://www.regioneliguria.info/public/traduction.asp?lang=ru&dir=http://www.regioneliguria.info/index.asp" coords="462,58,481,73">')
document.write('<area shape="rect" rel="nofollow" alt="english version" target="_top" href="http://www.regioneliguria.info/public/traduction.asp?lang=en&dir=http://www.regioneliguria.info/index.asp" coords="497,58,518,74">')
document.write('<area shape="rect" rel="nofollow" alt="french version" target="_top" href="http://www.regioneliguria.info/public/traduction.asp?lang=fr&dir=http://www.regioneliguria.info/index.asp" coords="532,59,553,74">')
document.write('<area shape="rect" rel="nofollow" alt="german version" target="_top" href="http://www.regioneliguria.info/public/traduction.asp?lang=de&dir=http://www.regioneliguria.info/index.asp" coords="567,59,586,74">')
document.write('<area shape="rect" rel="nofollow" alt="spanish version" target="_top" href="http://www.regioneliguria.info/public/traduction.asp?lang=es&dir=http://www.regioneliguria.info/index.asp" coords="602,58,621,74">')
document.write('<area shape="rect" rel="nofollow" alt="japanese version" target="_top" href="http://www.regioneliguria.info/public/traduction.asp?lang=ja&dir=http://www.regioneliguria.info/index.asp" coords="637,58,657,74">')
document.write('<area shape="rect" rel="nofollow" alt="chinese version" target="_top" href="http://www.regioneliguria.info/public/traduction.asp?lang=zh&dir=http://www.regioneliguria.info/index.asp" coords="670,58,692,74">')
document.write('<area shape="rect" rel="nofollow" alt="home cittaditorino" target="_top" href="http://www.regioneliguria.info" coords="13,20,319,97">')
document.write('</map>')
/*document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="195" height="99" codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" style="margin-left:19px; margin-top:10px">')
document.write('<param name="movie" value="http://www.regioneliguria.info/immagini/vialattea_lateraledestro.swf">') 
document.write('<param name="play" value="true"> ')
document.write('<param name="loop" value="true"> ')
document.write('<param name="quality" value="high">') 
document.write('<embed src="http://www.regioneliguria.info/immagini/vialattea_lateraledestro.swf" width="195" height="99" play="true" loop="true" quality="high" pluginspage="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>')
document.write('</object>')*/
//document.write('<a rel="nofollow" href="http://www.regioneliguria.info/Adv.asp?q=bl&ID=20" target=_blank rel="nofollow"><img src="http://www.regioneliguria.info/immagini/Logosonafin.jpg" alt="SONAFIN FINANZIARIA" border="0" STYLE="vertical-align: top; margin-top:25px;margin-left:8px"></a>')
}

function compmail(id1,id2){
window.location.href = "mailto:" + id1 + "@" + id2
}

function ShowAndHide(id1,id2,id3){

if(document.getElementById){
    el1=document.getElementById(id1);
    el2=document.getElementById(id2);
    if(el1.style.display=="none"){
        el1.style.display="inline";
        el2.style.display="none";
        }
    else{
        el1.style.display="none";
        el2.style.display="inline";
        }
    }   
    if(id1=="mostra"){
    categoriecorrelate(id3)
    }     
}

function categoriecorrelate(id3){
url="/risultaticatcorrelate.asp?" + id3
var xmlDoc = getXMLHttpRequestInstance();
xmlDoc.open("GET" , url, false);
xmlDoc.send("");
var x = xmlDoc.responseText
//alert('x= ' + x)
commenti.innerHTML= "<a onclick=ShowAndHide('mostra','commenti','');return(false)>Chiudi</a><br><br>" + x
}

function forum(){
this.document.formforum.Submit();
}

function change(linguetta, scheda){

if(scheda == 'scheda2'){
document.getElementById("select10100").style.visibility = "hidden"
}
if(scheda == 'scheda1'){
document.getElementById("select10100").style.visibility = "visible"
}
if(document.getElementById){
var linguetta_x = document.getElementById(linguetta);
var scheda_x = document.getElementById(scheda);
var linguette = document.getElementById("linguette").getElementsByTagName("li");
var schede = document.getElementById("container").getElementsByTagName("div"); 
for(var i=0; i<linguette.length; i++){
//linguette[i].style.height = '30px';
linguette[i].style.background = '#fff';

}
for(var i=0; i<schede.length; i++){
schede[i].style.display="none";
}
//linguetta_x.style.height = '31px';
linguetta_x.style.background = '#e5ecf9';
scheda_x.style.display="inline";
//scheda2.style.height ="145px";
}

}

function runClock() {
theTime = window.setTimeout("runClock()", 200);
var today = new Date();
self.status = today.toLocaleString();
}
//runClock()

function eventi(a){

b=String(a)
//alert (''+b)
refer=b.substring(40,b.length)
//alert(''+refer)
indirizzo=b
//alert(''+indirizzo)
window.open(''+indirizzo,'e','height=500,width=700,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=no')
//window.navigate(indirizzo)
return false
}


function eventi2(a){

b=String(a)
refer=b.substring(40,b.length)
//alert(''+refer)
indirizzo='eventi.asp?url2='+refer
//alert(''+indirizzo)
window.navigate(indirizzo)
return false
}


function cambiafac(a){
et=this.document.ris.facolta.options.selectedIndex;
ct=this.document.ris.facolta.options[et].text;
ct=ct.replace("'","''")
//alert(''+ct);
if (a>0){
et=this.document.ris.esame.options.selectedIndex;
ct1=this.document.ris.esame.options[et].text;
ct1=ct1.replace("'","''")
window.navigate('Appunti.asp?facolta='+ct+'&esame='+ct1)
}else{
window.navigate('Appunti.asp?facolta='+ct)}
}

function cerca(){
et=this.document.ris.facolta.options.selectedIndex;
ct=this.document.ris.facolta.options[et].text;
et=this.document.ris.esame.options.selectedIndex;
ct1=this.document.ris.esame.options[et].text;
ct1=ct1.replace("'","''")
window.navigate('Appunti.asp?facolta='+ct+'&esame='+ct1+'&submit=cerca')
}

function pubbl(id){

var idfinestra = window.open('pippo','DESCRIZIONE','height=500,width=700,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=no');
idfinestra.document.open();
idfinestra.document.write("<html><scri")
idfinestra.document.write("pt language=javascript>")
idfinestra.document.write("function ridim(){window.resizeTo(document.images[0].width+50,document.images[0].height+90)}</scri")
idfinestra.document.write("pt>")
idfinestra.document.write("<body onLoad=ridim()><center><img src='/ImgLocali/"+id+"'>");
idfinestra.document.write("</center></body></html>");
idfinestra.document.close();
return false;
}

function cambianom(a){
//alert(''+a)
//lung=this.document.cerca.elements[a].length;
//et=this.document.cerca.elements[a].options.selectedLocali;
//ct=this.document.cerca.elements[a].options[et].text;

ct=this.document.cerca.elements[a].value;
//alert(''+ct);
	if(ct!="Cerca locale" && a==0){

	window.navigate('Locali.asp?lista='+ct)
	}

	if(ct!="Tipo di locale" && a==1){

	window.navigate('Locali.asp?tipo='+ct)
	}

}

function modelesswin(url,mwidth,mheight)
{
  if (document.all&&window.print) //if ie5
     eval('window.showModelessDialog(url,"LOCALE IN EVIDENZA","dialogtop:120px;dialogleft:20px;help:0;resizable:0;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
  else
     eval('window.open(url,"LOCALE IN EVIDENZA","width='+mwidth+'px,height='+mheight+'px,resizable=0,scrollbars=0")')
}


function smista(){
window.open('SmistaIscrizione.htm','Iscrizione','height=200,width=400,left=0,top=0,resizable=yes,scrollbars=no,toolbar=no,location=no')
return false;
}

function cancella(){
d=confirm('CANCELLARE IL PROFILO?')
if (d==true) {return true}
else{return false};
}

function mercatino(id){
//alert('')+id
window.open('Mercatino/'+id,'Cittaditorino','height='+(screen.height-100)+',width='+screen.width+',left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=no');
}

function generale(url,titolo,larghezza,altezza){
//alert('')+titolo
window.open(url,titolo,'height='+altezza+',width='+larghezza+',left=0,top=0,resizable=yes,scrollbars=no,toolbar=no,location=no');
return false;
}

function generaleconscroll(url,titolo,larghezza,altezza){
//alert('')+titolo
window.open(url,titolo,'height='+altezza+',width='+larghezza+',left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=no');
return false;
}

function generaleconscrolleloc(url,titolo,larghezza,altezza){
//alert('')+titolo
window.open(url,titolo,'height='+altezza+',width='+larghezza+',left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=yes');
return false;
}

function messag(id){
//alert('')+id
window.open('http://www.regioneliguria.info/Messaggi.asp?ID='+id,'Cittaditorino','height='+(screen.height-50)+',width='+screen.width+',left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=no');
return false;
}

function control(){

ww=document.getElementById('login').value;
aa=document.getElementById('password').value;
si=document.getElementById('sessionid').value;
	if(ww=="" || aa==""){
alert('Inserire sia la login sia la password');
return (false);}else{
//window.navigate('index.asp?valida=Entra&login='+ww+'&password='+aa+'&sid='+si)
document.logg.submit()
}
	}
	
	function passw(){
window.open('http://www.regioneliguria.info/Recupero.asp','PASSWORD','height=200,width=300,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=no')
return false;
}

	function segnalaci(){
window.open('http://www.regioneliguria.info/Segnalaci.asp','PASSWORD','height=400,width=400,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=no')
return false;
}

	function contattaci(){
window.open('http://www.regioneliguria.info/Contattaci.asp','PASSWORD','height=600,width=400,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=no')
return false;
}

function pubbl(id){

var idfinestra = window.open('pippo','DESCRIZIONE','height=500,width=700,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=no,location=no');
idfinestra.document.open();
idfinestra.document.write("<html><scri")
idfinestra.document.write("pt language=javascript>")
idfinestra.document.write("function ridim(){window.resizeTo(document.images[0].width+50,document.images[0].height+90)}</scri")
idfinestra.document.write("pt>")
idfinestra.document.write("<body onLoad=ridim()><center><img src='/ImgLocali/"+id+"'>");
idfinestra.document.write("</center></body></html>");
idfinestra.document.close();
return false;
}

function cambianom(a){
//alert(''+a)
//lung=this.document.cerca.elements[a].length;
//et=this.document.cerca.elements[a].options.selectedLocali;
//ct=this.document.cerca.elements[a].options[et].text;

ct=this.document.cerca.elements[a].value;
//alert(''+ct);
	if(ct!="Cerca locale" && a==0){

	window.navigate('Locali.asp?lista='+ct)
	}

	if(ct!="Tipo di locale" && a==1){

	window.navigate('Locali.asp?tipo='+ct)
	}

}

function Banner(objName){
	this.obj = objName;
	this.aNodes = [];
	this.currentBanner = 0;
	
};

Banner.prototype.add = function(bannerType, bannerPath, bannerDuration, height, width, hyperlink) {
	this.aNodes[this.aNodes.length] = new Node(this.obj +"_"+ this.aNodes.length, bannerType, bannerPath, bannerDuration, height, width, hyperlink);
};

function Node(name, bannerType, bannerPath, bannerDuration, height, width, hyperlink) {
	this.name = name;
	this.bannerType = bannerType;
	this.bannerPath = bannerPath;
	this.bannerDuration = bannerDuration;
	this.height = height
	this.width = width;
	this.hyperlink= hyperlink;
//	alert (name +"|" + bannerType +"|" + bannerPath +"|" + bannerDuration +"|" + height +"|" + width + "|" + hyperlink);
};

Banner.prototype.toString = function() {
	var str = ""
	for (var iCtr=0; iCtr < this.aNodes.length; iCtr++){
		str = str + '<span name="'+this.aNodes[iCtr].name+'" '
		str = str + 'id="'+this.aNodes[iCtr].name+'" ';
		str = str + 'class="m_banner_hide" ';
		str = str + 'bgcolor="#FFFFFF" ';	// CHANGE BANNER COLOR HERE
		str = str + 'align="center" ';
		str = str + 'valign="top">\n';
		if (this.aNodes[iCtr].hyperlink != ""){
			//str = str + '<a href="'+this.aNodes[iCtr].hyperlink+'" target=_blank>';
			//str = str + '<a href="http://www.regioneliguria.info" target=_blank>'
		}
			
		if ( this.aNodes[iCtr].bannerType == "FLASH" ){
			str = str + '<OBJECT '
			str = str + 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
			str = str + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '
			str = str + 'WIDTH="'+this.aNodes[iCtr].width+'" '
			str = str + 'HEIGHT="'+this.aNodes[iCtr].height+'" '
			str = str + 'id="bnr_'+this.aNodes[iCtr].name+'" '
			str = str + 'ALIGN="" '
			str = str + '>'
			str = str + '<PARAM NAME=movie VALUE="'+ this.aNodes[iCtr].bannerPath + '">'
			str = str + '<PARAM NAME=quality VALUE=high>'
			str = str + '<PARAM NAME=bgcolor VALUE=#FFFFFF>'
			str = str + '<PARAM NAME=wmode value=transparent>' 
			str = str + '<EMBED ';
			str = str + 'src="'+this.aNodes[iCtr].bannerPath+'" '
			str = str + 'quality=high '
//			str = str + 'bgcolor=#FFFCDA '
			str = str + 'WIDTH="'+this.aNodes[iCtr].width+'" '
			str = str + 'HEIGHT="'+this.aNodes[iCtr].height+'" '
			str = str + 'NAME="bnr_'+this.aNodes[iCtr].name+'" '
			str = str + 'ALIGN="center" '
			str = str + 'TYPE="application/x-shockwave-flash" '
			str = str + 'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">'
			str = str + '</EMBED>'
			str = str + '</OBJECT>'
			
		}else if ( this.aNodes[iCtr].bannerType == "IMAGE" ){
			str = str + '<img src="'+this.aNodes[iCtr].bannerPath+'" ';
			str = str + 'border="0" ';
			str = str + 'height="'+this.aNodes[iCtr].height+'" ';
			str = str + 'width="'+this.aNodes[iCtr].width+'">';
		}

		if (this.aNodes[iCtr].hyperlink != ""){
			//str = str + '</a>';
		}
		str += '</span>';
	}
	document.write(str)
	var str= ''
	return str;
	
};

Banner.prototype.start = function(){
	this.changeBanner();
	var thisBannerObj = this.obj;
	setTimeout(thisBannerObj+".start()", this.aNodes[this.currentBanner].bannerDuration * 1000);
}

Banner.prototype.changeBanner = function(){
	var thisBanner;
	var prevBanner = -1;
	if (this.currentBanner < this.aNodes.length ){
		thisBanner = this.currentBanner;
		if (this.aNodes.length > 1){
			if ( thisBanner > 0 ){
				prevBanner = thisBanner - 1;
			}else{
				prevBanner = this.aNodes.length-1;
			}
		}
		if (this.currentBanner < this.aNodes.length - 1){
			this.currentBanner = this.currentBanner + 1;
		}else{
			this.currentBanner = 0;
		}
	}
	

	if (prevBanner >= 0){
		document.getElementById(this.aNodes[prevBanner].name).className = "m_banner_hide";
	}
	document.getElementById(this.aNodes[thisBanner].name).className = "m_banner_show";
}
