var isLoaded = 0;
var divCount = '';
var entInterval;
var activeTab = new Array();
var activeToolTip = '';
var msgObj = null;
var is_aol = navigator.userAgent.toLowerCase().indexOf("aol") != -1;
var is_mac = navigator.userAgent.indexOf('Mac') != -1;

// set is_flash var
var is_flash = false; var flashVer = 7;
if (window.ActiveXObject && !is_mac) {document.write('<scr' + 'ipt language="VBScript">' + '\n' + 'On Error Resume Next' + '\n' + 'is_Flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & flashVer)))' + '\n' + '<\/sc' + 'ript>'); } 
else {var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0; var pluginStr = plugin.description; if (plugin){ if (parseInt(pluginStr.substring(pluginStr.indexOf(".")-1)) >= flashVer) { is_flash = true; }}}

function openWindow (url) {
	var argv = openWindow.arguments;
	var argc = argv.length;
	if (argc == 1) {var handle = window.open(url);}
	else if (argc == 2) {var handle = window.open(url,argv[1]);}
	else {var handle = window.open(url,argv[1],argv[2]);}
	handle.focus();
}

function interceptLinks () {
	for (var i = document.links.length-1; i >= 0 ; i--) {
		var url = document.links[i].href;
		if (url.substring(0,3) == 'aol') {document.links[i].onclick = showClientMsg;}
	}
	msgObj = document.createElement('div');
	msgObj.setAttribute("id", "clientMsg");
	msgObj.innerHTML = "<p>We're sorry, this page is not yet available on AOL.com. Please sign in to your AOL software to view this page.<\/p><ul><li class=\"first\"><a href=\"\" id=\"launchLink\">Launch AOL Now<\/a><\/li><li><a href=\"http://www.aol.com/downloads/\">Download 9.0 Optimized<\/a><\/li><\/ul><div class=\"closeBtn\"><a href=\"\" onclick=\"return hideClientMsg();\">Close<\/a><\/div><\/div>";
	document.body.appendChild(msgObj);
}

function showClientMsg(e) {
	if (!msgObj || window != top) {alert("This area is only available within the AOL client."); return false;}
	if (document.getElementById) {var launchLink = document.getElementById("launchLink");}
	else if (document.all) {var launchLink = document.all.launchLink;}
	else {alert("This area is only available within the AOL client."); return false;}
	launchLink.href = this.href;
	e = e ? e : event;
	var cm_xPos = (e.pageX != undefined) ? e.pageX : e.clientX + (document.documentElement ? document.documentElement.scrollLeft : document.body.scrollLeft);
	var cm_yPos = (e.pageY != undefined) ? e.pageY : e.clientY + (document.documentElement ? document.documentElement.scrollTop : document.body.scrollTop);
	cm_xPos = (cm_xPos > 438) ? 438 : cm_xPos;
	msgObj.style.left = cm_xPos + "px";
	msgObj.style.top = cm_yPos + "px";
	msgObj.style.display = "block";
	if (msgObj.focus) msgObj.focus();
	return false;
}

function hideClientMsg() {
	msgObj.style.display = "none";
	return false;
}


// For "You Said It" module
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_display(id,state){
	if (document.getElementById(id)){
		if (typeof(state)=="undefined"){state=document.getElementById(id).style.display=="block"?false:true;}
		document.getElementById(id).style.display=state?"block":"none";
	}
}


// For "Newsmaker" module
var maxNewsmaker=new Array(), activeNewsmaker=new Array();

function swapNewsmaker(id,direction){
	if (typeof(maxNewsmaker[id])=="undefined" && document.getElementById("newsmaker"+id+"."+1)){
		maxNewsmaker[id]=activeNewsmaker[id]=1;
		while (document.getElementById("newsmaker"+id+"."+(++maxNewsmaker[id]))){}
		maxNewsmaker[id]--;
	}
	if (maxNewsmaker[id]>1){
		toggle_display("newsmaker"+id+"."+activeNewsmaker[id],false);
		if (direction=="next"){
			if (document.getElementById("newsmaker"+id+"."+(activeNewsmaker[id]+1))){
				toggle_display("newsmaker"+id+"."+(++activeNewsmaker[id]),true);
			} else {
				toggle_display("newsmaker"+id+"."+(activeNewsmaker[id]=1),true);
			}
		} else if (direction=="previous"){
			if (document.getElementById("newsmaker"+id+"."+(activeNewsmaker[id]-1))){
				toggle_display("newsmaker"+id+"."+(--activeNewsmaker[id]),true);
			} else {
				toggle_display("newsmaker"+id+"."+(activeNewsmaker[id]=maxNewsmaker[id]),true);
			}
		}
		document.getElementById("newsmakerTally"+id).innerHTML=activeNewsmaker[id]+"/"+maxNewsmaker[id];
	}
}


// For any module with tabs
function tabs_handleMouseOver(id,color,instance) {
	var undefined;
	if (instance !== undefined){
		if (activeTab[instance] == id) return;
		instance = '_' + instance;
		instance2 = '_' + instance + '_';
	} else {
		instance = '';
		instance2 = '';
		if(activeTab == id) return;
	}
	if (color == "ntrl"){eval('document.images.img' + instance2 + id + '.src = tabs_on_ntrl' + instance + '[' + id + ']');}
	else {eval('document.images.img' + instance2 + id + '.src = tabs_on' + instance + '[' + id + ']');}
}

function tabs_handleMouseOut(id,instance) {
	var undefined;
	if (instance !== undefined){
		if (activeTab[instance] == id) return;
		instance = '_' + instance;
		instance2 = '_' + instance + '_';
	} else {
		instance = '';
		instance2 = '';
		if(activeTab == id) return;
	}
	eval('document.images.img' + instance2 + id + '.src = tabs_off' + instance + '[' + id + ']');
}

function tabs_handleClick(id,color,instance) {
	var undefined;
	if (instance !== undefined){
		var numTabs = eval('tabs_off_'+instance+'.length');
		if(activeTab[instance] != id) {
			for (k=1; k<numTabs; k++){
				eval('document.images.img_' + instance + '_' + k + '.src=tabs_off_' + instance + '[k]');
			}
			if (color == "ntrl") {eval('document.images.img_' + instance + '_' + id + '.src=tabs_on_ntrl_' + instance + '['+id+']');}
			else {eval('document.images.img_' + instance + '_' + id + '.src=tabs_on_' + instance + '['+id+']');}
		}
		activeTab[instance] = id;
	} else {
		activeTab = id;
	}
}

function activateTab(idx,moduleId,activeClassName) {
    if (activeTab[moduleId] != idx) {
        // turn off active tab
        eval(activeElement = document.getElementById('tab_' + activeTab[moduleId] + '_' + moduleId));
        activeElement.className = null;

        // activate the clicked tab
        activeTab[moduleId] = idx;
        eval(tabToActivate = document.getElementById('tab_' + idx + '_' + moduleId));
        tabToActivate.className = activeClassName;
    }
}

function sendGenContent(frameName,srcDiv,destDiv) {
	if (parent.document.location == document.location) {return;}
	else {parent.serveGenContent(frameName,srcDiv,destDiv);}
}

function serveGenContent(frameName,srcDiv,destDiv) {
	divCopy(srcDiv+'?'+frameName,destDiv);
}

function divCopy(srcDiv,destDiv) {
	var src = findObj(srcDiv);
	var dest = findObj(destDiv);
	if (src && dest) {dest.innerHTML = src.innerHTML;}
}

function findObj(theObj, theDoc){
	var p, i, foundObj;
	if (!theDoc) theDoc = document;
	if ((p = theObj.indexOf("?")) > 0 && parent.frames.length){
		theDoc = parent.frames[theObj.substring(p+1)].document;
		theObj = theObj.substring(0,p);
	}
	if (!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
	for (i=0; !foundObj && i < theDoc.forms.length; i++)
		foundObj = theDoc.forms[i][theObj];
	for (i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
		foundObj = findObj(theObj,theDoc.layers[i].document);
	if (!foundObj && theDoc.getElementById) foundObj = theDoc.getElementById(theObj);
	return foundObj;
}


// For Tool Tips
var x,y,xMouse,yMouse,zInterval2;
document.onmousemove = setMouseCoords;

function setMouseCoords(e) {
 if(!isLoaded)return;
	if(document.all) {
		xMouse = window.event.clientX + returnScrollDimensions(0);
		yMouse = window.event.clientY + returnScrollDimensions(1);
	} else {
		xMouse = e.pageX;
		yMouse = e.pageY;
	}
}

function returnScrollDimensions(which) {
	if (which) {
		if (document.body.scrollTop != 0) return document.body.scrollTop;
		if (document.documentElement.scrollTop != 0) return document.documentElement.scrollTop;
	} else {
		if (document.body.scrollLeft != 0) return document.body.scrollLeft;
		if (document.documentElement.scrollLeft != 0) return document.documentElement.scrollLeft;
	}
	return 0;
}

function showToolTip(divID) {showToolTip2(divID, -140,-10);}
function showToolTipRight(divID) {showToolTip2(divID, 10,-10);}
function timeOutToolTip(){zInterval2 = setTimeout("hideToolTip()",100);}

function showToolTip2(divID, dx, dy) {
	if (activeToolTip==divID) {hideToolTip();}
	else if (activeToolTip!=divID) {
		document.getElementById("toolTip").style.top = (yMouse+dy) + "px";
		document.getElementById("toolTip").style.left = (xMouse+dx) + "px";
		document.getElementById("toolTip").innerHTML = document.getElementById("toolTip_"+divID).innerHTML;
		document.getElementById("toolTip").style.display = "block";
		activeToolTip = divID;
	}
	clearInterval(zInterval2);
}

function hideToolTip() {
	document.getElementById("toolTip").style.display = "none";
	document.getElementById("toolTip").innerHTML = "";
	clearInterval(zInterval2);
	activeToolTip = "";
}


// For What's Hot module
var d = document;
var whTimer=9;
var startFrom=0;
var pause = 0;
var activeTab = 0;

function decrTimer() {
	if (pause) {
		d.getElementById("timerText").innerHTML="Paused"
		d.getElementById("playid").onmouseout = function(){d.getElementById("playid").src="http://cdn.channel.aol.com/ch_sports/info_play";};
		d.getElementById("playid").onmouseover = function(){d.getElementById("playid").src="http://cdn.channel.aol.com/ch_sports/info_play_rollover";};
		d.getElementById("pauseid").onmouseout = function(){return;};
		return;
	}
	d.getElementById("pauseid").onmouseover = function(){d.getElementById("pauseid").src="http://cdn.channel.aol.com/ch_sports/info_pause_rollover";};
	d.getElementById("pauseid").onmouseout = function(){d.getElementById("pauseid").src="http://cdn.channel.aol.com/ch_sports/info_pause";};
	d.getElementById("playid").onmouseout = function(){return;};	
	whTimer--;
	if(whTimer<=0){ 
		showWhatsHot();
		whTimer=9;
	}
	d.getElementById("timerText").innerHTML="Updates in " +whTimer+" seconds"
}

function showWhatsHot(){
	listObj=document.getElementById("whatsHot");
	for(i=0;i<listObj.childNodes.length;i++) {

		if (el[startFrom][2] == "e"){
			trendimg = "http://cdn.channel.aol.com/ch_sports/info_dash";
		} else {
			if (el[startFrom][2] == "u"){
				trendimg = "http://cdn.channel.aol.com/ch_sports/info_up_arrow";
			} else {
				trendimg = "http://cdn.channel.aol.com/ch_sports/info_down_arrow";
			}
		}
		if(listObj.childNodes[i].nodeType == 1) {
			listObj.childNodes[i].innerHTML = "";
			if (startFrom<el.length/2){
				y = listObj.childNodes[i].appendChild(document.createElement("img"));
				y.src = trendimg;
			}
			x = listObj.childNodes[i].appendChild(document.createElement("a"));
			tempURL = unescape(el[startFrom][0]);
			spot = '&_s=htsitelnk_' + i;
			if (tempURL.substring(0,3) == 'aol'){
				x.href = tempURL;
			} else {
				x.href = redirUrl + spot + '&_u=' + el[startFrom][0];
			}
			x.innerHTML = el[startFrom][1];
			startFrom++;
			if(!activeTab) {
				if(startFrom>=el.length/2)startFrom=0;
			} else {
				if(startFrom>=el.length) startFrom = el.length/2;
			}
		}
	}
}


// For dynamic lead modules
var dynLeads = new Array();
var activeObjIndex = null;
var zInterval = null;
var yInterval = null;
var autoIndex = 1;
var TRANS_SPEED = 5;
var AUTO_RESTART = 10000;
var AUTO_INTERVAL=12;

function dl_init() {
	if (!document.getElementById("dl2")) return;
	dlObj = document.getElementById("dl_container");

	for (i=0; i<dlObj.getElementsByTagName("div").length; i++) {
		dynLeads[i]  = dlObj.getElementsByTagName("div")[i];
		dynLeads[i].xid = i;
		dynLeads[i].xdirection = 0;
		dynLeads[i].xheight = dynLeads[i].getElementsByTagName("h2")[0].offsetHeight*i;
		dynLeads[i].xtop = dynLeads[i].offsetTop;
		dynLeads[i].getElementsByTagName("h2")[0].onclick = function() { dl_handleClick(this.parentNode.xid); }
	}

	dlObj.style.height = dlObj.offsetHeight+"px";
	dynLeads[0].xtop=0;
	dynLeads[0].xdirection = 1;

	for (i=0; i<dynLeads.length; i++) {
		dynLeads[i].style.position = "absolute";
		dynLeads[i].style.top = dynLeads[i].xtop+"px";
	}

	yInterval = setInterval("autoScroll()",(AUTO_INTERVAL*1000));
}

function restartAutoScroll() {
	clearInterval(yInterval);
	yInterval = setInterval("autoScroll()",(AUTO_INTERVAL*1000));
}

function autoScroll() {
	activeObjIndex = autoIndex;
	dynLeads[activeObjIndex].getElementsByTagName("span")[0].style.display = "block";
	clearInterval(zInterval);
	zInterval = setInterval(dl_animate,10);
	autoIndex++;
	if (autoIndex == dynLeads.length) autoIndex = 0;
}

function dl_handleClick(objIndex) {
	if (activeObjIndex == objIndex) return;
	clearInterval(yInterval);
	autoIndex = objIndex;
	yInterval = setTimeout("restartAutoScroll()",AUTO_RESTART);
	activeObjIndex = objIndex;
	dynLeads[activeObjIndex].getElementsByTagName("span")[0].style.display = "block";
	clearInterval(zInterval);
	zInterval = setInterval(dl_animate,10);
}

function dl_animate() {
	if (dynLeads[activeObjIndex].xdirection == 0) {
		for (i=activeObjIndex; i>0; i--) {
			y = dynLeads[i].offsetTop;
			if (y>parseInt(dynLeads[i].xheight)) {
				y-=TRANS_SPEED;
				dynLeads[i].style.top = y+"px";
			} 
		}
	} else {
		svar = activeObjIndex?activeObjIndex+1:activeObjIndex;
		if (activeObjIndex == 0) svar=1;
		for (i=svar; i<dynLeads.length; i++) {
			y=dynLeads[i].offsetTop;
			if (y<=parseInt(dynLeads[i].xtop)) {
				y+=TRANS_SPEED;
				dynLeads[i].style.top = y+"px";
			}
		}
	}
	if (dynLeads[activeObjIndex+1]) {
		svar=activeObjIndex+1;
	} else {
		svar=activeObjIndex;
	}
	if (parseInt(dynLeads[activeObjIndex].style.top) <= dynLeads[activeObjIndex].xheight && dynLeads[activeObjIndex].xdirection == 0) {
		clearInterval(zInterval);
		zInterval = null;
		for (i=activeObjIndex; i>0; i--) dynLeads[i].xdirection = 1;
	} else if (parseInt(dynLeads[svar].style.top) >= dynLeads[svar].xtop && dynLeads[svar].xdirection == 1) {
		clearInterval(zInterval);
		zInterval = null;
		for (i=svar; i<dynLeads.length; i++) {
			dynLeads[i].xdirection = 0;
			dynLeads[i].style.top = dynLeads[i].xtop+"px";
		}
	}
}


// for info pages
function toggle_image(id, src){
	if (document.getElementById(id)){document.getElementById(id).src=src;}
}


// for entertainment pages
function doAOLHeader () {
	if (!is_aol){
		if (document.getElementById("aolheader")){
			document.getElementById("aolheader").style.display="block";
			changeDivTop(navWidth);
		}
	}
	if (!document.getElementById("ad")){
		navWidth-=is_aol?144:94;
		changeDivTop(navWidth);
	} 
}
 
function changeDivTop(newTop) {
	divObj = document.getElementsByTagName("div");
	for (i=0;i<divObj.length;i++) {
		if (divObj[i].className == "subNav"){divObj[i].style.top = newTop+"px";}
	}
}

function makeImageFit(obj,maxHt,maxWd) {
	var src_height = obj.height;
	var src_width  = obj.width;
	var wdiff = src_width - maxWd;
	var hdiff = src_height - maxHt;
	var aspect = 0;
  
	if (wdiff > hdiff) {
		newWd = maxWd;   
		aspect = newWd / src_width;
		newHt = Math.round(src_height * aspect);		
	} else {
		newHt = maxHt;
		aspect = newHt / src_height;
		newWd = Math.round(src_width * aspect);
	}
  
 
	obj.height= newHt;
	obj.width= newWd;
}

function showEntGuide () {
	if (document.getElementById("ent_guide")){
		clearInterval(entInterval);
		document.getElementById("ent_guide").style.display = "block";
	}
}

function hideEntGuide () {
	if (document.getElementById("ent_guide")){
		entInterval = setTimeout("document.getElementById(\"ent_guide\").style.display=\"none\"",100);
	}
}

function openlink(url){window.open(url, '_dlplayer');}


function setSpeed(speed) {
   document.cookie = "_qbit_cs="+escape(speed)+";DOMAIN=.aol.com;PATH=/;";
}

function setOptCookie(name,value) {
   document.cookie = escape(name)+"="+escape(value)+";DOMAIN=.aol.com;PATH=/;";
}

function markTime() {
    ySpeed = new Date();
    ySpeedTime = ySpeed.getTime();
    tSpeedTime = (ySpeedTime-xSpeedTime)/1000;
    Speedkbps = Math.floor(50/tSpeedTime);
    setSpeed(Speedkbps);
    if(Speedkbps<64) {
	setOptCookie("bboptout","falseBB");
    } else {
	setOptCookie("bboptout","trueBB");
    }
}

function speedCookieCheck() {
    if (typeof setSpeedCookie != 'undefined') {
        xSpeed = new Date();
        xSpeedTime = xSpeed.getTime();
        xSpeed=document.body.appendChild(document.createElement("img"));
        xSpeed.onload=function() { markTime(); }
        xSpeed.width="1";
        xSpeed.height="1";
        xSpeed.src="http://cdn.channel.aol.com/channels/speed.jpg?z=" + Math.floor(Math.random()*1000);
    }
}

function loadEC() {
    var ecIFRAMEID = "ecIFRAME";
    var eciframe = document.getElementById(ecIFRAMEID);
    if (eciframe == null)
       return;

    /* Append referer only if we are outside the client */
    if (navigator.userAgent.toLowerCase().indexOf("aol") >= 0) {
         ecLocation = "http://" + ecHost + "/ECLogin.svc?room=" + ecRoomID + "&channelStyle=" + ecChannelURL;
    } else {
         ecReferer = document.location;
         ecLocation = "http://" + ecHost + "/ECLogin.svc?room=" + ecRoomID + "&channelStyle=" + ecChannelURL + "&referer=" + ecReferer;
    }

    var pstr = unescape(document.location.search);
    re = new RegExp("instance=([0-9]+)", "i");
    marr = pstr.match(re);
    if (marr != null) {
        eciframe.src = ecLocation +  "&" + marr[1];
    } else {
        eciframe.src = ecLocation;
    }
}

// for photo gallery module
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-pf","info_btn_2_off-pf","info_btn_3_off-pf","info_btn_4_off-pf","info_btn_5_off-pf","info_btn_6_off-pf","info_btn_7_off-pf","info_btn_8_off-pf","info_btn_9_off-pf","info_btn_10_off-pf","info_btn_11_off-pf","info_btn_12_off-pf","info_btn_prev_off-pf","info_btn_pause_off-pf","info_btn_next_off-pf")
var onImg = new Array("info_btn_1_on-pf","info_btn_2_on-pf","info_btn_3_on-pf","info_btn_4_on-pf","info_btn_5_on-pf","info_btn_6_on-pf","info_btn_7_on-pf","info_btn_8_on-pf","info_btn_9_on-pf","info_btn_10_on-pf","info_btn_11_on-pf","info_btn_12_on-pf","info_btn_prev_on-pf","info_btn_pause_on-pf","info_btn_next_on-pf")

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++;
			}
		}
		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_pf/" + 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_pf/" + onImg[12]}
		x=x-1;
		if (x<1){x=maxStory}
	}
	if (document.getElementById("titledefault") && document.getElementById("photo" + x + "title") && document.getElementById("photo" + x + "title").innerHTML!=""){document.getElementById("titledefault").innerHTML=document.getElementById("photo" + x + "title").innerHTML}
	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_pf/" + offImg[14]}
	if (playingBackward==true && document.getElementById("pic12")){document.getElementById("pic12").src = "http://cdn.channel.aol.com/ch_pf/" + 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_pf/" + 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_pf/" + onImg[buttonNumber];
				break;
			case "off":
				if (activeButton!=buttonNumber && playControlActive!=buttonNumber && storyControlActive!=buttonNumber){
					document.getElementById(buttonID).src = "http://cdn.channel.aol.com/ch_pf/" + 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_pf/" + offImg[i]}
			else if (playingBackward==true && i!=12 && document.getElementById("pic" + i)){document.getElementById("pic" + i).src = "http://cdn.channel.aol.com/ch_pf/" + offImg[i]}
			else if (playingForward==false && playingBackward==false && document.getElementById("pic" + i)){document.getElementById("pic" + i).src = "http://cdn.channel.aol.com/ch_pf/" + offImg[i]}
		}
	}
	if (document.getElementById("pic" + activeButton)){document.getElementById("pic" + activeButton).src = "http://cdn.channel.aol.com/ch_pf/" + onImg[activeButton]}
}

function photoLead_changePhotoStory(photStorNumber){
	if (photStorNumber>maxStory){photStorNumber=maxStory}
	storyControlActive=photStorNumber-1;
	x=photStorNumber;
	photoLead_makeActive(photStorNumber);
	if (document.getElementById("titledefault") && document.getElementById("photo" + photStorNumber + "title") && document.getElementById("photo" + photStorNumber + "title").innerHTML!=""){document.getElementById("titledefault").innerHTML=document.getElementById("photo" + photStorNumber + "title").innerHTML}
	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 onLoadDalaiLlama() {
    if (typeof onLoadDalaiLlamaMxid != 'undefined') {
        if ((typeof onLoadDalaiLlamaMxidType != 'undefined') && (onLoadDalaiLlamaMxidType == 'audio')) {
            DalaiLlama.OpenAudioFullMXID("mp.aol.com", onLoadDalaiLlamaMxid)
        } else {
            DalaiLlama.OpenFullMXID("mp.aol.com", onLoadDalaiLlamaMxid)
        }
	setOptCookie("bbDL"+onLoadDalaiLlamaMxid,onLoadDalaiLlamaMxid);
    }
}

function channel_init(){
    onLoadDalaiLlama();
    if (!is_aol) {interceptLinks();}
    if (activeNav) manageMainNav("nav"+activeNav,"click");
    photoLead_playPhotos();
    dl_init();
    isLoaded = 1;
    loadEC();   
    speedCookieCheck();
}

