var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var defaultLeft = "";
var defaultHome = "index.cfm";
var movieRef = "";
var currentURL = document.location.href.split("#");
if (currentURL.length > 1)
	currentURL = currentURL[currentURL.length-1];
else
	currentURL = currentURL[0];
	

function loadFlash ()
{	
	// initialize the DHTML History
       // framework
	
	var thelocal = document.location.href;
	var locationsplit = thelocal.split("/");
	var file = locationsplit[locationsplit.length-1];
	file = file.split("#");
	var fileleft = file[0];
	var fileright = file[1];
	
	var baseurl = fileleft;
	if (file.length >1)
		baseurl = fileright;
	
	
	currentURL=baseurl;
	
	
	if (fileleft != defaultLeft)
	{
	
		if (fileleft.length > 0)
		{
			var newlocation = document.location.href.split("/");
			newlocation.pop();
			document.location = newlocation.join("/")+"/"+"#"+baseurl;
		}
		else
		{
			document.location = document.location+"#"+defaultHome;
		}
	}
	else
	{
	
		var so = new SWFObject("library/flash/mikesundell.swf", "theflash", "100%", "100%", "9.0.28.0", "#FFFFFF", true);
		so.addParam("scale", "noscale");
		
		//so.addParam("allowScriptAccess", "sameDomain");
		//so.addVariable("bookmarkable", "true");
		
		so.addParam("allowFullScreen", "true");
		so.useExpressInstall('library/swfobject1-5/expressinstall.swf');
		
		if (baseurl.length > 0)
			so.addVariable("baseurl", escape(baseurl));
		else
			so.addVariable("baseurl", escape(defaultHome));
		
		var page = new PageQuery(window.location.search); 
		var keys = page.getParameters();
		for (var i = 0; i<keys.length;i++)
		{
			so.addVariable(keys[i], page.getValue(keys[i]));
		}
		
		so.write("page");
		
	}
	movieRef=thisMovie("theflash");
}

// query string utilities
function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

// swf instance finder
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function setHeight(newheight)
{
	//window.alert(newheight);
	document.getElementById("content").style.height = newheight + 'px';	
	document.getElementById("theflash").style.height = newheight + 'px';	
}

function setWidth(newwidth)
{
	//window.alert(newheight);
	document.getElementById("content").style.width = newwidth + 'px';	
	document.getElementById("theflash").style.width = newwidth + 'px';	
}
