
/* ---------------------------------------------- Google Analytics --------------------------------------------- */

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17470926-1']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

/* ------------------------------------------------------------------------------------------------------------ */

/* ---------------------------------------------- Image Preloader --------------------------------------------- */


if (document.images) {
	
	hoverImg = new Image(); 
	hoverImg.src = "Images/hmenu_styles/hover.png";
	
	leftButton = new Image();
	leftButton.src = "Images/hmenu_styles/black_button_left.png";
	
	rightButton = new Image();
	rightButton.src = "Images/hmenu_styles/black_button_right.png";
	
	leftHoverImg = new Image(); 
	leftHoverImg.src = "Images/hmenu_styles/lefthover.png";
	
	rightHoverImg = new Image(); 
	rightHoverImg.src = "Images/hmenu_styles/righthover.png";
	
	yellowBulletImg = new Image(); 
	yellowBulletImg.src = "Images/bullets/bullet_yellow.png";
  
}


/* ------------------------------------------------------------------------------------------------------------ */


/* ----------------------------------------- horizontal cascader ---------------------------------------------- */

var expandingDiv;
var expandNum = 0;
var expNum = 0;
var theWidth = new Array (325, 107, 107, 107, 107, 107);
var hoverArray = new Array (0, 0);
var fadeInSpan;
var theAlpha = 0;

function selector(jsBoxNum) {
	
	hoverArray[0] = hoverArray[1];
	hoverArray[1] = jsBoxNum;
	
	if(hoverArray[0] != hoverArray[1]) {
	
		if(jsBoxNum != expandNum) {
			theAlpha = 0;
			expandNum = jsBoxNum;
			expandingDiv = document.getElementById("js_" + expandNum);
			expander(expandingDiv, expandNum);
		}
		divCheck();
	}
	return;
}

function expander(aDiv, expNum) {
	
	if(theWidth[expNum] < 325) {
		
		theWidth[expNum] += 46;
		aDiv.style.width = theWidth[expNum] + "px";
		setTimeout('expander(expandingDiv, expandNum)', 25);
		
	} else {
		
		fadeInSpan = document.getElementById("sp_" + expNum);
		fadeInSpan.style.display = "block";
		fadeIn(fadeInSpan, expNum);
		
		
	}
	//return;
}

function divCheck() {
	
	var collapsers = false;
	var totalWidth = 0;

	for(var i = 0; i <= theWidth.length; i++) {
		
		totalWidth += theWidth[i];
		
		if(i != expandNum && theWidth[i] > 107) {
			
			currentDiv = document.getElementById("js_" + i)
			theWidth[i] -= 46;
			currentDiv.style.width = theWidth[i] + "px";
			collapsers = true;	// avoids running divCheck() multiple times if more than one div is collapsing
			
			currentSpan = document.getElementById("sp_" + i);
			currentSpan.style.display = "none";
	
		}
		
	}
	
	if(collapsers) {
		setTimeout('divCheck()', 25);	
	}
	
	if(totalWidth > 700) { //not including margins 
			
		theWidth[expandNum] -= totalWidth - 700;
		expandingDiv.style.width = theWidth[expandNum] + "px";
		
	}
}

function fadeIn(aSpan, fadeInNum) {
	
	if(theAlpha < 100) {
		//alert("alpha != 100"); works
		theAlpha += 5;
		aSpan.style.filter = 'alpha(opacity = ' + theAlpha + ')';
		aSpan.style.opacity = theAlpha / 100;
		setTimeout('fadeIn(fadeInSpan, expNum)', 25);
	
	}
	
}

function initialise() {
	
	expNum = 0;
	fadeInSpan = document.getElementById("sp_" + expNum);
	fadeInSpan.style.display = "block";
	fadeIn(fadeInSpan, expNum);
	
}

/* ------------------------------------------------------------------------------------------------------------ */

/* ------------------------------------------------- popups --------------------------------------------------- */

function popup(theLink, windowName, winWidth, winHeight)
{
if(!window.focus) return true;
var href;
if (typeof(theLink) == 'string') href=theLink;
else href=theLink.href;
window.open(href, windowName, 'width=' + winWidth + ', height=' + winHeight + ', scrollbars=yes');
return false;
}

function popitup(url) {
	newwindow=window.open(url,'','height=600,width=800,resizable=1,scrollbars=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

/* ------------------------------------------------------------------------------------------------------------ */

/* ----------------------------------- regular text expand / collapse ----------------------------------------- */

function linkCursorOn(linkId) {
	
	var thisLink = document.getElementById(linkId);
	thisLink.style.color = 'rgb(120, 120, 120)';
	document.body.style.cursor = 'pointer';
	
}

function linkCursorOff(linkId) {

	var thisLink = document.getElementById(linkId);
	thisLink.style.color = 'rgb(180, 210, 250)';
	document.body.style.cursor = 'default';

}

function picCursorOn() {
	document.body.style.cursor = 'pointer';
}

function picCursorOff() {
	document.body.style.cursor = 'default';
}

function detailDisplay(BlockId) {
	
	var thisBlock = document.getElementById(BlockId);
	
	if(thisBlock.style.display == "block") {
		thisBlock.style.display = "none";
		return;
	}
	
	// must return as above otherwise display is set to "none" then immediately back to "block"

	if(thisBlock.style.display == "none") {
		thisBlock.style.display = "block";
		return;
	}

}

function expand(blockNum) {

	var thisNews = document.getElementById("news_" + blockNum);
	var thisLetter = document.getElementById("letter_" + blockNum); 
	var thisIntro = document.getElementById("newsIntro_" + blockNum);
	var thisBlock = document.getElementById("blockText_" + blockNum);
	var thisPic = document.getElementById("blockPic_" + blockNum);
	var thisHide = document.getElementById("hide_" + blockNum);

	if(thisNews.style.display == "block") {
		thisNews.style.display = "none";
		thisLetter.style.display = "none";
		thisHide.style.display = "none";
		thisIntro.style.display = "block";
		thisBlock.style.height = "19px";
		thisPic.style.height = "50px";
		return;
	}

	// must return as above otherwise display is set to "none" then immediately back to "block"

	if(thisNews.style.display == "none") {
		thisNews.style.display = "block";
		thisLetter.style.display = "block";
		thisHide.style.display = "block";
		thisIntro.style.display = "none";
		thisBlock.style.height = "169px";
		thisPic.style.height = "200px";
		return;
	}
	
}

/* ------------------------------------------------------------------------------------------------------------ */

/* --------------------------------------------- RESTART FLASH ------------------------------------------------ */

function restartFlash(flashId) {
	
	var flashMovie = getFlashMovieObject(flashId);
	flashMovie.SetVariable("restartFlash", 1);

}

function getFlashMovieObject(movieName) {
	
	if (window.document[movieName]) {
		return window.document[movieName];
	}
	
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
		
		if (document.embeds && document.embeds[movieName]) {
			return document.embeds[movieName];
		}
		
	} else { // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
		return document.getElementById(movieName);
	}
	
}


/* ------------------------------------------------------------------------------------------------------------ */
