// function to launch BigPond Guide
var contentIDArray = new Array ("4069","4070","4071","4072","4073","4045","4039","4040","4041","4042","4036","4044");

function openGuide(id, title){
	// replace spaces with underscores in url for SEO
	if(title)
		title = title.replace(/ /g, "_");
	window.open("http://bigpondguide.com/" + id + "_2_" + title,"epg", "width=1024,height=815,resizable=1");
}

function openOmniGuide(id, title, page)
{
	s.channel=page
    s.pageName=s.prop1 + ':' + s.prop2 + ':' + s.prop3 + ':' + s.channel;
    s.hier1= s.prop1+ '|' + s.prop2+ '|' + s.prop3 + '|' + s.channel; 
	var s_code=s.t();
	openGuide(id, title);
}

function submitSensis() {
  var searchString = document.getElementById('findField').value;
  document.getElementById('find').value = searchString;
  
  document.searchForm.submit();
  
}


// Article ratings

// Define variables
var STAR_BAR_MAX = 4;
var STAR_WIDTH = 13;
var STAR_HEIGHT = 12;
var STAR_EMPTY = new Image(STAR_WIDTH, STAR_HEIGHT);
var STAR_FULL = new Image(STAR_WIDTH, STAR_HEIGHT);
	STAR_EMPTY.src = "/DesktopModules/NRL_News/Images/Rating/starOff.gif";
	STAR_FULL.src = "/DesktopModules/NRL_News/Images/Rating/starOn.gif";
var endStar;

// This function turns on stars from 1 until star that is mouseovered
function starsOn(obj){
	var whichStar = obj.value;
	var rootElement = obj.parentNode.id;
	var tagElements = document.getElementById(rootElement).getElementsByTagName('input') ;
	
	//dd(whichStar);
	for (i=0;i<=whichStar-1;i++)			
		tagElements[i].src = STAR_FULL.src;		
}

// This function turns off stars -- Defaults to selected hidden amount
function starsOff(obj){
	var whichStar = obj.value;
	var rootElement = obj.parentNode.id;
	var tagElements = document.getElementById(rootElement).getElementsByTagName('input') ;
	
	//dd(whichStar);
	for (i=0;i<=STAR_BAR_MAX;i++)
		tagElements[i].src = STAR_EMPTY.src;
}

<!-- sub nav functions -->
	
	var selectedMenu = null ;
	var selectedSubMenu = null;
	
	function showSub(obj,subObj)
	{	
		// hide selected subnav
		
		if (selectedSubMenu != null ) document.getElementById(selectedSubMenu).className = 'subnav';
				
		if (subObj != null) document.getElementById(subObj).className = 'subnavShow';
		
		var selectedItem = 'dnn_dnnMENU_' + obj;
		document.getElementById(selectedItem).className = 'selectedNav';	
	}
	
	function hideSub(obj,subObj)
	{
		// hide active sub nav		
		if (subObj != null) document.getElementById(subObj).className = 'subnav';
		
		var nav = 'dnn_dnnMENU_' + obj;
		if (obj != selectedMenu) document.getElementById(nav).className = 'normal';
		
		//show selected subnav
		var subNav = obj + 'Lvl2';		
		if (selectedSubMenu != null) document.getElementById(selectedSubMenu).className = 'subnavShow';		
			
	}
	
	function setSelected(menu,subMenu)
	{
		if (subMenu != null) document.getElementById(subMenu).className = 'subnavShow';
		
		var selectedItem = 'dnn_dnnMENU_' + menu;
		//alert (selectedItem);
		document.getElementById(selectedItem).className = 'selectedNav';
	
	}


/* function to launch url for tickets promo */

	function doURLJump(obj){
	
		var launchURL = obj.options[obj.selectedIndex].value;
		
		obj.selectedIndex = 0;
		
		if (launchURL.length >0) window.open(launchURL,'tickets');
	
	}

function pageLink(url) {
  location.href = url; 
}

window.onload = attachHighlight;
function attachHighlight() { /* When page loads, attach highlight function to each news item */
	var alldivs = document.getElementsByTagName("div");
	for (var i=0; i<alldivs.length; i++) {
		if (alldivs[i].className == "newsItem") {
			alldivs[i].onmouseover = function() {
				highlightItem(this);
				return false;
			}
			alldivs[i].onmouseout = function() {
				highlightItem(this);
				return false;
			}

		}
	}
}

function highlightItem(object) { /* highlight and un-highlight news items on mouseover, mouseout */
highlight = (object.className == "newsItem") ? object.className="newsItem altColour" : object.className = "newsItem";
}

/* video console functions */

	var currentVideo = null;
	var videoList = new Array();
	
	videoList[1] = "mms://wmt.streaming.telstra.com/wh_telstr18/OnDemand/NRLHosting/NRL_TVC_1_Master.wmv";
	videoList[2] = "mms://wmt.streaming.telstra.com/wh_telstr18/OnDemand/NRLHosting/NRL_TVC_3_Master.wmv";
	videoList[3] = "mms://wmt.streaming.telstra.com/wh_telstr18/OnDemand/NRLHosting/NRL_TVC_2_Master.wmv";
	videoList[4] = "mms://wmt.streaming.telstra.com/wh_telstr18/OnDemand/NRLHosting/NRL_TVC_4_Master.wmv";
	//videoList[5] = "mms://wmt.streaming.telstra.com/wh_telstr18/OnDemand/NRLHosting/NRL_Behind_the_sceens_Master.wmv";
	
	function showVideo(id)
	{
		var selectedVid = videoList[id];
		document.getElementById('player').style.backgroundImage = "none";
		var playerStr =  '<object id="MediaPlayer" width="320" height="286" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">';
			playerStr += '	<param name="fileName" value="' +  selectedVid + '" />';		
			playerStr += '	<param name="animationatStart" value="true" />';
			playerStr += '			  <param name="transparentatStart" value="true" />';
			playerStr += '			  <param name="autoStart" value="true" />';
			playerStr += '			  <param name="showControls" value="true" />';
      playerStr += '			  <param name="ShowStatusBar" value="true" />';
      playerStr += '			  <param name="showtracker" value="false" />';
      playerStr += '			  <param name="showControls" value="true" />';
      playerStr += '			  <param name="loop" value="false" />';
			playerStr += '			  <embed type="application/x-mplayer2" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" id="mediaPlayer"  displaysize="4" autosize="-1"'; 
			playerStr += '			  	bgcolor="darkblue" showcontrols="true" showtracker="0" showdisplay="0" showstatusbar="-1" videoborder3d="-1" width="320" height="286"';
			playerStr += '				src="' +  selectedVid + '" autostart="True" designtimesp="5311" loop="False"> </embed>';
			playerStr += '</object>';
			
		currentVideo = id;
		document.getElementById('playerContainer').innerHTML = playerStr;
	}

  
// This sets the image URL through a drop down and the image size is set via the link ID
function setWPURL(obj) {
  
  
  var selectedteam = (document.getElementById(obj).options(document.getElementById(obj).selectedIndex).value);
  
  var wpName1 = "/portals/0/wallpapers/800x600/" + selectedteam + ".jpg";
  var wpName2 = "/portals/0/wallpapers/1024x768/" + selectedteam + ".jpg";
  var wpName3 = "/portals/0/wallpapers/1280x1024/" + selectedteam + ".jpg";
  
  document.getElementById('WP800x600').href = wpName1;
  document.getElementById('WP1024x768').href = wpName2;
  document.getElementById('WP1280x1024').href = wpName3;
  
}

//----------FAQ STUFF---------------------


var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)

var contractsymbol='- ' //HTML for contract symbol. For image, use: <img src="whatever.gif">
var expandsymbol='+ ' //HTML for expand symbol.


if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

//function sweeptoggle(ec){
//var thestate=(ec=="expand")? "block" : "none"
//var inc=0
//while (ccollect[inc]){
//ccollect[inc].style.display=thestate
//inc++
//}
//revivestatus()
//}


function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(curobj, cid){
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

//function revivecontent(){
//contractcontent("omitnothing")
//selectedItem=getselectedItem()
//selectedComponents=selectedItem.split("|")
//for (i=0; i<selectedComponents.length-1; i++)
//document.getElementById(selectedComponents[i]).style.display="block"
//}

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
statecollect[inc].innerHTML=expandsymbol
inc++
}
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

//----------END FAQ STUFF--------------


// -------------------- START TEAM MASCOT JS ---------------------
  
// This sets the image URL through the ID of the link and the alt text is a variable passed through the link also.
function setMascot(id, altTag) {
  
  // Convert the ID value to the variable "teamName"
  var teamName = id
  // Set the variable "mascotLink" to be the image path PLUS the passed through team name
  var mascotLink = "/portals/0/mascots/popup/" + teamName + ".jpg";
  
  // Declare that the variable "mascotLink" is the actual ID of the HREF that we passed through
  document.getElementById(teamName).href = mascotLink;
  
  // This bit passes the variables we have created through to the writeConsole function
  writeConsole(teamName,mascotLink,altTag)
}



function writeConsole(teamName,mascotLink,altTag) {
 
 top.consoleRef=window.open('','myconsole',
  'width=480,height=640'
   +',menubar=0'
   +',toolbar=0'
   +',status=0'
   +',scrollbars=0'
   +',resizable=0')
 top.consoleRef.document.writeln(
  '<html><head><title>' + altTag + ' Mascot</title></head>'
   +'<body style="margin: 0px; padding: 0px; background: #fff;" onLoad="self.focus()">'
   +'<img src="' + mascotLink + '" width="480" height="640" border="0" alt="' + altTag + ' Mascot" />'
   +'</body></html>'
 )
 top.consoleRef.document.close()
 
}

// -------------------- END TEAM MASCOT JS ---------------------


