
function PageURL(pageID) {
	/* This function takes a page id and returns the corresponding url */
	/* Set the site root */
	var strRoot = "/";
	/* Set the directories */
	var strMain = strRoot + "Main/";
	var strContact = strRoot + "Contact/";
	/* Check the page id */
	switch("" + pageID) {
			/* Site Root */
			case "PAGE_HOME":
				strPage = strMain + "home.htm";
				break;
			/* Contact */
			case "PAGE_CONTACT":
				strPage = strContact + "home.aspx";
				break;
			/* Main */
			case "PAGE_SITE_MAP":
				strPage = strMain + "siteMap.aspx";
				break;
			case "PAGE_LEGAL":
				strPage = strMain + "legal.aspx";
				break;
			case "PAGE_LINKING_POLICY":
				strPage = strMain + "linkingPolicy.aspx";
				break;
			case "PAGE_PRIVACY_POLICY":
				strPage = strMain + "privacyPolicy.aspx";
				break;
			/* EC-Group -specific */
			case "PAGE_MAP":
				strPage = "http://maps.yahoo.com/py/maps.py?BFCat=&Pyt=Tmap&newFL=%20%20Use+Address+Below&addr=12101+Woodcrest+Executive+Drive&csz=63141&Country=us&Get%20%20 Map=Get+Map";
				break;
			
			default:
				strPage = strMain + "home.aspx";
				break;
		}
		return strPage;
}

/* Modified 8/13/2005 - LRR: Added Download function for handling associated links */
function Download(downloadType, itemID) {
	alert("This link should initiate the download for " + downloadType + " Item ID#" + itemID);
}


function ShowPage(pageID, args) {
		/* This function is used to centralize calls to open pages that need to be displayed in a specific manner, 
		**	i.e. a non-standard size pop-up window 
		*/
		var strPage = PageURL(pageID);
		args = PrepShowPageArgs(args);
		strPage+=args;
		switch("" + pageID) {
			/* Special Opens */
			case "PAGE_LEGAL":
				PopOpen(strPage);
				break;
			case "PAGE_LINKING_POLICY":
				PopOpen(strPage);
				break;
			case "PAGE_PRIVACY_POLICY":
				PopOpen(strPage);
				break;
			case "PAGE_CONTACT":
				PopOpen(strPage);
				return;
				break;
			case "PAGE_SITE_MAP":
				PopOpen(strPage);
				break;
			case "PAGE_MAP":
				PopOpen(strPage);
				break;
			default:
				OpenFullWindow(strPage);
				break;
		}
		return;
}

/* WINDOW MANAGEMENT FUNCTIONS */
/* We need this var to ensure that each window is (relatively) unique to avoid cross-browser issues.  - LRR/02.28.2005 */
var winNum=Math.floor(Math.random() * 100);

function PopOpen(url) {
  /* This function opens the url in a smaller pop-up window */
		var popUpWin;
		winNum+=1;
		popUpWin=window.open(url,"win" + winNum,"width=550,height=600,status=yes,resizable=yes,location=yes,directories=yes,menubar=yes,toolbar=yes,scrollbars=yes,top=50,left=100");
		popUpWin.focus();
}

function SetOpenerLocation(url) {
	if (opener) {
		opener.location = url;
		//CloseWindow();	
	} else {
		//document.location = url;
		OpenFullWindow(url);
	}			
}
	
function OpenFullWindow(url) {
	/* This function opens the url in a full-size window */
	var fullWin;
	winNum+=1;
	fullWin=window.open(url,"win" + winNum,"height=400,width=600,status=yes,resizable=yes,location=yes,directories=yes,menubar=yes,toolbar=yes,scrollbars=yes,top=50,left=50");
	fullWin.focus();
}

function CloseWindow() {
	/* Close the Current Window */
	window.close();
}

function PrepShowPageArgs(pstrArgs) {
	 	/* Note that the strDefaultArgs var is typically set on the server-side, 
		** i.e. var strDefaultArgs="<%=sServerDefaultArgs%>";
		*/
		var strDefaultArgs = ""; 
		if (pstrArgs != "" && strDefaultArgs != "") {
			strDefaultArgs = strDefaultArgs + "&" + pstrArgs;
		} else {
			if (pstrArgs != "") {
				strDefaultArgs = pstrArgs;
			}
		} 
		if (strDefaultArgs!="") {
			strDefaultArgs = "?" + strDefaultArgs;
		}
		return strDefaultArgs;
	}
	
	function GoToPage(pageID, args) {
			/* Go to a new page - append page args to the url */
			var strPage = PageURL(pageID);
			args = PrepShowPageArgs(args);
			strPage+=args;
			document.location = strPage;
	}

	/* Modified 9/7/2005 - LRR: Added PopToPage function */
	function PopToPage(pageID, args) {
			/* Open the page in a pop-up window - append page args to the url */
			var strPage = PageURL(pageID);
			args = PrepShowPageArgs(args);
			strPage+=args;
			PopOpen(strPage);
	}
