
var map;
var kml = {
 "artcc": 
 {"url": "http://aviationweather.gov/testbed/kml/artcc.kml" },
 "ice": 
 {"url": "http://aviationweather.gov/data/products/cwsu/cwa/kml/cwaice.kml" },
 "pcpn":
 {"url": "http://aviationweather.gov/data/products/cwsu/cwa/kml/cwapcpn.kml" },
 "ts": 
 {"url": "http://aviationweather.gov/data/products/cwsu/cwa/kml/cwats.kml?12345" },
 "turb":
 {"url": "http://aviationweather.gov/data/products/cwsu/cwa/kml/cwaturb.kml" },
 "ifr":
 {"url": "http://aviationweather.gov/data/products/cwsu/cwa/kml/cwaifr.kml?12345" },
 "lifr":
 {"url": "http://aviationweather.gov/data/products/cwsu/cwa/kml/cwalifr.kml" },
 "frzpcpn":
 {"url": "http://aviationweather.gov/data/products/cwsu/cwa/kml/cwafrzpcpn.kml" }
}

function load() {

if (GBrowserIsCompatible()) {
  map = new GMap2(document.getElementById("map"));
  map.setCenter(new GLatLng(39, -96.1), 4);
  map.enableScrollWheelZoom();
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  map.setMapType(G_PHYSICAL_MAP);
  map.addMapType(G_NORMAL_MAP);
  map.addMapType(G_PHYSICAL_MAP);
 // var bndry = new GGeoXml("http://aviationweather.gov/testbed/kml/artcc.kml");
 // map.addOverlay(bndry);
  
  
 }
}


function toggleKML(checked, id) {

 if(checked== true) {

   currDate = new Date() ;
   day = currDate.getDate() ;
   year = currDate.getFullYear() ;
   month = currDate.getMonth() ;
   hour = currDate.getUTCHours() ;
   min = currDate.getUTCMinutes() ;
   ms = currDate.getMilliseconds() ;
  var geoXml = new GGeoXml(kml[id].url+"?"+year+day+month+hour+min+ms, function() {
   if (geoXml.loadedCorrectly()) {
    
   }
  });
  // This is the new created object not the url property of kml
  kml[id].obj = geoXml;
  map.addOverlay(kml[id].obj);
 }
 else {
  map.removeOverlay(kml[id].obj );
 }
}

//function toggleALL() {


//  var geoXml2 = new GGeoXml(http://www.julieshad.com/weather/cwaice.kml);
//  var geoXml3 = new GGeoXml(http://www.julieshad.com/weather/cwaifr.kml);
//  var geoXml4 = new GGeoXml(http://www.julieshad.com/weather/cwats.kml);
// var geoXml5 = new GGeoXml(http://www.julieshad.com/weather/cwapcpn.kml);
// var geoXml6 = new GGeoXml(http://www.julieshad.com/weather/cwaturb.kml);

  // This is the new created object not the url property of kml

//  map.addOverlay(geoXml2);
// }






