// © Copyright Symmetric Designs 2006/2007/2008
// All Rights Reserved

// +++ fix GBrowserIsCompatible() calls

//+++ 2nd copy of this in main.js
var cookieVersion = 20;

var map; //+++ change name to googleMap
var mapMarker;
var timeZoneArray=getTimeZoneArray();
var zoomLevel = 3;

// Default country code and city for each time zone.
var timeZoneDefaults=[
		["Pacific-UM","Midway"],                 // GMT-11
		["Pacific-US","Honolulu"],               // GMT-10
		["America-US","Anchorage"],              // GMT-9
		["America-US","Los_Angeles"],            // GMT-8
		["America-US","Denver"],                 // GMT-7
		["America-US","Chicago"],                // GMT-6
		["America-US","New_York"],               // GMT-5
		["America-VE","Caracas"],                // GMT-4
		["America-AR","Argentina/Buenos_Aires"], // GMT-3
		["America-BR","Sao_Paulo"],              // GMT-2
		["Atlantic-PT","Azores"],                // GMT-1
		["Europe-GB","London"],                  // GMT
		["Europe-FR","Paris"],                   // GMT+1
		["Europe-GR","Athens"],                  // GMT+2
		["Europe-RU","Moscow"],                  // GMT+3
		["Asia-IR","Tehran"],                    // GMT+4
		["Asia-PK","Karachi"],                   // GMT+5
		["Asia-IN","Calcutta"],                  // GMT+6
		["Asia-TH","Bangkok"],                   // GMT+7
		["Asia-HK","Hong_Kong"],                 // GMT+8
		["Asia-JP","Tokyo"],                     // GMT+9
		["Australia-AU","Brisbane"],             // GMT+10
		["Australia-AU","Sydney"],               // GMT+11
		["Pacific-FJ","Fiji"],                   // GMT+12
		["Pacific-NZ","Auckland"],               // GMT+13
		["Pacific-NZ","Chatham"]                 // GMT+14
		];

// Default country code and city for specific countries with more than one city.
var countryCodeDefaults=[
		["America-US","Chicago"],
		["America-CA","Toronto"],
		["America-MX","Mexico_City"],
		["Asia-CN","Shanghai"],
		["Asia-RU","Vladivostok"],
		["Australia-AU","Sydney"],
		["Europe-GB","London"],
		["Europe-RU","Moscow"],
		["Pacific-PF","Tahiti"]
		];

function timeZoneFromCookie()
  {
  // Get the timeZone cookie and split it up
	timeZoneString = getCookie("timeZone"+cookieVersion);
	latitude  		= getCookie("latitude"+cookieVersion);
 	longitude 		= getCookie("longitude"+cookieVersion);

//	alert("longitude="+longitude);

	disableSave = false;
	if (timeZoneString != "")
	  {
//alert("here 1");
		timeZoneSplit = timeZoneString.split("/");
		countryCode = timeZoneSplit[0];
		cityName    = timeZoneSplit[1];

		disableSave = true;
	  }

  // If there was no cookie, pick a time zone based on the javascript
  // time offset from GMT and pick a city from the timeZoneDefault table.
  else
    {
//alert("here 2");
		date = new Date();
//		offsetHours = -date.getTimezoneOffset()/60;  // Invert sign to get hours from GMT
		offsetHours = parseInt(hoursDiffStdTime());
		countryCode = timeZoneDefaults[offsetHours + 11][0];  // table start at -11 hours
		cityName    = timeZoneDefaults[offsetHours + 11][1];
		}

//alert("offsetHours="+offsetHours);
//alert("countryCode="+countryCode);
//alert("cityName="+cityName);

  // If lat,long cookies don't exist, get them from timeZoneArray
  // Also get offsetHours from timeZoneArray
	for (ii=0; ii<timeZoneArray.length; ii=ii+1)
	  {
		if (countryCode == timeZoneArray[ii][0])
		  {
  		cityNameArray = timeZoneArray[ii][1];
	  	for (jj=0; jj<cityNameArray.length; jj=jj+1)
  		  {
				if (cityName == cityNameArray[jj][0])
				  {
				  if (latitude == "")
					  latitude = cityNameArray[jj][1];
				  if (longitude == "")
					  longitude = cityNameArray[jj][2];
					offsetHours = cityNameArray[jj][3]/60/60;
					}
				}
			}
		}
//alert("offsetHours="+offsetHours);
//alert("countryCode="+countryCode);
//alert("cityName="+cityName);
  }

function load()
  {
  timeZoneFromCookie();

  /*
  // Get the timeZone cookie and split it up
	timeZoneString = getCookie("timeZone");
	latitude  		= getCookie("latitude");
 	longitude 		= getCookie("longitude");

	disableSave = false;
	if (timeZoneString != "")
	  {
		timeZoneSplit = timeZoneString.split("/");
		countryCode = timeZoneSplit[0];
		cityName    = timeZoneSplit[1];

		disableSave = true;
	  }

  // If there was no cookie, pick a time zone based on the javascript
  // time offset from GMT and pick a city from the timeZoneDefault table.
  else
    {
		date = new Date();
//		offsetHours = -date.getTimezoneOffset()/60;  // Invert sign to get hours from GMT
		offsetHours = parseInt(hoursDiffStdTime());
		countryCode = timeZoneDefaults[offsetHours + 11][0];  // table start at -11 hours
		cityName    = timeZoneDefaults[offsetHours + 11][1];
		}

  // If lat,long cookies don't exist, get them from timeZoneArray
  // Also get offsetHours from timeZoneArray
	for (ii=0; ii<timeZoneArray.length; ii=ii+1)
	  {
		if (countryCode == timeZoneArray[ii][0])
		  {
  		cityNameArray = timeZoneArray[ii][1];
	  	for (jj=0; jj<cityNameArray.length; jj=jj+1)
  		  {
				if (cityName == cityNameArray[jj][0])
				  {
				  if (latitude == "")
					  latitude = cityNameArray[jj][1];
				  if (longitude == "")
					  longitude = cityNameArray[jj][2];
					offsetHours = cityNameArray[jj][3]/60/60;
					}
				}
			}
		}
*/
  // Configure the google map
  if (GBrowserIsCompatible())
	  {
    map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());

    // If zoom level is changed, also change it in Google link below (z=)
		map.setCenter(new GLatLng(37.4419, -122.1419), zoomLevel);	// ++++ is this line needed ??? remove hard coded lat/long

	  var center = map.getCenter();
		mapMarker = new GMarker(center, { title: "Your location", draggable:true });

		GEvent.addListener(map, "moveend", function()
		  {
		  setMapCities();
/*
		  // Get the longititude and convert from +/- 180 (degrees) to +/- 12 (hours)
	  	offsetHours = map.getCenter().lng()*12/180;

	  	// Round to the nearest hour
	  	if (offsetHours > 0) offsetHours += 0.5;
	  	else offsetHours -= 0.5;
	  	offsetHours = parseInt(offsetHours);

			// Use +12 instead of -12
	  	if (offsetHours < -11) offsetHours = -offsetHours;

      // If the calculated offsetHours if different that the current locations time zone
      // change the selected time zone (set setLocation, moveMap to false so we don't recursively
			// move the map again!)
			timeZoneSelectElement=document.getElementById("timeZoneSelect");
			newSelectedIndex = offsetHours + 11;
			if (newSelectedIndex != timeZoneSelectElement.selectedIndex)
			  {
		  	timeZoneSelectElement.selectedIndex = offsetHours + 11;
				selectElementChanged('timeZoneSelect', false, false);
				}
*/
			});

		GEvent.addListener(mapMarker, "dragend", function()
		  {
		  var center = this.getPoint();
			setLocation(center.lat(), center.lng());
			moveMap(center.lat(), center.lng());
			});
    }

  setTimeZone(countryCode, cityName, latitude, longitude, offsetHours, true, true);

  if (disableSave)
	  document.getElementById("saveButton").disabled=true;
  }

// Code taken from:: http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CFB006C45F7
//function checkTimeZone() {
function hoursDiffStdTime()
	{
	var rightNow = new Date();
	var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); // Get UTC time on Jan 1st of this year
//  	var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
	var temp = date1.toGMTString();
//	alert("date1="+temp);
	var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); // Get local time on Jan 1st of this year (Remove time zone ("UTC"))
//  	var temp = date2.toGMTString();
//	alert("date2="+temp);
//  	var date4 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
	var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);  // Calc diff in local and UTC time on Jan 1st
//  	var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60);
//	alert("hoursDiffStdTime="+hoursDiffStdTime);
//	alert("hoursDiffDaylightTime="+hoursDiffDaylightTime);

//  	var observed = (hoursDiffDaylightTime == hoursDiffStdTime);

	return hoursDiffStdTime;
//	return hoursDiffDaylightTime;
	/*
	if (hoursDiffDaylightTime == hoursDiffStdTime) {
	  alert("Time zone is GMT " + hoursDiffStdTime + ".\nDaylight Saving Time is NOT observed here.");
	} else {
	  alert("Time zone is GMT " + hoursDiffStdTime + ".\nDaylight Saving Time is observed here.");
	}
	*/
	}

function setMarkerLocation()
  {
  var center = map.getCenter();
	mapMarker.setPoint(center);
  }

function setLocation(latitude, longitude)
  {
	document.getElementById("latitudeElement").value = latitude;
	document.getElementById("longitudeElement").value = longitude;
/*
  if (GBrowserIsCompatible())
	  {
    // If zoom level is changed, also change it in Google link below (z=)
    // +++ add constanct somewhere to set zoom level
    map.setCenter(new GLatLng(latitude, longitude));

		setMarkerLocation();
    }
*/
	document.getElementById("saveButton").disabled=false;
  }

function moveMap(latitude, longitude)
  {
  if (GBrowserIsCompatible())
	  {
    // If zoom level is changed, also change it in Google link below (z=)
    // +++ add constanct somewhere to set zoom level
    map.setCenter(new GLatLng(latitude, longitude));

		setMarkerLocation();
    }
  }

function insertOption(selectElement, optionText, optionValue)
  {
  var optionElement=document.createElement('option');
  optionElement.text=optionText;
  optionElement.value=optionValue;
  try
    {
    selectElement.add(optionElement,null); // standards compliant
    }
  catch(ex)
    {
    selectElement.add(optionElement); // IE only
    }

  return optionElement;
  }

function selectOption(selectElementName, optionValue)
	{
	var selectElement = document.getElementById(selectElementName)
	for (ii=0;ii<selectElement.length;ii++)
		{
		if (optionValue == selectElement.options[ii].value)
			{
			selectElement.selectedIndex = ii;
			return;
			}
		}
	}

function setCountryCodes()
  {
  var countryCodeElement=document.getElementById("countryCodeSelect")
	for (ii=0; ii<timeZoneArray.length; ii=ii+1)
	  {
		countryCode   = timeZoneArray[ii][0];
		cityNameArray = timeZoneArray[ii][1];
	  optionElement = insertOption(countryCodeElement, countryCode, countryCode);
	  optionElement.countryCode = countryCode;

    cityNameIndex = 0;
		// If there is more than one city for this country code, find the
		// country code entry in countryCodeDefaults.
		if (cityNameArray.length != 0)
			for (jj=0; jj<countryCodeDefaults.length; jj=jj+1)
			  if (countryCode == countryCodeDefaults[jj][0])
			    {
			    // Now, find the index of the default city in cityNameArray
			    cityName = countryCodeDefaults[jj][1];
					for (kk=0; kk<cityNameArray.length; kk=kk+1)
					  if (cityName == cityNameArray[kk][0])
					    cityNameIndex = kk;
			    }

	  optionElement.cityName    = cityNameArray[cityNameIndex][0];
	  optionElement.latitude    = cityNameArray[cityNameIndex][1];
	  optionElement.longitude   = cityNameArray[cityNameIndex][2];
	  optionElement.offsetHours = cityNameArray[cityNameIndex][3]/60/60;
		}
	}

function setCountryCodeCities()
  {
  var countryCodeElement=document.getElementById("countryCodeSelect")
  var countryCodeCityElement=document.getElementById("countryCodeCitySelect")

	for (ii=countryCodeCityElement.length-1; ii>=0; ii=ii-1)
    {
    countryCodeCityElement.remove(ii);
    }

	countryCode   = timeZoneArray[countryCodeElement.selectedIndex-1][0];
	cityNameArray = timeZoneArray[countryCodeElement.selectedIndex-1][1];
	for (jj=0; jj<cityNameArray.length; jj=jj+1)
		{
		cityName = cityNameArray[jj][0];
		optionElement = insertOption(countryCodeCityElement, cityName, cityName);
		optionElement.countryCode = countryCode;
		optionElement.cityName    = cityName;
		optionElement.latitude    = cityNameArray[jj][1];
		optionElement.longitude   = cityNameArray[jj][2];
		optionElement.offsetHours = cityNameArray[jj][3]/60/60;
		}
	}

function setTimeZones()
	{
	var timeZoneSelectElement=document.getElementById("timeZoneSelect")
	for (kk=-11; kk<=14; kk=kk+1)
		{
		defaultCountryCode = timeZoneDefaults[kk+11][0];
		defaultCityName    = timeZoneDefaults[kk+11][1];
		for (ii=0; ii<timeZoneArray.length; ii=ii+1)
			{
			countryCode = timeZoneArray[ii][0];
			if (defaultCountryCode == countryCode)
				{
				cityNameArray = timeZoneArray[ii][1];
				for (jj=0; jj<cityNameArray.length; jj=jj+1)
				  {
					cityName = cityNameArray[jj][0];
					if (defaultCityName == cityName)
						{
					  optionElement = insertOption(timeZoneSelectElement, kk, kk);
					  optionElement.countryCode = countryCode;
					  optionElement.cityName    = cityName;
					  optionElement.latitude    = cityNameArray[jj][1];
					  optionElement.longitude   = cityNameArray[jj][2];
					  optionElement.offsetHours = cityNameArray[jj][3]/60/60;
				    }
			    }
	      }
      }
    }
	}

function setTimeZoneCities()
  {
//	map.clearOverlays();

	var timeZoneElement=document.getElementById("timeZoneSelect");
  var timeZoneCityElement=document.getElementById("timeZoneCitySelect")
	for (ii=timeZoneCityElement.length-1; ii>=0; ii=ii-1)
    {
    timeZoneCityElement.remove(ii);
    }
	for (ii=0; ii<timeZoneArray.length; ii=ii+1)
	  {
		countryCode = timeZoneArray[ii][0];
    continent = countryCode.substring(0,countryCode.indexOf("-"));
		cityNameArray = timeZoneArray[ii][1];
		for (jj=0; jj<cityNameArray.length; jj=jj+1)
		  {
			cityName = cityNameArray[jj][0];
		  offsetHours = cityNameArray[jj][3]/60/60;
		  // Select cities within +/- 1 hour of selected time zone
			if ((offsetHours >= (parseInt(timeZoneElement.value)-1.0)) &&
			    (offsetHours <= (parseInt(timeZoneElement.value)+1.0)))
        {
			  var latitude = cityNameArray[jj][1];
			  var longitude = cityNameArray[jj][2];

		  	// Add cities to pull down within +/- 0.5 hours of selected time zone
				if ((offsetHours >= (parseInt(timeZoneElement.value)-0.5)) &&
				    (offsetHours <= (parseInt(timeZoneElement.value)+0.5)))
				  {
				  optionText  = countryCode + "/" + cityName + " (" + offsetHours + ")";
	
				  optionElement = insertOption(timeZoneCityElement, optionText, countryCode + "/" + cityName);
				  optionElement.countryCode = countryCode;
				  optionElement.cityName    = cityName;
				  optionElement.latitude    = latitude;
				  optionElement.longitude   = longitude;
				  optionElement.offsetHours = offsetHours;
			    }
/*
		  	// Add a map pin for those cities within +/- 1.5 hours of selected time zone
				var pinLocation = new GLatLng(latitude, longitude);

			  var icon = new GIcon(G_DEFAULT_ICON);
			  //icon.image = "http://www.google.com/mapfiles/markerA.png";
			  icon.image = "http://www.DaysUntil.com/images/dd-start.png";
			  // baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";

				var pinMarker = new GMarker(pinLocation, { title: cityName, icon: icon });
				pinMarker.timeZoneCitySelectedIndex = timeZoneCityElement.length - 1;
				pinMarker.countryCode = countryCode;
				pinMarker.cityName    = cityName;
				pinMarker.latitude    = latitude;
				pinMarker.longitude   = longitude;
				pinMarker.offsetHours = offsetHours;

			  map.addOverlay(pinMarker);

				GEvent.addListener(pinMarker, "click", pinMarkerClicked);
*/
				}
			}
		}

//  map.addOverlay(mapMarker);
	}

var mapOffsetHours = -100; // Illegal value to force mapping of cities on the first call
function setMapCities()
  {
  // Get the longititude and convert from +/- 180 (degrees) to +/- 12 (hours)
	newOffsetHours = map.getCenter().lng()*12/180;

	// Round to the nearest hour
//	if (newOffsetHours > 0) newOffsetHours += 0.5;
//	else newOffsetHours -= 0.5;
//	newOffsetHours = parseInt(newOffsetHours);

	// Use +12 instead of -12
//	if (newOffsetHours < -11) newOffsetHours = -newOffsetHours;

  // If the offset hours hasn't changed, just return
//  if (newOffsetHours == mapOffsetHours)
//    return;

  mapOffsetHours = newOffsetHours;

	map.clearOverlays();
xyz = 0;
	for (ii=0; ii<timeZoneArray.length; ii=ii+1)
	  {
		countryCode = timeZoneArray[ii][0];
    continent = countryCode.substring(0,countryCode.indexOf("-"));
		cityNameArray = timeZoneArray[ii][1];
		for (jj=0; jj<cityNameArray.length; jj=jj+1)
		  {
			cityName = cityNameArray[jj][0];
		  offsetHours = cityNameArray[jj][3]/60/60;

		  var latitude = cityNameArray[jj][1];
		  var longitude = cityNameArray[jj][2];

			distance = map.getCenter().distanceFrom(new GLatLng(latitude, longitude));
//			if (xyz <= 4)
//			  alert(distance);
xyz += 1;
			plotCity = false;
//			if (map.getCenter().distanceFrom(new GLatLng(latitude, longitude)) < 2000000)
			if (map.getCenter().distanceFrom(new GLatLng(latitude, longitude)) < 1500000)
			  plotCity = true;
/*
			plotCity = false;
		  // Select cities within +/- 1.5 hours of selected time zone (map position)
			if ((offsetHours >= (mapOffsetHours-1.5)) &&
			    (offsetHours <= (mapOffsetHours+1.5)))
        plotCity = true;

      // Handle the international date line
		  // If >= 10.5 also plot <=-10.5
		  // If >= 11.5 also plot >=-11.5
		  // if <=-10.5 also plot >= 10.5
		  // if <=-11.5 also plot <=-11.5
			if (mapOffsetHours >=  10.5 && offsetHours <= -10.5) plotCity = true;
			if (mapOffsetHours >=  11.5 && offsetHours >= -11.5) plotCity = true;
			if (mapOffsetHours <= -10.5 && offsetHours >=  10.5) plotCity = true;
			if (mapOffsetHours <= -11.5 && offsetHours <= -11.5) plotCity = true;
*/
			// Plot the city if it's within range
			if (plotCity)
        {
//			  alert(distance);
//			  var latitude = cityNameArray[jj][1];
//			  var longitude = cityNameArray[jj][2];

		  	// Add a map pin for those cities within +/- 1.5 hours of selected time zone
				var pinLocation = new GLatLng(latitude, longitude);

			  var icon = new GIcon(G_DEFAULT_ICON);
			  //icon.image = "http://www.google.com/mapfiles/markerA.png";
//			  icon.image = "http://www.DaysUntil.com/images/dd-start.png";
			  icon.image = "/images/dd-start.png";

			  // baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";

				var pinMarker = new GMarker(pinLocation, { title: cityName, icon: icon });

				pinMarker.countryCode = countryCode;
				pinMarker.cityName    = cityName;
				pinMarker.latitude    = latitude;
				pinMarker.longitude   = longitude;
//				pinMarker.offsetHours = parseInt(offsetHours);

				// ??? What is the +/- 0.5 for? (handling .5 hr offset time zone of something?)	
				if (offsetHours > 0)
					pinMarker.offsetHours = parseInt(offsetHours + 0.5);
				else
					pinMarker.offsetHours = parseInt(offsetHours - 0.5);

//if (cityName == "New_York")
//	alert ("cityName1="+pinMarker.cityName+":offsetHours="+offsetHours+"/pinMarker.offsetHours="+pinMarker.offsetHours);
//	alert ("cityName1="+cityName+"/offsetHours="+this.offsetHours);
				
			  map.addOverlay(pinMarker);

				GEvent.addListener(pinMarker, "click", pinMarkerClicked);
				}
			}
		}

  map.addOverlay(mapMarker);
	}

function pinMarkerClicked()
	{
	// When a pin is moved, change the location, but don't move the map (or we'll mess up the shown times zones)
	//+++??? why not move the map
//	alert ("cityName="+this.cityName+" offsetHours="+this.offsetHours);
  setTimeZone(this.countryCode, this.cityName, this.latitude, this.longitude, this.offsetHours, true, true);
	}

function setTimeZone(countryCode, cityName, latitude, longitude, offsetHours, flagSetLocation, flagMoveMap)
	{
  selectOption("countryCodeSelect", countryCode);
  setCountryCodeCities();

//	alert ("cityName="+cityName+" offsetHours="+offsetHours);
  selectOption("timeZoneSelect", offsetHours);
  setTimeZoneCities();
  setMapCities();

//alert(countryCode + ":" + cityName + ":" + offsetHours);
  selectOption("countryCodeCitySelect", cityName);
  selectOption("timeZoneCitySelect",    countryCode + "/" + cityName);

  if (flagSetLocation)
    setLocation(latitude, longitude);

  if (flagMoveMap)
    moveMap(latitude, longitude);
	}

function selectElementChanged(elementName, flagSetLocation, flagMoveMap)
	{
	var selectElem = document.getElementById(elementName);
	option = selectElem.options[selectElem.selectedIndex];
	setTimeZone(option.countryCode, option.cityName, option.latitude, option.longitude, option.offsetHours, flagSetLocation, flagMoveMap);
	}

function saveTimeZone()
  {
//  var timeZoneElement=document.getElementById("timeZoneCitySelect");
  var latitudeElement=document.getElementById("latitudeElement");
  var longitudeElement=document.getElementById("longitudeElement");

//	countryCodeIndex = parseInt(timeZoneElement.value / 1000);
//	cityIndex        = timeZoneElement.value % 1000;
//  cityArray = timeZoneArray[countryCodeIndex][1][cityIndex];

//  countryCode            = timeZoneArray[countryCodeIndex][0];
//  cityName               = cityArray[0];
//  latitudeElement.value  = cityArray[1];
//  longitudeElement.value = cityArray[2];

  countryCode = document.getElementById("countryCodeSelect").value;
  cityName    = document.getElementById("countryCodeCitySelect").value;

	setCookie("timeZone"+cookieVersion,countryCode + "/" + cityName,365);
	setCookie("latitude"+cookieVersion,latitudeElement.value,365);
	setCookie("longitude"+cookieVersion,longitudeElement.value,365);

	document.getElementById("saveButton").disabled=true;
  }

function getCookie(c_name)
	{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=")
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1 
	    c_end=document.cookie.indexOf(";",c_start)
	    if (c_end==-1) c_end=document.cookie.length
	    return unescape(document.cookie.substring(c_start,c_end))
	    } 
	  }
	return ""
	}

/*
function setCookie(c_name,value,expiredays)
	{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie=c_name+ "=" + escape(value) +
	  ";path=" + cookiePath +
	  ";domain=" + cookieDomain +
	  ((expiredays==null) ? "" : ";expires="+exdate);
	}
*/

function submitForm()
	{
	formElem=document.getElementById("daysUntilForm");
	formElem.submit();
	}
