// JavaScript Document
/*
	HISTORY MANAGEMENT
	Copyright (c) 2006 Daniel Kyburz (http://www.clickwerk.ch)
	
	The above copyright notice and this permission notice shall be
	included in all copies or substantial portions of the Software.

	SCRIPT.ACULO.US (Prototype)
	Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
	
	Permission is hereby granted, free of charge, to any person obtaining
	a copy of this software and associated documentation files (the
	"Software"), to deal in the Software without restriction, including
	without limitation the rights to use, copy, modify, merge, publish,
	distribute, sublicense, and/or sell copies of the Software, and to
	permit persons to whom the Software is furnished to do so, subject to
	the following conditions:
	
	The above copyright notice and this permission notice shall be
	included in all copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
	NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
	LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
	OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
	WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  

	REALLY SIMPLE HISTORY (RSH)
	Copyright (c) 2005, Brad Neuberg, bkn3@columbia.edu
	http://codinginparadise.org
	
	Permission is hereby granted, free of charge, to any person obtaining 
	a copy of this software and associated documentation files (the "Software"), 
	to deal in the Software without restriction, including without limitation 
	the rights to use, copy, modify, merge, publish, distribute, sublicense, 
	and/or sell copies of the Software, and to permit persons to whom the 
	Software is furnished to do so, subject to the following conditions:
	
	The above copyright notice and this permission notice shall be 
	included in all copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
	OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
	IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
	CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 
	OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
	THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var histCount = 0;	

function initialize() { 
	//return;

	/** Initialize all of our objects now. */
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(historyChange);
	initSlideShow(); // slideshow

	if (dhtmlHistory.isFirstLoad()) {
		try { // nothin' yet
		} catch (e) {}
	}
}

function historyChange(historyId, historyData) {
	//return;
	var historyString = historyId.split(';')[1];
	var historyUri = '';
	var newLocation = '';
	if(historyString == 'clickObject') {
		historyUri = historyData.param.join('&');
		var huutf = utf8t2d(historyUri);
		var hub64 = b64d2t(huutf);
		newLocation = 'refresh.cfm?cs=' + encodeURIComponent(hub64);
		getUrl(newLocation, false);
	}
}

function getUrl(linkLocation, setHistory) { 
	var ld = document.getElementById('loading');
	ld.style.visibility = 'visible';

	if(setHistory == true) { 
		histCount++; 
		var linkString = linkLocation.split('?cs=')[1];
		var lsb64 = b64t2d(linkString);
		var lsutf = utf8d2t(lsb64);
		var lsSplit = lsutf.split('&');
		var histString = histCount.toString() + ";clickObject";
		var clickObject = new Object();
		clickObject.param = new Array();
		for(i=0; i<lsSplit.length; i++) {
			clickObject.param[i] = lsSplit[i];
		}
		dhtmlHistory.add(histString, clickObject);
	} 
	var myAjax = new Ajax.Updater( 
		{success: 'refresh'},
		websiteURL + "/" + linkLocation,
		{method: 'get'}
	);
}

window.onload = initialize;
