function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function userLoggedIn()
{
	//return readCookie('userloggedin');
	return (readCookie('userloggedin') || readCookie('venda') != null || readCookie('VLUID') != null);
}

function toggleShowHide(sDiv)
{
	if (document.getElementById(sDiv).style.display == "block")
	{
		document.getElementById(sDiv).style.display = "none";
	}else{
		document.getElementById(sDiv).style.display = "block";
	}
}	

function popup(name, sUrl, width, height) {
	window.open(sUrl, name,'width='+width+'px,height='+height+'px,menubar=no,status=yes,scrollbars=no,toolbar=no,location=no,directories=no,resizable=yes,top=25,left=30'); 
	return false; //necessary so it doesn't follow href 
}

function externalLinks()
{
	 if (!document.getElementsByTagName) return;
	 var anchors = document.getElementsByTagName("a");
	
	 for (var i=0; i<anchors.length; i++) {
	   var anchor = anchors[i];
	   if (anchor.getAttribute("id") == 'loginLink' || anchor.getAttribute("id") == 'registerLink') continue;
	   
		var ancHref = anchor.getAttribute("href");
		if( undefined == ancHref ){
			return;
		}
		//if (anchor.getAttribute("href") == 'http://tv.arsenal.com' || anchor.getAttribute("href") == 'http://tv.arsenal.com/'){ 
//		if (anchor.getAttribute("href").toLowerCase().indexOf('http://tv.arsenal.com') > -1){
		if (ancHref.toLowerCase().indexOf('http://tv.arsenal.com') > -1){
	   		anchor.setAttribute('onclick', "return popup('arsenaltv', '"+anchor.getAttribute("href")+"', 990, 691);");
	   		//IE 6 requires this.
	   		anchor.parentNode.innerHTML = anchor.parentNode.innerHTML
		}
		else if (anchor.getAttribute("href").toLowerCase().indexOf('http://www.arsenal.com/webforms') > -1) { 
	   		anchor.setAttribute('onclick', "return popup('webforms','"+anchor.getAttribute("href")+"', 800, 455);");
	   		//IE 6 requires this.
	   		anchor.parentNode.innerHTML = anchor.parentNode.innerHTML
		}
		else if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
		 anchor.target = "_blank";
	   }//end if else
	 }//end for
}//end function





var gTextSize = 63;
function textSizeChange()
{
	var btnL = document.getElementById("naTextLarger");
	var btnS = document.getElementById("naTextSmaller");

	btnL.onclick = function(){
		gTextSize += 10;
		if( 203 < gTextSize ){
			gTextSize = 203;
		}
		document.getElementsByTagName("body")[0].style.fontSize = gTextSize + "%";
	};
	btnS.onclick = function(){
		gTextSize -= 10;
		if( 33 > gTextSize ){
			gTextSize = 33;
		}
		document.getElementsByTagName("body")[0].style.fontSize = gTextSize + "%";
	};
}

function onloadInit()
{
	externalLinks();
	textSizeChange();
}


window.onload = onloadInit;
