function initBlankContainers(){
	blankContainer = $("blank-container");
	blankTop = $("blank-top");
	blankRight = $("blank-right");;
	blankBottom = $("blank-bottom");
	blankLeft = $("blank-left");
}

function initMenuEvents(){
	var menu = document.getElementById("menu-wrapper");
	var links = menu.getElementsByTagName("a");
	for (var i=0; i<links.length; i++){
		links[i].onclick = function() {
			if (this.href && this.href.length>1)
				menuTracker._trackEvent(this.innerHTML);
		};
	}
	
	var list = getElementsByClassName("nav-wrapper","div",$("navigation"));
	for (var i = 0;i<list.length;i++){
		list[i].onmouseover = function(){ track(this,"mouseover"); };
		list[i].onmouseout = function(){ track(this,"mouseout"); };
	}
	$("but-game-a").onmouseover = function(){ track(this,"mouseover"); };
	$("but-media-a").onmouseover = function(){ track(this,"mouseover"); };
	$("but-clancy-a").onmouseover = function(){ track(this,"mouseover"); };
	$("but-game-a").onmouseout = function(){ track(this,"mouseout"); };
	$("but-media-a").onmouseout = function(){ track(this,"mouseout"); };
	$("but-clancy-a").onmouseout = function(){ track(this,"mouseout"); };
}

function StripHTML(xStr){
	var regExp = /<\/?[^>]+>/gi;
	xStr = xStr.replace(regExp,"");
	return xStr;
}

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

var BlankDivs = {
	init: function(currObj,clickfn,mousefn){
		if (!blankTop) initBlankContainers();
				
		this.clickEvent = blankTop.onmouseover;

		this.currObj = currObj;
		this.clickfn = clickfn;
		this.mousefn = mousefn?mousefn:this.clear;
		
		blankContainer.style.zIndex = 15000;
	},
	drawBlankDivs: function(currObj) {
		if (currObj){this.currObj = currObj}
		
		blankTop.onclick = this.clickfn;
		blankLeft.onclick = this.clickfn;
		blankRight.onclick = this.clickfn;
		blankBottom.onclick = this.clickfn;

		blankTop.onmouseover = this.mousefn;
		blankLeft.onmouseover = this.mousefn;
		blankRight.onmouseover = this.mousefn;
		blankBottom.onmouseover = this.mousefn;
		
		blankTop.style.height = Math.max((this.getTop()-(this.currObj.className.indexOf("search-box-list")>=0?20:0)),0)+"px";
		blankTop.style.width = (this.getWidth())+"px";
		
		blankLeft.style.top = (this.getTop()-(this.currObj.className.indexOf("search-box-list")>=0?20:0))+"px";
		blankLeft.style.width = this.getLeft()+"px";
		blankLeft.style.height = Math.max((this.getHeight()-this.getTop()),0)+"px";
		
		blankRight.style.top = (this.getTop()-(this.currObj.className.indexOf("search-box-list")>=0?20:0))+"px";
		blankRight.style.left = (this.getLeft()+this.currObj.offsetWidth)+"px";
		blankRight.style.height = (this.getHeight()-this.getTop())+"px";
		blankRight.style.width = Math.max((this.getWidth()-this.getLeft()-this.currObj.offsetWidth),0)+"px";
		
		blankBottom.style.left = (this.getLeft())+"px";
		blankBottom.style.top = (this.getTop()+this.currObj.offsetHeight)+"px";
		blankBottom.style.top = (this.getTop()+this.currObj.offsetHeight)+"px";
		blankBottom.style.width = (this.currObj.offsetWidth)+"px";
		blankBottom.style.height = Math.max((this.getHeight()-this.getTop()-this.currObj.offsetHeight),0)+"px";
		
		blankContainer.style.display = "block";
	},
	hideBlankDivs: function() {
		blankTop.onclick = null;
		blankLeft.onclick = null;
		blankRight.onclick = null;
		blankBottom.onclick = null;

		blankTop.onmouseover = this.clickEvent;
		blankLeft.onmouseover = this.clickEvent;
		blankRight.onmouseover = this.clickEvent;
		blankBottom.onmouseover = this.clickEvent;

		blankTop.style.height = "170px";
		blankRight.style.top = "209px";
		blankLeft.style.top = "209px";
		
		blankContainer.style.display = "none";
	},
	getHeight: function(){

		var height;
		if (document.body.clientHeight) {
			height = document.body.clientHeight;
		} else if (typeof window.innerWidth == "number") {
			height = window.innerHeight;
		} else if (document.documentElement &&
			(document.documentElement.clientWidth ||
			document.documentElement.clientHeight)) {
			height = document.documentElement.clientHeight;
		}
		return height;
	},
	getWidth: function(){
		var width;
		if (typeof window.innerWidth == "number") {
			width = window.innerWidth;
		} else if (document.documentElement &&
			(document.documentElement.clientWidth ||
			document.documentElement.clientHeight)) {
			width = document.documentElement.clientWidth;
		}
		return width-30;
	},
	getLeft: function(){
		var iReturnValue = 0;
		var oElement = this.currObj;
		while( oElement != null ) {
			iReturnValue += oElement.offsetLeft;
			oElement = oElement.offsetParent;
		}
		return iReturnValue;
	},
	getTop: function(){
		var iReturnValue = 0;
		var oElement = this.currObj;
		while( oElement != null ) {
			iReturnValue += oElement.offsetTop;
			oElement = oElement.offsetParent;
		}
		return iReturnValue;
	},
	clear: function(){},
	clickEvent:null,
	currObj:null,
	clickfn:null,
	mousefn:null,
	isIE7:null
};


var GlobalAccordion = {
	init: function(group1, group2, parent){
		var accordion1 = new Accordion(getElementsByClassName(group1,'div',$(parent)), getElementsByClassName(group2,'div',$(parent)), {
		onActive: function(toggler, element){
			if (element.className == "news-details") element.style.marginBottom = "10px";
			var obj = getElementsByClassName('plus-png','div',toggler)[0] || getElementsByClassName('plus-png-on','div',toggler)[0];
			obj.className = "minus-png-on";
			toggler.onmouseover = function(){ var obj = getElementsByClassName("minus-png-off","div",this)[0]; if (obj) {obj.className = "minus-png-on";}};
			toggler.onmouseout = function(){ var obj = getElementsByClassName("minus-png-on","div",this)[0]; if (obj) {obj.className = "minus-png-off";}};
			toggler.onclick = function(){
				if (element.style.height.length>=4){
					var obj = getElementsByClassName("minus-png-on","div",this)[0]; if (obj) {obj.className = "plus-png-on";}
					toggler.onmouseover = function(){ var obj = getElementsByClassName("plus-png","div",this)[0]; if (obj) {obj.className = "plus-png-on";}};
					toggler.onmouseout = function(){ var obj = getElementsByClassName("plus-png-on","div",this)[0]; if (obj) {obj.className = "plus-png";}};
				};
			};
		},
	 
		onBackground: function(toggler, element){
			if (element.className == "news-details") element.style.marginBottom = "0px";
			var obj = getElementsByClassName('minus-png-off','div',toggler)[0];
			if (obj){
				obj.className = "plus-png";
				obj.onmouseover = function(){ var obj = getElementsByClassName("plus-png","div",this)[0]; if (obj) {obj.className = "plus-png-on";}};
				obj.onmouseout = function(){ var obj = getElementsByClassName("plus-png-on","div",this)[0]; if (obj) {obj.className = "plus-png";}};
			}
		}	});
		
		var list = getElementsByClassName(group1,"div");
		for (var i=0; i<list.length; i++){
			list[i].onmouseover = function(){ var obj = getElementsByClassName("plus-png","div",this)[0]; if (obj) {obj.className = "plus-png-on";}};
			list[i].onmouseout = function(){ var obj = getElementsByClassName("plus-png-on","div",this)[0]; if (obj) {obj.className = "plus-png";}};
		}	
		
		var list = getElementsByClassName(group2,"div");
		for (var i=0; i<list.length; i++){
			var k;
			if (getElementsByClassName("feature-image","div",list[i])[0]){
				k = getElementsByClassName("feature-image","div",list[i])[0];
				k.innerHTML += "<div class=\"sdw-png\"></div>";
			}
			else if (list[i].className = group2){
				if (list[i].innerHTML.toLowerCase().indexOf("<img")>=0){
					list[i].innerHTML += "<div class=\"sdw-png\"></div>";
				}
			}
		}	
		
	}
};


var Poll = {
	selectItem: function (obj,value) {
		//Initial c
		if (this.currItem!=null){
			this.currItem.className = this.styleOff;
		}
		obj.className = this.styleOn;
		this.value = value;
		this.currItem = obj;
		/*Begin Modif to select Poll radio button INPUT inside DIV*/
		obj.childNodes[1].childNodes[0].checked = true;
		/*End Modif to select Poll radio button INPUT inside DIV*/
	},
	submitForm: function () {
		//Initial c
		if (this.currItem==null){
			alert("Please select an item");
			return;
		}
		
		this.ajaxSubmit();
	},
	ajaxSubmit: function() {
		AjaxPoll.fetch(this.pollURL+"?poll="+this.value,this.pollDIV);		
	},
	styleOn: "poll-selected-item",
	styleOff: "poll-item",
	pollDIV: "poll-container",
	pollURL: "poll/poll.jsp",
	currItem: null,
	value: null
};

var AjaxPoll = {
	fetch: function(url,divID) {
		AjaxPoll.divID = divID;
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.onreadystatechange = this.processReqChange;
			req.open("POST", url, true);
			req.send(null);
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = this.processReqChange;
				req.open("POST", url, true);
				req.send();
			}
		}
	},
	processReqChange: function () {
		if (req.readyState == 4) {
			if (req.status == 200) {
				$(AjaxPoll.divID).innerHTML=req.responseText;
				if (navigator.appVersion.indexOf("Mac")!=-1) {$("poll-thanks").style.paddingBottom="4px";}
				$("poll-retults-container").style.visibility = "visible";
			}
			else {
			}
		}
	},
	divID: null
};

//	window.onDomReady= new function(){alert('ok');};
/*
	window.onDomReady(function(){
		var version = deconcept.SWFObjectUtil.getPlayerVersion();
		if (document.getElementById && version["major"] > 0) {
			//document.getElementById('flashversion').innerHTML = "You have Flash player "+ version['major'] +"."+ version['minor'] +"."+ version['rev'] +" installed.";
		}
		alert(version["major"]+"-"+version["minor"]+"-"+version["rev"]);
	});
*/



/************* New Functions MG *************/
function SelectPollRadio(){
	UL_Poll = document.getElementById('poll_test');
	for( var x = 0; UL_Poll.childNodes[x]; x++ ){
		UL_Poll.childNodes[x].id = 'li_' + x;
		UL_Poll.childNodes[x].childNodes[0].id = 'input_' + x;
		alert (UL_Poll.childNodes[x].childNodes[0].checked);
	}
	
}


/*
	Updated flash detect implementation
*/
var FlashDetect = {
	version : {
		Major:0,
		Minor:0,
		Revision:0
	},
	
	isIE  : (navigator.appVersion.indexOf("MSIE") != -1) ? true : false,
	isWin : (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false,
	isOpera : (navigator.userAgent.indexOf("Opera") != -1) ? true : false,	
	
	GetSwfVer : function (){
		// NS/Opera version >= 3 check for Flash plugin in plugin array
		var flashPlugs = new Array;
		if (navigator.plugins != null && navigator.plugins.length > 0) {
			for(x=0; x< navigator.plugins.length; x++){
				if(navigator.plugins[x].name.indexOf('Shockwave Flash')>=0){
					flashPlugs.push(navigator.plugins[x]);
				}
			}

			var version = [0,0,0];
			
			for(x=0; x< flashPlugs.length; x++){
				var flashDescription = flashPlugs[x].description;
				var descArray = flashDescription.split(" ");
				var tempVersion = descArray[2].split(".");
				tempVersion.push(parseInt(descArray[descArray.length-1].substr(1,descArray[descArray.length-1].length)));
				
				var major = parseInt(tempVersion[0]);
				var minor = parseInt(tempVersion[1]);
				var revis = parseInt(tempVersion[2]);
				tempVersion = [major,minor,revis];
				
				if ((tempVersion[0]>version[0]) || (tempVersion[0]==version[0] && tempVersion[1]>version[1]) || (tempVersion[0]==version[0] && tempVersion[1]==version[1] && tempVersion[2]>version[2])){
					version = tempVersion;
				}
			}
			this.version.Major = version[0];
			this.version.Minor = version[1];
			this.version.Revision = version[2];
		}
		// MSN/WebTV 2.6 supports Flash 4
		else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
		// WebTV 2.5 supports Flash 3
		else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
		// older WebTV supports Flash 2
		else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
		else if ( FlashDetect.isIE && FlashDetect.isWin && !FlashDetect.isOpera ) {
			flashVer = this.ControlVersion();
			if (flashVer==-1) return this.version;
			
			flashVerString = flashVer + '';
			if(flashVerString.indexOf('WIN')>=0){
				flashVer = flashVerString.substr((flashVerString.indexOf('WIN')+4) , flashVerString.length);
			}
			version = flashVer.split(',');
			this.version.Major = version[0];
			this.version.Minor = version[1];
			this.version.Revision = version[2];
		}
		return this.version;
	},
	ControlVersion : function(){
		var version;
		var axo;
		var e;
	
		// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
		
		try {
			// version will be set for 7.X or greater players
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.9");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
		
		
		try {
			// version will be set for 7.X or greater players
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.8");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
		
		
		try {
			// version will be set for 7.X or greater players
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	
		if (!version)
		{
			try {
				// version will be set for 6.X players only
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				
				// installed player is some revision of 6.0
				// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
				// so we have to be careful. 
				
				// default to the first public version
				version = "WIN 6,0,21,0";
	
				// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
				axo.AllowScriptAccess = "always";
	
				// safe to call for 6.0r47 or greater
				version = axo.GetVariable("$version");
	
			} catch (e) {
			}
		}
	
		if (!version)
		{
			try {
				// version will be set for 4.X or 5.X player
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
				version = axo.GetVariable("$version");
			} catch (e) {
			}
		}
	
		if (!version)
		{
			try {
				// version will be set for 3.X player
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
				version = "WIN 3,0,18,0";
			} catch (e) {
			}
		}
	
		if (!version)
		{
			try {
				// version will be set for 2.X player
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				version = "WIN 2,0,0,11";
			} catch (e) {
				version = -1;
			}
		}
		
		return version;
	},
	DetectVersion : function (major,minor,revision){
		var compare = this.GetSwfVer();
		return ((compare.Major>major) || (compare.Major==major && compare.Minor>minor) || (compare.Major==major && compare.Minor==minor && compare.Revision>=revision));
	}
}

