
blnDOM = (document.getElementById) ? true : false;
blnNS4 = (document.layers) ? true : false;
blnIE = (document.all) ? true : false;
blnIE4 = blnIE && !blnDOM;
blnIE5 = (navigator.appVersion.indexOf("MSIE 5.0") != -1);
blnNS6 = blnDOM && !blnIE;
blnMac = (navigator.appVersion.indexOf("Mac") != -1);
blnOpera = (navigator.userAgent.indexOf("Opera")!=-1);
blnKonqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);


function loginToggle(element, imageName) {
	element.style.background = "url(" + imageName + ") top left no-repeat";
}

//Swap images with an optional fade effect
var transitionToggle = 0;

function imgToggle(id,name,transitionDisable)
	{
	if (transitionDisable || !document.images[id].filters || blnIE5 || blnNS4)
		{
		if (document.images)
			{
			document.images[id].src=eval(name+".src");
			}
		}
	else
		{
		document.images[id].filters[0].Apply();
		// After setting Apply, changes to the object
		// are not displayed until Play is called.

		if (transitionToggle)
			{
			transitionToggle = 0;
			document.images[id].src=eval(name+".src");
			}
		else
			{
			transitionToggle = 1;
			document.images[id].src=eval(name+".src");
			}
		document.images[id].filters[0].Play();
		}
	}

if (document.images)
	{
	b_this_month_off = new Image();b_this_month_off.src = '/images/templates/b_this_month.gif';
	b_this_month_on = new Image();b_this_month_on.src = '/images/templates/b_this_month_on.gif';

	b_last_month_off = new Image();b_last_month_off.src = '/images/templates/b_last_month.gif';
	b_last_month_on = new Image();b_last_month_on.src = '/images/templates/b_last_month_on.gif';

	b_go_off = new Image();b_go_off.src = '/images/templates/b_go_off.gif';
	b_go_on = new Image();b_go_on.src = '/images/templates/b_go_on.gif';

	b_latest_movies_off = new Image();b_latest_movies_off.src = '/images/templates/b_latest_movies.gif';
	b_latest_movies_on = new Image();b_latest_movies_on.src = '/images/templates/b_latest_movies_on.gif';

	b_latest_games_off = new Image();b_latest_games_off.src = '/images/templates/b_latest_games.gif';
	b_latest_games_on = new Image();b_latest_games_on.src = '/images/templates/b_latest_games_on.gif';

	b_about_civic_video_off = new Image();b_about_civic_video_off.src = '/images/templates/b_about_civic_video.gif';
	b_about_civic_video_on = new Image();b_about_civic_video_on.src = '/images/templates/b_about_civic_video_on.gif';

	b_competitions_off = new Image();b_competitions_off.src = '/images/templates/b_competitions.gif';
	b_competitions_on = new Image();b_competitions_on.src = '/images/templates/b_competitions_on.gif';

	b_store_locations_off = new Image();b_store_locations_off.src = '/images/templates/b_store_locations.gif';
	b_store_locations_on = new Image();b_store_locations_on.src = '/images/templates/b_store_locations_on.gif';

	b_contact_civic_video_off = new Image();b_contact_civic_video_off.src = '/images/templates/b_contact_civic_video.gif';
	b_contact_civic_video_on = new Image();b_contact_civic_video_on.src = '/images/templates/b_contact_civic_video_on.gif';
	
	n_moviesdb = new Image();n_moviesdb.src = '/images/templates/n_moviesdb.gif';
	n_moviesdb_on = new Image();n_moviesdb_on.src = '/images/templates/n_moviesdb_on.gif';
	n_latestgames_off = new Image();n_latestgames_off.src = '/images/templates/n_latestgames.gif';
	n_latestgames_on = new Image();n_latestgames_on.src = '/images/templates/n_latestgames_on.gif';
	n_civicinteractive_off = new Image();n_civicinteractive_off.src = '/images/templates/n_civicinteractive.gif';
	n_civicinteractive_on = new Image();n_civicinteractive_on.src = '/images/templates/n_civicinteractive_on.gif';
	n_aboutcivicvideo_off = new Image();n_aboutcivicvideo_off.src = '/images/templates/n_aboutcivicvideo.gif';
	n_aboutcivicvideo_on = new Image();n_aboutcivicvideo_on.src = '/images/templates/n_aboutcivicvideo_on.gif';
	n_compsandpromos_off = new Image();n_compsandpromos_off.src = '/images/templates/n_compsandpromos.gif';
	n_compsandpromos_on = new Image();n_compsandpromos_on.src = '/images/templates/n_compsandpromos_on.gif';
	n_storelocations_off = new Image();n_storelocations_off.src = '/images/templates/n_storelocations.gif';
	n_storelocations_on = new Image();n_storelocations_on.src = '/images/templates/n_storelocations_on.gif';

	}
	
// ##################
// Browser Detection
// ##################

// Note: Browser detection may be outside this file if
// site is heavily JS driven and different JS files are
// loaded for each browser (e.g. separate DOM / NS / IE
// files)

DOM = (document.getElementById) ? true : false;
NS4 = (document.layers) ? true : false;						//Netscape 4 specifically
NS6 = (!document.all && document.getElementById) ? 1 : 0;	//Netscape 6 & 7
IE = (document.all) ? true : false;							//Any IE
IE4 = IE && !DOM;											//IE4 specifically
IE5 = (IE4 && navigator.appVersion.indexOf("5.") != -1);	//Any IE 5 series
IE50 = (navigator.appVersion.indexOf("MSIE 5.0") != -1);	//IE5.0 specifically
ver4 = (NS4 || IE4 || DOM);									//Version 4 or ABOVE
isMac = (navigator.appVersion.indexOf("Mac") != -1);		//Any Mac browser
isDynamic = (DOM || NS4 || NS6 || (IE4 && !isMac) || (IE5 && isMac));
															//Any browsing supporting dHTML (Apparently... This may need work!)
canPrint = (window.print) ? 1 : 0;


// ##################
// Navigation
// ##################

function goThere(frmName,fdName)
	{
	WhichOne = document[frmName].elements[fdName].options.selectedIndex
	URL = document[frmName].elements[fdName].options[WhichOne].value
	document[frmName].elements[fdName].options.selectedIndex = 0
	if (URL != "")
		{
		location.href = URL
		}
	}

// ##################
// Windows & Alerts
// ##################

function wPopup(wPage,wWidth,wHeight,wID,wScrollbars,wLocation,wToolbar,wStatus,wResizable) {
	if (!wID) {wID = "Popup"}
	if (!wWidth) {wWidth = 500}
	if (!wHeight) {wHeight = 320}
	if (!wScrollbars) {wScrollbars = "yes"}
	if (!wLocation) {wLocation = "no"}
	if (!wToolbar) {wToolbar = "no"}
	if (!wStatus) {wStatus = "no"}
	//if (isLoaded == 0) { location.reload() }
	if (!wResizable) {wResizable = "yes"}
	popupWindow = window.open(wPage,wID,"width="+wWidth+",height="+wHeight+",scrollbars="+wScrollbars+",location="+wLocation+",toolbar="+wToolbar+",status="+wStatus+",resizable="+wResizable)
	if (window.focus) { popupWindow.focus() }
}

function wLink(URL)
	{
	top.opener.location.href = URL
	top.close()
	}

// ##################
// Image Manipulation
// ##################

// Swap any image to another
function imgSwap(id,name)
	{
	if (document.images)
		{
		document.images[id].src=eval(name+".src");
		}
	}

// Swap images with an optional fade effect
// - Requires fading style to be set.
// - Only works for IE5.5+ but falls back nicely
var transitionToggle = 0;
function imgSwapFX(id,name,transitionDisable)
	{
	if (transitionDisable || !document.images[id].filters || IE50)
		{
		if (document.images)
			{
			document.images[id].src=eval(name+".src");
			}
		}
	else
		{
		document.images[id].filters[0].Apply();
		// After setting Apply, changes to the object
		// are not displayed until Play is called.

		if (transitionToggle)
			{
			transitionToggle = 0;
			document.images[id].src=eval(name+".src");
			}
		else
			{
			transitionToggle = 1;
			document.images[id].src=eval(name+".src");
			}
		document.images[id].filters[0].Play();
		}
	}

// ##################
// Layer Manipulation
// ##################


// Turn any layer on and off
function layerToggle(togglelayer,state)
	{
	if (document.layers)
		{
		if (document.layers[togglelayer])
			{
			document.layers[togglelayer].visibility = state
			}
		}
	else if (document.getElementById)
		{
		if (document.getElementById(togglelayer))
			{
			document.getElementById(togglelayer).style.visibility = state
			}
		}
	else
		{
		if (document.all[togglelayer])
			{
			document.all[togglelayer].style.visibility = state
			}
		}
	}


// Turn any layer on and off
function layerToggleDisplay(togglelayer,state)
	{
	if (document.layers)
		{
		if (document.layers[togglelayer])
			{
			document.layers[togglelayer].display = state;
			}
		}
	else if (document.getElementById)
		{
		if (document.getElementById(togglelayer))
			{
			document.getElementById(togglelayer).style.display = state;
			}
		}
	else
		{
		if (document.all[togglelayer])
			{
			document.all[togglelayer].style.display = state;
			}
		}
	}

// ##################
// Printing
// ##################

if (IE4 && !canPrint && !isMac) with (document)
	{
	writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
	writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
	writeln('Sub window_onunload');
	writeln('    On Error Resume Next');
	writeln('    Set WB = nothing');
	writeln('End Sub');
	writeln('Sub vbPrintPage');
	writeln('    OLECMDID_PRINT = 6');
	writeln('    OLECMDEXECOPT_DONTPROMPTUSER = 2');
	writeln('    OLECMDEXECOPT_PROMPTUSER = 1');
	writeln('    On Error Resume Next');
	writeln('    WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
	writeln('End Sub');
	writeln('<' + '/SCRIPT>');
	}

function printPage()
	{
	if (canPrint)
		{
		window.print()
		}
	else if (IE4 && !isMac)
		{
		vbPrintPage()
		}
	else
		{
		alert("Your web browser does not appear to support the automatic\nPrint function. To print this page, please select the \"Print\"\noption from the \"File\" menu of your web browser.")
		}
	}

// ##################
// Interface Functions
// ##################

// Alternating table row colours. (Define two or more colours.)
var arrTableRowColors = new Array('#f8f8f8','#ffffff');

// Various table attributes
// These should be set within an interface definition file (i.e. like a style
// sheet) but must be set here otherwise.
//var arrTableRowColors = new Array('#eeeeee','#ffffff');
//var arrOtherAttributes = new Array('value1','value2');
function SetTableRowAttributes(strRowID, i)
{
	if(!arrTableRowColors)
	{
		arrTableRowColors = new Array('#eeeeee','#ffffff');
	}
	if(arrTableRowColors)
	{
		strRowID.style.backgroundColor = arrTableRowColors[i % arrTableRowColors.length];
		//strRowID.style.OtherAttribute = arrOtherAttributes[i % arrOtherAttributes.length];
	}
}

// Paint table rows in a table with 
function PaintTableRows(strTableID)
{
	var objTable = document.getElementById(strTableID);
	var arrTableRows = objTable.getElementsByTagName("tr");

	// Keep track of how far through the attribute array we've come
	intAttributeCounter = 0;
	
	for(i = 0; i < arrTableRows.length; i++)
	{
		// Only process table rows that are direct children of the 
		// requested table. This accounts for embedded tables. Use a
		// double "parentNode" to account for the TBODY element.
		if (arrTableRows[i].parentNode.parentNode.id == strTableID)
		{
			if (arrTableRows[i].className != "")
			{
				// Class name is not blank. This row must be
				// special (e.g. a header) so we'll skip it
				// and reset the attribute counter to 0.
				intAttributeCounter = 0;
			}
			else
			{
				// Alter the row attributes
				SetTableRowAttributes(arrTableRows[i], intAttributeCounter);
				
				// Increment the attribute counter
				intAttributeCounter++;
				if (intAttributeCounter > arrTableRows.length)
				{
					intAttributeCounter = 0;
				}
			}
		}
	}
}

// ====================
// Function:    GetObjectWidth
//
// Purpose:     Returns the width of any passed in block level object
//
// Input:       ID of item
//
// Output:      Returns the width of any passed in block level object
//
// Assumptions: -
//
// History:     SC 2006-05-15
// ====================
function GetObjectWidth(objectRef)
{
	var intWidth = -1;

	if (document.getElementById)
	{
		if (document.getElementById(objectRef))
		{
			intWidth = eval(document.getElementById(objectRef).offsetWidth);
		}
	}
	else if (document.all)
	{
		if (document.all[objectRef])
		{
			intWidth = document.all[objectRef].scrollWidth;
		}
	}
	else if (document.layers)
	{
		if (document[objectRef])
		{
			intWidth = document[objectRef].clip.bottom;
		}
	}

	return intWidth;
}

// ====================
// Function:    GetObjectHeight
//
// Purpose:     Returns the height of any passed in block level object
//
// Input:       ID of item
//
// Output:      Returns the height of any passed in block level object
//
// Assumptions: -
//
// History:     SC 2006-05-15
// ====================
function GetObjectHeight(objectRef)
{
	var intHeight = -1;

	if (document.getElementById)
	{
		if (document.getElementById(objectRef))
		{
			intHeight = eval(document.getElementById(objectRef).offsetHeight);
		}
	}
	else if (document.all)
	{
		if (document.all[objectRef])
		{
			intHeight = document.all[objectRef].scrollHeight;
		}
	}
	else if (document.layers)
	{
		if (document[objectRef])
		{
			intHeight = document[objectRef].clip.bottom;
		}
	}

	return intHeight;
}

// ##################
// Fun Stuff / Easter Eggs
// ##################

// No easter eggs currently present. :-)

