/** 
  2DayFM Custom Functionality 
    CHANGELOG: 
      20080118 - Born 
      20080121 - Fixed Nav functionality so all dropdowns are independant 
               - Added onload functionality to ammend the background gradient 
                 depending on which (primary or secondary) is taller. 
      20080122 - Updated background gradient resize to use scroll event on FF and IE7 (only once) 
                 load was not firing reliably in IE7 
      20080204 - Removed onmouseout behaviour to restart feature loop to improve readability. 
      20080205 - Updated _initPrimaryHeight to use scroll event for ie6 and remove scroll events once fired. 
	  20080222 - Fixed _initAutoInputs not to let event bubble into submit button. 
      20080222 - Updated _initAutoInputs to add class userInput when there is a value 
	  20080318 - Updated _initControlTabs to accept multiple classes rather than single id element. (Jens) 
	  20080411 - Added _initValidateForm and _initRegistrationForm (show/hide form elements) (Jens) 
	  20080502 - Added a maxlength3 form validation rule (nick) 
  	  20080502 - Added a function to enable/disable buttons in profile form (Bhabani) 
  	  20080811 - Updated _initControlList function to set the height of each control panel show, for the case when the "On Air Today" tab is not selected on page load (Claire) 
      20080926 - Removed non todayNetwork specific JS. 
      20081002 - Moved some of the JS back into this file as it actually was TodayNetwork specific. 
      20081210 - Re-adding showControlPanelHeight to allow for scrolling in the music widget. 
      20081224 - Pass through cat2 to AREA 
      20090518 - Don't Pass through cat2 to AREA - only required when uri prefix 
      20100118 - Updated function for generating SiteAdvertDesc for ads. (Whe) 
 **/ 
var adSizes={acquisitionpromo:"1x1",acquisitionad:"1x1",domainresizable:"1x1",enttop:"60x18",lastop:"60x18",weatherad:"65x55",emailfriendsponsor:"100x29",toolbox:"115x28",whatsonad:"140x25",mmmpodcast:"145x30",mmmfooty:"145x30",mmmonair:"145x30",mmmpoll:"145x30",homeweatherad:"180x30",bizquotebox:"192x16",travelfeature:"192x51",techfeature:"192x51",sportfeature:"192x51",sectiontool:"282x60",scoreboard:"290x60",dlbox1:"292x65",dlbox2:"292x65",multilink:"295x60",multilink:"300x105",featad:"300x36",textad:"300x28",traveltextad:"300x28",networkad:"300x250",multilink:"300x55",minibar:"300x40",promobox:"300x125",bizlink:"300x20",promobox:"300x145",mmmpollresults:"330x40",mmmshowsponsor:"330x40",mmmpodcastlisten:"400x100",acquisitionminilink:"638x20",resizable:"638x68",wideresizable:"645x40",domaintext:"0x1",iwos:"3x1"};
if(window.FD){FD.getSiteAdvertDesc=function(A){var C,B;var D=A.params;if(D&&D.site){C=[siteAdvertDesc.group,D.network,D.site,siteAdvertDesc.section].join(".");B=[siteAdvertDesc.section,D.network,D.site].join(".");if(D.cat){B+="."+D.cat;if(D.cat1){B+="."+D.cat1}}}return{redir:"/adredirect.html?ad=",area:B.toUpperCase(),site:C.toUpperCase()}}}if(window.FD){FD.todayNetwork=new Class({Implements:[Events,Options],options:{showControlPanelHeight:71},initialize:function(){this.setOptions();window.addEvent("scroll",this._initPrimaryHeight.bind(this));
this._initControlList();this._initNav()},_initPrimaryHeight:function(){window.removeEvents("scroll");var D=$("primary"),A=$("secondary");if(D&&A){pHeight=D.offsetHeight;sHeight=A.offsetHeight;var C=(Browser.Engine.trident4)?"height":"min-height";var B=(pHeight<sHeight)?[D,A,0]:[A,D,5];B[0].setStyle(C,(B[1].offsetHeight-B[2])+"px")}},_initControlList:function(){var A=this.getControlList();if(A){this.clPos=0;this.clCount=0;this.clScrolling=false;var E=A.getElement("ul");var B=E.getElements("li");var F=0;
for(var D=0;D<B.length;D++){if(B[D].getParent()==E){if(!this.clDist){this.clDist=this.options.showControlPanelHeight}if(B[D].hasClass("now")){F=this.clCount}this.clCount++}}this.clLastPos=this.clCount-3;if(F>0){var C=F;if(C<=this.clLastPos){C--}if(C>0){this.moveCLToPos(E,C)}}A.addEvent("click",this.scrollCL.bindWithEvent(this,E))}},scrollCL:function(D,B){if(D&&D.target&&!this.clScrolling){var C=$(D.target);if(C.hasClass("scroll")){new Event(D).stop();var A=this.clPos+((C.hasClass("list-up"))?-1:1);
this.moveCLToPos(B,A)}}},moveCLToPos:function(B,A){if(!isNaN(A)){if(A>this.clLastPos){A=this.clLastPos}if(A<0){A=0}this.clPos=A;var F=(this.clDist*A)*-1;var E=(A<this.clPos)?-1:1;F+=(E*-1);var D={onComplete:this.clComplete.bind(this)};var C=new Fx.Morph(B,D).start({top:F+"px"})}},clComplete:function(){this.clScrolling=false},getControlList:function(){return $("onairnow")},_initNav:function(){var A=$("navigation");if(A){A.addEvent("click",this.togglePlusNav.bindWithEvent(this));var B=A.getElements("li.expand");
if(B){B.addEvent("click",this.openAllNav.bindWithEvent(this))}}},togglePlusNav:function(G){if(G&&G.target){var A;var E=$(G.target);if(E.get("tag")=="a"){E=E.getParent()}if(!E.hasClass("plus")){return true}if(E.hasClass("expand")){return false}var B=E.getParent();if(B.get("tag")=="ul"){var D=B.getElement("li.expand");if(D){A=D.hasClass("expanded")}var F;if(!E.hasClass("open")){F=true}if(!A){B.getElements("li.plus").removeClass("open")}if(F){E.addClass("open");var H=B.getElements("li.plus").hasClass("open");
for(var C=0;C<H.length;C++){if(!H[C]){return false}}D.addClass("expanded")}else{if(A){E.removeClass("open");var H=B.getElements("li.open");if(H.length==0){var A=B.getElement("li.expanded");if(A){A.removeClass("expanded")}}}}return false}}},openAllNav:function(C){if(C&&C.target){new Event(C).stop();var B=$(C.target);if(B.get("tag")=="a"){B=B.getParent()}var A=B.getParent();var D=A.getElements("li.plus");D.each(function(E,F){if(!B.hasClass("expanded")){E.addClass("open")}else{E.removeClass("open")}});
if(!B.hasClass("expanded")){B.addClass("expanded")}else{B.removeClass("expanded")}}}});var todayNetwork;function initTodayNetwork(){todayNetwork=new FD.todayNetwork()}FD.register("TodayNetwork",1)};