window.isInternetExplorer = function(){
	var userAgent = navigator.userAgent.toLowerCase();
	if (document.all && userAgent.indexOf('msie')!=-1){
    	return true;
	}
    else{
    	return false;
	}
};
window.isInternetExplorer6 = function(){
	var userAgent = navigator.userAgent.toLowerCase();
	if (document.all && userAgent.indexOf('msie 6')!=-1){
    	return true;
	}
    else{
    	return false;
	}
};
/*if(window.isInternetExplorer6()){
	document.write("<iframe style='border: 0px; width: 1px; " + "height: 1px; position: absolute; bottom: 0px; " + "right: 0px; visibility: visible;' " + "name='DhtmlHistoryFrame' id='DhtmlHistoryFrame' " + "src='_admin/_lib/dhtmlHistoryDummyPage.html?" + "" + "'>" + "</iframe>");
}*/
window.showVersionFlashAppSupportJs = function(){
	alert("flash_app_support.js Version 1.0.2");
};
window._parseArgs = function(str){
	var args = new Object();
	var query = str;
	var pairs = query.split("&");
	args.query = query;
	for(var i=0; i< pairs.length; i++){
	   var pos = pairs[i].indexOf('=');
	   if (pos == -1){
	       continue;
	   }
	   var argname = pairs[i].substring(0,pos);
	   var value = pairs[i].substring(pos+1);
	   args[argname] = unescape(value);
	}
	return args;
};
window.setSiteData = function(str){
	if(!window.siteData){
	   window.siteData = new Object();
	}
	window.siteData = window._parseArgs(str);
};
if(location.search.substring(1)){
	window.setSiteData(location.search.substring(1));
}
window.getSiteData = function(){
	return window.siteData;
};
window.promptForBookmark = function(){
	var NSstring = "[Ctrl + D]"; 
	var OPstring = "[Ctrl + T]"; 
	var OTHstring = "[Ctrl + D] " 
	var whichString = OTHstring ; 
	var agt = navigator.userAgent.toLowerCase(); 
	var app = navigator.appName.toLowerCase(); 
	var ieAgent = agt.indexOf('msie'); 
	var nsAgent = app.indexOf('netscape');
	var opAgent = app.indexOf('opera');
	if(document.all){
		window.external.addFavorite(location.href, document.title);
	}
	else if(nsAgent != -1){
		whichString = NSstring;
	}
	else if(opAgent != -1){
		whichString = OPstring;
	}
	window._removeCookieData();
};
window.updateAddress = function(s){
	if(s != ""){
		window.setAddressChangeFromNavigation(true);
		if(!s || s == "undefined"){
			s = "";
		}
		if(window.isInternetExplorer6()){
			//document.getElementById("DhtmlHistoryFrame").src = "_admin/_lib/dhtmlHistoryDummyPage.html?" + s;
		}
		else{
			window.location.hash = s;
		}
	}
};
window.getAddress = function(){
	var sHash = "";
	if(window.isInternetExplorer6()){
      	sHash = document.getElementById("DhtmlHistoryFrame").contentWindow.document.location.search;
      	if(sHash.length == 1 && sHash.charAt(0) == "?"){
       		sHash = "";
	  	}
      	else{
			if(sHash.length >= 2 && sHash.charAt(0) == "?"){
        		sHash = sHash.substring(1);
			}
		}
	}
	else{
		sHash = location.hash.substring(1);
	}
	if(sHash == "undefined"){
		sHash = "";
	}
	return sHash;
};
window.setPrevAddress = function(s){
	window._sPrevAddress = s;
};
window.getPrevAddress = function(){
	return window._sPrevAddress;
};
window.setAddressChangeFromNavigation = function(b){
	window._bAddressChangeFromNavigation = b;
};
window.getAddressChangeFromNavigation = function(){
	return window._bAddressChangeFromNavigation;
};
window.onAddressChange = function(){
	var sLoc = window.getAddress();
	if(window.getAddressChangeFromNavigation() == false){
		window.cmsComm('locMainnav','gotoLocFromBackButton',sLoc);
	}
	window.setAddressChangeFromNavigation(false);
};
window.watchAddress = function(){
	var sNewAddress = window.getAddress();
	var sPrevAddress = window.getPrevAddress();
	if (sPrevAddress != sNewAddress){
		if(window.isInternetExplorer6()){
			window.location.hash = sNewAddress;
		}
		window.setPrevAddress(sNewAddress);
		window.onAddressChange(sNewAddress);
	}
};
// set the interval
if(setInterval){
	//_intervalID = setInterval(window.watchAddress, 100);
}
window.invokeTracking = function(sAcct, sMlc, sPn){
	if(sPn != ""){
	   /*
	    * Status-bar output test, comment in and out for testing
	    */
	   window.status = "Invoking Hitbox _acct: "+sAcct+" _mlc: " + sMlc + " _pn: " + sPn;
	   /*
	    * Set Hitbox vars
	    */
	   window._acct = sAcct;
	   window._mlc = sMlc;
	   window._pn = sPn;
	}
};
window._setCookieData = function(sNamePairs){
	//alert("window._setCookieData called: "+sNamePairs);
	var today = new Date();
    var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days
    var name = "my_cookie";
    var path;
    var domain;
    var secure;
    var value = sNamePairs;
    var sCookie = name + "=" + escape(value) + ((expiry) ? "; expires=" + expiry.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = name + "=" + escape(value) + ((expiry) ? "; expires=" + expiry.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); 
	//alert('Cookie has been set with this name-pair string:\r' + sNamePairs + "\rActual cookie string:\r" + sCookie);
};
window._getCookieData = function(){
	function getCookieVal (offset) { 
	   var endstr = document.cookie.indexOf (";", offset); 
	   if (endstr == -1) { endstr = document.cookie.length; } 
	   return unescape(document.cookie.substring(offset, endstr)); 
	}
	var result = "";
	var name = "my_cookie";
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) { 
	   var j = i + alen; 
	   if (document.cookie.substring(i, j) == arg) { 
	       result = getCookieVal(j);
	       break;
	   }
	   i = document.cookie.indexOf(" ", i) + 1; 
	   if (i == 0) break; 
	}
	//alert("window._getCookieData called: "+result);
    return result;
};
window._removeCookieData = function(){
	var name = "my_cookie";
	var path;
	var domain;
	document.cookie = name + "=" + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
};
window.setIsFromLoadIframe = function(b){
	//alert("setIsFromLoadIframe: "+b);
	top.window._bFromLoadIframe = b;
};
window.getIsFromLoadIframe = function(){
	//alert("getIsFromLoadIframe: "+top.window._bFromLoadIframe);
	return top.window._bFromLoadIframe;
};
window.loadIframe = function(iframeName, url, sReplaceHistoryRecordBoolString){
	//alert("loadIframe: "+iframeName+" - "+url+" - "+sReplaceHistoryRecordBoolString);
  	if(top.window.frames[iframeName]){
  		top.window.setIsFromLoadIframe(true);
  		if(window.location.replace){ // if browser supports location.replace
  			if(top.window._bReplace == true){
  				top.window.frames[iframeName].location.replace(url);
  			}
  			else{
  				top.window.frames[iframeName].location = url;
  			}
  			if(sReplaceHistoryRecordBoolString == "true"){
  				top.window._bReplace = true;
  			}
  			else{
  				top.window._bReplace = false;
  			}
  		}
  		else{
  			top.window.frames[iframeName].location = url;
  		}
  	}
  	else{
  		alert("cms data definition error. specified iframe id: "+iframeName+", does not exist on page. URL attempted to load is: "+url);
  	}
};
window.sendtofriend = function(sEmailTo, sSubject, sBody){
	if(!sEmailTo){
		sEmailTo="someone@somewhere.com";
	}
	if(!sSubject){
		sSubject="My Subject Here";
	}
	if(!sBody){
		sBody="My body text goes here.";
	}
	var h;
	h = "mailto:"+sEmailTo+"?subject="+sSubject+"&cc=&bcc=&body="+sBody; 
	location.replace(h);
};
window.onAdminOpened = function(){
	if(window._onAdminOpened){
		window._onAdminOpened();
	}
}
window.getPermalink = function(){
	var s = location.toString();
	if(s.indexOf("#") != -1){ // if from flash deeplink, don't return a permalink structure
		s = "";
	}
	else{
		s = "";
		if(window.sWordpressRootPath){
			var sLocation =location.toString();
			var iLen = sLocation.length;
			var iStart = window.sWordpressRootPath.length;
			s = "#"+sLocation.substring(iStart+1, iLen-1);
			if(s == "#/"){
				s="";
			}
		}
	}
	return s;
}
window._writeEmbed = function(sNamePairs, sFlashSwf, sFlashWidth, sFlashHeight, sFlashBGColor, sFlashQuality, sFlashSwfVersion, oWindowToWriteTo, sDivToWriteTo, sDivCmsHidden, sFlashSubVersion, sHash){
	var sOrigNamePairs = "";
	if(sNamePairs){
		sOrigNamePairs = sNamePairs;
	}
	sNamePairs = location.search.substring(1);
	if(!sHash){
		sHash = window.location.hash;
	}
	if(!sFlashSubVersion){
		sFlashSubVersion = ",0,0,0";
	}
	if(sHash == "#undefined"){
		sHash = "";
	}
	if (sHash.substring(0,1) == "#"){
		sNamePairs = "gotoLoc="+sHash.substring(1);
	}
   // ---------------------------------------------
   	if(!sFlashSwf){
		sFlashSwf = "mainnav.swf";
		sFlashWidth = "100%";
		sFlashHeight = "100%";
		sFlashBGColor = "#ffffff";
		sFlashQuality = "best"; // ["low" | "high" | "best"]
		sFlashSwfVersion = "8";
	}
	// ---------------------------------------------
	var sCookieNamePairs = window._getCookieData();
	var sPrefix = "";
	var sServerHostname = location.hostname;
	var sServerPathname = location.pathname;
	var sServerPort = location.port;
	var sUniqueSharedObjectIdSuffix = window.getUniqueSharedObjectIdSuffix();
	var sDeploymentType = "Unknown";
	var sWordpressMode = "true";
	if(sCookieNamePairs){
	   if(sNamePairs){
	       sPrefix = "&";
	   }
	   sNamePairs += sPrefix + "cookieData=" + escape(sCookieNamePairs);
	}
   if(sNamePairs){
	   sPrefix = "&";
   }
   else{
   		sPrefix = "";
   }
   sNamePairs += sPrefix + "sUniqueSharedObjectIdSuffix=" + sUniqueSharedObjectIdSuffix + "&sOrigNamePairs=" + sOrigNamePairs + "&sDeploymentType=" + sDeploymentType + "&sWordpressMode=" + sWordpressMode + "&sServerHostname=" + sServerHostname + "&sServerPort=" + sServerPort + "&sServerPathname=" + sServerPathname+"&"+sOrigNamePairs;
   //alert(sNamePairs);
	var sFlashSwfId = sFlashSwf.substring(0, sFlashSwf.length-4);
	var sEmbedTag = "<object id='" + sFlashSwfId + "' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + sFlashSwfVersion + sFlashSubVersion +"'";
	sEmbedTag += " width='" + sFlashWidth + "' height='" + sFlashHeight + "' id='fullscreen'";
	sEmbedTag += "> <param name='movie' value='" + sFlashSwf + "?" + sNamePairs;
	sEmbedTag += "'> <param name='loop' value='false'> <param name='quality' value='" + sFlashQuality + "'> <PARAM NAME='scale' VALUE='noscale'> <param name='bgcolor' value='" + sFlashBGColor + "'> ";
	sEmbedTag += "<param name='allowFullScreen' value='true'> ";
	//sEmbedTag += "<param name='wmode' value='opaque'> ";
	sEmbedTag += "<embed name='" + sFlashSwfId + "' src='" + sFlashSwf + "?" + sNamePairs;
	sEmbedTag += "' loop='false' scale='noscale' salign='LT' quality='" + sFlashQuality + "' allowFullScreen='true'" + " bgcolor='" + sFlashBGColor + "' width='" + sFlashWidth + "' height='" + sFlashHeight+"' allowscriptaccess='always'";
	//sEmbedTag += " wmode='opaque'";
	sEmbedTag += " swLiveConnect='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'><\/embed><\/object>";
	if(!oWindowToWriteTo && !sDivToWriteTo){
		window.document.write(sEmbedTag);
		window._writeCmsHiddenIFrame();
		window._writeCmsHidden2IFrame();
	}
	else{
		if(!sDivToWriteTo){
			oWindowToWriteTo.document.write(sEmbedTag);
		}
		else{
  			document.getElementById(sDivToWriteTo).innerHTML = sEmbedTag;
		}
	}
};
window.outputXml = function(sFilePath){
	window.openwin("_admin/_backend/php/outputXml.php?filePath="+sFilePath, 700, 500, true, 0, 0);
}
window.setTitle = function(s){
	document.title = s;
}
window.openwin = function(url, w, h, bEnableSbars, x, y){
	var _w;
	var sSbars = "no";
	if(bEnableSbars == true){
		sSbars = "yes";
	}
	//url = "'"+url+"'";
	var myDate = new Date();
	var win = myDate.getTime();
	_w = window.open(url, win,'width='+(w-3)+', height='+(h-3)+', location=no, menubar=no, resizable=no, scrollbars='+sSbars+', status=no, toolbar=no, directories=no');
};
window._writeCmsHiddenIFrame = function(sDivToWriteTo){
	var s = "<iframe name='cmsHidden' id='cmsHidden' src='_admin/_lib/cmsComm.html' style='width:0px;height:0px;overflow:hidden;border-style:hidden;visibility:hidden' frameborder='0' marginwidth='0' marginheight='0'><\/iframe>";
	if(document.all){
		s = "<iframe name='cmsHidden' id='cmsHidden' src='_admin/_lib/cmsComm.html'  frameborder='0' style='width:1px;height:1px' marginwidth='0' marginheight='0'><\/iframe>";
	}
	if(!sDivToWriteTo){
		window.document.write(s);
	}
	else{
		document.getElementById(sDivToWriteTo).innerHTML = s;
	}
};
window._writeCmsHidden2IFrame = function(sDivToWriteTo){
	var s = "<iframe name='cmsHidden2' id='cmsHidden2' src='' style='width:0px;height:0px;overflow:hidden;border-style:hidden;visibility:hidden' frameborder='0' marginwidth='0' marginheight='0'><\/iframe>";
	if(document.all){
		s = "<iframe name='cmsHidden2' id='cmsHidden2' src=''  frameborder='0' style='width:1px;height:1px' marginwidth='0' marginheight='0'><\/iframe>";
	}
	if(!sDivToWriteTo){
		window.document.write(s);
	}
	else{
		document.getElementById(sDivToWriteTo).innerHTML = s;
	}
};
//window._writeCmsHiddenIFrame();
//window._writeCmsHidden2IFrame();
window.getUniqueSharedObjectIdSuffix = function(){
	if(!window._sUniqueSharedObjectIdSuffix){
		var myDate = new Date();
		window._sUniqueSharedObjectIdSuffix = "_TOK"+myDate.getMilliseconds()+(Math.round(9999*Math.random()));
	}
	return window._sUniqueSharedObjectIdSuffix;
};
window.cmsCommOld = function(sSharedObjectId, sMethod, sParam1, sParam2, sParam3, sParam4, sParam5, sParam6, sParam7, sParam8, sParam9, sParam10, sParam11, sParam12){
	var myDate = new Date();
	var iUnique = myDate.getTime();
	var sUrl = "_admin/_lib/cmsComm.html?sSharedObjectId="+sSharedObjectId+"&sMethod="+sMethod+"&sParam1="+sParam1+"&sParam2="+sParam2+"&sParam3="+sParam3+"&sParam4="+sParam4+"&sParam5="+sParam5+"&sParam6="+sParam6+"&sParam7="+sParam7+"&sParam8="+sParam8+"&sParam9="+sParam9+"&sParam10="+sParam10+"&sParam11="+sParam11+"&sParam12="+sParam12+"&nocache="+iUnique;
	window.loadIframe("cmsHidden", sUrl);
};
window.cmsComm = function(sSharedObjectId, sMethod, sParam1, sParam2, sParam3, sParam4, sParam5, sParam6, sParam7, sParam8, sParam9, sParam10, sParam11, sParam12){
	//window._oFlash.broadcastToSharedObjects(sSharedObjectId, sMethod, sParam1, sParam2, sParam3, sParam4, sParam5, sParam6, sParam7, sParam8, sParam9, sParam10, sParam11, sParam12);
	top.window._oFlash.broadcastToSharedObjects(sSharedObjectId, sMethod, sParam1, sParam2, sParam3, sParam4, sParam5, sParam6, sParam7, sParam8, sParam9, sParam10, sParam11, sParam12);
};
window.showVersions = function(){
	alert("Showing versions of all participating modules...");
	window.showVersionFlashAppSupportJs();
	window.showVersionAdminJs();
	window.cmsComm('','showVersions');
};

