var sport_serial = '717319';

if (typeof sANID == 'undefined') {
  var sANID = '';
}

if (typeof GS_googleAddAdSenseService == 'function') {
  GS_googleAddAdSenseService("ca-pub-4989789738673683");
  GS_googleEnableAllServices();
}

function testPrint(){
	if (window.print){
 	document.write('<div class="print"><a href="javascript:window.print();" onclick="pageTracker._trackEvent(\'print\', \'click\', \'page=<?php echo $thispage; ?>\')"><img src="/_images/print.gif" width="25" height="25" alt="Print page" class="img" border="0" />Print page</a></div>');
	}	
}

function sportSelect(){
	document.write('<input type="button" name="splist" id="spdd" onclick="javascript:addchecks(this);" value="Select all sports" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="splist" id="spremove" value="Deselect all sports" onclick="javascript:clearchecks(this);" />');
}

function channelSelect(){
	document.write('<input type="button" name="chlist" id="chadd" onclick="javascript:addchecks(this);" value="Select all channels" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="chlist" id="chremove" value="Deselect all channels" onClick="javascript:clearchecks(this);" />');
}

function checkDrop(){
	if(document.getElementById("channel").selectedIndex!=0){
		document.getElementById("_search").action="/search.php?s=1&dd=1";
	}	
}
  
function setCookie(sName, sValue)
{
  document.cookie = sName + "=" + escape(sValue);
  // Expires the cookie in one month
  var date = new Date();
  date.setMonth(date.getMonth()+1);
  document.cookie += ("; expires=" + date.toUTCString()); 
}


function popupQuiz(siteid,qotd_correct) {
	var width=520,height=370;
	var left=(((screen.availWidth / 2 ) - (width / 2)) -12);
	var top=((screen.availHeight / 2 ) - (height / 2));
  	navigator.appName.indexOf("netscape") ? r=0 : r=1;
	var features='width='+width+',height='+height+',left='+left+',top='+top+',resizable=1';
	var domain = self.location.hostname;

	
		switch(siteid){
			case 1: var url = 'http://quiz.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 2: var url = 'http://football.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 4: var url = 'http://f1.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 5: var url = 'http://sport.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 7: var url = 'http://rugbyunion.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;		
			case 8: var url = 'http://golf.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;		
			case 9: var url = 'http://cricket.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;		
			case 16: var url = 'http://horseracing.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;				
			case 17: var url = 'http://rugbyleague.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 19: var url = 'http://tennis.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 20: var url = 'http://www.soyouthink.com/?fuseaction=ShowHome&win=mini&partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 28: var url = 'http://olympics.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 31: var url = 'http://worldcup.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 67: var url = 'http://scottishfootball.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 138: var url = 'http://championsleague.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 139: var url = 'http://sixnations.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 140: var url = 'http://cricketworldcup.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 142: var url = 'http://rugbyworldcup.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			case 148: var url = 'http://euro2008.soyouthink.com/miniwindow.cfm?partner_id=00&link_id=353&ref=livefootballontv'; break;
			default: var url = 'http://www.soyouthink.com/?fuseaction=ShowHome&win=mini&partner_id=00&link_id=353&ref=livefootballontv'; break;
		}
	
	
	if(qotd_correct != undefined && qotd_correct != null)
	{
		url += '&syt_t='+siteid+'&syt_c='+qotd_correct;
	}
	
	url += '&domain='+escape(domain);
	var activeWindow=window.open(url,'quiz_window',features);
}

function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();


function displaycountdown(){
	if (seconds<1){
		document.location=location.href;
	}
	else{
		seconds-=1;
		document.getElementById('counter').innerHTML=seconds;
		setTimeout("displaycountdown()",1000);
	}
}

function goog(){
	var newsouter = document.getElementById("newsmain");
	var beeblink = newsouter.getElementsByTagName("a");
	for (i=0; i < beeblink.length; i++){
		myLink=beeblink[i];
		if(myLink.className == "bbclink"){
			myLink.onClick=pageTracker._trackEvent('link', 'bbcnews', document.location);
		}
	}
}

function doWidth(ad){

	var adWidth = document.getElementById('mainad').offsetWidth;
	
	if (adWidth==250){
		//news
		document.getElementById("news_head").id = "widenews_head";
		document.getElementById("news").id = "widenews";
		//scores
		//if(document.getElementById("liveticker")!=null){
//			document.getElementById("liveticker").id = "wideliveticker";
//			document.getElementById("scores").id = "widescores";
//			document.getElementById("scoresmain").id = "scoresmain";
//			document.getElementById("scores_head").id = "widescores_head";
//		}
	}
	
}


function getOffset( el ) {
    var _x = 0;
    var _y = 0;
    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
        _x += el.offsetLeft - el.scrollLeft;
        _y += el.offsetTop - el.scrollTop;
        el = el.parentNode;
    }
    return { top: _y, left: _x };
}




function popUp(URL,width,height,sc) {
	day = new Date();
	id = day.getTime();
	if (sc=="0"){
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=false,menubar=0,resizable=0,width=" + width + ",height=" + height + ",top=100,left=100');");
	}
	else{
	
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height=" + height + ",top=100,left=100');");
	}
}

function spPopup(intsp, intecId, intevId, intmktId, intselId, intprice, strWindowName) {
	var xWidth=550;
	var xHeight=560;
	var strQueryString;
					
	var strTPid="15256";

	if (document.all)
	  var xMax = screen.width, yMax = screen.height;
	else
	  if (document.layers)
	      var xMax = window.outerWidth, yMax = window.outerHeight;
	 else
	      var xMax = 800, yMax=600;
					
	var xOffset = (xMax - xWidth)/2;  // width
	var yOffset = 0;
	if (yMax > 600)
		yOffset = (yMax - xHeight)/2;  // height
			
	VBS=window.open("http://www.sportingbet.com/t/mini/betSlip.aspx?tpid="+strTPid+"&sp="+intsp+"&ecId="+intecId+"&evId="+intevId+"&mktId="+intmktId+"&selId="+intselId+"&price="+intprice, strWindowName, "width="+xWidth+",height="+xHeight+",screenX="+xOffset+",screenY="+yOffset+",top="+yOffset+",left="+xOffset+",toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=no");
	if (VBS.opener == null)
		VBS.opener = self;
	VBS.focus();
}


function clearchecks (el) {
	var grp = el.name;
	var frm = document.getElementById('_search');
	for (i=0; i<frm.length; i++) {
	
		var item = frm.elements[i];
		if (item.name.substr(0,grp.length) == grp && item.name.length>6) {
			if (el.checked) {
				// do nothing
			} else {
				switch (item.type) {
					case 'checkbox':
						item.checked = false;
						break;
					case 'radio':
						item.checked = false;
						break;
					case 'select':
						item.selectedIndex = 0;
						break;
					default:
						item.value = '';
				}
			}
		}
	}
}

function addchecks (el) {
	var grp = el.name;
	var frm = document.getElementById('_search');
	for (i=0; i<frm.length; i++) {
		var item = frm.elements[i];
		if (item.name.substr(0,grp.length) == grp && item.name.length >6) {
			if (el.checked) {
				// do nothing
			} else {
				switch (item.type) {
					case 'checkbox':
						item.checked = true;
						break;
					case 'radio':
						item.checked = true;
						break;
				}
			}
		}
	}
}

function fbs_click(){
	u=location.href;
	t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

//feedback
function feedback() {
	var strAlert = "Please enter a valid email address."
	var checkmail = "pass"
	if (0 == document.feed.realname.value.length) {
		alert("Please enter your name.");
		document.feed.realname.focus();
		return false;
	}
	if (0 == document.feed.message.value.length) {
		alert("Please enter your comments.");
		document.feed.comments.focus();
		return false;
	}
    if (document.feed.email.value == "") {
		checkmail="fail"; 
	}
	else{
		emailarray = document.feed.email.value.split("@");
		if (emailarray.length != 2) {
			checkmail="fail";   
		}
		else { 
			if (emailarray[0].search("^[A-Za-z0-9]") == -1){
				checkmail="fail";
			}
            if (emailarray[0].search("[A-Za-z0-9]$") == -1){
				checkmail="fail";
			}
			if (emailarray[0].search("[\.\_\-]+") > 0) { 
				if (emailarray[0].search("[A-Za-z0-9][\.\_\-][A-Za-z0-9]+$") == -1){
					checkmail="fail"; 
				}
			}
			if (emailarray[1].search("^[A-Za-z0-9][A-Za-z0-9\-]+[\.]+[A-Za-z0-9]{2,}") == -1){
				checkmail="fail";
			}
			if (document.feed.email.value.indexOf("..") >= 0){
				checkmail="fail";
			}
		}
	}
	if (checkmail == "fail") {
		alert (strAlert);
		document.feed.email.focus();
		return false;
	}
	else {
		return true;
	}
 }

function menuStyles(){
	var menu = document.getElementById("menu");
	var objLink = menu.getElementsByTagName("div");
	for (i=0; i < objLink.length; i++){
		myLink=objLink[i];
		if(myLink.className == "menuitem"){
			myLink.onmouseout = function(){
				this.className = "menuitem";
			}
			myLink.onmouseover = function(){
				this.className = "menuitem_on";
			}
		}
	}
}

function setCookie(c_name,value,expiredays,id)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+"="+escape(value)+"+exp"+id+"="+exdate.toGMTString()+"+orig="+ exdate.toGMTString() + ";" + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()+";path=/;domain=.livesportontv.com");
}

function deleteCookie(c_name)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()-5);
	document.cookie=c_name+"=;expires="+exdate.toGMTString()+";path=/;domain=.livesportontv.com";
}

function updateCookie(c_name,value,expiredays,id)
{
	origDate = unescape(document.cookie).split('exp'+id+'=')[1];
	neworigDate = unescape(origDate).split('orig=')[1];
	document.cookie=c_name+"="+escape(value)+"+exp"+id+"="+neworigDate+"+orig="+ neworigDate + ";" + ((expiredays==null) ? "" : ";expires="+neworigDate+";path=/;domain=.livesportontv.com");
}

//Setanta
var setsport = 'http://impgb.tradedoubler.com/imp?type(inv)g(17378516)a(1527478)' + new String (Math.random()).substring (2, 11);

/*GA_googleAddSlot("ca-pub-4989789738673683", "Fixture_Footer");
GA_googleAddSlot("ca-pub-4989789738673683", "Inline_Fixture");
GA_googleAddSlot("ca-pub-4989789738673683", "Menu_Spotlight_1");
GA_googleAddSlot("ca-pub-4989789738673683", "Menu_Spotlight_2");
GA_googleAddSlot("ca-pub-4989789738673683", "Skycraper_2");
GA_googleAddSlot("ca-pub-4989789738673683", "Skyscaper_1");
GA_googleAddSlot("ca-pub-4989789738673683", "Skyscraper_3");
GA_googleAddSlot("ca-pub-4989789738673683", "Skyscraper_4");
GA_googleAddSlot("ca-pub-4989789738673683", "Top_MPU");
GA_googleFetchAds();*/

function concat(aObj) {
  var href = aObj.href;
  var params = [];
  
  if (href.indexOf('lang=') == -1) {
    params.push('lang=en');
  }
  
  if (href.indexOf('sr=') == -1) {
    params.push('sr=' + sport_serial);
  }
    
  var params_str = '';
  for (var i = 0; i < params.length; ++i) {
    params_str += params[i] + '&';
  }

  if (params_str[params_str.length - 1] == '&') {
    params_str = params_str.substr(0, params_str.length - 1);
  }
  
  if (params_str != '') {
    aObj.href = aObj.href + (aObj.href.indexOf('?') == -1 ? '?' : '&') + params_str;
  }
}