var isLoaded = 0;
var ccob = new cob();
var divCount = '';
var entInterval;
var activeTab = new Array();
var msgObj = null;
var is_aol = navigator.userAgent.toLowerCase().indexOf("aol") != -1;
var is_mac = navigator.userAgent.indexOf('Mac') != -1;
sb_disable=1;

function channel_init(){
    onLoadDalaiLlama();
    if (!is_aol) {interceptLinks();}
    if (window.activeNav) manageMainNav("nav"+activeNav,"click");
    photoLead_playPhotos();
    dl_init();
    isLoaded = 1;
    loadEC();   
    speedCookieCheck();
//    bb_makebar();
//    if(window.sb_id) {sb_check_jaws()};
}

// 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>The page you have reached soon will be available on the new <a href=\"http://startpage.aol.com/\">AOL.com</a>. In the meantime, please use our <a href=\"http://memberselfservice.aol.com/atoz/external/index.adp\">site map</a> to check out other AOL.com content.<\/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;
	}
}

/*----------------------  top11deeplink js -----------------------*/
//Top11playlist version of the activate tab function.
function activateTab(idx,moduleId,activeClassName) {
    if (activeTab[moduleId] != idx) {
        // turn off active tab
        eval(activeElement = document.getElementById('tab_' + activeTab[moduleId] + '_' + moduleId));
                if (activeElement.className == "vidPLon")
                {
                        activeElement.className = "vidPLoff";
                }
                else
                {
                        activeElement.className = null;
                }

                // activate the clicked tab
        activeTab[moduleId] = idx;
        eval(tabToActivate = document.getElementById('tab_' + idx + '_' + moduleId));
        tabToActivate.className = activeClassName;
    }
}

//Dynamic CSS manipulation tools.
function setClassByID(objectID, newClass)
{
        var object = document.getElementById(objectID);
        object.className = newClass;
}

function setClassByObj(senderObj, newClass)
{
        senderObj.className = newClass;
}

//This function recursivelly finds a DIV in a parent element.
//It is needed because the mozilla and ie doms have different hierarchies.
//Called from hiLiteRow, a top11deeplink function.
function recurseDiv(el)
{
        if (el.nodeName == "DIV")
        {
                return el;
        }
        else if (el.hasChildNodes)
        {
                for (i = 0 ; i < el.childNodes.length; i++)
                {
                        if (el.childNodes[i].nodeName == "DIV")
                        {
                                return el.childNodes[i];
                        }
                        else if (el.childNodes[i].hasChildNodes)
                        {
                                var returnEl = recurseDiv(el.childNodes[i]);
                                if (returnEl) return returnEl;
                        }
                }
        }
        else
        {return null};
}

//A Top11DeepLink function.
function hiLiteRow(senderObj, newClass)
{
        //Set the row class.
        setClassByObj(senderObj, newClass);

        //Set the number class.
        //Get the number div element.
        var numClass = (newClass == "mouseOn")? "numPLon" : "numPL";
        setClassByObj(recurseDiv(senderObj), numClass);
}


/*---------------------- end  top11deeplink js -----------------------*/

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 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--) {
			_w = dynLeads[i].offsetTop;
			if (_w>parseInt(dynLeads[i].xheight)) {
				_w-=TRANS_SPEED;
				dynLeads[i].style.top = _w+"px";
			} 
		}
	} else {
		svar = activeObjIndex?activeObjIndex+1:activeObjIndex;
		if (activeObjIndex == 0) svar=1;
		for (i=svar; i<dynLeads.length; i++) {
			_w=dynLeads[i].offsetTop;
			if (_w<=parseInt(dynLeads[i].xtop)) {
				_w+=TRANS_SPEED;
				dynLeads[i].style.top = _w+"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);
    }
}

// gets the value of the query string
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
}

// check for the valid object
function testIsValidObject(objToTest) {
    if (objToTest == null || objToTest == undefined) {
        return false;
    }
    return true;
}



//BigBowl Menus
var bb_selected=-1,bb_selected_pm=-1,bb_selected_fm=-1,bb_selected_bm=-1,bb_selected_gn=-1,bb_selected_gnp=-1;
var bb_subindex=new Array(),bb_flyindex=new Array();
var bb_menu_timer,bb_fly_timer,bb_bmenu_timer,bb_gnmenu_timer;
var bb_menu_delay=500,bb_fly_delay=200;
var bb_cgid=-1,bb_ll=-1;
var bb_ie,bbh_m,bbh_gn,bbh_gnp,bbh_bm,bbh_bmp,bbh_mp,bbh_mf,n;
if (typeof(bb_lf) == "undefined") {
var bb_lf = new Array();
}

navigator.userAgent.toLowerCase().indexOf('msie')!=-1?bb_ie=1:bb_ie=0;

////Main setup////
function bb_makebar(){

	var s,vC,vM,c=0,p,sub;

	//Setup menu bar
	if(bbh_m=bb_o("bb_m")){
		bbh_mf=bb_o("bb_mf");
		bbh_mp=bb_o("bb_mp");
		bb_ll=bb_md.length;
		s="<ul>";
		for(var i=0;i<bb_ll;i++){
			if(bb_md[i].l==0){
				vM=bb_md[i].v.charAt(0);
				vC=bb_md[i].v.charAt(1);
				if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
					sub=0;
					s+="<li id='bb_m"+c+"'";
					if(i+1!=bb_ll&&bb_md[i+1].l==1){
						s+=" class='bb_ma'";
						bb_subindex[c]=i+1;
						sub=1;
					}
					s+="><a href='"+bb_md[i].u+"'";
					if(bb_md[i].n=="Y")s+=" target='_blank'";
					s+=" onMouseOver='bb_hoverbar("+c+","+sub+")' onMouseOut='bb_unhover()'>"+bb_md[i].t+"</a></li>";
					c++;
				}
			}
		}
		s+="</ul>";
		bbh_m.innerHTML=s;
		bb_hoverbar(bb_sel);
	}

	//Setup Global Navigation
	if(bbh_gn=bb_o("bb_gn")){
		if(window.bb_ngcg){
			bb_ng.push(bb_ngcg[0]);
			bb_cgid=bb_ng.length-1;
		}
		s="<ul>";
		c=0;
		for(i=0;i<bb_ng.length;i++){
			vM=bb_ng[i].v.charAt(0);
			vC=bb_ng[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
				s+="<li id='bb_gn"+c+"'><a href='"+bb_ng[i].u+"'";
				if(bb_ng[i].n=="Y")s+=" target='_blank'";
				s+=" onMouseOver='bb_hovergnbar("+c+")' onMouseOut='bb_ungnhover("+c+")'>"+bb_ng[i].t;
				if(bb_cgid==i){
					s+="<span id='bb_gna'>&nbsp;&nbsp;</span>";
					bb_cgid=c;
				}
				s+="</a></li>";
				c++;
			}
		}
		s+="</ul>";
		bbh_gn.innerHTML=s;
		
		//Setup branding menu pulldown
		if(bb_cgid!=-1){
			bbh_gnp=bb_o("bb_gnp");
			bb_ie?s="<iframe class='bb_iehack'></iframe><ul>":s="<ul>";
			c=0;
			for(i=0;i<bb_gncg.length;i++){
			vM=bb_gncg[i].v.charAt(0);
			vC=bb_gncg[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
					s+="<li><a href='"+bb_gncg[i].u+"'";
					if(bb_gncg[i].n=="Y")s+=" target='_blank'";
					s+=" onMouseOver='bb_gnhoversub("+c+")' onMouseOut='bb_unhover_gnmenu()'>"+bb_gncg[i].t+"</a></li>";
					c++;
				}
			}
			s+="</ul>";
			bbh_gnp.innerHTML=s;
		}
	}

	//Setup optional Channel Guide menu
	if(bbh_bm=bb_o("bb_bm")){
		bbh_bm.innerHTML="<a href='#' onMouseOver='bb_hover_bmenu()' onMouseOut='bb_unhover_bmenu()'>"
			+bb_cgt+"<span id='bb_bma'>&nbsp;&nbsp;</span></a>";
		bb_ie?s="<iframe class='bb_iehack'></iframe><ul>":s="<ul>";
		c=0;
		for(i=0;i<bb_cg.length;i++){
			vM=bb_cg[i].v.charAt(0);
			vC=bb_cg[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
				s+="<li><a href='"+bb_cg[i].u+"'";
				if(bb_cg[i].n=="Y")s+=" target='_blank'";
				s+=" onMouseOver='bb_bhoversub("+c+")' onMouseOut='bb_unhover_bmenu()'>"+bb_cg[i].t+"</a></li>";
				c++;
			}
		}
		s+="</ul>";
		bbh_bmp=bb_o("bb_bmp");
		bbh_bmp.innerHTML=s;
	}
	
	//Setup footer link bar
	if(p=bb_o("bb_fme")){
		c=0;
		bb_ll=bb_md.length;
		s="<ul>";
		for(i=0;i<bb_ll;i++){
			if(bb_md[i].l==0){
				vM=bb_md[i].v.charAt(0);
				vC=bb_md[i].v.charAt(1);
				if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
					s+="<li id='bb_fme"+c+"'><a href='"+bb_md[i].u+"'";
					if(bb_md[i].n=="Y")s+=" target='_blank'";
					s+=">"+bb_md[i].t+"</a></li>";
					c++;
				}
			}
		}
		s+="</ul>";
		p.innerHTML=s;
	}	

	//Setup footer plain old links
	if (typeof(bb_fm)=="undefined" || typeof(bb_fm)!="string"){
		//return;
	}else{
	if(p=bb_o("bb_fr")){
		s="<span class='bb_ftb'>"+bb_fm+"</span> ";
		c=0;
		for(i=0;i<bb_fg.length;i++){
			vM=bb_fg[i].v.charAt(0);
			vC=bb_fg[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
				s+="<a href='"+bb_fg[i].u+"'";
				if(bb_fg[i].n=="Y")s+=" target='_blank'";
				s+=">"+bb_fg[i].t+"</a> | ";
			}
		}
		s=s.slice(0,-3);
		p.innerHTML=s;
	}
	}
	//Setup footer links
	if(p=bb_o("bb_frfb")){
		s=document.getElementById(bb_frfb).innerHTML;
		c=0;
		for(i=0;i<bb_lf.length;i++){
			vM=bb_lf[i].v.charAt(0);
			vC=bb_lf[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
				s+="<a href='"+bb_lf[i].u+"'";
				if(bb_lf[i].n=="Y")s+=" target='_blank'";
				s+=">"+bb_lf[i].t+"</a> | ";
			}
		}
		s=s.slice(0,-3);
		p.innerHTML=s;
	}
}

function bb_makehbar(){
	var s,vC,vM,c=0,p,sub;

	//Setup menu bar
	if(bbh_m=bb_o("bb_m")){
		bbh_mf=bb_o("bb_mf");
		bbh_mp=bb_o("bb_mp");
		bb_ll=bb_md.length;
		s="<ul>";
		for(var i=0;i<bb_ll;i++){
			if(bb_md[i].l==0){
				vM=bb_md[i].v.charAt(0);
				vC=bb_md[i].v.charAt(1);
				if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
					sub=0;
					s+="<li id='bb_m"+c+"'";
					if(i+1!=bb_ll&&bb_md[i+1].l==1){
						s+=" class='bb_ma'";
						bb_subindex[c]=i+1;
						sub=1;
					}
					s+="><a href='"+bb_md[i].u+"'";
					if(bb_md[i].n=="Y")s+=" target='_blank'";
					s+=" onMouseOver='bb_hoverbar("+c+","+sub+")' onMouseOut='bb_unhover()'>"+bb_md[i].t+"</a></li>";
					c++;
				}
			}
		}
		s+="</ul>";
		bbh_m.innerHTML=s;
        bb_slc_cpg(bb_sel);   
	}

	//Setup Global Navigation
	if(bbh_gn=bb_o("bb_gn")){
		if(window.bb_ngcg){
			bb_ng.push(bb_ngcg[0]);
			bb_cgid=bb_ng.length-1;
		}
		s="<ul>";
		c=0;
		for(i=0;i<bb_ng.length;i++){
			vM=bb_ng[i].v.charAt(0);
			vC=bb_ng[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
				s+="<li id='bb_gn"+c+"'><a href='"+bb_ng[i].u+"'";
				if(bb_ng[i].n=="Y")s+=" target='_blank'";
				s+=" onMouseOver='bb_hovergnbar("+c+")' onMouseOut='bb_ungnhover("+c+")'>"+bb_ng[i].t;
				if(bb_cgid==i){
					s+="<span id='bb_gna'>&nbsp;&nbsp;</span>";
					bb_cgid=c;
				}
				s+="</a></li>";
				c++;
			}
		}
		s+="</ul>";
		bbh_gn.innerHTML=s;
		
		//Setup branding menu pulldown
		if(bb_cgid!=-1){
			bbh_gnp=bb_o("bb_gnp");
			bb_ie?s="<iframe class='bb_iehack'></iframe><ul>":s="<ul>";
			c=0;
			for(i=0;i<bb_gncg.length;i++){
			vM=bb_gncg[i].v.charAt(0);
			vC=bb_gncg[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
					s+="<li><a href='"+bb_gncg[i].u+"'";
					if(bb_gncg[i].n=="Y")s+=" target='_blank'";
					s+=" onMouseOver='bb_gnhoversub("+c+")' onMouseOut='bb_unhover_gnmenu()'>"+bb_gncg[i].t+"</a></li>";
					c++;
				}
			}
			s+="</ul>";
			bbh_gnp.innerHTML=s;
		}
	}

	//Setup optional Channel Guide menu
	if(bbh_bm=bb_o("bb_bm")){
		bbh_bm.innerHTML="<a href='#' onMouseOver='bb_hover_bmenu()' onMouseOut='bb_unhover_bmenu()'>"
			+bb_cgt+"<span id='bb_bma'>&nbsp;&nbsp;</span></a>";
		bb_ie?s="<iframe class='bb_iehack'></iframe><ul>":s="<ul>";
		c=0;
		for(i=0;i<bb_cg.length;i++){
			vM=bb_cg[i].v.charAt(0);
			vC=bb_cg[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
				s+="<li><a href='"+bb_cg[i].u+"'";
				if(bb_cg[i].n=="Y")s+=" target='_blank'";
		if(bb_cg[i].t=="Celebrities")s+=" onclick=\"s_linkType='o';s_linkName='Entertainment Guide: Celebrities';t=s_account.split(',');s_account2=(t\[0\].indexOf('aolsvc')==-1?t\[0\]:t\[1\]);s_lnk=s_co(this);s_gs(s_account2);\" ";
		if(bb_cg[i].t=="CityGuide")s+=" onclick=\"s_linkType='o';s_linkName='Entertainment Guide: CityGuide';t=s_account.split(',');s_account2=(t\[0\].indexOf('aolsvc')==-1?t\[0\]:t\[1\]);s_lnk=s_co(this);s_gs(s_account2);\" ";
		if(bb_cg[i].t=="Entertainment")s+=" onclick=\"s_linkType='o';s_linkName='Entertainment Guide: Entertainment';t=s_account.split(',');s_account2=(t\[0\].indexOf('aolsvc')==-1?t\[0\]:t\[1\]);s_lnk=s_co(this);s_gs(s_account2);\" ";
		if(bb_cg[i].t=="Games")s+=" onclick=\"s_linkType='o';s_linkName='Entertainment Guide: Games';t=s_account.split(',');s_account2=(t\[0\].indexOf('aolsvc')==-1?t\[0\]:t\[1\]);s_lnk=s_co(this);s_gs(s_account2);\" ";
		if(bb_cg[i].t=="Music")s+=" onclick=\"s_linkType='o';s_linkName='Entertainment Guide: Music';t=s_account.split(',');s_account2=(t\[0\].indexOf('aolsvc')==-1?t\[0\]:t\[1\]);s_lnk=s_co(this);s_gs(s_account2);\" ";
		if(bb_cg[i].t=="Movies")s+=" onclick=\"s_linkType='o';s_linkName='Entertainment Guide: Movies';t=s_account.split(',');s_account2=(t\[0\].indexOf('aolsvc')==-1?t\[0\]:t\[1\]);s_lnk=s_co(this);s_gs(s_account2);\" ";
		if(bb_cg[i].t=="Television")s+=" onclick=\"s_linkType='o';s_linkName='Entertainment Guide: Television';t=s_account.split(',');s_account2=(t\[0\].indexOf('aolsvc')==-1?t\[0\]:t\[1\]);s_lnk=s_co(this);s_gs(s_account2);\" ";
		s+=" onMouseOver='bb_bhoversub("+c+")' onMouseOut='bb_unhover_bmenu()'>"+bb_cg[i].t+"</a></li>";
				c++;
			}
		}
		s+="</ul>";
		bbh_bmp=bb_o("bb_bmp");
		bbh_bmp.innerHTML=s;
	}
	
}

function bb_makefbar () {
	var s,vC,vM,c=0,p,sub;

	//Setup footer link bar
	if(p=bb_o("bb_fme")){
		c=0;
		bb_ll=bb_md.length;
		s="<ul>";
		for(i=0;i<bb_ll;i++){
			if(bb_md[i].l==0){
				vM=bb_md[i].v.charAt(0);
				vC=bb_md[i].v.charAt(1);
				if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
					s+="<li id='bb_fme"+c+"'><a href='"+bb_md[i].u+"'";
					if(bb_md[i].n=="Y")s+=" target='_blank'";
					s+=">"+bb_md[i].t+"</a></li>";
					c++;
				}
			}
		}
		s+="</ul>";
		p.innerHTML=s;
	}	

	//Setup footer plain old links
	if (typeof(bb_fm)=="undefined" || typeof(bb_fm)!="string"){
		//return;
	}else{
		if(p=bb_o("bb_fr")){
		s="<span class='bb_ftb'>"+bb_fm+"</span> ";
		c=0;
		for(i=0;i<bb_fg.length;i++){
			vM=bb_fg[i].v.charAt(0);
			vC=bb_fg[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
				s+="<a href='"+bb_fg[i].u+"'";
				if(bb_fg[i].n=="Y")s+=" target='_blank'";
				s+=">"+bb_fg[i].t+"</a> | ";
			}
		}
		s=s.slice(0,-3);
		p.innerHTML=s;
	}
	}

	//Setup footer links
	if(p=bb_o("bb_frfb")){
		s="";
		c=0;
		for(i=0;i<bb_lf.length;i++){
			vM=bb_lf[i].v.charAt(0);
			vC=bb_lf[i].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
				s+="<a href='"+bb_lf[i].u+"'";
				if(bb_lf[i].n=="Y")s+=" target='_blank'";
				s+=">"+bb_lf[i].t+"</a> | ";
			}
		}
		s=s.slice(0,-3);
		d=p.innerHTML;
                s+=" | " + d;
		p.innerHTML=s;
	}
}

////Manage Global Navigation////

function bb_hovergnbar(i){
	n=bb_l(bbh_gn);
	if(bb_selected_gn!=-1)n[bb_selected_gn].className='inactive';
	n[i].className='active';
	bb_selected_gn=i;
	if(i==bb_cgid){
		clearTimeout(bb_gnmenu_timer);
		bbh_gnp.style.top=bb_bottom(bbh_gn)+"px";
		bbh_gnp.style.left=bb_left(bb_o("bb_gn"+bb_cgid))+"px";
		bbh_gnp.style.display="block";
	} else {
		bb_gnhidesub();
	}
}

function bb_ungnhover(i){
	n=bb_l(bbh_gn);
	if(bb_selected_gn!=-1)n[bb_selected_gn].className='inactive';
	bb_selected_gn=-1;
	if(i==bb_cgid){
		bb_gnmenu_timer=setTimeout("bb_gnhidesub()",bb_menu_delay);
	}
}

function bb_gnhidesub(){
		bbh_gnp.style.display="none";
}

function bb_gnhoversub(i){
	clearTimeout(bb_gnmenu_timer);
	n=bb_l(bbh_gnp);
	if(bb_selected_gnp!=-1)n[bb_selected_gnp].className='inactive';
	n[i].className='active';
	bb_selected_gnp=i;
}

function bb_unhover_gnmenu(){
	n=bb_l(bbh_gnp);
	if(bb_selected_gnp!=-1)n[bb_selected_gnp].className='inactive';
	bb_selected_pm=-1;
	bb_gnmenu_timer=setTimeout("bb_gnhidesub()",bb_menu_delay);
}

////Manage Channel Guide pull-down menu////

function bb_hover_bmenu(){ 
	clearTimeout(bb_bmenu_timer);
	n=bb_l(bbh_bmp);
	if(bb_selected_bm!=-1)n[bb_selected_bm].className='inactive';
	bb_selected_pm=-1;
	bbh_bmp.style.top=bb_bottom(bbh_bm)+"px";
	bbh_bmp.style.left=bb_left(bbh_bm)+"px";
	bbh_bmp.style.display="block";
}

function bb_bhoversub(i){
	clearTimeout(bb_bmenu_timer);
	n=bb_l(bbh_bmp);
	if(bb_selected_bm!=-1)n[bb_selected_bm].className='inactive';
	n[i].className='active';
	bb_selected_bm=i;
}

function bb_unhover_bmenu(){
	bb_bmenu_timer=setTimeout("bb_hidebsub()",bb_menu_delay);
}

function bb_hidebsub(){
	bbh_bmp.style.display="none";
}

////Manage menu bar////

function bb_hoverbar(i,sub){
	clearTimeout(bb_menu_timer);
	n=bb_l(bbh_m);
	var s="";
	if(bb_selected!=-1){
		if(n[bb_selected].className.indexOf("active")>-1){
			if(n[bb_selected].className.indexOf("bb_ma")>-1) s="bb_ma ";
			 n[bb_selected].className=s+((bb_selected == bb_sel)? 'bb_sel':'inactive');
		}
	}
	s="";
	if(n[i].className.indexOf("bb_ma")>-1) s="bb_maa ";
	n[i].className=s+'active';
	bb_selected=i;
	sub?bb_makesub(i):bb_hidesub();
}

function bb_unhover(){
	bb_menu_timer=setTimeout("bb_hidesub()",bb_menu_delay);
}

function bb_makesub(i){
	bb_hidefly();
	bb_selected_pm=-1;
	var c=0,x=bb_subindex[i],s,vC,vM,fly;
	bb_ie?s="<iframe class='bb_iehack'></iframe><ul>":s="<ul>";
	while (x<bb_ll){
	
		if(bb_md[x].l!=2){ //If item is in flyout then skip
			vM=bb_md[x].v.charAt(0);
			vC=bb_md[x].v.charAt(1);
			if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
				fly=0;
				if(x+1!=bb_ll&&bb_md[x+1].l==2)fly=1;
				s+="<li><a href='"+bb_md[x].u+"'";
				if(bb_md[x].n=="Y")s+=" target='_blank'";
				s+=" onMouseOver='bb_hoversub("+c+","+fly+")' onMouseOut='bb_unhover()'>";
				if(fly){
					s+="<span id='bb_mpa'>&#9658</span>";
					bb_flyindex[c]=x+1;
				}
				s+=bb_md[x].t+"</a></li>";
				c++;
			}
		}
		x++;
		if(x==bb_ll||bb_md[x].l==0)break;
	}
	s+="</ul>";

	bbh_mp.innerHTML=s;
	bbh_mp.style.top=bb_bottom(bbh_m)+"px";
	bbh_mp.style.left=bb_left(bb_o("bb_m"+i))+"px";
	bbh_mp.style.display="block";
}

function bb_hoversub(i,fly){
	clearTimeout(bb_menu_timer);
	n=bb_l(bbh_mp);
	if(bb_selected_pm!=-1)n[bb_selected_pm].className='inactive';
	bb_selected_pm=i;
	fly?bb_fly_timer=setTimeout("bb_makefly(bb_selected_pm)",bb_fly_delay):bb_hidefly();
	n[i].className='active';
}

function bb_hidesub(){
	bbh_mp.style.display="none";
	bb_hidefly();
}

////Manage Flyout menus////

function bb_makefly(i){
	var x=bb_flyindex[i],c=0,vC,vM,s;
	bb_ie?s="<iframe class='bb_iehack'></iframe><ul>":s="<ul>";
	while(x<bb_ll){
		vM=bb_md[x].v.charAt(0);
		vC=bb_md[x].v.charAt(1);
		if((vC==2||vC==bb_isC)&&(vM==2||vM==bb_isM)){
			s+="<li><a href='"+bb_md[x].u+"'";
			if(bb_md[x].n=="Y")s+=" target='_blank'";
			s+=" onMouseOver='bb_hoverfly("+c+")' onMouseOut='bb_unhover()'>"+bb_md[x].t+"</a></li>";
			c++;
		}
		x++;
		if(x==bb_ll||bb_md[x].l!=2)break;
	}
	s+="</ul>";
	bbh_mf.innerHTML=s;
	//If flyout won't fit then go left
	var ow=bbh_mp.offsetWidth;
	bb_left(bbh_mp)+ow+ow>728?bbh_mf.style.left=bb_left(bbh_mp)-ow+"px":bbh_mf.style.left=bb_left(bbh_mp)+ow+"px";
	bbh_mf.style.top=bb_l(bbh_mp)[i].offsetTop+bb_bottom(bbh_m)-1+"px";
	bbh_mf.style.display="block";
}

function bb_hoverfly(i){
	clearTimeout(bb_menu_timer);
	n=bb_l(bbh_mf);
	if(bb_selected_fm!=-1)n[bb_selected_fm].className="inactive";
	n[i].className='active';
	bb_selected_fm=i;
}

function bb_hidefly(){
	clearTimeout(bb_fly_timer);
	bbh_mf.style.display="none";
}

////Helper Functions////

function bb_bottom(o){
	var y=o.offsetHeight;
    while(o.offsetParent){
        y+=o.offsetTop;
        o=o.offsetParent;
    }
    y+=o.offsetTop;
    return y;
}

function bb_left(o){
	var x=0;
	while(o.offsetParent){
		x+=o.offsetLeft;
		o=o.offsetParent;
	}
//	x+=o.offsetLeft;	
	return x;
}

function bb_o(o){return document.getElementById(o);}

function bb_l(o){return o.getElementsByTagName("li");}

function bb_slc_cpg(idx) {
  n=bb_l(bbh_m);
  s="";
  if(idx>-1) {
    if(n[idx].className.indexOf("bb_ma")>-1) s="bb_ma ";
    n[idx].className=s+'bb_sel';    
  }
}

/*new ticker functions*/
function tickerInit(ticker){
       ticker.start();
}

function Ticker(name, id, shiftBy, interval){
  this.name     = name;
  this.id       = id;
  this.shiftBy  = shiftBy ? shiftBy : 1;
  this.interval = interval ? interval : 100;
  this.runId	= null;
  this.div = document.getElementById(id);

  var node = this.div.firstChild;
  var next;

  while (node)  {
    next = node.nextSibling;
    if (node.nodeType == 3)
      this.div.removeChild(node);
    node = next;
  }
  this.left = 436;
  this.shiftLeftAt = this.div.firstChild.offsetWidth;
  this.div.style.height	= this.div.firstChild.offsetHeight;
  this.div.style.width = 2 * screen.availWidth;
  this.div.style.visibility = 'visible';
}

function startTicker(){
  this.stop();
  
  this.left -= this.shiftBy;

  if (this.left <= -this.shiftLeftAt)
  {
    this.left = 436;
    this.div.appendChild(this.div.firstChild);
  
    this.shiftLeftAt = this.div.firstChild.offsetWidth;
  }

  this.div.style.left = (this.left + 'px');

  this.runId = setTimeout(this.name + '.start()', this.interval);
}

function stopTicker(){
  if (this.runId)
    clearTimeout(this.runId);
    
  this.runId = null;
}

function changeTickerInterval(newinterval){

  if (typeof(newinterval) == 'string')
    newinterval =  parseInt('0' + newinterval, 10); 
	
  if (typeof(newinterval) == 'number' && newinterval > 0)
    this.interval = newinterval;
    
    this.stop();
    this.start();
}

Ticker.prototype.start = startTicker;
Ticker.prototype.stop = stopTicker;
Ticker.prototype.changeInterval = changeTickerInterval;

function ctaPopup(ctaUrl)
{
	if (ctaUrl) {
		window.open (ctaUrl,'CTA','scrollbars=no,location=no,directories=no,height=265,width=275,menubar=no,resizable=no,titlebar=no');
	} else {
		window.open ("",'CTA','scrollbars=no,location=no,directories=no,height=265,width=275,menubar=no,resizable=no,titlebar=no');
	}
}

function ctaPopup2(ctaUrl)
{
	if (!ctaUrl) {
		ctaUrl = "";
	}
	window.open (ctaUrl,'CTA','scrollbars=no,location=no,directories=no,height=265,width=275,menubar=no,resizable=no,titlebar=no');
}


/*Omniture Custom Link Tracking Script For Info Themed List Modules*/
function doNMClick(oLink){

/*the value of s_linkTrackVars should be set to include the variables that need to related to the link. The values of s_channel and s_prop19 will be gathered from the underlying page. s_prop19 contains the value of s_pageName from the underlying page. */
      s_linkTrackVars="s_channel,s_prop16,s_prop17,s_prop18,s_prop19,s_prop20";

//s_linkType is the same for all links, type "o" refers to Custom Links
      s_linkType='o';

//set Link Name to equal the innerHTML from the Link Object
     
		  s_linkName=oLink.innerHTML;

/* back up the original values in the s_props on the page */ 
var s_prop16bu=s_prop16;
var s_prop17bu=s_prop17;
var s_prop18bu=s_prop18;
var s_prop19bu=s_prop19;
var s_prop20bu=s_prop20;

//set the various s_props
    s_prop16=oLink.mt;
    s_prop17= (window['s_channel']==undefined||window['s_channel']=="")?"unavailable":s_channel;
    s_prop18=(window['s_pageName']==undefined||window['s_pageName']=="")?document.title:s_pageName;
    s_prop19=document.URL
    s_prop20=oLink.href;
//these functions are called for every link
     if (window['s_account'] != undefined){
      	s_lnk=s_co(oLink);
s_gs('aolnwmodule');
//s_gs('aolnwmoduledev');
     }
/* replace the original values in the s_props on the page */ 
s_prop16=s_prop16bu;
s_prop17=s_prop17bu;
s_prop18=s_prop18bu;
s_prop19=s_prop19bu;
s_prop20=s_prop20bu;

}

/*Omniture Custom Link Tracking Script For Info Themed List Modules*/
function doNMClickimg(oLink,image){

/*the value of s_linkTrackVars should be set to include the variables that need to related to the link. The values of s_channel and s_prop19 will be gathered from the underlying page. s_prop19 contains the value of s_pageName from the underlying page. */
      s_linkTrackVars="s_channel,s_prop16,s_prop17,s_prop18,s_prop19,s_prop20";

//s_linkType is the same for all links, type "o" refers to Custom Links
      s_linkType='o';

//set Link Name to equal the innerHTML from the Link Object
     
		  s_linkName=image;
	      
/* back up the original values in the s_props on the page */ 
var s_prop16bu=s_prop16;
var s_prop17bu=s_prop17;
var s_prop18bu=s_prop18;
var s_prop19bu=s_prop19;
var s_prop20bu=s_prop20;

//set the various s_props
    s_prop16=oLink.mt;
    s_prop17= (window['s_channel']==undefined||window['s_channel']=="")?"unavailable":s_channel;
    s_prop18=(window['s_pageName']==undefined||window['s_pageName']=="")?document.title:s_pageName;
    s_prop19=document.URL
    s_prop20=oLink.href;
//these functions are called for every link
     if (window['s_account'] != undefined){
      	s_lnk=s_co(oLink);
s_gs('aolnwmodule');
//s_gs('aolnwmoduledev');
     }
/* replace the original values in the s_props on the page */ 
s_prop16=s_prop16bu;
s_prop17=s_prop17bu;
s_prop18=s_prop18bu;
s_prop19=s_prop19bu;
s_prop20=s_prop20bu;

}

// STaF Functions for Email this and IM this Functionalities


var IM_global_title;
var IM_global_url;
var IM_default_text_IE = "Your%20friend%20wants%20you%20to%20check%20this%20out:";
var IM_default_text_OT = "Your friend wants you to check this out:";

// To check AIM install in the local machine or not

function canRunAIM() {
    var agt = navigator.userAgent.toLowerCase();
    var isIE =  (agt.indexOf("msie") != -1);
    if (!isIE) 
       return true;

    var a = document.anchors;
    for (var i=0;i<a.length;i++) {
        if (a[i].name=="aimnotfound") {
            return false;
        }
    }
    return true;
}

// To check AOL Client install in the local machine or not

function canRunAOLClient() {
    var agt = navigator.userAgent.toLowerCase();
    var isIE =  (agt.indexOf("msie") != -1);
    if (!isIE) 
        return true;

    var a = document.anchors;
    for (var i=0;i<a.length;i++) {
        if (a[i].name=="aolclientnotfound") {
            return false;
        }
    }
    return true;
}

// To send IM through AOL Client Messenger

function sendAOLCLNT() {
 
 var title = IM_global_title;
 var url   = IM_global_url;

 var uAgt	=	navigator.userAgent.toLowerCase();
 var isAOL	=	uAgt.indexOf(" aol ")	!= -1;
 var isIE =  uAgt.indexOf("msie") != -1;
 
 try {

  if (!isAOL) {
 	 if (!isIE) {
        document.location="aol://9293::"+ IM_default_text_OT + "<br><a href='" + url + "'>" + title + "</a>";
	 } else {
	   document.location="aol://9293::"+ IM_default_text_IE +"%3cbr%3e%3ca href='" + url + "'%3e" + title + "%3c%2fa%3e";
     }
  } else {
     document.location='aol://9293::' + IM_default_text_OT +'<br><a href="' + url + '">' + title + '</a>'
  }

 } catch (e) {
    AIMExpress.start();
 }
}

// To send IM through AIM

function sendAIM() {
 
 var title = IM_global_title;
 var url   = IM_global_url;

 var title = title.replace(/ /g, "+");
 var uAgt	=	navigator.userAgent.toLowerCase();
 var isIE	=	uAgt.indexOf(" msie ")	!= -1;
 var isAOLBrowser	=	uAgt.indexOf(" america online browser ") != -1; 
 if (!isIE) {
    var message = IM_default_text_OT + '<br><a href="' + escape(url) + '">' + title + '</a>';
 } else if(isAOLBrowser) {
    var message = IM_default_text_OT + '<br><a href="' + escape(url) + '">' + title + '</a>';
 } else {
    var message = IM_default_text_IE + "%3cbr%3e%3ca+href=%22" + escape(url) + "%22%3e" + title + "%3c%2fa%3e";
 }
	message = escape(message);  
 
 try {
  document.location = 'aim:GoIm?message=' + message;
 } catch (e) {
//	sendAOLCLNT();
  AIMExpress.start();
 }
}

// If user is not using AOL Client then 
// send IM thro AIM if exists else if AOLClient exists then 
// send IM thro AOLClient else launch AIM Express and send IM

// If user in using the AOL Client then send IM thro AOL Client Instant Messenger


function sendIM(title, url) {

 if(title == '') {
	title = 'Click here to checkout';
 }

 IM_global_title = title;
 IM_global_url = url;

 var uAgt	=	navigator.userAgent.toLowerCase();
 var isAOL	=	uAgt.indexOf(" aol ")	!= -1;
 var isIE	=	uAgt.indexOf(" msie ")	!= -1;
 if (!isAOL) {
   if (!isIE) {
      sendAIM ();
   } else {
	  if (!canRunAIM()) {
//	     if (!canRunAOLClient()) {
		    AIMExpress.start();
//	     } else {
//          sendAOLCLNT ();
//	     }
      } else {
         sendAIM ();
      }
   }
 } else {
       sendAOLCLNT ();
 }

}

// To launch the STAF User Console

function openstaf(title, url, channel) {
   window.open("http://sendtoafriend.aol.com?type=disp&channelurl="+url+"&title="+title+"&channel="+channel+"&url="+url+"",null,"height=420,width=296,statusbar=0,toolbar=no,menubar=no,location=no")
}

function p(j){return document.getElementById(j)}
function ob(j){return document.getElementById(j)}

function cob() {
    var cache = new Array();
	
    // methods
    this.add     = function add(key,data) {cache[key] = data}
    this.getData = function getData(key) {return cache[key]}
    this.getKeys = function getKeys() {
        var keys = new Array();
		  var ix = 0;
        for (var i in 	cache) {
            keys[ix] = i;
		    ix++;
        }
        return keys;
    }
    this.hvDat = function hvDat(key) {
	    if (cache[key] || cache[key] == 0){return 1}
 	    return 0;
    }
}

/**
 * For tabbed module v2
 */
function tbmd_set(mod,t) {
    
    // get all the li tags from the parent ul 
    lis = ob('tbsid' + mod).getElementsByTagName('UL').item(0).getElementsByTagName('LI');
	  
    // if data key is in the cache object then use it to turn off tab
    key = 'curidx' + mod;
    if (ccob.hvDat(key)) {
        aObj = lis.item(ccob.getData(key)).getElementsByTagName('A').item(0);
        aObj.className = '';
	aObj.style.display = 'block';
    }
	 
    // turn on clicked tab current tab if 
    if (lis.length >= t) {
        aObj = lis.item(t).getElementsByTagName('A').item(0);
        aObj.className = 'selected';
        aObj.style.display = 'block';
        ccob.add(key,t);
    }
}
function getData(tbmid,mod,t) {
     
    // if data for tab is not it cache the get item
    key = tbmid + '_' + t;
    tbd = '';
	  
	if (ccob.hvDat(key)) {
	    tbd = ccob.getData(key);

	    tbmd_set(tbmid,t);

            // get content div object
            modObj = ob('cntd' + tbmid);

	    modObj.innerHTML = tbd;
	} else {
            // get iframe div
            tbfObj = ob('tbf' + tbmid);
            
            // store iframe src url
            tbfUrl = '/mod.adp?_miid=' + mod + '&_tbmid=' + tbmid + '&_mtb=' + t; 

            // append current query params, they may be needed by module being output via mod.adp
            tbfQry = document.location.search;
            if(tbfQry) {tbfUrl += '&' + tbfQry.substring(1)}

            // append current url and the idx of tab clicked, some modules will use this for a redir
            defTab = "_deftb" + tbmid;
            tbfTmp = location.href; 

            // rebuild params without "_deftab{instanceid}"
            if(tbfTmp.indexOf(defTab) > 1) {
                aTmp = new Array();
                aQps = tbfQry.substring(1,tbfQry.length).split('&');
                for (i=0;i < aQps.length;i++) {
                    if (aQps[i].indexOf(defTab) == -1) {
                       aTmp.push(aQps[i]);
                    } 
                }
                tbfTmp = tbfTmp.substring(0,tbfTmp.indexOf('?') + 1) + aTmp.join('&');
            }
            // append the default tab with the idx of the tab clicked
            if(tbfTmp.indexOf('?') == -1) {tbfTmp += '?'} else {tbfTmp += '&'}
            tbfUrl += '&_tbdref=' + encodeURIComponent(tbfTmp + defTab + '=' + (t + 1));
            
            // stuff iframe div then set update src
            tbfHtm = '<iframe class=\"tbf\" id=\"tbdframe\" src=\"\"></iframe>';
            tbfObj.innerHTML = tbfHtm;
            tbfObj.getElementsByTagName('iframe').item(0).src = tbfUrl;
    }
    return false;
}
function fillFromHttp(req,a) {
    // confirm data recieved successfully
	tbd = '';
    if(req) {
        key = a.key;
	tbd = req
        ccob.add(key,tbd)
    } else {
        tbd = '0';
    }
	  
    // flip tabs
    tbmd_set(a.mod,a.t);
	 
    // fillDiv 
    ob('cntd' + a.mod).innerHTML = tbd;
}

function toggleArticleDrawer(obj,id) {
	var pObj = document.getElementById(id);
	if (obj.className == "off") {
		obj.className = "on";
		if(pObj.className.match("wrap")) {
			pObj.className = "artDrawer on wrap";
		} else {
			pObj.className = "artDrawer on";
		}
	}
	else {
		obj.className = "off";
		if(pObj.className.match("wrap")) {
			pObj.className = "artDrawer off wrap";
		} else {
			pObj.className = "artDrawer off";
		}
	}
}

function toggleClassName(id,stateOne,stateTwo) {
	var obj = document.getElementById(id);
	if (obj.className == stateOne) {
		obj.className = stateTwo;
	} else {
		obj.className = stateOne;
	}
}

function o(j){return document.getElementById(j).style}
var nm_a,nm_b,nm_r,nm_s,nm_f=11;
var nm_cur=new Array();

function nm_init(mod){
    var nm_max=1,f;
    nm_r=.5/20*1000;
	nm_s=10/20;
	nm_cur[mod]=1;
	while(p(mod+"."+nm_max)){nm_max++;}
	nm_max--;
	p(mod+".cou").innerHTML="1/"+nm_max;
	o(mod+".nav").visibility="visible";
	f=function nm_pre(){
		if(nm_f>=10){
			var n=nm_cur[mod]-1;
			if(!n)n=nm_max;
			p(mod+"."+n).innerHTML=p(mod+"."+n).innerHTML.replace(/AOL:/i,"");
			cf(mod+"."+nm_cur[mod],mod+"."+n);
			nm_cur[mod]=n;
			p(mod+".cou").innerHTML=n+"/"+nm_max;
		}
                return false; 
	}
	p(mod+".pre").onclick=f;
	f=function nm_nex(){
		if(nm_f>=10){
			var n=nm_cur[mod]+1;
			if(n>nm_max)n=1;
			p(mod+"."+n).innerHTML=p(mod+"."+n).innerHTML.replace(/AOL:/i,"");
			cf(mod+"."+nm_cur[mod],mod+"."+n);
			nm_cur[mod]=n;
			p(mod+".cou").innerHTML=n+"/"+nm_max;
		}
		return false;
     }
     p(mod+".nex").onclick=f;
}
function cf(c,d){
    nm_a=o(c);nm_b=o(d);
    nm_b.display="block";
    nm_f=0;
    df();
}
function df(){
    nm_a.opacity=((10-nm_f)/10);nm_a.filter="alpha(opacity:"+(10-nm_f)*10+")";
    nm_b.opacity=(nm_f/10);nm_b.filter="alpha(opacity:"+nm_f*10+")";
    nm_f+=nm_s;
    if(nm_f<10)setTimeout("df()",nm_r);
        else nm_a.display="none";
}

// Modification for Omniture tracking in DL
function sendLinkEvent()
{
	ns=s_account;  
	s_linkType="o"; 
	s_lnk=true;
	void(s_gs(ns));
}
// End Omniture tracking modifications
