// Groovy Flash HTML resources. Copyright 2005 James Gretton - Igloo Web Design . com (unless otherwise stated). All rights reserved.
var HOST = "columbusmedia.com";
var FLA = "index";
var htmlWaiting;
var currentPage = checkLoc();
var saveNavPage = "";
var setTo = currentPage;


//Set page function
function setPage(url){
	htmlWaiting = url;
}

// Detection from www.dithered.com
var ua        = navigator.userAgent.toLowerCase(); 
var is_pc_ie  = ( (ua.indexOf('msie') != -1 ) && ( ua.indexOf('win') != -1 ) && ( ua.indexOf('opera') == -1 ) && ( ua.indexOf('webtv') == -1 ) );

// Returns true if refered from url site.
function checkRef(){
	url = HOST;
	if (checkParams()) 
		return true;
	var ref = unescape(document.referrer);
	if (ref != ""){
		var begin = ref.indexOf('/') + 2;
		ref = ref.substring(begin,ref.length);
		var end = ref.indexOf('/');
		if (end < 0) end = ref.length;
		ref = ref.substring(0,end);
		if(ref.indexOf(url) != -1 ){
			return true;
		}else{
			return false;
		}
	}else{
		return false;
	}
}

function checkParams(){
	//Checks for get data on header.
	url = HOST;
	var loc = unescape(document.location.href);
	//check for root of page
	loc.substring(loc.indexOf('?'), loc.length);
	if ( loc.indexOf('disp=html') != -1 )
		return true;
	else
		return false;
}

function checkLoc(){
	url = HOST;
	var loc = unescape(document.location.href);
	//check for root of page
	if (loc.indexOf('?') == -1){
		return "";
	}
	// remove . from domain name
	if (loc.indexOf(url) != -1){
		loc = loc.substring(loc.indexOf(url) + url.length, loc.length);
	}
	// trim down to just name (without &disp=html)
	var a = loc.indexOf('&disp=html');
	if(a != -1){
		loc = loc.substring(loc.lastIndexOf('/?'), a);	
	}
	return loc;
}


//Swap between flash and html
function displayWhich(which){
	var h = document.getElementById('html');	
	var f = document.getElementById('flash');		
	// Display the flash div, and set the page variable
	if (which == 'flash'){
		if(h) h.style.display = 'none';
		if(f) f.style.display = 'block';
	}
	// Display the html div, changing html page if neccesery.
	if (which == 'html'){
		//Do page change.
		if (checkHtmlWaiting())
			return;
		if(h) h.style.display = 'block';
		if(f) f.style.display = 'none';
	}
}

function checkHtmlWaiting(){
	if (!htmlWaiting) return false;
	if (htmlWaiting == currentPage) return false;
	//Otherwise call goto
	gotoHtmlWaiting();
	return true;
}

function gotoHtmlWaiting(){
	location.href = htmlWaiting+"&disp=html";
}

function setHtmlWaiting(p){
	htmlWaiting = p;
}

//Mustard's Code
function setFlashVariables(movieid, flashquery){
	var i,values;
	if(is_pc_ie){
		var chunk = flashquery.split("&");
		for(i in chunk){
			values = chunk[i].split("=");
			document[movieid].SetVariable(values[0],values[1]);
		}
	}else{
		var divcontainer = "flash_setvariables_"+movieid;
		if(!document.getElementById(divcontainer)){
			var divholder = document.createElement("div");
			divholder.id = divcontainer;
			document.body.appendChild(divholder);
		}
		document.getElementById(divcontainer).innerHTML = "";
		var divinfo = "<embed src='gateway.swf' FlashVars='lc="+movieid+"&fq="+escape(flashquery)+"' width='0' height='0' type='application/x-shockwave-flash'></embed>";
		document.getElementById(divcontainer).innerHTML = divinfo;
	}
	//Save Nav Page
	saveNavPage = flashquery;
}


function writeFlash(vars){
	document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"100%\" height=\"100%\" id=\"hold\" align=\"middle\">");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
	document.write("<param name=\"movie\" value=\"columbus.swf?r=3\" />");
	document.write("<param name=\"FlashVars\" value=\""+vars+"\" />");
	document.write("<param name=\"quality\" value=\"best\" />");
	document.write("<param name=\"bgcolor\" value=\"#ffffff\" />");
	document.write("<embed src=\"columbus.swf?r=3\" FlashVars=\""+vars+"\" swLiveConnect=\"true\" quality=\"best\" bgcolor=\"#ffffff\" width=\"100%\" height=\"100%\" name=\"hold\" align=\"middle\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />");
	document.write("</object>");
}