
var circuitInfoPage = false;
var cPage;
var sPage;
var fPage;

function load(){
	
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	sPage = sPage.replace("index","");
	sPage = sPage.replace(".php","");

		
	if(window.location.hash.length > 3){
		switch(window.location.hash){
			case "#competition":
			loadUp(1);
			break;
			case "#spectator":
			loadUp(2);
			break;
			case "#watchlive":
			loadUp(3);
			break;
			case "#halo":
			loadUp(4);
			break;
			case "#gow":
			loadUp(5);
			break;
			case "#wow":
			loadUp(6);
			break;
		}
	
	}else{
		$('mainCallouts').style.display = 'block';
	}

		
		switch(sPage){
		
			default:
			$('event1').className = "next";
			$('event2').className = "active";
			$('event3').className = "active";
			$('event4').className = "active";
			$('event5').className = "active";
			
			break;
			
			case '2':
			
			$('event1').className = "active";
			$('event2').className = "next";
			$('event3').className = "active";
			$('event4').className = "active";
			$('event5').className = "active";
			
			break;
			
			case '3':
			
			$('event1').className = "active";
			$('event2').className = "active";
			$('event3').className = "next";
			$('event4').className = "active";
			$('event5').className = "active";
			
			break;
			
			case '4':
			
			$('event1').className = "active";
			$('event2').className = "active";
			$('event3').className = "active";
			$('event4').className = "next";
			$('event5').className = "active";
			
			break;
			
			case '5':
			
			$('event1').className = "active";
			$('event2').className = "active";
			$('event3').className = "active";
			$('event4').className = "active";
			$('event5').className = "next";
			
			break;	
			
			
		}	


}


function loadUp(section){
var section  = section * 1;

if($('mainCallouts').style.display == "block"){
$('mainCallouts').style.display = "none";
}

$('backgroundMain').style.backgroundImage = "none";
$('contentArea').style.display='block';

	switch(section){
	
		case 1:
			$('link1').className="active";
			$('link2').className="inactive";
			$('link3').className="inactive";
			$('link1Content').style.display="block";
			$('link2Content').style.display="none";
			$('link3Content').style.display="none";
			$('haloContent').style.display="none";
			$('gowContent').style.display="none";
			$('wowContent').style.display="none";
			window.location.hash = "competition";				
		break;
		
		case 2:
			$('link1').className="inactive";
			$('link2').className="active";
			$('link3').className="inactive";
			$('link1Content').style.display="none";
			$('link2Content').style.display="block";
			$('link3Content').style.display="none";
			$('haloContent').style.display="none";
			$('gowContent').style.display="none";
			$('wowContent').style.display="none";
			window.location.hash = "spectator";				
		break;
		
		case 3:
			$('link1').className="inactive";
			$('link2').className="inactive";
			$('link3').className="active";
			$('link1Content').style.display="none";
			$('link2Content').style.display="none";
			$('link3Content').style.display="block";
			$('haloContent').style.display="none";
			$('gowContent').style.display="none";
			$('wowContent').style.display="none";
			window.location.hash = "watchlive";				
		break;
		
		case 4:
			$('link1').className="active";
			$('link2').className="inactive";
			$('link3').className="inactive";
			$('link1Content').style.display="none";
			$('link2Content').style.display="none";
			$('link3Content').style.display="none";
			$('haloContent').style.display="block";
			$('gowContent').style.display="none";
			$('wowContent').style.display="none";
			window.location.hash = "halo";				
		break;
		
		case 5:
			$('link1').className="active";
			$('link2').className="inactive";
			$('link3').className="inactive";
			$('link1Content').style.display="none";
			$('link2Content').style.display="none";
			$('link3Content').style.display="none";
			$('haloContent').style.display="none";
			$('gowContent').style.display="block";
			$('wowContent').style.display="none";
			window.location.hash = "gow";				
		break;
		
		case 6:
			$('link1').className="active";
			$('link2').className="inactive";
			$('link3').className="inactive";
			$('link1Content').style.display="none";
			$('link2Content').style.display="none";
			$('link3Content').style.display="none";
			$('haloContent').style.display="none";
			$('gowContent').style.display="none";
			$('wowContent').style.display="block";
			window.location.hash = "wow";				
		break;
	
	}

}

function loadEvent(event){
	
	if(event == 1){
		window.location.href = 'index1.php';
	}else if(event == 2 || event == 3 || event == 4 || event == 5){
		window.location.href ='index'+event+'.php';
	}else{

	}
	
}

function closeLightBox(){
	
	$('lightBoxHolder').innerHTML = '';
	$('lightBoxContent').innerHTML = ''
}

function loadLightBox(title,nid){
	getHeight();
	var nid = nid * 1;// Sanitize to ensure its a integer.
	var content;
	var link = '<a href="http://www.mlgpro.com/?q=node/'+nid+'">'+title+'</a>';
	$('lightBoxHolder').style.display = 'none';
	
	new Ajax.Updater('lightBoxHolder', '/pro-circuit/2009/_data/fetchContent.php?item='+nid, {
										method: 'post',
										onComplete: function(){
										
										content = $('lightBoxHolder').innerHTML;	
																
										var arrayPageScroll = document.viewport.getScrollOffsets();
									    var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
									    var lightboxLeft = arrayPageScroll[0];
									    
									
										$('lightBoxContent').innerHTML = '<div style="position:absolute;top:'+lightboxTop+'px;left:0;z-index:99;width:100%;">'+
																		"<table cellspacing='0' cellpadding='0' style='' align=\"center\" width=\"100%\"><tr><td width=\"725\" onclick=\"closeLightBox();\"></td><td>"+
										 								 "<table cellspacing='0' cellpadding='0' style='background-color:#FFF;width:700px;' align=\"center\">"+
										 								 '<tr><td align="left" height="40px" style="text-align: left;color: white;background-color:#94261a; padding:1em;"><a onclick="closeLightBox()">[ x ] Close</a></td></tr>'+
										 								 //'<tr><td align="left"><img src="_images/header.jpg"></td></tr>'+
										 								 '<tr><td align="left" style="padding-left:15px;"padding-right:15px;"><h2 style="margin-bottom:0px;padding-bottom:0px;">'+link+'</h2></td></tr>'+
										 								 '<tr><td style="padding-left:15px;"padding-right:15px;font-size:11px;" class="lightboxContent"><span style="font-size:11px;"><div style="text-align: left; padding: 2em; overflow: scroll; max-height: 290px;">'+content+'</div></td></tr>'+
										 								 '<tr><td align="left" height="40px" style="text-align: right;color: white;background-color:#94261a; padding:1em;"><a onclick="closeLightBox()">[ x ] Close</a></td></tr>'+
										 								 '</table></td><td width=\"725\" onclick=\"closeLightBox();\"></td></tr></table></div></div>'+
																		 '<div id="lighboxTransparency" onclick="closeLightBox();" class="transparency" style="z-index: 10;position:absolute;left:0;top:0;width:100%;height:100%;"></div>';

										$('lighboxTransparency').style.height = getPageSizeWithScroll()+"px";
										}})
	 
	
}

function getDocheight(){
docheight = document.getElementById("lightBoxContent").offsetTop; 
 return alert(docheight);
}   
  
function getHeight(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox		
		return window.scrollY + 25;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		return document.body.offsetTop;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		return document.body.offsetTop;
  	}
}
function getHeight2(){
	
	
	
}

function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	return yWithScroll;
}
