/* Image rollovers from DHTML Utopia: Modern Web Design Using Javascript & Dom. Author: Stuart Langridge. Published by: Sitepoint */

function setupRollovers() {
	if (!document.getElementsByTagName)
		return;
	var all_links = document.getElementsByTagName('a');
	for (var i = 0; i < all_links.length; i++) {
		var link = all_links[i];
		if (link.className && (' ' + link.className + ' ').indexOf(' rollover ') != -1) {
			if (link.childNodes && link.childNodes.length == 1 && link.childNodes[0].nodeName.toLowerCase() == 'img') {
				link.onmouseover = mouseover;
				link.onmouseout = mouseout;
			}
		}
	}
}
function find_target(e) {
	/* Begin the DOM events part, which you can ignore for now if it's confusing */
	var target;
	if (window.event && window.event.srcElement)
		target = window.event.srcElement;
	else if (e && e.target)
		target = e.target;
	if (!target)
		return null;
	while (target != document.body && target.nodeName.toLowerCase() != 'a')
		target = target.parentNode;
	if (target.nodeName.toLowerCase() != 'a')
		return null;
	return target;
}
function mouseover(e) {
	var target = find_target(e);
	if (!target) return;
	// the only child node of the a tag in target will be an img tag
	var img_tag = target.childNodes[0];
	// Take the "src", which names an image called "something.ext",
	// Make it point to "something_over.ext"
	// This is done with a regular expression
	img_tag.src = img_tag.src.replace(/(\.[^.]+)$/, '_over$1');
}
function mouseout(e) {
	var target = find_target(e);
	if (!target) return;
	// the only child node of the A-tag in |target| will be an IMG-tag
	var img_tag = target.childNodes[0];
	// Take the "src", which names an image as "something_over.ext",
	// Make it point to "something.ext"
	// This is done with a regular expression
	img_tag.src = img_tag.src.replace(/_over(\.[^.]+)$/, '$1');
}
// When the page loads, set up the rollovers
window.onload = setupRollovers;
/* End Image Rollovers */


/* ObjectSwap - Bypasses the new ActiveX Activation requirement in Internet Explorer by swapping existing ActiveX objects on the page with the same objects. Can also be used for Flash version detection by adding the param: <param name="flashVersion" value="6" /> to the object tag. Author: Karina Steffens, www.neo-archaic.net. Created: April 2006. Changes and bug fixes: May 2006 */

//Check if the browser is InternetExplorer
var ie = (navigator.appName.indexOf("Microsoft") != -1);
//Hide the object to prevent it from loading twice
if (ie) {
	document.write ("<style id='hideObject'> object {display:none;} </style>");
}
/*Replace all flash objects on the page with the same flash object,
by rewriting the outerHTML values
This bypasses the new IE ActiveX object activation issue*/
objectSwap = function() {
	//An array of ids for flash detection
	var stripQueue = [];
	//Get a list of all ActiveX objects
	var objects = document.getElementsByTagName('object');
	for (var i=0; i<objects.length; i++) {
		var o = objects[i];
		var h = o.outerHTML;
		//The outer html omits the param tags, so we must retrieve and insert these separately
		var params = "";
		var hasFlash1 = true;
		for (var j = 0; j<o.childNodes.length; j++) {
			var p = o.childNodes[j];
			if (p.tagName == "PARAM") {
				//Check for version first - applies to all browsers
				//For this to work, a new param needs to be included in the object with the name "flashVersion" eg:
				//<param name="flashVersion" value="7" />
				if (p.name == "flashVersion") {
					hasFlash1 = detectFlash(p.value);
					if (!hasFlash1) {
						//Add the objects id to the list (create a new id if there's isn't one already)
						o.id = (o.id == "") ? ("stripFlash"+i) : o.id;
						stripQueue.push(o.id);
						break;
					}
				}
				params += p.outerHTML;
			}
		}
		if (!hasFlash1) {
			continue;
		}
		//Only target internet explorer
		if (!ie) {
			continue;
		}
		//Avoid specified objects, marked with a "noswap" classname
		if (o.className.toLowerCase().indexOf ("noswap") != -1) {
			continue;
		}
		//Get the tag and attributes part of the outer html of the object
		var tag = h.split(">")[0] + ">";
		//Add up the various bits that comprise the object:
		//The tag with the attributes, the params and it's inner html
		var newObject = tag + params + o.innerHTML + " </OBJECT>";
		//And rewrite the outer html of the tag
		o.outerHTML = newObject;
	}
	//Strip flash objects
	if (stripQueue.length) {
		stripFlash(stripQueue)
	}
	//Make the objects visible again
	if (ie) {
		document.getElementById("hideObject").disabled = true;
	}
}
detectFlash = function(version) {
	if(navigator.plugins && navigator.plugins.length) {
		//Non-IE flash detection.
		var plugin = navigator.plugins["Shockwave Flash"];
		if (plugin == undefined) {
			return false;
		}
		var ver = navigator.plugins["Shockwave Flash"].description.split(" ")[2];
		return (Number(ver) >= Number(version))
	} else if (ie) {
	//IE flash detection.
		try {
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + version);
			return true;
		}
		catch(e) {
			return false;
		}
	}
	//Catchall - skip detection
	return true;
}
//Loop through an array of ids to strip
//Replace the object by a div tag containing the same innerHTML.
//To display an alternative image, message for the user or a link to the flash installation page, place it inside the object tag.
//For the usual object/embed pairs it needs to be enclosed in comments to hide from gecko based browsers.
stripFlash = function (stripQueue) {
	for (var i=0; i<stripQueue.length; i++) {
		var o = document.getElementById(stripQueue[i]);
		var newHTML = o.innerHTML;
		//Strip the comments
		newHTML = newHTML.replace(/<!--\s/g, "");
		newHTML = newHTML.replace(/\s-->/g, "");
		//Neutralise the embed tag
		newHTML = newHTML.replace(/<embed/gi, "<span");
		//Create a new div element with properties from the object
		var d = document.createElement("div");
		d.innerHTML = newHTML;
		d.className = o.className;
		d.id = o.id;
		//And swap the object with the new div
		o.parentNode.replaceChild(d, o);
	}
}
//Initiate the function without conflicting with the window.onload event of any preceding scripts
if (window.onload) {
	window.onload = function() {
		window.onload;
		objectSwap();
	}
} else {
	window.onload = objectSwap;
}
/* End ObjectSwap */


/* Begin news scroller */
/* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com). This notice MUST stay intact for legal use. Visit http://www.dynamicdrive.com/ for this script and 100s more. */
function pausescroller(content, divId, divClass, delay){
	this.content=content //message array content
	this.tickerid=divId //ID of ticker div to display information
	this.delay=delay //Delay between msg change, in miliseconds.
	this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
	this.hiddendivpointer=1 //index of message array for hidden div
	document.write('<div id="'+divId+'" class="'+divClass+'" style="position:relative; overflow:hidden"><div class="innerDiv" style="position:absolute; width:100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position:absolute; width:100%; visibility:hidden" id="'+divId+'2">'+content[1]+'</div></div>')
	var scrollerinstance=this
	if (window.addEventListener) //run onload in DOM2 browsers
		window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
	else if (window.attachEvent) //run onload in IE5.5+
		window.attachEvent("onload", function(){scrollerinstance.initialize()})
	else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
		setTimeout(function(){scrollerinstance.initialize()}, 500)
}
// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------
pausescroller.prototype.initialize=function(){
	this.tickerdiv=document.getElementById(this.tickerid)
	this.visiblediv=document.getElementById(this.tickerid+"1")
	this.hiddendiv=document.getElementById(this.tickerid+"2")
	this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
	//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
	this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
	this.getinline(this.visiblediv, this.hiddendiv)
	this.hiddendiv.style.visibility="visible"
	var scrollerinstance=this
	document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
	document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
	if (window.attachEvent) //Clean up loose references in IE
		window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
	setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}
// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------
pausescroller.prototype.animateup=function(){
	var scrollerinstance=this
	if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
		this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
		this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
		setTimeout(function(){scrollerinstance.animateup()}, 50)
	} else {
		this.getinline(this.hiddendiv, this.visiblediv)
		this.swapdivs()
		setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
	}
}
// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------
pausescroller.prototype.swapdivs=function(){
	var tempcontainer=this.visiblediv
	this.visiblediv=this.hiddendiv
	this.hiddendiv=tempcontainer
}
pausescroller.prototype.getinline=function(div1, div2){
	div1.style.top=this.visibledivtop+"px"
	div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}
// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------
pausescroller.prototype.setmessage=function(){
	var scrollerinstance=this
	if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
		setTimeout(function(){scrollerinstance.setmessage()}, 100)
	else{
		var i=this.hiddendivpointer
		var ceiling=this.content.length
		this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
		this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
		this.animateup()
	}
}
pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
	if (tickerobj.currentStyle)
		return tickerobj.currentStyle["paddingTop"]
	else if (window.getComputedStyle) //if DOM2
		return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
	else
		return 0
}
/* End news scroller */


/* Load multiple functions */
function start() {
	setupRollovers();
	objectSwap();
	dsds_onload();
	dsds2_onload();
	showHide(1);
}
window.onload = start;
/* End load multiple functions */