document.write ("<style type='text/css'>.js-hdn{display:none}</style>");


//ie detection script
isIE = function(){return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);}

// unobtrusive global pop up function
msPopups = function() {
	
	$("a[@rel^='pop']").click(function(){
	
		var pA = $(this).attr('rel');
		pA=pA.split('|');
		
		switch(pA[0]){
		
			case 'popUp':
				var pW = pA[1];
				var pH = pA[2];
				
			break;
			
			case 'popUpFootballScores':
				var pW = '700';
				var pH = '300';
			break;
			
			case 'popUpCricketScores':
				var pW = '400';
				var pH = '140';
			break;
		
		}
		
		var pL = Math.floor((screen.width-pW)/2);
		var pT = Math.floor((screen.height-pH)/2);
			
		window.open($(this).attr('href'),pA[0],'width='+pW+',height='+pH+',top='+pT+',left='+pL+',scrollbars=1');
		return false;
	
	})
}

vpTabs = function(el){
	
	/*  el is the id of the ul you wish to apply tabbed navigation to. */
	
	if(document.getElementById(el)){
	
		var tabs = document.getElementById(el).getElementsByTagName('li');
		for(i=0;i<tabs.length;i++){
			
			tabs[i].onclick=function(){
				
				for(j=0;j<tabs.length;j++){
					tabs[j].className="";
				}
				this.blur();
				this.className="vp-tab-on";
				
				var channelToChange = this.id;
				vpInit(channelToChange,'','');
				playerFunctions(channelToChange);
				
				return false;
			
			}
		
		}
	
	}

}

vpImgSwap = function(el){

	if(document.getElementById(el)){
	
		/* el is the id of the ul you wish to apply the image swap to */

		var ims = document.getElementById(el).getElementsByTagName('li');
		
		for(var i=ims.length-1;i>=0;i--){
			
			if(ims[i].getElementsByTagName('a')[0]){
				ims[i].getElementsByTagName('a')[0].onclick=function(){
					
					for(var j=ims.length-1;j>=0;j--){
						
						if(ims[j].getElementsByTagName('img')[0]){
							var ims2 = ims[j].getElementsByTagName('img')[0].src;
							ims2 = ims2.replace(/active/,"");
							ims[j].getElementsByTagName('img')[0].src = ims2;
							
							
						}
					}
					var cursrc = this.getElementsByTagName('img')[0].src;
					if(cursrc.indexOf("active")==-1){
						cursrc = cursrc.split('.gif')
						newsrc=cursrc[0]+"active"+".gif";
						this.getElementsByTagName('img')[0].src=newsrc;
					}
					
					
					this.blur();
					changePlayerSize(this.rel);
					return false;
					
				
				}
			}
		
		}
	}

}


vpInit = function(channel,size,setting){
        // use this function to set what buttons are switched on onload
        
        if(document.getElementById('vp-channel-nav')){
               
                var c = parseInt(channel);
               
               if(channel){
               
                       // set main channel tab
                       var tabs1 = document.getElementById('vp-channel-nav').getElementsByTagName('li');
                       for(var i=tabs1.length-1;i>=0;i--){tabs1[i].className=""}
                       tabs1[c-1].className="vp-tab-on";
 
               }
 
        }
}


changePlayerSize = function(size){
	//insert whatever player resize are needed here
	alert(size)

}

onLoadEvents = function(){

	vpInit('1','1','1');
	vpTabs('vp-channel-nav');
	vpImgSwap('vp-player-size');
	vpImgSwap('vp-player-settings');
	msPopups();
}



$(document).ready(function(){

	onLoadEvents();

	$('#faqs-list a').click(function(){
		$.scrollTo( this.hash, 800);
		$(".vp-col-faqs dl"+this.hash).addClass('faq-target')
		return false;
	});
	
	$('a.vp-top').click(function(){
		$.scrollTo(0, 800);
		$(".vp-col-faqs dl").removeClass('faq-target');
		return false;
	});
	
	$('.vp-main-nav a,.vp-footer a').click(function(){
		var h = this.hash;$(".vp-col-faqs dl"+h).addClass('faq-target');
	
	})
	
	if(location.hash!=""){var dl = location.hash.substring(1);$(".vp-col-faqs dl#"+dl).addClass('faq-target')}
	

		
})




$(document).ready(
	function()
	{
		$(".vp-home-r1 a, .vp-home-r1 img, .tabs-container a, .tabs-container img, .clip-tabs a, ").ToolTip("#CEE6F0", "#000");
	}
	
);