var active = null;
//
var agent = navigator.userAgent.toLowerCase(); 
var isMac = (agent.indexOf("mac") != -1) ? true : false;
var isMSIE = (navigator.appVersion.indexOf("MSIE")!=-1) ? true : false;
var ajaxBusy = false;
//
toCamelCase=function (s) {
	for (var exp = /-([a-z])/; exp.test(s); s=s.replace(exp, RegExp.$1.toUpperCase())) {
	}
	return s;
}
//
getStyle=function (el, style) {
	if (!document.getElementById) {
		return;
	}
	var value = el.style[toCamelCase(style)];
	if (!value) {
		if (document.defaultView) {
			value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
		} else if (el.currentStyle) {
			value = el.currentStyle[toCamelCase(style)];
		}
	}
	return value;
}
//
getElement=function(id){	
	if (!document.getElementById){
	 return;
	}
	//
	if (document.getElementById){
		// this is the way the standards work
		var el = document.getElementById(id);
	}else if (document.all){
		// this is the way old msie versions work
		var  el = document.all[id];
	}else if (document.layers){
		// this is the way nn4 works
		var el = document.layers[id];
	}
	return el;
}
//
toggleDisplay=function(el){
	el.style.display = el.style.display ? "" : "block";
}
//


//
switchContent=function(id){	
	//turn off last active
	if(active){
		toggleDisplay(active);
	}
	active=getElement(id);
	toggleDisplay(active);	

	trackEvent(window.location.host, "/"+id+".ajaxPage", id, '');
}
//
writeToolbar=function(src){
	(getElement('toolbar')).innerHTML='<iframe src="'+src+'" name="toolbarframe" height="26" width="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>';
}
//
function trackEvent(domain, URL, Title, offSite) {
	dcsMultiTrack('DCS.dcssip',domain,'DCS.dcsuri',URL,'WT.ti',Title,'WT.os',offSite);
}

function GetXMLHttpObject()
{
      var oXMLHttp = null;

      try
      {
            oXMLHttp = new ActiveXObject("MSXML2.XMLHTTP");
      }
      catch (E)
      {
            try
            {
                  oXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (E)
            {
              oXMLHttp = null;
            }
    }

      if ((oXMLHttp == null) && (typeof(XMLHttpRequest) != 'undefined'))
      {
            oXMLHttp = new XMLHttpRequest();
      }

      return oXMLHttp;
}

var ajaxBusy = false;

function swapNews(news)
{
	if(ajaxBusy)
	{
		oXMLHttp.onreadystatechange = function () {};
		oXMLHttp.abort();
	}

	var oXMLHttp = GetXMLHttpObject();
	
	var url= "includes/news.php?startAt="+news;
	
	document.getElementById('newsContent').innerHTML = "Loading News...";
	
	oXMLHttp.open("GET", url, true);

	oXMLHttp.onreadystatechange = function()
	    {
		  if (oXMLHttp.readyState == 4)
		  {
			document.getElementById('newsContent').innerHTML = oXMLHttp.responseText;
			ajaxBusy = false;
		  }
	    }

	oXMLHttp.send(null);
	ajaxBusy = true;
}

function getDates()
{
	if(ajaxBusy)
	{
		oXMLHttp.onreadystatechange = function () {};
		oXMLHttp.abort();
	}

	var oXMLHttp = GetXMLHttpObject();
	
	var url= "php/homeTour.php";
	
	document.getElementById('dates').innerHTML = "<span id=\"tourDate\">Loading Dates...</span>";
	
	oXMLHttp.open("GET", url, true);

	oXMLHttp.onreadystatechange = function()
	    {
		  if (oXMLHttp.readyState == 4)
		  {
			document.getElementById('dates').innerHTML = oXMLHttp.responseText;
			ajaxBusy = false;
		  }
	    }

	oXMLHttp.send(null);
	ajaxBusy = true;
}

function stopAudio()
{

	document.getElementById('mediaplayerf').stopAudio();
}
