//<!-- TOPIC Javascript Libraries -->
// Functions for Demo System
// Include this with amessages.js

// Check if this is a demo site
function IsDemo() {
	var szHost = window.location.hostname;
	var szPort = window.location.port;

	if (szHost.indexOf("fafsademo") >= 0 ||
		szHost.indexOf("fotwdemo")  >= 0 ||
	    szHost.indexOf("demodev")   >= 0 ||
		szPort == "8099" || szPort == "8499" ) {
		return true;
	} else {
	 	return false;
	}
}

// Check if this is FAA Access
function IsFAA() {
	var szHost = window.location.hostname;

	if (szHost.toLowerCase() == "faaaccess.ed.gov") {
		return true;
	} else {
	 	return false;
	}
}

// Add a link to the demo page
function AddDemoLink() {
	if (IsDemo()) {
		var a = "<a href=\"/webdemo.htm\">" + szDemoName + "</a>";
		document.writeln(a);
	}
}

// Block access to an application.
// return true if block the demo; false if no block
function BlockDemo() {
	if (IsDemo()) {
		alert(szDemoBlockMsg);
		return true;
	} else {
		return false;
	}
}

// This is for WebTrend tagging.  Call this inside the <head> tag at the top of the page.
function AddWTInitTag() {
	if (IsDemo()) {
		var tag = "<script src=\"/js/wtinit_fafsademo.js\" type=\"text/javascript\"></script>\n";
		document.writeln(tag);	
	}
	else {
		if (IsFAA()) {
			var tag = "<script src=\"/js/wtinit_FAFSA.js\" type=\"text/javascript\"></script>\n";
			document.writeln(tag);	
		}
	}
}

// This is for WebTrend tagging.  Call this right above </body> at the end of the page.
function AddWTBaseTag() {
	if (IsDemo() || IsFAA()) {
		var tag  = "<script src=\"/js/wtbase.js\" type=\"text/javascript\"></script>\n";
        	tag += "<noscript>\n"
			if(IsDemo()) {
				tag += "<div><img alt=\"DCSIMG\" id=\"DCSIMG\" width=\"1\" height=\"1\" src=\"http://statse.webtrendslive.com/dcshdmxg810000knrgkj5gebg_2j7x/njs.gif?dcsuri=/nojavascript&amp;WT.js=No&amp;WT.tv=1.1.0\"/></div>\n";
			}
			else {
				tag += "<div><img alt=\"DCSIMG\" id=\"DCSIMG\" width=\"1\" height=\"1\" src=\"http://statse.webtrendslive.com/dcsp8mg3h10000wkhcw35vmeg_3q5c/njs.gif?dcsuri=/nojavascript&amp;WT.js=No&amp;WT.tv=1.1.0\"/></div>\n";
			}
			tag += "</noscript>\n";
		document.writeln(tag);	
	}
}
