		/* 		 * Global Variables		 */                var minZoomLevel = 5;		var region = "ITALIA";		var mypopup;		var infowindow = new google.maps.InfoWindow(); 				var ParentTabIndex = 'dhtmlgoodies_tabView1';		var SoundingTabIndex;		var WindgramTabIndex;		var BlipmapTabIndex = 0;		var n_soundings = 0;		var n_windgrams = 0;      var clckTimeOut = null; //per discrimare doppio click    var currIndex = 0;				var currSoundingId;    var currSoundingDesc;				var  BlipmapTabIndex;				var map;		var oldmap;		var allowedBounds;		var mapBounds;		var desc = [];		var wgID = [];		var soundingDesc = [];    var sound_lat = [];		var sound_lon = [];		var sound_markers=[];		var windgram_markers=[];		var sound_polies=[];		var windgram_polies=[];    var day_xmlhttp;		var par_xmlhttp;		var GmPar_xmlhttp;		var gmParas = [];		var url_xmlhttp;                		var Blipmapper = "http://www.ilpulcino.org/rasp/blipmapper.php?";    var Blipurler = "http://www.ilpulcino.org/rasp/blipurler.php?";		var oldDayIndex;		var Loaded;		var ffversion;		var fullSet;		// var ref;		var oldParam;		var oldDay;		var oldRegion;		var paramWindow;		var origTblHt;		var imgHt;		var	imgSiz;		var times = [                     ["10:00","1000"],                     ["11:00", "1100"],                    ["12:00", "1200"],                    ["13:00", "1300"],                    ["14:00", "1400"],                    ["15:00", "1500"],                    ["16:00", "1600"],                    ["17:00", "1700"],                    ["18:00", "1800"],                    ["19:00", "1900"],                    ["20:00", "2000"]                  ];    var dayList = [];function hidePopupMenu(){  var menu = mypopup.style.display='none';}    function findPos(obj) {	var curleft = curtop = 0;	if (obj.offsetParent) {	  do {		  	 curleft += obj.offsetLeft;			   curtop += obj.offsetTop;		   } while (obj = obj.offsetParent);	}	return [curleft,curtop];}		 	function showContextMenu(caurrentLatLng  ) {         var clickedPosition = getCanvasXY(caurrentLatLng);         var lat = Math.round(caurrentLatLng.lat()*10000)/10000;         var lon = Math.round(caurrentLatLng.lng()*10000)/10000;         var abs = findPos(document.getElementById('map_canvas'));         xabs = clickedPosition.x + abs[0];         yabs = clickedPosition.y + abs[1];         //alert ("Lat: " + lat + ", lon: " + lon + ", x-rel: " + clickedPosition.x + ", y-rel: " + clickedPosition.y +         //       ", x-abs: " + xabs + ", y-abs: " + yabs);         //mypopup.innerHTML = '<ul>' +         //                    '<li>Lat: ' + lat + '</li>' +         //                    '<li>Lng: ' + lon + '</li>' +         //                    '</ul>';         mypopup.style.top = yabs + 'px';         mypopup.style.left = xabs + 'px';         document.getElementById('popupmenu-lat').innerHTML = lat + " N";         document.getElementById('popupmenu-lon').innerHTML = lon + " E";         mypopup.style.display = 'block'; }function getCanvasXY(caurrentLatLng){      var scale = Math.pow(2, map.getZoom());      var nw = new google.maps.LatLng(          map.getBounds().getNorthEast().lat(),          map.getBounds().getSouthWest().lng()      );      var worldCoordinateNW = map.getProjection().fromLatLngToPoint(nw);      var worldCoordinate = map.getProjection().fromLatLngToPoint(caurrentLatLng);      var caurrentLatLngOffset = new google.maps.Point(          Math.floor((worldCoordinate.x - worldCoordinateNW.x) * scale),          Math.floor((worldCoordinate.y - worldCoordinateNW.y) * scale)      );      return caurrentLatLngOffset;}function hideShowHTMLItem(itemID, iState) {    htmlItem = document.getElementById(itemID);    if (htmlItem) {      if (iState == 0) {  // hide        htmlItem.style.display = 'none';      } else {  // show        htmlItem.style.display = '';     }    }  }function php_urlencode (str) {  str = escape(str);  return str.replace(/[*+\/@]|%20/g,    function (s) {      switch (s) {        case "*": s = "%2A"; break;        case "+": s = "%2B"; break;        case "/": s = "%2F"; break;        case "@": s = "%40"; break;        case "%20": s = "+"; break;      }      return s;    });}function changeHour(dir,obj) {   var currValue = document.getElementById("Time").selectedIndex;  var newValue = (currValue + dir);  if (newValue < 0 ||  newValue > times.length-1) return;  document.getElementById("Time").options[newValue].selected  = true;  if (newValue == 0 ||  newValue == times.length-1) {    obj.style.color='#888888';    obj.style.fontStyle='italic';  } else {    document.getElementById("nextHour").style.color=document.getElementById("prevHour").style.color='black';    document.getElementById("nextHour").style.fontStyle=document.getElementById("prevHour").style.fontStyle='normal';  }  loadImage();} /**function mapClick() {   if (clckTimeOut) {     window.clearTimeout(clckTimeOut);     clckTimeOut = null;     //doubleClick();   } else {     clckTimeOut = window.setTimeout(function()       {singleClick()},500);   } } function doubleClick() {   if (clckTimeOut) {     window.clearTimeout(clckTimeOut);     clckTimeOut = null;   }  // Process double click   //alert("doppio click");} function singleClick() {         window.clearTimeout(clckTimeOut);         clckTimeOut = null;         // Process single click 				var i = document.getElementById("Time").selectedIndex;				i = (i + 1) % times.length;				document.getElementById("Time").options[i].selected   = true;				loadImage();} **/function soundingClick() {         // Process single click 				var i = document.getElementById("soundingTime").selectedIndex;				i = (i + 1) % times.length;				document.getElementById("soundingTime").options[i].selected   = true;				loadSounding();} function windgramClick() {         // Process single click ;                                var windgramDay = document.getElementById("windgramDay");                                windgramDay.selectedIndex = (windgramDay.selectedIndex + 1) % windgramDay.options.length; 				windgramDay.options[windgramDay.selectedIndex].selected   = true;				loadWindgram();}  /*********************** * initIt()             * *                      * * Initialise Variables * * Build Menus, etc     * ***********************/function initIt(){ 		// ref = document.forms[0];	// shorthand		oldDayIndex = document.getElementById("Day").options.selectedIndex;		oldParam = document.getElementById("Param").options.value;		oldDay = document.getElementById("Day").value;    oldRegion = document.getElementById("region").value;    //mypopup = document.getElementById('contextmenu');    mypopup = document.getElementById('popupmenu');try {document.body['onclick'] = function() {mypopup.style.display = 'none'; return true;}}catch(error) {};		paramWindow = "" ;    var strictDocType = true;    initTabs(ParentTabIndex,Array('Blipmaps'),0,830,"",Array(false));    //var tab=getTabIndexByTitle('Blipmaps');    BlipmapTabIndex = currIndex++; //tab[1];    switch(document.getElementById("region").value)    {    case "ITALIA_NE":      // alert("A causa di un problema tecnico sono saltati gli aggiornamenti per il NORD EST per il 10 (oggi) e 11 (domani). ALCUNE Blipmap ed TUTTI i windgram del NE sono quelli generati ieri. Controllate la pagina Stato Elaborazioni per i dettagli!");      break;        default:          }        		// Google Map Inizializations         var lat=gmParas["center_lat"];         var lon=gmParas['center_lon'];         var latlng = new google.maps.LatLng(lat,lon);         minZoomLevel=parseInt(gmParas['zoom_level'])+1;         var myOptions = {            zoom: minZoomLevel,            center: latlng,            mapTypeId: google.maps.MapTypeId.TERRAIN,            scrollwheel: false,            draggableCursor: "crosshair"         };        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);        //google.maps.event.addListener(map, 'click', mapClick);         google.maps.event.addListener(map, "rightclick",function(event){showContextMenu(event.latLng);});        //google.maps.event.addListener(map, 'click', function() { alert("click"); });        //google.maps.event.addListener(map, 'dblclick', doubleClick);/**        //** Listen for the dragend event        google.maps.event.addListener(map, 'dragend', function() {          if (allowedBounds.contains(map.getCenter())) return;          // Out of bounds - Move the map back within the bounds          var c = map.getCenter(),            x = c.lng(),            y = c.lat(),            maxX = allowedBounds.getNorthEast().lng(),            maxY = allowedBounds.getNorthEast().lat(),            minX = allowedBounds.getSouthWest().lng(),            minY = allowedBounds.getSouthWest().lat();          if (x < minX) x = minX;          if (x > maxX) x = maxX;          if (y < minY) y = minY;          if (y > maxY) y = maxY;          //alert("map.setCenter(new google.maps.LatLng("+y+","+x+"));");          map.setCenter(new google.maps.LatLng(y, x));       });      // Limit the zoom level      google.maps.event.addListener(map, 'zoom_changed', function() {        //alert(map.getZoom());        if (map.getZoom() < minZoomLevel) {          map.setZoom(minZoomLevel);        } else {          var b = map.getBounds(),              width = b.getNorthEast().lng() - b.getSouthWest().lng(),              heigth = b.getNorthEast().lat() - b.getSouthWest().lat();              //alert("old " +  allowedBounds.getNorthEast().lng());              allowedBounds = new google.maps.LatLngBounds(new google.maps.LatLng(parseFloat(gmParas['south_lat'])+heigth/2,parseFloat(gmParas['west_lon'])+width/2),                                                           new google.maps.LatLng(parseFloat(gmParas['north_lat'])-heigth/2,parseFloat(gmParas['east_lon'])-width/2)                                                          );	               //alert("new " +  allowedBounds.getNorthEast().lng());        }      });**/  		/**********************/		/* Build the Day Menu */		/**********************/		var Now = new Date().getTime();	// Time now - in milliSec(!)		var mS_Day = 24 * 60 * 60 * 1000;	// mS in a day		var T = new Date();			// Instantiate a Date object                // fill available days for selected region  		RequestDays(document.getElementById("region").value); 		/***********************/		/* Set Default Options */		/***********************/		// Parameters		RequestParameters(document.getElementById("region").value);    		document.getElementById("Param").onchange = doChange;	// Install handler		document.getElementById("Day").onchange = doChange;	// Install handler		document.getElementById("Time").onchange = doChange;	// Install handler		document.getElementById("region").onchange = doChange;	// Install handler                document.getElementById("soundingDay").onchange = loadSounding;	// Install handler		document.getElementById("soundingTime").onchange = loadSounding;	// Install handler		document.getElementById("soundingParam").onchange = loadSounding;	// Install handler				document.getElementById("windgramDay").onchange = loadWindgram;	// Install handler		document.getElementById("windgramParam").onchange = loadWindgram;	// Install handler 				document.getElementById("windgramCheckbox").onclick = showWindgrams;	// Install handler		document.getElementById("soundingCheckbox").onclick = showSoundings;	// Install handler		}function add_windgram_marker(lat,lon,id,desc,gridCenter,gridSize) {  var yellowIcon = new google.maps.MarkerImage('http://www.ilpulcino.org/images/markeryellow.png',                   new google.maps.Size(20, 34),                   new google.maps.Point(0,0), // origin                   new google.maps.Point(9, 34)); // anchor     // Shapes define the clickable region of the icon.      // The type defines an HTML &lt;area&gt; element 'poly' which      // traces out a polygon as a series of X,Y points. The final      // coordinate closes the poly by connecting to the first      // coordinate.  var shape = {      coord: [1, 1, 1, 20, 18, 20, 18 , 1],      type: 'poly'  };  var myLatlng = new google.maps.LatLng(lat,lon);    var whichMap;  if (document.getElementById("windgramCheckbox").checked) {    whichMap = map;  } else {    whichMap = null;  }  windgram_markers[n_windgrams] = new google.maps.Marker({                       position: myLatlng,                        map: whichMap,                        title:desc,                       icon:yellowIcon,                       shape: shape,                       zIndex: 50                       //icon: 'http://google-maps-icons.googlecode.com/files/info.png'                      });   attachWindgram(windgram_markers[n_windgrams],id,desc);  var coords = [          new google.maps.LatLng(gridCenter[0]-gridSize[0]/2, gridCenter[1]-gridSize[1]/2),          new google.maps.LatLng(gridCenter[0]+gridSize[0]/2, gridCenter[1]-gridSize[1]/2),          new google.maps.LatLng(gridCenter[0]+gridSize[0]/2, gridCenter[1]+gridSize[1]/2),          new google.maps.LatLng(gridCenter[0]-gridSize[0]/2, gridCenter[1]+gridSize[1]/2),          new google.maps.LatLng(gridCenter[0]-gridSize[0]/2, gridCenter[1]-gridSize[1]/2)      ];    windgram_polies[n_windgrams] = new google.maps.Polygon({        paths: coords,        map: whichMap,         strokeColor: "#FFFFFF",        strokeOpacity: 0.7,        strokeWeight: 2,        fillColor: "#FFFFFF",        fillOpacity: 0.15      });  n_windgrams++;  }function showSoundings() {  if (document.getElementById("soundingCheckbox").checked) {    showMarkers(sound_markers,map);    showMarkers(sound_polies,map);  } else {    showMarkers(sound_markers,null);    showMarkers(sound_polies,null);  }}function showWindgrams() {  if (document.getElementById("windgramCheckbox").checked) {    showMarkers(windgram_markers,map);    showMarkers(windgram_polies,map);  } else {    showMarkers(windgram_markers,null);    showMarkers(windgram_polies,null);  }}function showMarkers(markers,whichMap) {  for (var i=0; i<markers.length ; i++) {    markers[i].setMap(whichMap);  }}function add_sounding_marker(lat,lon,id,desc,windgramID,gridCenter,gridSize) {  var redIcon = new google.maps.MarkerImage('http://www.ilpulcino.org/images/markerred.png',                new google.maps.Size(20, 34),                new google.maps.Point(0,0), // origin                new google.maps.Point(9, 34)); // anchor     // Shapes define the clickable region of the icon.      // The type defines an HTML &lt;area&gt; element 'poly' which      // traces out a polygon as a series of X,Y points. The final      // coordinate closes the poly by connecting to the first      // coordinate.  var shape = {      coord: [1, 1, 1, 20, 18, 20, 18 , 1],      type: 'poly'  };  var myLatlng = new google.maps.LatLng(lat,lon);    var whichMap;  if (document.getElementById("soundingCheckbox").checked) {    whichMap = map;  } else {    whichMap = null;  }  sound_markers[n_soundings] = new google.maps.Marker({                       position: myLatlng,                        map: whichMap,                        title:desc,                       icon: redIcon,                       shape: shape,                       zIndex: 100                       //icon: 'http://google-maps-icons.googlecode.com/files/info.png'                      });   attachSounding(sound_markers[n_soundings],id,desc,windgramID);    //alert(gridCenter[0]);    var coords = [          new google.maps.LatLng(gridCenter[0]-gridSize[0]/2, gridCenter[1]-gridSize[1]/2),          new google.maps.LatLng(gridCenter[0]+gridSize[0]/2, gridCenter[1]-gridSize[1]/2),          new google.maps.LatLng(gridCenter[0]+gridSize[0]/2, gridCenter[1]+gridSize[1]/2),          new google.maps.LatLng(gridCenter[0]-gridSize[0]/2, gridCenter[1]+gridSize[1]/2),          new google.maps.LatLng(gridCenter[0]-gridSize[0]/2, gridCenter[1]-gridSize[1]/2)      ];    sound_polies[n_soundings] = new google.maps.Polygon({        paths: coords,        map: whichMap,         strokeColor: "#FFFFFF",        strokeOpacity: 0.7,        strokeWeight: 2,        fillColor: "#FFFFFF",        fillOpacity: 0.15      });  n_soundings++;}function attachSounding(marker,soundingID,desc,windgramID) {  var contentString = '<div id="content">' +     '<h4>' + desc + '</h4>' +    '<A HREF="javascript:void(0)" onclick="openSounding(\''+soundingID +'\',\''+desc + '\')">Visualizza Curva di Stato</A><br />' +    '<A HREF="javascript:void(0)" onclick="openWindgram(\''+windgramID +'\',\''+desc + '\')">Visualizza windgram</A>' +    '</div>';      google.maps.event.addListener(marker, 'click', function() {     infowindow.setContent(contentString);    infowindow.open(map,marker);   });}function attachWindgram(marker,windgramID,desc) {  var contentString = '<div id="content">' +     '<h4>' + desc + '</h4>' +    '<A HREF="javascript:void(0)" onclick="openWindgram(\''+windgramID +'\',\''+desc + '\')">Visualizza windgram</A>' +    '</div>';    google.maps.event.addListener(marker, 'click', function() {     infowindow.setContent(contentString);    infowindow.open(map,marker);   });}function openSounding(soundingID,desc) {        infowindow.close(map,this);        document.getElementById("soundingTime").options[document.getElementById("Time").selectedIndex].selected = true;        document.getElementById("soundingDay").options[document.getElementById("Day").selectedIndex].selected = true;        document.getElementById("soundingParam").value = soundingID;        document.getElementById("soundingParam").text = desc;        loadSounding();        }function openWindgram(windgramID,desc) {        infowindow.close(map,this);        document.getElementById("windgramDay").options[document.getElementById("Day").selectedIndex].selected = true;        document.getElementById("windgramParam").value = windgramID;        document.getElementById("windgramParam").text = desc;        loadWindgram();        }/**************************************** *      END OF INITIALISATION STUFF     * *      Start of functions              * ****************************************//***************************//* Set Initial Image Size  *//***************************/function setSize(){}/*******************************//* CallBack from the selectors *//*******************************/function doChange(){      var donotload = false;			if(document.getElementById("Param").value === "nope1" ) {				return 0;		// Catch a stupid selection			}			/*  Descriptions */			(document.getElementById("desc")).innerHTML = desc[document.getElementById("Param").selectedIndex] ;      					/* Reload Parm List if changed region*/			if (oldRegion !== document.getElementById("region").value) {			   			   // reload par list	      	RequestParameters(document.getElementById("region").value)        	  		/* Reload Day List if changed region*/  	  		RequestDays(document.getElementById("region").value);  	  		  	  		//donotload = true;  	  		      }    									/* Save current values, so can detect change */			oldParam = document.getElementById("Param").value;			oldDay = document.getElementById("Day").value;                        oldRegion = document.getElementById("region").value;						/* Load images */			  if (!donotload) loadImage();}/************************************//* Load the Image *//************************************/function loadImage(){	var tIdx = document.getElementById("Time").selectedIndex;	var tValue;	var imgURL;	var T = new Date();			// Instantiate a Date object; initialised to "Now"	var str;	tValue = document.getElementById("Time").options[tIdx].value;	offset = document.getElementById("Day").selectedIndex;	if(offset > 1){		T.setDate(T.getDate() + offset - 1);	}	month = T.getMonth() + 1;	if(month < 10) month = "0" + month;	rasp_date = T.getDate();	if(rasp_date < 10) rasp_date = "0" + rasp_date;	year = T.getFullYear();	// alert(date + "/" + month + "/" + year);	tValue = document.getElementById("Time").options[tIdx].value; 	par=document.getElementById("Param").value;		  if (par.substring(0,8) != 'sounding') {  	imgURL = Blipurler  			+ "type=FCST"  			+ "&par="+par  			+ "&day="+document.getElementById("Day").value  			+ "&time="+tValue // + "lst.w2"  			+ "&region="+document.getElementById("region").value  			+ "&dummy="+(new Date()).getTime() //Cache Buster  		;  	//alert("request URL " + imgURL);  	RequestURL(imgURL);  	var title= document.getElementById("Param").options[document.getElementById("Param").selectedIndex].text;  	changeTitle(ParentTabIndex,0,title);	}}/************************** * badimage()             * * Put up a warning image * * if image not found etc * **************************/function badImage(){							alert("No Image!");}function changedTab(parentId,tabIndex) {  // call back function from tab-view: called whenever the active tab changes!!  //alert("tabindex = " + typeof(tabIndex) + " SoundingTabIndex = " + typeof(SoundingTabIndex));  switch(tabIndex * 1) {    case SoundingTabIndex:      hideShowHTMLItem("paramSelector", 0);      hideShowHTMLItem("slider-container", 0);      hideShowHTMLItem("blipmapSelector", 0);      hideShowHTMLItem("markersSelector", 0);      hideShowHTMLItem("soundingSelector",1);        hideShowHTMLItem("soundingParamSelector",1);       hideShowHTMLItem("windgramSelector",0);        hideShowHTMLItem("windgramParamSelector",0);       break;    case WindgramTabIndex:      hideShowHTMLItem("paramSelector", 0);      hideShowHTMLItem("slider-container", 0);      hideShowHTMLItem("blipmapSelector", 0);      hideShowHTMLItem("markersSelector", 0);      hideShowHTMLItem("soundingSelector",0);        hideShowHTMLItem("soundingParamSelector",0);       hideShowHTMLItem("windgramSelector",1);        hideShowHTMLItem("windgramParamSelector",1);       break;    default:      hideShowHTMLItem("paramSelector", 1);      hideShowHTMLItem("slider-container", 1);      hideShowHTMLItem("blipmapSelector", 1);      hideShowHTMLItem("markersSelector", 1);      hideShowHTMLItem("soundingSelector",0);        hideShowHTMLItem("soundingParamSelector",0);      hideShowHTMLItem("windgramSelector",0);        hideShowHTMLItem("windgramParamSelector",0);   }}function loadSounding(){	var tIdx = document.getElementById("soundingTime").selectedIndex;	var tValue;	var T = new Date();			// Instantiate a Date object; initialised to "Now"	var str;	tValue = document.getElementById("soundingTime").options[tIdx].value;	offset = document.getElementById("soundingDay").selectedIndex;	if(offset > 1){		T.setDate(T.getDate() + offset - 1);	}	month = T.getMonth() + 1;	if(month < 10) month = "0" + month;	rasp_date = T.getDate();	if(rasp_date < 10) rasp_date = "0" + rasp_date;	year = T.getFullYear();	// alert(date + "/" + month + "/" + year);	  var imgURL = Blipmapper  			+ "type=FCST"  			+ "&par=" + document.getElementById("soundingParam").value  			+ "&day=" + document.getElementById("soundingDay").value  			+ "&time="  +tValue // + "lst.w2"  			+ "&region=" + document.getElementById("region").value  			+ "&dummy="+(new Date()).getTime() //Cache Buster  	;     var title="Sounding per " +   document.getElementById("soundingParam").options[document.getElementById("soundingParam").selectedIndex].text;    if (document.getElementById("sounding_canvas")) {      changeTitle(ParentTabIndex,SoundingTabIndex,title);      document.getElementById("sounding_canvas").src = imgURL;      showTab(ParentTabIndex,SoundingTabIndex);    } else {      SoundingTabIndex = 1 * createNewTab(ParentTabIndex,title,'<img id="sounding_canvas" onClick="soundingClick()" style="width: 800px; height: 800px" src="' + imgURL + '" />','',false);    }    changedTab(ParentTabIndex,SoundingTabIndex);      }function loadWindgram(){	var tValue;	var T = new Date();			// Instantiate a Date object; initialised to "Now"	var str;	offset = document.getElementById("windgramDay").selectedIndex;	if(offset > 1){		T.setDate(T.getDate() + offset - 1);	}	month = T.getMonth() + 1;	if(month < 10) month = "0" + month;	rasp_date = T.getDate();	if(rasp_date < 10) rasp_date = "0" + rasp_date;	year = T.getFullYear();	// alert(date + "/" + month + "/" + year);	  	;   var wgURL = Blipmapper  			+ "type=WINDGRAMS"  			+ "&par=" + document.getElementById("windgramParam").value  			+ "&day=" + document.getElementById("windgramDay").value  			+ "&region=" + document.getElementById("region").value  			+ "&dummy="+(new Date()).getTime() //Cache Buster  	;   	    var wgTitle="Windgram per " + document.getElementById("windgramParam").options[document.getElementById("windgramParam").selectedIndex].text;    if (document.getElementById("windgram_canvas")) {      changeTitle(ParentTabIndex,WindgramTabIndex,wgTitle);      document.getElementById("windgram_canvas").src = wgURL;    } else {      WindgramTabIndex = 1 * createNewTab(ParentTabIndex,wgTitle,'<img id="windgram_canvas"  onClick="windgramClick()" style="width: 800px; height: 800px" src="' + wgURL + '" />','',false);    }    showTab(ParentTabIndex,WindgramTabIndex);    changedTab(ParentTabIndex,WindgramTabIndex);      }function RequestGmParameters()  {  GmPar_xmlhttp=GetXmlHttpObject();  if (GmPar_xmlhttp==null)    {    alert ("Your browser does not support XML HTTP Request");    return;    }  var url="http://www.ilpulcino.org/php/ajax.php?type=gm_paras&region="+document.getElementById("region").value+"&dummy="+(new Date()).getTime();  GmPar_xmlhttp.onreadystatechange=fillGmParameters;  GmPar_xmlhttp.open("GET",url,true);  GmPar_xmlhttp.send(null);  }function fillGmParameters(){  if (GmPar_xmlhttp.readyState==4) {    gmParas=JSON.parse(GmPar_xmlhttp.responseText);      initIt();     }}function RequestParameters(region)  {  par_xmlhttp=GetXmlHttpObject();  if (par_xmlhttp==null)    {    alert ("Your browser does not support XML HTTP Request");    return;    }  var url="http://www.ilpulcino.org/php/ajax.php?type=paras&region="+region+"&dummy="+(new Date()).getTime();  par_xmlhttp.onreadystatechange=fillParameters;  par_xmlhttp.open("GET",url,true);  par_xmlhttp.send(null);  }function fillParameters(){  if (par_xmlhttp.readyState==4) {    fullSet = false;    var parsize = 0;    var soundsize = 0;    var windgramsize = 0;    soundingList=JSON.parse(par_xmlhttp.responseText);         if (null == soundingList) return;      for (var i = 0; i < soundingList.length; i++) {      if (soundingList[i][1].substring(0,8) == "sounding" || soundingList[i][2] == "Curve di stato") {        if (soundingList[i][2] != "Curve di stato") {          add_sounding_marker(soundingList[i][4],soundingList[i][5],soundingList[i][1],soundingList[i][3],soundingList[i][6],soundingList[i][7],soundingList[i][8]);          document.getElementById("soundingParam").options[soundsize] = new Option(soundingList[i][3], soundingList[i][1]);          document.getElementById("soundingParam").options[soundsize].className = soundingList[i][0];          } else {          document.getElementById("soundingParam").options[soundsize] = new Option(soundingList[i][2], soundingList[i][1]);          document.getElementById("soundingParam").options[soundsize].className = soundingList[i][0];          }           soundsize++;                          } else {        if (soundingList[i][1].indexOf("windgram") > 0 || soundingList[i][2] == "Windgram") {          if (soundingList[i][2] != "Windgram") {            add_windgram_marker(soundingList[i][3],soundingList[i][4],soundingList[i][1],soundingList[i][2],soundingList[i][5],soundingList[i][6]);            document.getElementById("windgramParam").options[windgramsize] = new Option(soundingList[i][2], soundingList[i][1]);            document.getElementById("windgramParam").options[windgramsize].className = soundingList[i][0];            } else {            document.getElementById("windgramParam").options[windgramsize] = new Option(soundingList[i][2], soundingList[i][1]);            document.getElementById("windgramParam").options[windgramsize].className = soundingList[i][0];            }             windgramsize++;                            } else {          document.getElementById("Param").options[parsize] = new Option(soundingList[i][2], soundingList[i][1]);          document.getElementById("Param").options[parsize].className = soundingList[i][0];          desc[parsize] = soundingList[i][3];            	      if (soundingList[i][1]=="hbl") document.getElementById("Param").options[parsize].selected  = true;	          parsize++;        }      }    }  			    if(document.getElementById("Param").options.length > parsize){      for(i = parsize; i < document.getElementById("Param").length; i++){        document.getElementById("Param").options[i] = null;      }    }    document.getElementById("Param").options.length = parsize;    document.getElementById("Param").size = parsize;    document.getElementById("soundingParam").options.length = soundsize;    document.getElementById("soundingParam").size = soundsize;    document.getElementById("windgramParam").options.length = windgramsize;    document.getElementById("windgramParam").size = windgramsize;    document.getElementById("desc").innerHTML = desc[document.getElementById("Param").selectedIndex] ;    // Load first image    //setTimeout("loadImage()", 2000);           loadImage();     }}function RequestURL(url)  {   //alert("request: " + url);  url_xmlhttp=GetXmlHttpObject();  if (url_xmlhttp==null)    {    alert ("Your browser does not support XML HTTP Request");    return;    }  url_xmlhttp.onreadystatechange=setURL;  url_xmlhttp.open("GET",url,true);  url_xmlhttp.send(null);  }function setURL() {  if (url_xmlhttp.readyState==4) {    var url = php_urlencode(url_xmlhttp.responseText);    //alert("response: " + url);    //if (url != "unavailable.png") {      if (oldmap) {        //alert("about to set " + Blipmapper + "type=PNG&part=body&par=" + url);        oldmap.url_ = Blipmapper + "type=PNG&part=body&par=" + url;        //oldmap.setOpacity(50);        //alert("press700");        //oldmap.url = "http://www.ilpulcino.org/gapi/maps/press700.curr+1.1400lst.w2.body.png";        oldmap.draw();      } else {        // crerate ground overlay        //alert("new "+ url_xmlhttp.responseText);        mapBounds = new google.maps.LatLngBounds(new google.maps.LatLng(gmParas['south_lat'],gmParas['west_lon']), new google.maps.LatLng(gmParas['north_lat'],gmParas['east_lon']));	         //var b = map.getBounds(),        //    width = b.getNorthEast().lng() - b.getSouthWest().lng(),        //    heigth = b.getNorthEast().lat() - b.getSouthWest().lat();        //allowedBounds = new google.maps.LatLngBounds(new google.maps.LatLng(parseFloat(gmParas['south_lat'])+heigth/2,parseFloat(gmParas['west_lon'])+width/2),        //                                                new google.maps.LatLng(parseFloat(gmParas['north_lat'])-heigth/2,parseFloat(gmParas['east_lon'])-width/2)        //                                               );	                	oldmap = new ProjectedOverlay(Blipmapper + "type=PNG&part=body&par=" + url, mapBounds, map);                //create slider                var slider = new SimpleSlider(document.getElementById('slider-container'), {          onSlide: function(pos) {            oldmap.setOpacity(pos);          },          max: 100,          startPosition: 60,          width: 150,          formatPosFn: function(pos) { return Math.floor(pos) + '%'; }        });              }      if (url != "unavailable.png") {        document.getElementById("header_canvas").src = Blipmapper + "type=PNG&part=head&par=" + url;        document.getElementById("footer_canvas").src = Blipmapper + "type=PNG&part=foot&par=" + url;      }  }}function RequestDays(region)  {  day_xmlhttp=GetXmlHttpObject();  if (day_xmlhttp==null)    {    alert ("Your browser does not support XML HTTP Request");    return;    }  var url="http://www.ilpulcino.org/php/ajax.php?type=days&region="+region+"&dummy="+(new Date()).getTime();  day_xmlhttp.onreadystatechange=fillDays;  day_xmlhttp.open("GET",url,true);  day_xmlhttp.send(null);  }function fillDays() {  if (day_xmlhttp.readyState==4) {    dayList=JSON.parse(day_xmlhttp.responseText);    if (null == dayList) return;        var day = document.getElementById("Day");	// save typing    var soundingDay = document.getElementById("soundingDay");	// save typing    var windgramDay = document.getElementById("windgramDay");	// save typing    var parsize = 0;    var selected = false;		    for (var i = 0; i < dayList.length; i++) {      day.options[parsize] = new Option(dayList[i][1], dayList[i][0]);      soundingDay.options[parsize] = new Option(dayList[i][1], dayList[i][0]);      windgramDay.options[parsize] = new Option(dayList[i][1], dayList[i][0]);      if (dayList[i][0] < 0) {        day.options[parsize].className = "optionArchive";        soundingDay.options[parsize].className = "optionArchive";        windgramDay.options[parsize].className = "optionArchive";      }      if (dayList[i][0] == 0) {  	day.options[parsize].selected = true;	  	soundingDay.options[parsize].selected  = true;	   	windgramDay.options[parsize].selected  = true;	 	selected = true;      }      parsize++;    }    if (!selected) {      day.options[parsize-1].selected = true;      soundingDay.options[parsize-1].selected  = true;      windgramDay.options[parsize-1].selected  = true;    }		       if(day.options.length > parsize) {      for(i = parsize; i < day.length; i++) {        day.options[i] = null;        soundingDay.options[i] = null;        windgramDay.options[i] = null;      }    }    day.options.length = parsize;    soundingDay.options.length = parsize;    windgramDay.options.length = parsize;    day.options.size = soundingDay.options.size = windgramDay.options.size = 1;    oldDay = day.value;  }  // Install Time options  var time = document.getElementById("Time");  var soundingTime = document.getElementById("soundingTime");  for (var i = 0; i < times.length; i++) {    time.options[i] = new Option(times[i][0], times[i][1]);    soundingTime.options[i] = new Option(times[i][0], times[i][1]);    if(times[i][0] == "12:00") {      time.options[i].selected = true;    }  }  time.options.size = soundingTime.options.size = 1;		}function GetXmlHttpObject(){if (window.XMLHttpRequest)  {  // code for IE7+, Firefox, Chrome, Opera, Safari  return new XMLHttpRequest();  }if (window.ActiveXObject)  {  // code for IE6, IE5  return new ActiveXObject("Microsoft.XMLHTTP");  }return null;} function setDivs(){    var header;    var footer;    var index;    /**    switch(region)    {      case "ITALIA":        header = 95;        footer = 65;        break;      case "ITALIA_CN":        header = 188;        footer = 154;        break;      default:        // Default values for square grid        header = 68;        footer = 53;    }    **/        index = document.getElementById("Day").selectedIndex;    header = dayList[index][2];    footer = dayList[index][3];        /**document.getElementById("map_header").style.height = header + "px";    document.getElementById("map_footer").style.height = footer + "px";    document.getElementById("map_footer").style.top = 830-footer + "px";    document.getElementById("theMap_footer").style.top = -(830-footer) + "px";**/}/**** Subclass of Ground Overlay to add Opacity ****/function ProjectedOverlay(imageUrl, bounds, map){ this.url_ = imageUrl ; this.bounds_ = bounds ; this.map_ = map ;        // Add the zoom to the image as a parameter this.id = imageUrl ;        // Added to allow for multiple images this.percentOpacity = 60;  // Explicitly call setMap() on this overlay this.setMap(map); // Is this IE, if so we need to use AlphaImageLoader var agent = navigator.userAgent.toLowerCase(); if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)) {  this.ie = true ; } else {  this.ie = false ; } this.ie = false ;}ProjectedOverlay.prototype = new google.maps.OverlayView();ProjectedOverlay.prototype.onAdd = function(){ var div = document.createElement("div") ; div.style.position = "absolute" ; div.setAttribute('id',this.id) ;  this.div_ = div ;  var panes = this.getPanes();  panes.overlayLayer.appendChild(div); if( this.percentOpacity ) {  this.setOpacity(this.percentOpacity) ; }}// Remove the main DIV from the map paneProjectedOverlay.prototype.remove = function(){ this.div_.parentNode.removeChild(this.div_); this.div_ = null;}// Copy our data to a new ProjectedOverlay...//ProjectedOverlay.prototype.copy = function()//{// return new ProjectedOverlay(this.url_, this.bounds_, this.addZ_);//}// Redraw based on the current projection and zoom level...ProjectedOverlay.prototype.draw = function(){ // We only need to redraw if the coordinate system has changed //if (!force) //{ // return ; //} var overlayProjection = this.getProjection(); var c1 = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest()); var c2 = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast()); // Now position our DIV based on the DIV coordinates of our bounds this.div_.style.width = Math.abs(c2.x - c1.x) + "px"; this.div_.style.height = Math.abs(c2.y - c1.y) + "px"; this.div_.style.left = Math.min(c2.x, c1.x) + "px"; this.div_.style.top = Math.min(c2.y, c1.y) + "px";  var url = this.url_ ; if (this.ie) {  var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod='scale');" ;  this.div_.innerHTML = '<div style="height:' + this.div_.style.height + 'px; width:' + this.div_.style.width + 'px; ' + loader + '" ></div>' ; } else {  this.div_.innerHTML = '<img src="' + url + '"  width=' + this.div_.style.width + ' height=' + this.div_.style.height + ' >' ; }}ProjectedOverlay.prototype.setOpacity=function(opacity){ if (opacity < 0) {  opacity = 0 ; } if(opacity > 100) {  opacity = 100 ; } var c = opacity/100 ; var d = document.getElementById( this.id ) ; if (d) {   if (typeof(d.style.filter) =='string')   {     d.style.filter = 'alpha(opacity:' + opacity + ')' ;   }   if (typeof(d.style.KHTMLOpacity) == 'string' )   {     d.style.KHTMLOpacity = c ;   }   if (typeof(d.style.MozOpacity) == 'string')   {    d.style.MozOpacity = c ;   }   if (typeof(d.style.opacity) == 'string')   {    d.style.opacity = c ;   } }}
