

/**
 * Cross browser method for adding event listeners - as usual
 * it's IE that breaks from the standards.
 */
function addNewEventListener(element, type, func, bubbling){
	bubbling = bubbling || false;
	if(typeof element.addEventListener != 'undefined'){ // DOM standards compliant
		element.addEventListener(type, func, bubbling);
		return true;
	}else if(window.attachEvent){ // IE
		element.attachEvent('on' + type, func);
		return true;
	}else
		return false;
}

/**
 * Hides and displays the main text area of an article, to allow an unimpaired
 * view of the images behind it.
 */
function toggleText(){
	var artTxt = document.getElementById('articletxt');
	artTxt.style.display = artTxt.style.display != 'none' ? 'none' : 'block';
}

/**
 * Tries to add an onclick handler to the hide text link, and shows the
 * link if it is successful.
 */
function instantiateTextToggle(){
	var hideTxt = document.getElementById('hideText');
	if(hideTxt && addNewEventListener(hideTxt.firstChild, 'click', toggleText))
		hideTxt.style.display = 'block';
}

//Function called from Flash when each section finishes loading
//to stop the 'transferring data' message showing in the status
//bar
function DoneLoading() {
	var flashvars = {};
	var params = {};
	var attributes = {};
	swfobject.embedSWF("", "DoneLoading", "100%", "100%", "8", flashvars, params, attributes);
}

var reqdFlashVersion = '9.0.0';
if(swfobject.hasFlashPlayerVersion(reqdFlashVersion)){
	SWFAddress.setValue(swfUrl);
	var flashvars = {};
	var params = {
		allowfullscreen:	'true',
		wmode:				'window',
		bgcolor:			'#000000'
	};
	var attributes = {};
	swfobject.embedSWF("cabstudios_preloader.swf", "flashcontent", "100%", "100%", reqdFlashVersion, false, flashvars, params, attributes);
} else {
	addNewEventListener(window, 'load', instantiateTextToggle);
}