var oSite = new Object();

oSite.getPlatform = function()
{
     var sUA = navigator.userAgent.toLowerCase();
     if (sUA.indexOf("mac") != -1) return "mac";
     else if (sUA.indexOf("win") != -1) return "min";
     else if (sUA.indexOf("linux") != -1) return "linux";
     else if (sUA.indexOf("x11") != -1) return "unix";
     else return "unknown";
}
oSite.sPlatform = oSite.getPlatform();

// CHANGE CLASSNAME 
oSite.changeClassName = function(elem, className)
{
     var elem = document.getElementById(elem);
     elem.className = className;
}

// SWAP IMAGE
// (ImgId, NewImgName)
oSite.swapImage = function()
{ 
	var args = swapImage.arguments;
	for (i=0; i<args.length; i=i+2) {
          oImgRef = document.getElementById(args[i]);
          oImgRef.src = args[i+1];
	}
}

// EMAIL LINK CREATOR 
oSite.siteDomainName = "sub-hub.com";
oSite.emailLink = function(sEmailName, sDomain, sSubject)
{
    if (!sDomain) var sDomain = oSite.siteDomainName;
	var subject = (sSubject) ? "?" + sSubject : "";
	var sEmailLink = "mailto:" + sEmailName + "@" + sDomain + subject;
    location.href = sEmailLink;
}

// WINDOW OPENER SCRIPT 
oSite.openWindow = function(URLToOpen, windowName, windowWidth, windowHeight, features)
{
	var xPos = (screen.availWidth - windowWidth)/2;
	var yPos = (screen.availHeight - windowHeight)/2;
	var features = "height=" + windowHeight 
				 + ",width=" + windowWidth + ",top=" + yPos 
				 + ",left=" + xPos + "," + features;
	newWindow = window.open(URLToOpen, windowName, features);
	if(newWindow==null)
	{
		alert('We have detected that you are using popup blocking software.\nPlease turn off the popup blocker to enable full functionality.');
	}
	else
	{
		newWindow.focus();
	}
}

oSite.addEvent = function(oObjectRef, sEventType, fFunctionName)
{
	if (oObjectRef.addEventListener){ 
		oObjectRef.addEventListener(sEventType,fFunctionName,false); 
		return true; 
	} else if (oObjectRef.attachEvent){ 
		return oObjectRef.attachEvent("on"+sEventType,fFunctionName); 
	} else { return false; } 
}


// ---[ home page scripts ]-------------------------------------------------
var oHomePage = new Object();
oHomePage.aCitiesIn = [
	"Washington D.C.",
	"Houston, TX",
	"Dallas/Fort Worth, TX",
	"Seattle, WA",
	"Portland, OR"
	];
oHomePage.iArrIndex = 0;
oHomePage.iCitiesArrLength = oHomePage.aCitiesIn.length;

oHomePage.changeCityTxt = function()
{
	var oCitiesTxtRef = document.getElementById('citiesTxt');
	oCitiesTxtRef.innerHTML = oHomePage.aCitiesIn[oHomePage.iArrIndex];
	oHomePage.iArrIndex ++;
	if (oHomePage.iArrIndex == oHomePage.iCitiesArrLength) oHomePage.iArrIndex = 0;
	window.setTimeout("oHomePage.changeCityTxt()", 2000);
}

oHomePage.init = function()
{
	oHomePage.changeCityTxt();
}


// ---[ init scripts ]-------------------------------------------------------
oSite.pgInit = function()
{
     if (document.getElementById('homePage')) oHomePage.init();
}

oSite.addEvent(window, "load", oSite.pgInit);
