window.onload=template_init;
function template_init(){
    channel_init();
}

function popup_window(url,width,height){
var features="status=0,menubar=0,location=0,toolbar=0";
if (!isNaN(parseInt(width))){features+=",width="+width;}
if (!isNaN(parseInt(height))){features+=",height="+height;}
if (typeof(window.screenLeft)!="undefined"){
features+=",left="+window.screenLeft;
features+=",left="+Math.round(window.screenLeft+((document.body.clientWidth/2)-(width/2)));
}else if (typeof(window.screenX)!="undefined"){
features+=",left="+Math.round(window.screenX+((window.outerWidth/2)-(width/2)));
}
if (typeof(window.screenTop)!="undefined"){
features+=",top="+window.screenTop;
features+=",top="+Math.round(window.screenTop+150);
}else if (typeof(window.screenY)!="undefined"){
features+=",top="+Math.round(window.screenY+((window.outerHeight-window.innerHeight)+150));
}
var popupWin=window.open(url,"popupWin",features);
if (popupWin.focus){popupWin.focus();}
}
function toggle_imagetabs(){
if (document.getElementById(arguments[0])){
toggle_display(arguments[0],true);
toggle_tab_image(arguments[0],true);
if (arguments.length>1){
for (var i=1;i<arguments.length;i++){
if (document.getElementById(arguments[i]) && arguments[i]!=arguments[0]){
toggle_display(arguments[i],false);
toggle_tab_image(arguments[i],false);
}
}
}
}
}

var activeYousaidit=0;
function toggle_yousaidit(){
if (document.getElementById("yousaidit"+(activeYousaidit+1))){
toggle_display("yousaidit"+activeYousaidit,false);
toggle_display("yousaidit"+(++activeYousaidit),true);
}else{
toggle_display("yousaidit"+activeYousaidit,false);
toggle_display("yousaidit"+(activeYousaidit=0),true);
}
}
function toggle_tab_image(id,state){
if (document.getElementById(id+"Tab")){
var src=document.getElementById(id+"Tab").src.substr(0,document.getElementById(id+"Tab").src.lastIndexOf(".")+1);
if (state && src.indexOf("off.")>0){
document.getElementById(id+"Tab").src=src.substr(0,src.length-4)+"on";
}else if (!state && src.indexOf("on.")>0){
document.getElementById(id+"Tab").src=src.substr(0,src.length-3)+"off";
}
}
}
function toggle_hottabs(url,tab){
if (document.getElementById("whatsHotContent")){
if (document.getElementById("whatsHotContent").className.indexOf(" "+tab)==-1){
document.getElementById("whatsHotContent").className="content "+tab;
if (document.getElementById("whatsHotFrame")){
document.getElementById("whatsHotFrame").src=url;
}
}
}
}
function toggle_visibility(id,state){
if (document.getElementById(id)){
if (typeof(state)=="undefined"){state=document.getElementById(id).style.visibility=="visible"?false:true;}
if (state){var x=document.getElementById(id).offsetLeft;}
document.getElementById(id).style.visibility=state?"visible":"hidden";
}
}
function test_browser_animation_caps(){
return true;
}


var activeButton, playingForward, playingBackward, photoPlayer, playControlActive, storyControlActive, maxStory
var timeDelay = 10;
var autoPlay = "on";
var playDirection = "forward";
var x = 0;
var offImg = new Array("info_btn_1_off","info_btn_2_off","info_btn_3_off","info_btn_4_off","info_btn_5_off","info_btn_6_off","info_btn_7_off","info_btn_8_off","info_btn_9_off","info_btn_10_off","info_btn_11_off","info_btn_12_off","info_btn_prev_off","info_btn_pause_off","info_btn_next_off");
var onImg = new Array("info_btn_1_on","info_btn_2_on","info_btn_3_on","info_btn_4_on","info_btn_5_on","info_btn_6_on","info_btn_7_on","info_btn_8_on","info_btn_9_on","info_btn_10_on","info_btn_11_on","info_btn_12_on","info_btn_prev_on","info_btn_pause_on","info_btn_next_on");
function photoLead_playPhotos(seconds,onOff,direction){
if (document.getElementById("photoGalleryParent")){
if (seconds!=undefined){timeDelay = seconds}
timeDelay = timeDelay * 1000;
if (typeof(maxStory)=="undefined"){
maxStory = 0;
while (document.getElementById("pic"+maxStory)){
maxStory++;
}
//maxStory-=3;
}
if (onOff!=undefined){autoPlay=onOff.toLowerCase()}
else{autoPlay=autoPlay.toLowerCase()}
if (direction!=undefined){playDirection=direction.toLowerCase();}
   else{playDirection=playDirection.toLowerCase();}
if (playDirection=="forward"){
playingForward=true;
playingBackward=false;
playControlActive=14;
}
else{
playingForward=false;
playingBackward=true;
playControlActive=12;
}
if (autoPlay=="on"){photoLead_startTimer()}
else (photoLead_changePhotoStory(1));
}
}
function photoLead_startTimer(){
if (playingForward==true){
if (document.getElementById("pic14")){document.getElementById("pic14").src = "http://cdn.channel.aol.com/ch_sports/" + onImg[14]}
if (document.getElementById("photostory" + (x+1)) && document.getElementById("pic" + x)){x=x+1}
 else{
  maxStory=x;
x=1;
}
}
if (playingBackward==true){
if (document.getElementById("pic12")){document.getElementById("pic12").src = "http://cdn.channel.aol.com/ch_sports/" + onImg[12]}
x=x-1;
if (x<1){x=maxStory}
}
if (document.getElementById("photodefault") && document.getElementById("photostory" + x + "photo") && document.getElementById("photostory" + x + "photo").innerHTML!=""){document.getElementById("photodefault").innerHTML=document.getElementById("photostory" + x + "photo").innerHTML}
if (document.getElementById("textdefault") && document.getElementById("photostory" + x + "text") && document.getElementById("photostory" + x + "text").innerHTML!=""){document.getElementById("textdefault").innerHTML=document.getElementById("photostory" + x + "text").innerHTML}
if (document.getElementById("linkWrapperDefault") && document.getElementById("linkWrapper" + x) && document.getElementById("linkWrapper" + x).innerHTML!=""){document.getElementById("linkWrapperDefault").innerHTML=document.getElementById("linkWrapper" + x).innerHTML}
storyControlActive=x-1;
photoLead_makeActive(x);
photoPlayer=setTimeout("photoLead_startTimer()", timeDelay);
}
function photoLead_stopTimer(){
if (playingForward==true && document.getElementById("pic14")){document.getElementById("pic14").src = "http://cdn.channel.aol.com/ch_sports/" + offImg[14]}
if (playingBackward==true && document.getElementById("pic12")){document.getElementById("pic12").src = "http://cdn.channel.aol.com/ch_sports/" + offImg[12]}
playingForward=false;
playingBackward=false;
playControlActive=-1;
if (photoPlayer){
clearTimeout(photoPlayer);
}else{
if (photoPlayer==undefined && document.getElementById("pic13")){document.getElementById("pic13").src = "http://cdn.channel.aol.com/ch_sports/" + offImg[13]}
}
}
function photoLead_rollover(buttonID,buttonNumber,buttonState){
if (document.getElementById(buttonID)){
switch (buttonState){
case "on":
document.getElementById(buttonID).src = "http://cdn.channel.aol.com/ch_sports/" + onImg[buttonNumber];
break;
case "off":
if (activeButton!=buttonNumber && playControlActive!=buttonNumber && storyControlActive!=buttonNumber){
document.getElementById(buttonID).src = "http://cdn.channel.aol.com/ch_sports/" + offImg[buttonNumber];
}
break;
}
}
}
function photoLead_makeActive(isActiveNum){
activeButton = isActiveNum - 1;
if (activeButton==13){}
else{
for (i=0;i<15;i++){
if (playingForward==true && i!=14 && document.getElementById("pic" + i)){document.getElementById("pic" + i).src = "http://cdn.channel.aol.com/ch_sports/" + offImg[i]}
else if (playingBackward==true && i!=12 && document.getElementById("pic" + i)){document.getElementById("pic" + i).src = "http://cdn.channel.aol.com/ch_sports/" + offImg[i]}
else if (playingForward==false && playingBackward==false && document.getElementById("pic" + i)){document.getElementById("pic" + i).src = "http://cdn.channel.aol.com/ch_sports/" + offImg[i]}
}
}
if (document.getElementById("pic" + activeButton)){document.getElementById("pic" + activeButton).src = "http://cdn.channel.aol.com/ch_sports/" + onImg[activeButton]}
}
function photoLead_changePhotoStory(photStorNumber){
if (photStorNumber>maxStory){photStorNumber=maxStory}
storyControlActive=photStorNumber-1;
x=photStorNumber;
photoLead_makeActive(photStorNumber);
if (document.getElementById("photodefault") && document.getElementById("photostory" + photStorNumber + "photo") && document.getElementById("photostory" + photStorNumber + "photo").innerHTML!=""){document.getElementById("photodefault").innerHTML=document.getElementById("photostory" + photStorNumber + "photo").innerHTML}
if (document.getElementById("textdefault") && document.getElementById("photostory" + photStorNumber + "text") && document.getElementById("photostory" + photStorNumber + "text").innerHTML!=""){document.getElementById("textdefault").innerHTML=document.getElementById("photostory" + photStorNumber + "text").innerHTML}
if (document.getElementById("linkWrapperDefault") && document.getElementById("linkWrapper" + photStorNumber) && document.getElementById("linkWrapper" + photStorNumber).innerHTML!=""){document.getElementById("linkWrapperDefault").innerHTML=document.getElementById("linkWrapper" + photStorNumber).innerHTML}
}
function toggle_image(id, src){
if (document.getElementById(id)){
document.getElementById(id).src=src;
}
}

