/* unFocus.History, version2.0 (Beta 2) (2007/09/10)
Copyright: 2005-2007, Kevin Newman (http://www.unfocus.com/Projects/HistoryKeeper/)
License: http://www.gnu.org/licenses/lgpl.html */

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8 o={};o.Q=2(){h.j={};B(8 i=0;i<18.l;i++){h.j[18[i]]=[]}};o.Q.W={12:2(a,b){B(8 i=0;i<h.j[a].l;i++)4(h.j[a][i]==b)7;h.j[a].1Z(b)},1V:2(a,b){B(8 i=0;i<h.j[a].l;i++){4(h.j[a][i]==b){h.j.1S(i,1);7}}},p:2(a,b){B(8 i=0;i<h.j[a].l;i++)h.j[a][i](b)}};o.14=(2(){2 C(){8 c=h,E=1E,v,3;8 d=2(){7 1p.1k.23(1)};3=d();8 e=2(a){z.1p.1k=a};2 1f(){8 a=d();4(3!=a){3=a;c.p("n",a)}}4(O)v=O(1f,E);2 r(a){4(!1c(a)){8 b;4(/1b/.19(A.17)&&!z.16)b=6.w(\'<a G="\'+a+\'">\'+a+"</a>");u b=6.w("a");b.t("G",a);Z(b.D){V="U";1D="1A";1d=s()+"R";1v=1t()+"R"}6.k.L(b,6.k.P)}}2 1c(a){4(6.24(a).l>0)7 q}4(1i 1h.1g=="22"){2 s(){7 1h.1g}}u 4(6.N&&6.N.M){2 s(){7 6.N.M}}u 4(6.k){2 s(){7 6.k.M}}21(20(s).1X().1e(/1W/g,"1U").1e(/Y/g,"X"));c.1T=2(){7 3};2 9(a){4(3!=a){r(a);3=a;e(a);c.p("n",a)}7 q}c.9=2(a){r(3);c.9=9;7 c.9(a)};4(/1a\\/\\d+/.19(A.1n)&&A.1n.1o(/1a\\/(\\d+)/)[1]<1R){8 f=H.l,x={},m,y=15;2 S(){m=6.w("1O");m.13="1N";m.1M="1L";6.k.L(m,6.k.P)}e=2(a){x[f]=a;m.1K="#"+d();m.1J()};d=2(){7 x[f]};x[f]=3;2 T(a){4(3!=a){r(a);3=a;f=H.l+1;y=q;e(a);c.p("n",a);y=15}7 q}c.9=2(a){r(3);S();c.9=T;7 c.9(a)};2 10(){4(!y){8 a=H.l;4(a!=f){f=a;8 b=d();4(3!=b){3=b;c.p("n",b)}}}};1I(v);v=O(10,E)}u 4(1i 1H!="1G"&&z.1F&&!z.16&&A.17.1o(/1b (\\d\\.\\d)/)[1]>=5.5){8 g,F;2 11(){8 a="1C";g=6.w("1B");g.t("G",a);g.t("13",a);g.t("1P",\'1Q:;\');g.D.V="U";g.D.1d="-1z";6.k.L(g,6.k.P);F=1y[a];J(3,q)}2 J(a){Z(F.6){1x("1w/I");1u("<I><1q></1q><k 1s",\'1Y="1r.o.14.K(\\\'\'+a+\'\\\');">\',a+"</k></I>");25()}}2 1m(a){3=a;c.p("n",a)}c.K=2(){c.K=1m};2 1l(a){4(3!=a){3=a;J(a)}7 q};c.9=2(a){11();c.9=1l;7 c.9(a)};c.12("n",2(a){e(a)})}}C.W=1j o.Q("n");7 1j C()})();',62,130,'||function|_currentHash|if||document|return|var|addHistory||||||||this||_listeners|body|length|_form|historyChange|unFocus|notifyListeners|true|_createAnchor|getScrollY|setAttribute|else|_intervalID|createElement|_historyStates|_recentlyAdded|window|navigator|for|Keeper|style|_pollInterval|_historyFrameRef|name|history|html|_createHistoryHTML|_updateFromHistory|insertBefore|scrollTop|documentElement|setInterval|firstChild|EventManager|px|_createSafariSetHashForm|addHistorySafari|absolute|position|prototype|||with|_watchHistoryLength|_createHistoryFrame|addEventListener|id|History|false|opera|userAgent|arguments|test|WebKit|MSIE|_checkAnchorExists|top|replace|_watchHash|pageYOffset|self|typeof|new|hash|addHistoryIE|updateFromHistory|appVersion|match|location|head|parent|onl|getScrollX|write|left|text|open|frames|900px|block|iframe|unFocusHistoryFrame|display|200|print|undefined|ActiveXObject|clearInterval|submit|action|get|method|unFocusHistoryForm|form|src|javascript|420|splice|getCurrent|Left|removeEventListener|Top|toString|oad|push|String|eval|number|substring|getElementsByName|close'.split('|'),0,{}))

function addToHistory(inHash)
{
	trace("addToHistory(" + inHash + ")");
	unFocus.History.addHistory(inHash);
}

//JSCRIPT->ACTIONSCRIPT COMMUNICATION/////////////////////////////////////////////////////
var flShell;
var ie = navigator.appName.indexOf("Microsoft") != -1;

//alert(BrowserDetect.browser + " " + BrowserDetect.version + " on " + BrowserDetect.OS);

/* When the HTML page loads (via the onLoad event of the <body> tag) we have it call the initialize() function. */
function initialize() 
{
	/* Check if the browser is IE. If so, flashVideoPlayer is window.videoPlayer. Otherwise, it's window.document.videoPlayer. The videoPlayer is the id assigned to <object> and <embed> tags. */
	
	flShell = (ie) ? window['shell'] : document['shell'];
}

function tellFlash(inPage, inParams)
{
	initialize() ;
	flShell.JSChangePage(BrowserDetect.browser, inPage, inParams);
	//BrowserDetect.version, 
}

//HASH KEY CODE FOR BACK AND FORWARD BROWSER CONTROL OF THE FLASH SITE/////////////////////
var bShowDebug = false;
var strURL;
var strHashURL;
var strLastHash; 
var nCommandIndex;
var nIntervalHaskChecker;

function getHashURL()
{
	strURL = document.location.hash;
	nCommandIndex = getCommandIndexFromURL();
	if(nCommandIndex < 0 || nCommandIndex==null || nCommandIndex=="undefined" || nCommandIndex=="false")
	{
		nCommandIndex = 0;
		appendToURL("home_mc")
	}

	if(strURL.indexOf("#") != -1)
	{
		var arrURL = strURL.split("#");
		strURL = arrURL[0];
		strHashURL = arrURL[1];
		
		var regExp = new RegExp("&nCI=[0-9]*");
		strLastHash = "#" + trim(strHashURL.replace(regExp, ""));
	}
}

function trace(inString)
{
	if(document.frmDebug !=null)
	{
		document.frmDebug.debug_txt.value += "\n" + inString;
		document.frmDebug.debug_txt.scrollTop = document.frmDebug.debug_txt.scrollHeight - document.frmDebug.debug_txt.clientHeight;
	}
}

function getCommandIndexFromURL()
{
	var nCommandIndex;

	var arrURL = document.location.hash.split("nCI=");
	if(arrURL.length>=1)
	{
		nCommandIndex = arrURL[1];
	}
	return nCommandIndex;
}



function checkHash()
{
	var nLastCommandIndex = getCommandIndexFromURL();
	trace("checkHash()" + nLastCommandIndex + "!=" + nCommandIndex);
	
	if(nLastCommandIndex != nCommandIndex)
	{
		trace("DO RELOAD " + nLastCommandIndex + "!=" + nCommandIndex);
		getLatestHashParameters();
	}
}

function trim(stringToTrim) 
{
	var strReturn = stringToTrim.replace(/^\s+|\s+$/g,"");
	strReturn = strReturn.replace("%20", " ");
	return strReturn;
}

function appendToURL(inThing)
{
	trace("appendToURL(" + inThing + ")");
	var strThing = inThing.replace("&null=undefined","");

	var strHash ="#page=" + trim(strThing);

	if(strLastHash==null ||(strLastHash.toUpperCase() != strHash.toUpperCase() && strLastHash.toUpperCase() != URLDeCode(strHash.toUpperCase()) && URLDeCode(strLastHash.toUpperCase()) != strHash.toUpperCase() && URLDeCode(strLastHash.toUpperCase()) != URLDeCode(strHash.toUpperCase())))
	{ 
		//trace("appendToURL()" + strLastHash);
		//trace("appendToURL()" + strHash);
		strLastHash = strHash;
		nCommandIndex ++;
		strHash += "&nCI=" + nCommandIndex;
		addToHistory(strHash);
	}
}

function URLEncode(inString)
{
	var strReturn = escape(inString); 
	strReturn=strReturn.replace("+", "%2B");
	strReturn=strReturn.replace("/", "%2F"); 
	return strReturn;
}

function URLDeCode(inString)
{
	var strReturn = unescape(inString); 
	strReturn=strReturn.replace("%2B", "+");
	strReturn=strReturn.replace("%2F", "/"); 
	return strReturn;
}

function getLatestHashParameters()
{
	getHashURL();
	var strPage = "";
	var strParams = "";
	trace("strHashURL =" + strHashURL );
	if(strHashURL != null)
	{
		//trace("getLatestHashParameters()");
		//trace("strHashURL=" + strHashURL);
		var strString = strHashURL + "\n\n";
		var arrPairs = strHashURL.split("&");
		for(var i=0; i< arrPairs.length; i++)
		{
			var arrPair = arrPairs[i].split("=");
			if(arrPair[0]=="page")
			{
				strPage = arrPair[1];
			}
			else
			{
				if(arrPair[0]!="nCI")
				{
					if(strParams != "")
					{
						strParams += "#";
					}
					strParams += URLDeCode(arrPair[0])  + "~" + URLDeCode(arrPair[1]);
				}
			}
		}
		//alert("strParams=" + strParams);
		tellFlash(strPage, strParams);
	}
} 

function getHashParameters(so)
{
	var strParams = "";
	if(strHashURL != null)
	{
		//trace("getHashParameters()");
		//var strURL = document.location.href;
		trace("strHashURL=" + strHashURL);
		var strString = strHashURL + "\n\n";
		var arrPairs = strHashURL.split("&");
		for(var i=0; i< arrPairs.length; i++)
		{
			var arrPair = arrPairs[i].split("=");
			if(arrPair[0]=="page")
			{
				so.addVariable("inPage", arrPair[1]);
			}
			else
			{
				if(arrPair[0]!="nCI")
				{
					if(strParams != "")
					{
						strParams += "#";
					}
					strParams += arrPair[0]  + "~" + arrPair[1];
				}
			}
		}
		so.addVariable("inParams", strParams);
		//alert(BrowserDetect.browser + " " + BrowserDetect.version);
		so.addVariable("inBrowser", BrowserDetect.browser);
		so.addVariable("inBrowserVersion", BrowserDetect.version);
	}
}
var stateVar = "nothin'";
function init()
{
	getHashURL();

	if(bShowDebug==true)
	{
		var strDebugHtml = "<div style='position:absolute; left: 20px; top: 20px; z-index:99;'>";
			strDebugHtml += "	<form name='frmDebug'>";
			strDebugHtml += "	<textarea name='debug_txt' rows='20' cols='30' style='font-size: 8pt'></textarea>";
			strDebugHtml += "	</form>";
			strDebugHtml += "	<input type='button' value='reset' onClick='document.frmDebug.debug_txt.value=\"\"'>";
			strDebugHtml += "	<input type='button' value='stop' onClick='stopInterval()'>";
			strDebugHtml += "</div>";

		document.body.innerHTML += strDebugHtml;
	}

	if(isValidBrowser()==true)
	{
		this.historyListener = function(historyHash) 
		{
			//trace(stateVar  + "!="+  historyHash)
			if(historyHash.indexOf("#") == -1)
			{
				//trace("this.historyListener(" + historyHash + ")");
				checkHash();
			}
			stateVar = historyHash;
		};
		unFocus.History.addEventListener('historyChange', this.historyListener);
		
		this.historyListener(unFocus.History.getCurrent());
	}

	//nIntervalHaskChecker = setInterval("checkHash()", 1000);
}

function isValidBrowser()
{
	//alert(BrowserDetect.browser + " " + BrowserDetect.version);
	var bReturn = false;
	if(BrowserDetect.browser == "Firefox")
	{
		if(BrowserDetect.version >= 1.5)
		{
			bReturn	= true;
		}
	}
	else if(BrowserDetect.browser == "Explorer")
	{
		if(BrowserDetect.version >= 6)
		{
			bReturn	= true;
		}
	}
	return bReturn;

}

function stopInterval()
{
	clearInterval(nIntervalHaskChecker);
}


//document.onload = init();