// JavaScript Document
var azmt = {map: null};
var center, posSole, pos2, pos3;
var puntIcon, SoleOn, SoleOff, bandiera;
var marker, markerSole;
function inizia(lat, lon, lente, icona, tipo) {
  if (GBrowserIsCompatible()) {
    azmt.map = new GMap2(document.getElementById("map"));
	center = new GLatLng(lat, lon);
	azmt.map.setCenter(center, lente);
	puntIcon = new GIcon();
	puntIcon.name="centro";
	var icn=document.video.ic.value;
	if(icona==1) {icn="";}
	puntIcon.image = "http://www.nonvedolora.it/gnomonica/grafica/puntatore"+icn+".png";
	puntIcon.iconSize=new GSize(32, 32);puntIcon.iconAnchor=new GPoint(16, 16);puntIcon.maxHeight=0;
    SoleOn = new GIcon();
    SoleOn.name="soleacceso";
	SoleOn.image="http://www.nonvedolora.it/gnomonica/grafica/soleacceso.png";
	SoleOn.iconSize=new GSize(32, 32);SoleOn.iconAnchor=new GPoint(16, 16);SoleOn.maxHeight=0;
	SoleOff = new GIcon();
	SoleOff.name="solespento";
	SoleOff.image="http://www.nonvedolora.it/gnomonica/grafica/solespento.png";
	SoleOff.iconSize=new GSize(32, 32);SoleOff.iconAnchor=new GPoint(16, 16);SoleOff.maxHeight=0;
	marker = new GMarker(center, {icon:puntIcon, draggable:true});
	azmt.map.addOverlay(marker);
    startclock();
	assegna();
	GEvent.addListener(azmt.map, "moveend", function() {
	  center = azmt.map.getCenter();
	  assegna();
	  var lente = azmt.map.getZoom();
      document.video.lnt.value=lente;
	});
	GEvent.addListener(azmt.map, "zoomend", function() {
	  var lente = azmt.map.getZoom();
      document.video.lnt.value=lente;
	  aggiornaRichiamo();
	});
	GEvent.addListener(azmt.map, "maptypechanged", function() {
	  var tp;
	  if(azmt.map.getCurrentMapType()==G_NORMAL_MAP) {tp=0;}
	  if(azmt.map.getCurrentMapType()==G_SATELLITE_MAP) {tp=1;}
	  if(azmt.map.getCurrentMapType()==G_HYBRID_MAP) {tp=2;}
      document.video.tipo.value=tp;
	  aggiornaRichiamo();
	});
	azmt.map.addControl(new GLargeMapControl3D());
	azmt.map.addControl(new GMapTypeControl());
	azmt.map.addControl(new GScaleControl());
	if(tipo==1) {azmt.map.setMapType(G_SATELLITE_MAP);}
	if(tipo==2) {azmt.map.setMapType(G_HYBRID_MAP);}
  }
}
function cambiaIcona(ik) {
  var icnow=document.video.ic.value;
  if(ik==icnow) {return;}
  document.video.ic.value=ik;
  var ik2=ik;
  if(ik==1) {ik2="";}
  puntIcon.image = "http://www.nonvedolora.it/gnomonica/grafica/puntatore"+ik2+".png";
  center=azmt.map.getCenter();
  assegna()
  document.getElementById('ic'+ik).style.backgroundColor='#ffffff';
  document.getElementById('ic'+icnow).style.backgroundColor='#999999';
  if(ik==6) {document.mostraSole.mostra.checked=false;}
}
function aggiornaRichiamo() {
  var dd=2;if(document.video.quadro[0].checked) {dd=1;}
  var tp=document.video.tipo.value;
  var ik=document.video.ic.value;
  var lng=document.video.lingua.value;
  var sl=document.video.sole.value;
  var dove="http://www.nonvedolora.it/gnomonica/coordinate.php?lat="+document.video.lat.value+"&lon="+document.video.lon.value+"&lnt="+document.video.lnt.value+"&quadro="+dd+"&lingua="+lng+"&tipo="+tp+"&ic="+ik+"&sole="+sl;
  document.collega.dove.value=dove;
}
function sistema() {
  if (document.quadro1.sistemo[1].checked==true) {
    document.video.sistema.value="1";
    document.imposta.l1.style.display="none";
    document.imposta.l2.style.display="none";
    document.imposta.l3.style.display="none";
    document.imposta.l4.style.display="";
    document.imposta.m1.style.display="none";
    document.imposta.m2.style.display="none";
    document.imposta.m3.style.display="none";
    document.imposta.m4.style.display="";
  } else {
    document.video.sistema.value="0";
    document.imposta.l1.style.display="";
    document.imposta.l2.style.display="";
    document.imposta.l3.style.display="";
    document.imposta.l4.style.display="none";
    document.imposta.m1.style.display="";
    document.imposta.m2.style.display="";
    document.imposta.m3.style.display="";
    document.imposta.m4.style.display="none";
  }
}
function caricapagina(sez) {
  document.video.action="gnomonica.php";
  document.video.sezione.value=sez;
  document.video.submit();
}
function aggiornasveglia(tipo, quanto) {
  var cosa=document.quando.ora.value;
  var ora, minuti, secondi;
  ora=cosa.substr(0,2);if(cosa.substr(0,1)=="0") {ora=cosa.substr(1,1);}
  ora=parseInt(ora);
  minuti=cosa.substr(3,2);if(cosa.substr(3,1)=="0") {minuti=cosa.substr(4,1);}
  minuti=parseInt(minuti);
  secondi=cosa.substr(6,2);if(cosa.substr(6,1)=="0") {secondi=cosa.substr(7,1);}
  secondi=parseInt(secondi);
  quanto=parseInt(quanto);
  if(tipo=="s") {secondi=secondi+quanto;}
  if(secondi>59) {secondi=secondi-60;minuti=minuti+1;}
  if(secondi<0) {secondi=secondi+60;minuti=minuti-1;}
  if(secondi<10) {secondi=secondi.toString();secondi="0"+secondi;}
  if(tipo=="m") {minuti=minuti+quanto;}
  if(minuti>59) {minuti=minuti-60;ora=ora+1;}
  if(minuti<0) {minuti=minuti+60;ora=ora-1;}
  if(minuti<10) {minuti=minuti.toString();minuti="0"+minuti;}
  if(tipo=="h") {ora=ora+quanto;}
  if(ora>23) {ora=ora-24;}
  if(ora<0) {ora=ora+24;}
  if(ora<10) {ora=ora.toString();ora="0"+ora;}
  cosa=ora+":"+minuti+":"+secondi;
  document.quando.ora.value=cosa;
}
function cambiasveglia() {
  if(document.images["cambia"]==undefined) {return;}
  if(document.images["cambia"].src=="http://www.nonvedolora.it/gnomonica/grafica/aprimenu.gif") {
    document.images["cambia"].src="grafica/chiudimenu.gif";
	document.forms["quando"].style.display="";
  } else {
    document.images["cambia"].src="grafica/aprimenu.gif";
	document.forms["quando"].style.display="none";
  }
}
function copia() {window.clipboardData.setData('Text', document.collega.dove.value);}
function assegna() {
  if(marker) {azmt.map.removeOverlay(marker);}
  marker = new GMarker(center, {icon:puntIcon, draggable:true});
  GEvent.addListener(marker, "dragend", function() {
    center = marker.getPoint();
	azmt.map.panTo(center);
  });
  GEvent.addListener(marker, "dragstart", function() {
    if(markerSole) {azmt.map.removeOverlay(markerSole);}
  });
  azmt.map.addOverlay(marker);
  center=center.toString();
  var lat, lon;
  var lun, pv, emi;
  var lat1, lat2, lat3, lon1, lon2, lon3;
  lun=center.length;
  center=center.substr(1, lun-1);
  center=center.substr(0, lun-2);
  pv=center.search(",");
  lat=parseFloat(center.substr(0,pv));
  lon=parseFloat(center.substr(pv+1, lun-3-pv));
  lat=(parseInt(lat*100000000+.5))/100000000;
  lon=(parseInt(lon*100000000+.5))/100000000;
  document.video.lat.value=lat;
  document.video.lon.value=lon;
  emi="N";
  if (lat<0) {lat=-lat; emi="S";}
  document.imposta.l4.value=lat;
  lat1=parseInt(lat);
  lat=(lat-lat1)*60;
  lat2=parseInt(lat);
  lat3=(parseInt((lat-lat2)*6000+.5))/100;
  if(lat3==60) {lat3=0;lat2=lat2+1;}
  if(lat2==60) {lat2=0;lat1=lat1+1;}
  document.imposta.l1.value=lat1;
  document.imposta.l2.value=lat2;
  document.imposta.l3.value=lat3;
  if (emi=="N") {document.imposta.quadrol[0].checked=true;} else {document.imposta.quadrol[1].checked=true;}
  emi="E";
  if (lon<0) {lon=-lon; emi="W";}
  document.imposta.m4.value=lon;
  lon1=parseInt(lon);
  lon=(lon-lon1)*60;
  lon2=parseInt(lon);
  lon3=(parseInt((lon-lon2)*6000+.5))/100;
  if(lon3==60) {lon3=0;lon2=lon2+1;}
  if(lon2==60) {lon2=0;lon1=lon1+1;}
  document.imposta.m1.value=lon1;
  document.imposta.m2.value=lon2;
  document.imposta.m3.value=lon3;
  if (emi=="E") {document.imposta.quadrom[0].checked=true;} else {document.imposta.quadrom[1].checked=true;}
  aggiornaRichiamo();
}
function startclock() {
  var now=new Date()
  var segno="+";
  var jd, jdA, jdB, secj, lms, ams, ecc, obl, yyy, edt;
  var lat, lon, hlon;
  var hours=now.getUTCHours();
  var minutes=now.getUTCMinutes();
  var seconds=now.getUTCSeconds();
  var tsegno=+1;
  var month=now.getUTCMonth()+1;
  var day=now.getUTCDate();
  var year=now.getUTCFullYear();
  var gmt00="system clock: ";
  var sgmt=now.getHours();
  sgmt=sgmt.toString();if(sgmt.length==1) {sgmt="0"+sgmt;}
  gmt00=gmt00+sgmt+":";
  sgmt=now.getMinutes();sgmt=sgmt.toString();if(sgmt.length==1) {sgmt="0"+sgmt;}
  gmt00=gmt00+sgmt+":";
  sgmt=now.getSeconds();sgmt=sgmt.toString();if(sgmt.length==1) {sgmt="0"+sgmt;}
  gmt00=gmt00+sgmt+" (GMT: "+now.getTimezoneOffset()/(-60)+")";
  var lng=document.video.lingua.value;
  if(document.images["cambia"]!=undefined) {
    if(document.images["cambia"].src=="http://www.nonvedolora.it/gnomonica/grafica/chiudimenu.gif") {
      if("it"==lng) {nomemesi=new Array("gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre");} else {nomemesi=new Array("january","february","march","april","may","june","july","august","september","october","november","december");}
      var cosa=document.quando.ora.value;
	  if(cosa!="") {
        hours=cosa.substr(0,2);if(cosa.substr(0,1)=="0") {hours=cosa.substr(1,1);}
		hours=parseInt(hours);
        minutes=cosa.substr(3,2);if(cosa.substr(3,1)=="0") {minutes=cosa.substr(4,1);}
		minutes=parseInt(minutes);
        seconds=cosa.substr(6,2);if(cosa.substr(6,1)=="0") {seconds=cosa.substr(7,1);}
		seconds=parseInt(seconds);
	  }
      var cosa=document.quando.data.value;
      var dove, day2="";
	  if(cosa!="") {
        if("it"==lng) {
	      dove=cosa.search(" ");day=cosa.substr(0,dove);
		  if(cosa.substr(0,1)=="0") {day=cosa.substr(1,dove);}
		  day=parseInt(day);
		  cosa=cosa.substr(dove+1);
	      dove=cosa.search(" ");month=cosa.substr(0,dove);
	      year=cosa.substr(dove+1,4);year=parseInt(year);
	      for(i=0; i<12; i++) {
		    if(nomemesi[i]==month) {dove=i;}
	      }
	      month=parseInt(dove)+1;
	    } else {
	      dove=cosa.search(" ");month=cosa.substr(0,dove);cosa=cosa.substr(dove+1);
	      dove=cosa.search(" ");day=cosa.substr(0,dove-1);day=parseInt(day);
	      year=cosa.substr(dove+1,4);year=parseInt(year);
	      for(i=0; i<12; i++) {
		    if(nomemesi[i]==month) {dove=i;}
	      }
	      month=parseInt(dove)+1;
	    }
	  }
	}
  }
  var thours=hours;
  var tmin=minutes;
  var tsec=seconds;
  var gmt0="";
  if(hours<10) {gmt0="0";}
  gmt0=gmt0+hours+":";
  if(minutes<10) {gmt0=gmt0+"0";}
  gmt0=gmt0+minutes+":";
  if(seconds<10) {gmt0=gmt0+"0";}
  gmt0=gmt0+seconds;
  if(document.images["cambia"]!=undefined) {
    if(document.images["cambia"].src=="http://www.nonvedolora.it/gnomonica/grafica/chiudimenu.gif") {
      if("it"==lng) {document.quando.data.value=day+" "+nomemesi[month-1]+" "+year;} else {document.quando.data.value=nomemesi[month-1]+" "+day+", "+year;}
	  document.quando.ora.value=gmt0;
	}
  }
  gmt0="GMT 0: "+gmt0;
  document.clockform.clockspot0.value=gmt00;
  document.clockform.clockspot1.value=gmt0;
  lon=document.video.lon.value;
  if(lon<0) {lon=-lon; tsegno=-1;}
  lon=lon/15;
  thours=thours+tsegno*parseInt(lon);
  lon=(lon-parseInt(lon))*60
  tmin=tmin+tsegno*parseInt(lon);
  tsec=tsec+tsegno*parseInt((lon-parseInt(lon))*60+.5);
  if(tsec>59) {tsec=tsec-60; tmin=tmin+1;}
  if(tsec<0) {tsec=tsec+60; tmin=tmin-1;}
  if(tmin>59) {tmin=tmin-60; thours=thours+1;}
  if(tmin<0) {tmin=tmin+60; thours=thours-1;}
  if(thours>23) {thours=thours-23;}
  if(thours<0) {thours=thours+24;} 
  jd=day+(hours+minutes/60+seconds/3600)/24;
  jdA=parseInt(year/100);
  jdB=2-jdA+parseInt(jdA/4);
  jd=parseInt(365.25*(year+4716))+parseInt(30.6001*(month+1))+jd+jdB-1524.5;
  secj=(jd-2415020)/36525;
  lms=279.69668+36000.76892*secj+Math.pow(0.0003025*secj,2);
  ams=358.47583+35999.04975*secj-0.00015*Math.pow(secj,2)-0.0000033*Math.pow(secj,3);
  ecc=0.01675104-0.0000418*secj-0.000000126*Math.pow(secj,2);
  obl=23.452294-0.0130125*secj-0.00000164*Math.pow(secj,2)+0.000000503*Math.pow(secj,3);
  yyy=Math.pow(Math.tan(obl/2*Math.PI/180),2);
  edt=yyy*Math.sin(2*lms*Math.PI/180)-2*ecc*Math.sin(ams*Math.PI/180)+4*ecc*yyy*Math.sin(ams*Math.PI/180)*Math.cos(2*lms*Math.PI/180)-.5*Math.pow(yyy,2)*Math.sin(4*lms*Math.PI/180)-(5/4)*Math.pow(ecc,2)*Math.sin(2*ams*Math.PI/180);
  edt=(edt*180/Math.PI)*4;
  tsegno=1;
  if (edt<0) {segno="-"; tsegno=-1; edt=-edt;}
  edt=((edt*6000)+.5)/6000;
  var edtr=parseInt(edt)
  tmin=tmin+tsegno*edtr;
  tsec=tsec+tsegno*parseInt((edt-edtr)*60);
  if(tsec>59) {tsec=tsec-60; tmin=tmin+1;}
  if(tsec<0) {tsec=tsec+60; tmin=tmin-1;}
  if(tmin>59) {tmin=tmin-60; thours=thours+1;}
  if(tmin<0) {tmin=tmin+60; thours=thours-1;}
  if(thours>23) {thours=thours-23;}
  if(thours<0) {thours=thours+24;}
  var tt=thours+":";if(tmin<10) {tt=tt+"0";}
  tt=tt+tmin+":";if(tsec<10) {tt=tt+"0";}
  tt=tt+tsec;
  edt=parseInt((edt-edtr)*6000);
  edtr=segno+edtr+" m ";if(edt<100) {edtr=edtr+"0";}
  if(edt<10) {edtr=edtr+"0";}
  edtr=edtr+edt;
  var lun=edtr.length;edtr=edtr.substr(0, lun-2)+"."+edtr.substr(lun-2,2);edtr=edtr+" s";
  var frase="EdT";if(lng!="it") {frase="EoT";}
  document.clockform.clockspot2.value=frase+": "+edtr;
  frase="ora vera locale";if(lng!="it") {frase="true local time";}
  document.clockform.clockspot3.value=frase+": "+tt;
  var cs, delta, delta2, lvs, ard, ard2, ardt, lat, htr, htr2, htrt, htrt2;
  lat=document.video.lat.value;
  cs=(1.919460-0.004789*secj-0.000014*Math.pow(secj,2))*Math.sin(ams*Math.PI/180)+(0.020094-0.000100*secj)*Math.sin(2*ams*Math.PI/180)+0.000293*Math.sin(3*ams*Math.PI/180);
  lvs=lms+cs;
  delta=Math.asin(Math.sin(obl*Math.PI/180)*Math.sin(lvs*Math.PI/180))*180/Math.PI;
  frase="declinazione Sole";if(lng!="it") {frase="Sun declination";}
  segno="";delta2=delta;if (delta2<0) {segno="-"; delta2=-delta2;}
  delta2=parseInt(delta2*1000000+.5);
  var deltas=": "+segno;
  if(delta2<1000000) {deltas="000000"+delta2;lun=deltas.length;deltas=deltas.substr(lun-6, 6);deltas=": "+segno+"0"+deltas;
  } else {deltas=deltas+delta2;}
  lun=deltas.length;
  deltas=deltas.substr(0, lun-6)+"."+deltas.substr(lun-6, 6);
  document.clockform.clockspot4.value=frase+deltas;
//  ard=Math.acos((-0.01454-Math.sin(lat*Math.PI/180)*Math.sin(delta*Math.PI/180))/(Math.cos(lat*Math.PI/180)*Math.cos(delta*Math.PI/180)))*180/Math.PI*2/15;
  ard=Math.acos((-Math.sin(lat*Math.PI/180)*Math.sin(delta*Math.PI/180))/(Math.cos(lat*Math.PI/180)*Math.cos(delta*Math.PI/180)))*180/Math.PI*2/15;
  if(ard) {
    ardt=parseInt(ard)+":";
    ard2=(ard-parseInt(ard))*60;
    if(parseInt(ard2)<10) {ardt=ardt+"0";}
    ardt=ardt+parseInt(ard2)+":";
    ard2=parseInt((ard2-parseInt(ard2))*60+.5);
    if (ard2<10) {ardt=ardt+"0";}
    ardt=ardt+ard2;
    htr=3600*12+ard/2*3600-thours*3600-tmin*60-tsec;
    if(htr<0) {htr=htr+24*3600;}
    if(htr>(24*3600-1)) {htr=htr-24*3600;}
    htr=htr/3600;
    htrt=parseInt(htr)+":";
    htr2=(htr-parseInt(htr))*60;
    if(parseInt(htr2)<10) {htrt=htrt+"0";}
    htrt=htrt+parseInt(htr2)+":";
    htr2=parseInt((htr2-parseInt(htr2))*60+.5);
    if (htr2<10) {htrt=htrt+"0";}
    htrt2=htrt+htr2;
    htr=thours*3600+tmin*60+tsec-3600*12+ard/2*3600;
    if(htr<0) {htr=htr+24*3600;}
    if(htr>(24*3600-1)) {htr=htr-24*3600;}
    htr=htr/3600;
    htrt=parseInt(htr)+":";
    htr2=(htr-parseInt(htr))*60;
    if(parseInt(htr2)<10) {htrt=htrt+"0";}
    htrt=htrt+parseInt(htr2)+":";
    htr2=parseInt((htr2-parseInt(htr2))*60+.5);
    if (htr2<10) {htrt=htrt+"0";}
    htrt=htrt+htr2;
  } else {ardt="---";htrt="---";htrt2="---";}
  frase="arco diurno";if(lng!="it") {frase="daylight";}
  document.clockform.clockspot5.value=frase+": "+ardt;
  frase="ore al tramonto";if(lng!="it") {frase="time to sunset";}
  document.clockform.clockspot6.value=frase+": "+htrt2;
  frase="ore dall'alba";if(lng!="it") {frase="true from sunrise";}
  document.clockform.clockspot7.value=frase+": "+htrt;
  var az, alt, altt, altts, az2, az3, azt2, azt2s;
  htr=-(thours+tmin/60+tsec/3600-12)*15;
  alt=Math.asin(Math.sin(lat*Math.PI/180)*Math.sin(delta*Math.PI/180)+Math.cos(lat*Math.PI/180)*Math.cos(delta*Math.PI/180)*Math.cos(htr*Math.PI/180))*180/Math.PI;
  az2=Math.sin(htr*Math.PI/180);
  az=Math.atan(Math.sin(htr*Math.PI/180)/(Math.cos(htr*Math.PI/180)*Math.sin(lat*Math.PI/180)-Math.tan(delta*Math.PI/180)*Math.cos(lat*Math.PI/180)))*180/Math.PI;
  az3=az;
  if(az2>0&&az<0) {az3=180+az;}
  if(az2<0&&az>0) {az3=az-180;}
  if(alt<0) {
	alt=-alt;altts=": -";altt=parseInt((alt*100)+.5);if(altt<100) {altts=altts+"0";}
	if(altt<10) {altts=altts+"0";}
	altts=altts+altt;alt=-alt;
  } else {
	altts=": ";altt=parseInt((alt*100)+.5);if(altt<100) {altts=altts+"0";}
	if(altt<10) {altts=altts+"0";}
    altts=altts+altt;
  }
  lun=altts.length;altts=altts.substr(0, lun-2)+"."+altts.substr(lun-2, 2);
  if(az3<0) {
	az3=-az3;azt2s=": ";azt2=parseInt((az3*100)+.5);if(azt2<100) {azt2s=azt2s+"0";}
	if(azt2<10) {azt2s=azt2s+"0";}
	azt2s=azt2s+azt2;az3=-az3;lun=azt2s.length;azt2s=azt2s.substr(0, lun-2)+"."+azt2s.substr(lun-2, 2)+" W";
  } else {
	azt2s=": ";azt2=parseInt((az3*100)+.5);if(azt2<100) {azt2s=azt2s+"0";}
	if(azt2<10) {azt2s=azt2s+"0";}
	azt2s=azt2s+azt2;lun=azt2s.length;azt2s=azt2s.substr(0, lun-2)+"."+azt2s.substr(lun-2, 2)+" E";
  }
  frase="altezza del Sole";if(lng!="it") {frase="Sun altitude";}
  document.clockform.clockspot8.value=frase+altts;
  frase="azimut del Sole";if(lng!="it") {frase="Sun azimuth";}
  document.clockform.clockspot9.value=frase+azt2s;
  if(markerSole) {azmt.map.removeOverlay(markerSole);}
  if(document.mostraSole.mostra.checked) {
    var aq=300;
	if(document.getElementById('piccolo').checked) {aq=150;}
    pos2 = new GPoint(300+120*Math.sin(az3*Math.PI/180), aq+120*Math.cos(az3*Math.PI/180));
    pos3 = azmt.map.fromContainerPixelToLatLng(pos2);
    if(alt>0) {markerSole = new GMarker(pos3, {icon:SoleOn, draggable:false});} else {markerSole = new GMarker(pos3, {icon:SoleOff, draggable:false});}
    azmt.map.addOverlay(markerSole);
	if(document.video.sole.value==1) {document.video.sole.value=0;aggiornaRichiamo();}
  } else {
	if(document.video.sole.value==0) {document.video.sole.value=1;aggiornaRichiamo();}
  }
  setTimeout('startclock()',1000);
}
function cambiacoordinate() {
  var ll, lat, lon, frase;
  var lng=document.video.lingua.value;
  if (document.quadro1.sistemo[0].checked==true) {
    ll=document.imposta.l1.value;
    ll=parseInt(ll);
	frase="la latitudine non puņ superare 90°";if(lng!="it") {frase="latitude cannot be greater than 90°";}
    if (ll>90) {alert(frase);return;}
    lat=ll;
    ll=document.imposta.l2.value;
    ll=parseInt(ll);
	frase="i primi della latitudine non possono superare 59";if(lng!="it") {frase="minutes of arc of latitude cannot be greater than 59";}
    if (ll>59) {alert(frase);return;}
	frase="con latitudine di 90° i primi devono essere nulli";if(lng!="it") {frase="with 90° latitude the minutes of arc must be 0";}
    if (lat==90&&ll>0) {alert(frase);return;}
    if (ll>0) {lat=lat+ll/60;}
    ll=document.imposta.l3.value;
    ll=parseFloat(ll);
	frase="i secondi della latitudine non possono superare 59";if(lng!="it") {frase="seconds of arc of latitude cannot be greater than 59";}
    if (ll>59) {alert(frase);return;}
	frase="con latitudine di 90° i secondi devono essere nulli";if(lng!="it") {frase="with 90° latitude the seconds of arc must be 0";}
    if (lat==90&&ll>0) {alert(frase);return;}
    if (ll>0) {lat=lat+ll/3600;}
    ll=document.imposta.m1.value;
    ll=parseInt(ll);
	frase="la longitudine non puņ superare 90°";if(lng!="it") {frase="longitude cannot be greater than 180°";}
    if (ll>180) {alert(frase);return;}
    lon=ll;
    ll=document.imposta.m2.value;
    ll=parseInt(ll);
	frase="i primi della longitudine non possono superare 59";if(lng!="it") {frase="minutes of arc of longitude cannot be greater than 59";}
    if (ll>59) {alert(frase);return;}
	frase="con longitudine di 180° i primi devono essere nulli";if(lng!="it") {frase="with 180° longitude the minutes of arc must be 0";}
    if (lon==180&&ll>0) {alert(frase);return;}
    if (ll>0) {lon=lon+ll/60;}
    ll=document.imposta.m3.value;
    ll=parseInt(ll);
	frase="i secondi della longitudine non possono superare 59";if(lng!="it") {frase="seconds of arc of longitude cannot be greater than 59";}
    if (ll>59) {alert(frase);return;}
	frase="con longitudine di 180° i secondi devono essere nulli";if(lng!="it") {frase="with 180° longitude the seconds of arc must be 0";}
    if (lon==180&&ll>0) {alert(frase);return;}
    if (ll>0) {lon=lon+ll/3600;}
  } else {
    lat=document.imposta.l4.value;
	frase="la latitudine non puņ superare 90°";if(lng!="it") {frase="latitude cannot be greater than 90°";}
	if (lat>90) {alert(frase);return}
    lon=document.imposta.m4.value;
	frase="la longitudine non puņ superare 180°";if(lng!="it") {frase="longitude cannot be greater than 180°";}
	if (lon>180) {alert(frase);return}
  }
  if (document.imposta.quadrol[1].checked) {lat=-lat;}
  if (document.imposta.quadrom[1].checked) {lon=-lon;}
  document.video.lat.value=lat;
  document.video.lon.value=lon;
  document.video.submit();
}
function ricorda() {
  var esito=provacookie();
  if (esito==0) {
	if(document.video.lingua.value="it") {alert("Per registrare le impostazioni abilitare i cookies per questa pagina");} else { alert("Enable cookies to save the settings");}
	return;
  }
  document.video.ricuk.value=1;
  document.video.submit();
}
function provacookie() {
  var oggi = new Date();
  var expires = new Date();
  expires.setTime(oggi.getTime() + 600000);
  document.cookie = "prova_cookie=prova; expires=" + expires.toGMTString();
  var asCookies = document.cookie.split("; ");
  var esito=0;
  for(i=0; i< asCookies.length; i++) {
    var asCookie = asCookies[i];
	var lun=asCookie.search("=");
	asCookie=asCookie.substr(0, lun);
    if ("prova_cookie"==asCookie) {
      expires.setTime(oggi.getTime());
	  document.cookie = "prova_cookie=; expires=" + expires.toGMTString();
	  esito=1;return esito;
	}
  }
  return esito;
}

