var myDirectory = "http://" + document.domain;
var gasTrendFile = "http://" + document.domain + "/gasTrendData.php";

function GetXmlHttpObject(handler)
{
   var objXMLHttp=null;
   
   if (window.XMLHttpRequest)
   {
       objXMLHttp=new XMLHttpRequest();
   }
   else if (window.ActiveXObject)
   {
       objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
   
   return objXMLHttp;
}

function getGasTrendData(instrumentID, gasName, gasID)
{	
   xmlGasTrend=GetXmlHttpObject();
   
   if (xmlGasTrend==null){return;}

   url=gasTrendFile+"?InstrumentID="+instrumentID+"&gasID="+gasID+"&gasName="+gasName; 
   url=url+"&sid="+Math.random();
   xmlGasTrend.open("GET",url,true);

   xmlGasTrend.onreadystatechange=function() 
   {   
	  if (xmlGasTrend.readyState==4 && xmlGasTrend.responseText != '')
	  {
		  var title = "Graph of Time vs. "+gasName+" Concentration (PPB)";
		  thisMovie("myFlashMap").showGasGraph(title,xmlGasTrend.responseText);
	  }
   }     
   
   xmlGasTrend.send(null);	
}

function updateMapCoords(latitude, longitude)
{
	thisMovie("myFlashMap").updateLongitude(longitude);
	thisMovie("myFlashMap").updateLatitude(latitude);
	thisMovie("myFlashMap").updateMapCoords();
	thisMovie("myFlashMap").updateMyMap();
}

function updateLongitude(longitude)
{
	thisMovie("myFlashMap").updateLongitude(longitude);
	thisMovie("myFlashMap").updateMapCoords();
	thisMovie("myFlashMap").updateMyMap();
}

function updateLatitude(latitude)
{
	thisMovie("myFlashMap").updateLatitude(latitude);
	thisMovie("myFlashMap").updateMapCoords();
	thisMovie("myFlashMap").updateMyMap();
}

function updateZoom(zoomLevel)
{
	thisMovie("myFlashMap").updateZoom(zoomLevel);
}

function updateMiles(miles)
{
	thisMovie("myFlashMap").updateMiles(miles);
}

function updateCityID(cityID)
{
	thisMovie("myFlashMap").updateCityID(cityID);
}

function updateCityName(cityName)
{
	thisMovie("myFlashMap").updateCityName(cityName);	
}

function updateStateID(stateID)
{
	thisMovie("myFlashMap").updateStateID(stateID);
}

function updateStateName(stateName)
{
	thisMovie("myFlashMap").updateStateName(stateName);	
}

function updateCountryID(countryID)
{
	thisMovie("myFlashMap").updateCountryID(countryID);
}

function updateCountryName(countryName)
{
	thisMovie("myFlashMap").updateCountryName(countryName);	
}

function thisMovie(movieName) 
{
   if (navigator.appName.indexOf("Microsoft") != -1) 
   {
      return window[movieName]
   }
   else 
   {
     return document[movieName]
   }
}

function isReady()
{
    return javascriptReady;
}

function initJavascript()
{
	javascriptReady = true;	
}
