var is_aol = navigator.userAgent.toLowerCase().indexOf("aol") != -1;
var is_mac = navigator.userAgent.indexOf('Mac') != -1;
var is_IE = navigator.userAgent.indexOf('MSIE') != -1;

function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) {objColl = objContElm.all;}
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) {continue;}
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) {c++;}
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr[arr.length] = objColl[i];
          //arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

// Start Channel 
function channel_init(){
}

// Header2.0
function p_o(o){return document.getElementById(o);}

function ai_posX(obj){
 var left=0;
 if(obj.offsetParent){
  while(obj.offsetParent){
   left+=obj.offsetLeft;
   obj=obj.offsetParent;
  }
 }else if(obj.x) {left+=obj.x;}
 return left;
}
function ai_posY(obj){
 var top=0;
 if(obj.offsetParent){
  while(obj.offsetParent){
   top+=obj.offsetTop;
   obj=obj.offsetParent;
  }
 } else if(obj.x) {top+=obj.y;}
 return top;
}

/*function posMore(e,oDivName){
    if ((oDivName === undefined) || (oDivName.length <= 0)) {
        oDivName = 'smore';
    }
    var oDiv=p_o(oDivName);
    var oLnk=p_o(oDivName+'a');

    posY = findMousePos(e);
    oDiv.style.left=(ai_posX(oLnk)+15)+'px';
    oDiv.style.top=(posY+oLnk.offsetHeight/2)+'px';
}*/

function togMore(e,state,oDivName){
 if ((oDivName === undefined) || (oDivName.length <= 0)) {
    oDivName = 'smore';
 }
 var oDiv=p_o(oDivName);
 if(state=='show'){
  //posMore(e,oDivName);
  oDiv.style.zIndex=99999999;
  oDiv.style.display='block';
 } else {
  oDiv.style.display='none';
 }
 return false;
}


// Begin : Headers 2 code
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
};

function srchSub(ref){
  var frm=p_o("search");
  var queryval = frm.topquery.value.trim();
  queryval = queryval.replace( /\+/, " ");
  newurl = ref.href + queryval;
  window.location = newurl;
  return false;
}

function srchSub2() {
    var frm=p_o("search");
    var queryval = frm.topquery.value.trim();
    queryval = queryval.replace( /\+/, " ");
    var newurl = frm.action + queryval;
    if (frm.target == '_blank') {
        window.open(newurl, '_blank', '');
    } else {
        window.location = newurl;
    }
    return false;
}

function srchSub3(ref){
  var frm=p_o("searchFt");
  var queryval = frm.botquery.value.trim();
  queryval = queryval.replace( /\+/, " ");
  newurl = ref.href + queryval;
  window.location = newurl;
  return false;
}

function srchSub4(){
  var frm=p_o("searchFt");
  var queryval = frm.botquery.value.trim();
  queryval = queryval.replace( /\+/, " ");
  var newurl = frm.action + queryval;
  if (frm.target == '_blank') {
      window.open(newurl, '_blank', '');
  } else {
      window.location = newurl;
  }
  return false;
}

function eventIsEnterKey(event) {
    if (event && event.which == 13 || window.event && window.event.keyCode == 13 || event && event.which == 3 || window.event && window.event.keyCode == 3) {
        return true;
    }
    return false;
}

function submitHeaderSearch(event) {
    if (event == "onclick" || eventIsEnterKey(event)) {
        return srchSub2();        
    } else {
        return true;
    }
}

function submitFooterSearch(event) {
    if (event == "onclick" || eventIsEnterKey(event)) {
        return srchSub4();        
    } else {
        return true;
    }
}


function searchTarget(url, newWindow, newTarget) {
    // Set the target for the form
    document.bb_topform.action = url;
    if (newWindow) {
        document.bb_topform.target = '_blank';
    } else {
        document.bb_topform.target = '';
    }

    // Update the tabs classes to allow highlighting of the selected
    var arrElements = getElementsByClassName ('searchCatBg', 'li');
    for (var i=0; i<arrElements.length; i++) {
        arrElements[i].className = '';
    }
    document.getElementById(newTarget).className = 'searchCatBg';
    if(document.bb_topform.query.value!=="") {
      submitHeaderSearch('onclick');
    }
    return false;
}

function searchTargetFt(url, newWindow, newTarget) {
    // Set the target for the form
    document.bb_botform.action = url;
    if (newWindow) {
        document.bb_botform.target = '_blank';
    } else {
        document.bb_botform.target = '';
    }

    // Update the tabs classes to allow highlighting of the selected
    var arrElements = getElementsByClassName ('searchCatBgFt', 'li');
    for (var i=0; i<arrElements.length; i++) {
        arrElements[i].className = '';
    }
    document.getElementById(newTarget).className = 'searchCatBgFt';
    if(document.bb_botform.query.value!=="") {
      submitFooterSearch('onclick');
    }
    return false;
}



//Prevent IE flickr
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

//Cross Promo
var d=document; var w=window;var docHg;
var range=400;
var cod_arr=new Array();
var arrLen = 0;
var modSpan = 6;
var currId = 0;
var opt = {
    ae:function(o,et,fn){if(o.addEventListener)o.addEventListener(et,fn,false);else if(o.attachEvent)o.attachEvent("on"+et,fn);},
    gt:function(t,o){o=o?o:document;return o.getElementsByTagName(t)},
    gc:function(c,t,s,o){var r=new Array();var os=opt.gt(t,o);for(var i=0,j=0,l=os.length;i<l;i++){var sc = s + os[i].className + s;if(sc.indexOf(s+c+s)!=-1){r[j] = os[i];j++;}}return r;},
        nview:function(obj,i) {
                if (obj.loaded==null) {
                    obj.loaded=0;
                }
                if (obj.loaded==0) {

                    if(document.all) {
                        var relTop=obj.offsetParent.offsetTop-(w.scrollY||d.documentElement.scrollTop);
                    } else {
                        var relTop=obj.offsetTop-(w.scrollY||d.documentElement.scrollTop);
                    }

                    if((relTop-docHg-20)<range) {
                      var codUrl=opt.gt('a',obj)[0].href;
                      opt.xhr(codUrl,obj,i);
                    }
                }
        },
        doCod:function(){
                var l=cod_arr.length;
                for (var i=0;i<l;i++) {
                        opt.nview(cod_arr[i],i);
                }
        },
        xhr:function(u,obj,i){
                obj.loaded=1;
                var f,r,m='GET';
                f=function(){if(r.readyState>3)opt.update(obj,r,i);}
                r= window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
                r.onreadystatechange=f;
                r.open(m,u,1);
                r.setRequestHeader('content-type','text/xml');
                r.send('');
        },
        update:function(obj,r,i) {
                if(r.status==200){
                        obj.innerHTML=r.responseText;
                } else {obj.loaded=0;}
        },
        init:function() {
                        cod_arr=opt.gc('cod','div','',document);
                        docHg=w.innerHeight||d.documentElement.offsetHeight;
                        opt.doCod();
                        opt.ae(window,'scroll',opt.doCod);
        },
        res:function(){
                docHg=w.innerHeight||d.documentElement.offsetHeight;
                opt.doCod();
        }

}
opt.ae(window,'resize',opt.res);
opt.ae(window,'load',opt.init);

function countCartridges() {
   var cartCount = 0;
   end = false;
   do {
      if(document.getElementById('cart'+cartCount)) {
         cartCount++;
      } else {
         end = true;
      }
   } while (end == false)
   arrLen = cartCount;
}

function showCartridges( startId ) {
  if(arrLen == 0) {
    countCartridges(); 
  }
  var i,j;
  for (i=0,j=startId; i < modSpan; i++,j++) {
     var strCart = j%arrLen;
     document.getElementById('cartridge'+i).innerHTML = document.getElementById('cart'+strCart).innerHTML;
  }
}

function isModFetched (modId) {
  if(document.getElementById('cart'+modId).innerHTML.length>0) {
      return true;
  } else {
      return false;
  }
}

function nextCartridge () {
  if(arrLen == 0) {
     countCartridges(); 
  }
  currId = currId + 1;
  if ( !isModFetched( (currId+modSpan)%arrLen ) ) {
      fetchModule((currId+modSpan)%arrLen);
  }
  showCartridges(currId);
}

function prevCartridge () {
  if(arrLen == 0) {
    countCartridges(); 
  }  
  if(currId!=0) {
      currId = currId - 1
  } else {
      currId=arrLen-1;
  }

  if ( !isModFetched( (currId+modSpan)%arrLen ) ) {
      fetchModule((currId+modSpan)%arrLen);
  }
  showCartridges(currId);
}
// Crosspromo end

// Cards on table
var cott = {
    timeout: 3750,
    maxLink: 0,
    init: function() {
        var topLink = document.getElementById("toplink");
        var links = topLink.getElementsByTagName("A");
        cott.maxLink = links.length;
        if (links.length == 0) { return; }
        for(var i=0;i<links.length;i++) {
            links[i].style.backgroundColor = '#fff';
            links[i].style.zoom = 1;
            if (i>0) { links[i].style.display = 'none'; }
        }
        setTimeout("cott.rotateLink(2)", cott.timeout); 
    },
    fadeTo: function(obj, lvl) {  
        obj.style.filter = 'alpha(opacity=' + lvl*10 + ')';
        obj.style.opacity = lvl/10;
    },
    rotateLink: function (linkNo) {
        cott.displayNextLink(linkNo);
        var nextLink = linkNo + 1;
        if (nextLink > cott.maxLink) {
            nextLink = 1;
        }
        var t = setTimeout("cott.rotateLink(" + nextLink + ")", cott.timeout);
    },
    displayNextLink: function(linkNo) {
        var lastLink = linkNo-1;
        if (lastLink == 0) {
            lastLink = cott.maxLink;
        }
        cott.fade("cottLink"+lastLink, "cottLink"+linkNo, -9.9);
    },
    fade: function(from, to, stage) {
        if (!document.getElementById(from)) { return; }
        fobj = document.getElementById(from);
        if (!document.getElementById(to)) { return; }
        tobj = document.getElementById(to);
        if (stage < 0) {
            cott.fadeTo(fobj, Math.abs(stage));
        } else if (stage == 10) {
            cott.fadeTo(tobj, 9.9);
        } else if (stage == 0) {
            fobj.style.display = 'none';
            cott.fadeTo(tobj, 1);
            tobj.style.display = 'inline';
        } else {
            cott.fadeTo(tobj, stage);
        }
        if (stage != 10) { 
            var b = setTimeout("cott.fade('" + from + "', '" + to + "', " + parseInt(stage+1) + ")", 40);
        }
    }
};

function buildCottImg(num) {
   var cPar = document.getElementById('card_' + num);
   var cImg = document.getElementById('image_' + num);
   var cPhoto = document.getElementById('photo_' + num);

   var newImg = new Image();
  
   if(navigator.userAgent.indexOf('MSIE') != -1) {
        newImg.setAttribute('src', cImg.href);
        newImg.setAttribute('alt', cImg.firstChild.nodeValue);
        cottDelay(100);
   } else {
     try
     {
         newImg.setAttribute('src', cImg);
         newImg.setAttribute('alt', cImg.innerHTML);
         cPhoto.appendChild(newImg);
     }
     catch (e)
     {
         //create html string for new input element
         var sHTML = "<a href=\"" + cPhoto + "\" target=\"_blank\"><img alt=\"" + cImg.innerHTML + "\" src=\"" + cImg + "\"></a>";
          cPhoto.innerHTML = sHTML;
     }
  }
 
   if (cPhoto != null) {
        try
        {
            cPhoto.appendChild(newImg);       
        }
        catch (e){}         
        cPhoto.removeAttribute("id");
        cImg.parentNode.removeChild(cImg);
   } else {
        try
        {
        newImg.parentNode.replaceChild(newImg,cImg);
        }
        catch (e){}         
   }
     return false;
}

function cottDelay(millis) {
    var date = new Date();
    var curDate = null;
    do { curDate = new Date(); }
    while(curDate-date < millis);
}

function displayCottMods(firstMod) {

  modInst = modInst + firstMod;
  if(modInst == -1) {
      modInst = maxCards - 1;
  }

  for (var m=0; m<3; m++) {
     var inst = (modInst + m)%(maxCards);
     var topcard='showcard'+ m;
     var hiddenCardId = "card_" + inst;
     var parentDiv = document.createElement("div");
     var hiddenCard = document.createElement("div");

     if(document.getElementById('image_'+inst)) {
         buildCottImg(inst);

         if(navigator.userAgent.indexOf('MSIE') != -1) {
             cottDelay(200);
         }
     }

     hiddenCard.id = "slot_" + inst;
     hiddenCard.className = "card";
     hiddenCard.innerHTML = (document.getElementById(hiddenCardId).innerHTML);
     parentDiv.appendChild(hiddenCard);
     document.getElementById(topcard).innerHTML = parentDiv.innerHTML;
  }
    return false;
}

function cottInit() {

   displayCottMods(0);
   document.getElementById('topHiddenModules').className="hideCards";
   document.getElementById('arrows').className="show_arws";
   document.getElementById('showcard0').className="showCards";
   document.getElementById('showcard1').className="showCards";
   document.getElementById('showcard2').className="showCards";
}

// Shared functions

function findMousePos(e) {
    var posY = 0;
    if (!e) var e = window.event;
    if (e.pageX || e.pageY)     {
        posY = e.pageY;
    }
    else if (e.clientX || e.clientY)    {
        posY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
    }
    return posY;
}



//adRefresh
function adRefresh() {
/*
var adSpots = '0';
try {
if (pgAdSpots != null && pgAdSpots != 'undefined' && pgAdSpots != '') {
adSpots = pgAdSpots;
}
} catch(e) {
adSpots = '0';
}
try {
top.ch_refresher.refresh_ads_by_spot(adSpots);
} catch(e) { }
*/
return true;
}


// NON-MODULE CODE
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 popupWindow(url,width,height,features) {
    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();}
}

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; }}}

// 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];
    }
  }
}

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

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

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

//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};
}

// BEGIN Functions for ActiveX patch to IE/IE7 ------------------//
function FlashTag(src, width, height, version) {
    if (arguments.length < 4)
    {
        throw new Exception('RequiredAttributeException',
                            'You must pass in a src, width, height, and version when creating a FlashTag.');
    }

    for (var i = 0; i < arguments.length; ++i)
    {
        if (arguments[i] == undefined || arguments[i] == null)
        {
            throw new Exception('RequiredAttributeException',
                                'All constructor arguments must have values.');
        }
    }

    // Required
    this.src            =  src;
    this.width          =  width;
    this.height         =  height;
    this.version        =  version;

    this.id             =  null;
    this.flashVars      =  null;
    this.flashVarsStr   =  null;
    this.genericParam   = new Object();
    this.ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
}
FlashTag.prototype.setSource = function(src) {
    this.src = src;
}
FlashTag.prototype.setWidth = function(w) {
    this.width = width;
}
FlashTag.prototype.setHeight = function(h) {
    this.h = height;
}
FlashTag.prototype.setVersion = function(v) {
    this.version = v;
}
FlashTag.prototype.setId = function(id) {
    this.id = id;
}
FlashTag.prototype.setBgcolor = function(bgc) {
    if (bgc.charAt(0) != '#') bgc = '#' + bgc;
    this.genericParam['bgcolor'] = bgc;
}
FlashTag.prototype.addFlashVars = function(fvs) {
    this.flashVarsStr = fvs;
}
FlashTag.prototype.addFlashVar = function(n, v) {
    if (this.flashVars == null) this.flashVars = new Object();
    this.flashVars[n] = v;
}
FlashTag.prototype.removeFlashVar = function(n) {
    if (this.flashVars != null) this.flashVars[n] = undefined;
}
FlashTag.prototype.setSwliveconnect = function(swlc) {
    this.genericParam['swliveconnect'] = swlc;
}
FlashTag.prototype.setPlay = function(p) {
    this.genericParam['play'] = p;
}
FlashTag.prototype.setLoop = function(l) {
    this.genericParam['loop'] = l;
}
FlashTag.prototype.setMenu = function(m) {
    this.genericParam['menu'] = m;
}
FlashTag.prototype.setQuality = function(q) {
    if (q != 'low' && q != 'high' && q != 'autolow' && q != 'autohigh' && q != 'best')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "low", "high", "autolow", "autohigh", and "best".');
    }
    this.genericParam['quality'] = q;
}
FlashTag.prototype.setScale = function(sc) {
    if (sc != 'showall' && sc != 'noborder' && sc != 'exactfit' && sc != 'noscale')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "showall", "noborder", "exactfit, and "noscale".');
    }
    this.genericParam['scale'] = sc;
}
FlashTag.prototype.setAlign= function(a) {
    if (a != 'l' && a != 't' && a != 'r' && a != 'b')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "l", "t", "r" and "b".');
    }
    this.genericParam['align'] = a;
}
FlashTag.prototype.setSalign= function(sa) {
    if (sa != 'l' && sa != 't' && sa != 'r' && sa != 'b' && sa != 'tl' && sa != 'tr' && sa != 'bl' && sa != 'br')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "l", "t", "r", "b", "tl", "tr", "bl" and "br".');
    }
    this.genericParam['salign'] = sa;
}
FlashTag.prototype.setWmode = function(wm) {
    if (wm != 'window' && wm != 'opaque' && wm != 'transparent')
    {
        throw new Exception('UnsupportedValueException',
                            'Supported values are "window", "opaque", and "transparent".');
    }
    this.genericParam['wmode'] = wm;
}
FlashTag.prototype.setBase = function(base) {
    this.genericParam['base'] = base;
}
FlashTag.prototype.toString = function() {
    var flashTag = new String();
    if (this.ie)
    {
        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';

        for (var n in this.genericParam)
        {
            if (this.genericParam[n] != undefined && this.genericParam[n] != null)
            {
                flashTag += '<param name="'+n+'" value="'+this.genericParam[n]+'"/>';
            }
        }

        if (this.flashVars != null)
        {
            var fv = this.getFlashVarsAsString();
            if (fv.length > 0)
            {
                flashTag += '<param name="flashvars" value="'+fv+'"/>';
            }
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'"';
        flashTag += ' width="'+this.width+'"';
        flashTag += ' height="'+this.height+'"';
        flashTag += ' type="application/x-shockwave-flash"';
        if (this.id != null)
        {
            flashTag += ' name="'+this.id+'"';
        }

        for (var n in this.genericParam)
        {
            if (this.genericParam[n] != undefined && this.genericParam[n] != null)
            {
                flashTag += (' '+n+'="'+this.genericParam[n]+'"');
            }
        }
        if (this.flashVars != null || this.flashVarsStr != null)
        {
            var fv = this.getFlashVarsAsString();
            if (fv.length > 0)
            {
                flashTag += ' flashvars="'+fv+'"';
            }
        }
        flashTag += ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
    return flashTag;
}
FlashTag.prototype.write = function(doc) {
    doc.write(this.toString());
}
FlashTag.prototype.getFlashVarsAsString = function() {
    var qs = new String();
    for (var n in this.flashVars)
    {
        if (this.flashVars[n] != undefined && this.flashVars[n] != null)
        {
            qs += (escape(n)+'='+escape(this.flashVars[n])+'&');
        }
    }

    if (this.flashVarsStr != null) return qs + this.flashVarsStr;

    return qs.substring(0, qs.length-1);
}
FlashTag.prototype.setParams = function( id, bgc, fvs, swlc, p, l, m, q, sc, a, wm, base ) {
    if (id != null) this.id             =  id;
    if (fvs != null) this.flashVarsStr   =  fvs;

    if (bgc != null) this.setBgcolor(bgc);
    if (swlc != null) this.setSwliveconnect(swlc);
    if (p != null) this.setPlay(p);
    if (l != null) this.setLoop(l);
    if (m != null) this.setMenu(m);
    if (q != null) this.setQuality(q);
    if (sc != null) this.setScale(sc);
    if (a != null) this.setAlign(a);
    if (wm != null) this.setWmode(wm);
    if (base != null) this.setBase(base); 
}
function writeOnLoad() {
         try {
                 if ( flashTagParams != undefined ) {
                         var tag =  new FlashTag(flashTagParams.src, flashTagParams.width, flashTagParams.height, flashTagParams.version );
                         document.write(tag.toString());
                 }
         } catch(ex) {
                // Do nothing
         }
}
writeOnLoad();
// END Functions for ActiveX patch to IE/IE7 ------------------//

function rsiAdInit(segmax) {

    var segQS="";
    var segs_beg=document.cookie.indexOf('rsi_segs=');
    if(segs_beg>=0){
        segs_beg=document.cookie.indexOf('=',segs_beg)+1;
        if(segs_beg>0){
            var segs_end=document.cookie.indexOf(';',segs_beg);
            if(segs_end==-1)segs_end=document.cookie.length;
            rsi_segs=document.cookie.substring(segs_beg,segs_end).split('|');
            for (var i=0;i<Math.min(segmax,rsi_segs.length);i++){
                segQS+=rsi_segs[i].replace(/.*_(.*)/,"rsi=$1;");
            }
            adSetOthDclk(segQS);
       }
    }
}

/* Begin: Code for video promo module*/

var vpObject = function() {
    this.totalImg = 0;
    this.vpTimer = 0;
    this.currImg = 0;
    this.imgSrcArray = new Array();
    this.imgCrdArray = new Array();
    this.ovrArray = new Array();
    this.vpOpTimer = 0;
    this.rotInt = 5;
    this.fadeSpeed = 50;
}

function vpClass() {

    var setOpacity = function(mId,id,value) {
                
        var object = ge(id).style;
        //beat the IE bug
        if(document.all)
            object.zoom=1;
        
        object.opacity = (value / 10);
        object.MozOpacity = (value / 10);
        object.KhtmlOpacity = (value / 10);
        object.filter = "alpha(opacity=" + value*10 + ")";
    }
    
    var ovrlayDomCreate = function(mId){
        var mI = window['vpMod_'+mId];
        var d = window.document;
        var pLnk = ge('vpImgLnk_'+mId);
        var imgCnt = ge('vpImgCnt_'+mId);

        a = d.createElement('a');
        a.className = 'ovrLay';
        a.id = 'vpOvrLnk_'+mId;
        a.href = pLnk.href;
        a.innerHTML = '&nbsp;';
        
        wd = d.createElement('div');
        wd.className = 'overLayWrp';
        wd.appendChild(a);
        imgCnt.appendChild(wd);
        pLnk.onclick = ge('lkLst'+mId+'_'+mI.currImg).onclick;
    }
    
    var next = function(mId) {
        var ovrlayDiv = '<div class="overLayWrp"><a href="http://food.aol.com/tyler-florence?video=3" class="ovrLay" id="vpOvrLnk_12190">&nbsp;</a></div>';
        var objId = 'vpMod_'+mId;
        var mI = window[objId];
        var fadeInt = 0;// fading speed
        //it is necessary to clear the previous timer as the user's next click may break the sequence
        clearTimeout(mI.vpTimer);
        setOpacity(mId,'vpImgCnt_'+mId,10);
        
        //current highlighted list item
        var curlkLst = 'lkLst'+mId+'_'+mI.currImg;
        //fade out the current image
        for(var i=10;i>=0;i--) {
            fn = "vpClassObj.setOpac('"+mId+"','vpImgCnt_" + mId + "','" + i + "')";
            setTimeout(fn,fadeInt);
            fadeInt+=mI.fadeSpeed;;
        }

        //remove the highlight from current list item
        fn = "document.getElementById('"+curlkLst+"').className=''";
        setTimeout(fn,fadeInt);
        
        fn = "window.vpClassObj.showNextWrap('"+mId+"')";
        mI.vpTimer = setTimeout(fn,fadeInt);
    }
    
    var showNext = function(mId) {
        var objId = 'vpMod_'+mId;
        var mI = window[objId];

            var fadeInt = 0;//fading speed

            if(++mI.currImg >= mI.totalImg) {
                mI.currImg = 0;
            }

            //remove highlight from the current link and add to next link
            var curlkLst = 'lkLst'+mId+'_'+mI.currImg;
            ge(curlkLst).className = "highlight";

            //update credit text , image and the overlay image
            ge('ptCredit_'+mId).innerHTML = mI.imgCrdArray[mI.currImg];
            ge('vpImgCnt_'+mId).innerHTML = mI.imgSrcArray[mI.currImg];
            if(mI.ovrArray[mI.currImg] == 1) {
                ovrlayDomCreate(mId);
            }
            //fade in the new image
            for(var i=0;i<=10;i++) {
                fn = "vpClassObj.setOpac('"+mId+"','vpImgCnt_" + mId + "','" + i + "')";
                mI.vpTimer=setTimeout(fn,fadeInt);
                fadeInt+=mI.fadeSpeed;
            }
            scroll(mId,(mI.rotInt-(mI.fadeSpeed/1000)));
    }
    
    var prev = function(mId) {
        var objId = 'vpMod_'+mId;
        var mI = window[objId];
        var fadeInt = 0;// fading interval
        //it is necessary to clear the previous timer as the user's next click may break the sequence
        clearTimeout(mI.vpTimer);
        setOpacity(mId,'vpImgCnt_'+mId,10);
        
        //current highlighted list item
        var curlkLst = 'lkLst'+mId+'_'+mI.currImg;
        //fade out the current image
        for(var i=10;i>=0;i--) {
            fn = "vpClassObj.setOpac('"+mId+"','vpImgCnt_" + mId + "','" + i + "')";
            setTimeout(fn,fadeInt);
            fadeInt+=mI.fadeSpeed;;
        }

        //remove the highlight from current list item
        fn = "document.getElementById('"+curlkLst+"').className=''";
        setTimeout(fn,fadeInt);
        
        fn = "window.vpClassObj.showPrevWrap('"+mId+"')";
        mI.vpTimer = setTimeout(fn,fadeInt);
    }
    
    var showPrev = function(mId) {
        var objId = 'vpMod_'+mId;
        var mI = window[objId];

            var fadeInt = 0;//fading speed
            
        if(--mI.currImg < 0) {
            mI.currImg = parseInt(mI.totalImg-1);
        }

            //remove highlight from the current link and add to next link
            var curlkLst = 'lkLst'+mId+'_'+mI.currImg;
            ge(curlkLst).className = "highlight";

            //update credit text and image
            ge('ptCredit_'+mId).innerHTML = mI.imgCrdArray[mI.currImg];
            ge('vpImgCnt_'+mId).innerHTML = mI.imgSrcArray[mI.currImg];
            if(mI.ovrArray[mI.currImg] == 1) {
                ovrlayDomCreate(mId);
            }
            //fade in the new image
            for(var i=0;i<=10;i++) {
                fn = "vpClassObj.setOpac('"+mId+"','vpImgCnt_" + mId + "','" + i + "')";
                mI.vpTimer=setTimeout(fn,fadeInt);
                fadeInt+=mI.fadeSpeed;
            }
            scroll(mId,(mI.rotInt-(mI.fadeSpeed/1000)));
    }
    
    var scroll = function(mId,time) {
        var objId = 'vpMod_'+mId;
        mI = window[objId];
        var fn = "window.vpClassObj.vpNextImg('"+mId+"')";
        mI.vpTimer = setTimeout(fn,1000*time);
    }

    var ge = function(id){return document.getElementById(id);}
    
    return {
    
        vpNextImg : function(mId) {
            next(mId);
        },
        
        vpPrevImg : function(mId) {
            prev(mId);
        },
        
        autoScroll : function(mId,time) {
            scroll(mId,time);
        },
        
        stopScroll : function(mId) {
            var objId = 'vpMod_'+mId;
            mI = window[objId];
            clearTimeout(mI.vpTimer);
        },
        
        setOpac : function(mId,objId,value) {
            setOpacity(mId,objId,value);
        },
        
        showNextWrap: function(mId) {
            showNext(mId);
        },
        
        showPrevWrap: function(mId) {
            showPrev(mId);
        }
        
    };

}

var vpClassObj = new vpClass();
/* End code for video promo module */

// Tag Cloud/List (Blog Chatter)
function showTags()
{
    if (iTagType == 1) // Show as Cloud
    {
        caption = "List";
        iTagType = 2;
        document.getElementById("newsTagCloud").style.display = "block";
        document.getElementById("newsTagList").style.display = "none";
    } 
    else // Show as List
    {
        caption = "Cloud";
        iTagType = 1;
        document.getElementById("newsTagCloud").style.display = "none";
        document.getElementById("newsTagList").style.display = "block";
    }
    document.getElementById("newsTagTypeAnc").innerHTML = caption;
}
// End: Tag Cloud/List (Blog Chatter)

// Mouse Over Popup for What are Tags? (Blog Chatter)
function showWhatPop(iShow)
{
    if (iShow == 1) {
        document.getElementById("popMainCont").style.display = "block";
    } else {
        document.getElementById("popMainCont").style.display = "none";
    }
}
// End: Mouse Over Popup for What are Tags? (Blog Chatter)

// Top Videos
var AOLVS = null;
var theHTML =null;
var query = null;
var tab =0;
var tabtopic = null;
var numbertab = null;
var currentSlide = 0;
var vidArray = new Array();
var maxChar = null;

function handlePageLoad() {
    numbertab = document.getElementById("videotab").getElementsByTagName('li');
    AOLVS = new AOLVideoSearch('sskxzi7esi3tjgqvl');

    AOLVS.results = arguments[1];
    query = arguments[0];
    maxChar = arguments[2];
    AOLVS.attachEvent('onload', 'handleVSLoad(query, 0);');
    AOLVS.attachEvent('onupdate', 'handleUpdate();');
    AOLVS.initialize();
}

function loadVideo(){
    handleVSLoad(arguments[0],arguments[1]);
    initvideo = null;
    currentSlide=0;
    return initvideo;
}
 
function handleVSLoad() {
    displayMessage();
    tabtopic = arguments[1];
    param = arguments[0];   
    AOLVS.getVideos(arguments[0]);  
    activeTab(arguments[1]);
    return tabtopic;
}
 
function activeTab(){
    for(var v=0; v<numbertab.length; v++){
        if (arguments[0] != v) {
            document.getElementById("tb."+v).className = '';
        }
    }
    document.getElementById("tb."+arguments[0]).className = 'selected';
}
  
function displayMessage() {
    theHTML = '<div style="text-align:center;clear:both;height:85px;width:308px;background-color:#f3f3f3;border-top:45px solid #f3f3f3;"><img src="http://myfeeds.aolcdn.com/vis/progress_animation.gif"> Loading...</div>';
    document.getElementById('video_results').innerHTML = theHTML;
}

function vidSlide(direct) {
    if (direct == 1){
        if (currentSlide + 1  == AOLVS.results){
            currentSlide = 0;
        } else if (currentSlide +1 < AOLVS.results){
            currentSlide += 1;
        }
    } else {
        if (currentSlide == 0) {
            currentSlide = AOLVS.results-1;
        } else if (currentSlide -1 >= 0) {
           currentSlide -=1;
        }
    }
    document.getElementById('tally').innerHTML = '      '+(currentSlide + 1)+ '  of  ' + '  '+AOLVS.results+'      ';
    document.getElementById('video').innerHTML = vidArray[currentSlide];
}

function intializeSeq() {
    initVidHTML = vidArray[0];  
    document.getElementById('video').innerHTML = initVidHTML;
}

function handleUpdate() {
    theHTML = '';
    initHTML ='';
    viewAllHTML = '';

    switch(tabtopic){   
        case 0:
            viewAllHTML += '<a href="http://video.aol.com/video-search/query/category%3A%22News%22%20channel%3A%22AOL%20News%22%20sort%3AmostRecent%20distributor%3A%22AP%22/familyFilter/0" target="_blank">See all AP Videos</a>';
            break;
        case 1:
            viewAllHTML += '<a href="http://video.aol.com/video-search/query/category%3A%22News%22%20channel%3A%22AOL%20News%22%20sort%3AmostRecent%20distributor%3A%22CNN%22/familyFilter/0" target="_blank">See all CNN Videos</a>';
            break;
        case 3:
            viewAllHTML += '<a href="http://video.aol.com/video-search/query/category%3A%22News%22%20channel%3A%22AOL%20News%22%20sort%3AmostRecent%20distributor%3A%22CBS%22/familyFilter/0" target="_blank">See all CBS Videos</a>';
            break;
        case 2:
            viewAllHTML += '<a href="http://video.aol.com/video-search/query/category%3A%22News%22%20channel%3A%22AOL%20News%22%20sort%3AmostRecent%20distributor%3A%22Reuters%22/familyFilter/0" target="_blank">See all Reuters Videos</a>';
            break;
    }

    theHTML +='<div id="video">';

    if ( AOLVS.VideoSet.totalResultsReturned < AOLVS.results ) {    
        AOLVS.results = AOLVS.VideoSet.totalResultsReturned;
    }

    if ( AOLVS.VideoSet.totalResultsReturned > 0 ) {
        for (var i=0; i < AOLVS.VideoSet.totalResultsReturned; i++) {   
            var caption = AOLVS.VideoSet.Video[i].description;
            var charCount = new description(caption, maxChar);
            vidArray[i] ='<div id="vid.'+i+'" class="tab"><div class="video_content"><p class="news_title">'+ AOLVS.VideoSet.Video[i].title+'</p><div class="news_image"><a href="'+AOLVS.VideoSet.Video[i].videoUrl +'" target="_blank" class="img"><img src="'+ AOLVS.VideoSet.Video[i].thumbnailUrl +'" width="116" height="82"></a></div><p class="news_content">'+ charCount.characherCount() +'<span class="details">'+ viewAllHTML+'</span></p><div class="clear"></div></div></div>';         
        }
        theHTML += '</div>';
        theHTML += '<div class="top_ftr">';
        theHTML += '<span class="prev"><a href="javascript:void(0);" onClick="vidSlide();return false;">< Previous</a></span>';
        theHTML += '<span id="tally" class="count">'+'      1 of '+ '     '+AOLVS.results+'   </span>'; 
        theHTML += '<span class="nxt"><a href="javascript:void(0);" onClick="vidSlide(1);return false;">Next ></a></span>';
        theHTML += '</div>';
    
        document.getElementById('video_results').innerHTML = theHTML;
        intializeSeq();
    }
}

function countChar(){
    if (this.desclength > this.descmax){
        this.desc = this.desc.substring(0, this.descmax)+'...';
    }else{
        this.desc = this.desc;
    }
    return this.desc;
}
 
function description(caption, descriptionmax){
    this.desc = caption;
    this.desclength = caption.length;
    this.descmax = descriptionmax;
    this.characherCount = countChar;
}
// End: Top Videos

// Start:  SHARE THIS WIDGET JS

var sharePopFlag = true;                             //variable for onclick popup
  
function showShareThisPop(topDivId, botDivId)        //function to call the popup onclick
{
    if (sharePopFlag)
    {
        document.getElementById('shareLeftIDBB').style.borderBottom = "1px solid #000";
        document.getElementById(botDivId).style.display = "block";
        document.getElementById(topDivId).className = "share_right_on";
    }
    else 
    {
        document.getElementById('shareLeftIDBB').style.borderBottom = "none";
        document.getElementById(botDivId).style.display = "none";
        document.getElementById(topDivId).className = "share_right";
    }
    sharePopFlag = !sharePopFlag;
}

function shareOperation(iOperation, strUrl, strTitle)
{
    var staf_obj = new staf_SE();
    staf_obj.setLang("en-US");
    if (strUrl != "")
    {
        staf_obj.setURL(strUrl);
    }
    if (strTitle != "")
    {
        staf_obj.setTitle(strTitle);        
    }
    if (iOperation == 1) // IM This
    {
        staf_obj.sendIM();
    }
    else
    {
        staf_obj.sendEmail();
    }
}

function mouseoverup()
{
    document.getElementById("thumbsup").className="thumbsup_on";
}

function mouseoutup()
{
    document.getElementById("thumbsup").className="thumbsup";
} 

function mouseoverdown()
{
    document.getElementById("thumbsdown").className="thumbsdown_on";
}

function mouseoutdown()
{
    document.getElementById("thumbsdown").className="thumbsdown";
}

// End: SHARE THIS WIDGET JS

// Start: News Article - User Comments JS 
// rating
var xmlHttpRating;

function getRating(objectURI, category, type, score, appId) {
    var procName = "dms.trri.addRatingAndGet"
    var parameters = objectURI + ',' + category + ',' + type  + ',' + score + ',' + appId;

     if (window.ActiveXObject) {
        xmlHttpRating = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttpRating = new XMLHttpRequest();
    }
   
    xmlHttpRating.onreadystatechange = handleStateChange;
   
    var ourl = document.URL;

    //url="http://sports.channel.office.aol.com/httprequest.adp"
    var ind = ourl.indexOf('aol.com/');
    var url = ourl.substring(0, ind+8);
    url += 'httprequest.adp';

    url = url + "?_pn=" + procName;
    if (parameters!="")
    {
          url = url + "&_pa=" + parameters;
    }

    url += '&date=' + new Date().getTime();

    //alert(url);
    xmlHttpRating.open("GET", url, true);
    xmlHttpRating.setRequestHeader("Accept", "text/xml");
    xmlHttpRating.send(null);
}
   
function handleStateChange() {
    if(xmlHttpRating.readyState == 4) {
        if(xmlHttpRating.status == 200) {
            if(xmlHttpRating.responseText.length) {
                var result = xmlHttpRating.responseText.substring(1, xmlHttpRating.responseText.length - 1 );
                var results = result.split(" ");
                document.getElementById('label').innerHTML = "Thanks";
                document.getElementById('thumbsup').innerHTML = '<img src="http://www.aolcdn.com/ch_news/news-icon-thumbup" title="Thumbs Up" border="0" class="images" />' + results[0] + ' %';
                document.getElementById('thumbsdown').innerHTML = '<img src="http://www.aolcdn.com/ch_news/news-icon-thumbdown" title="Thumbs Up" border="0" class="images" />' + results[1] + ' %';
                document.getElementById('total').innerHTML = results[2] + ' VOTES';
                mouseoutup();
                mouseoutdown();
            }
        }
    }
}


// comment

var xmlHttpComment;

function displayComments(start) {
    var uri = document.getElementById("cmmt_uri").value;
    var category = document.getElementById("cmmt_category").value;
    var assetType = document.getElementById("cmmt_assetType").value;
    var appID = document.getElementById("cmmt_appID").value;
    var numCmmt = document.getElementById("cmmt_numCmmt").value;
    var AddBtnLbl = document.getElementById("cmmt_AddBtnLbl").value;
    var CanBtnLbl = document.getElementById("cmmt_CanBtnLbl").value;
    var reportThis = document.getElementById("cmmt_reportThis").value;
    var thisurl = document.getElementById("cmmt_thisurl").value;

    var procName = "dms.trri.displayReviews"
    var del=',';
    var parameters = uri;
    parameters += del + category;
    parameters += del + assetType;
    parameters += del + appID;
    parameters += del + start;
    parameters += del + numCmmt;
    parameters += del + AddBtnLbl;
    parameters += del + CanBtnLbl;
    parameters += del + reportThis;
    parameters += del + thisurl;

    if (window.ActiveXObject) {
        xmlHttpComment = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttpComment = new XMLHttpRequest();
    }
   
    xmlHttpComment.onreadystatechange = readyForComments;
   
    var ourl = document.URL;

    var ind = ourl.indexOf('aol.com/');
    var url = ourl.substring(0, ind+8);
    url += 'httprequest.adp';

    url = url + "?_pn=" + procName;
    if (parameters!="")
    {
          url = url + "&_pa=" + parameters;
    }

    url += '&date=' + new Date().getTime();

    //alert(url);
    xmlHttpComment.open("GET", url, true);
    xmlHttpComment.setRequestHeader("Accept", "text/xml");
    xmlHttpComment.send(null);
}
   
function readyForComments() {
    if(xmlHttpComment.readyState == 4) {
        if(xmlHttpComment.status == 200) {
            document.getElementById('cmmntBox').innerHTML = xmlHttpComment.responseText;
            //checks cookie for hide/show
            checkCookie('cmnt');
        }
    }
}


function submitComments()
{
    /* if no screen_name for page, use sns screen name */

    if (screen_name=="") {
        screen_name = loginId;
    }
    submitCommentsWithSN(screen_name);

}
var xmlHttpAddComment;
function submitCommentsWithSN(sn)
{
    var comment = document.getElementById("addCommentHere").value;
    if(comment == null || comment.length < 1 || comment == 'Type your own comment here')
        return;

    var uri = document.getElementById("cmmt_uri").value;
    var category = document.getElementById("cmmt_category").value;
    var assetType = document.getElementById("cmmt_assetType").value;
    var appID = document.getElementById("cmmt_appID").value;

    procName = "dms.trri.addReview";

    var del='|';
    parameters = uri;
    parameters += del + sn;
    parameters += del + comment;
    parameters += del + category;
    parameters += del + assetType;
    parameters += del + appID;

    if (window.ActiveXObject) {
        xmlHttpAddComment = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttpAddComment = new XMLHttpRequest();
    }
    
    xmlHttpAddComment.onreadystatechange = afterAddComments;
    
    var ourl = document.URL;

    var ind = ourl.indexOf('aol.com/');
    var url = ourl.substring(0, ind+8);
    url += 'httprequest.adp';

    data = "_pn=" + procName;
    data += "&_pa=" + parameters;
    data += "&_del=" + del;

    xmlHttpAddComment.open("POST",url,true);
    xmlHttpAddComment.setRequestHeader("Accept", "text/xml");
    xmlHttpAddComment.send(data);
} 

function afterAddComments() 
{ 
     if(xmlHttpAddComment.readyState == 4) {
        if(xmlHttpAddComment.status == 200) { 
            var status = xmlHttpAddComment.responseText;
            if (status == '1') {
                displayComments(0);
            } else {   
                document.getElementById('ucMsg').innerHTML = "Your comment could not be successfully saved at this time. Please try again later."
            }
        }
    } 
}

//Enforce maxlength attribute of usercomments textarea.
function checkMaxLength(obj) {
    var maxLength = obj.getAttribute('maxlength');
    var currentLength = obj.value.length;

    if (currentLength > maxLength)
        obj.value=obj.value.substring(0,maxLength)

    var counter = getEl(obj.getAttribute('counter'));
    counter.firstChild.nodeValue = currentLength + '/' + maxLength;
    // not innerHTML
}

// Login Functions
function AsnsSignIn() {
    pSNS = getEl("snsMiniUI");
    pSNS.innerHTML = "";
    pSNS.innerHTML = _sns_var_;
    pSNS.style.display = 'block';
}

function getEl( id ){ 
    return document.getElementById( id ); 
}

function showToolTip(oCaller, ttID){
    document.getElementById(ttID).style.display = "block";
}

function hideToolTip(oCaller, ttID){
    document.getElementById(ttID).style.display = "none";
}
// End: News Article - User Comments JS

/****
Project: light xmlhttp library
Author : Amit Rai
Version : 1
****/


function xL(url,requestType,isAsync,requestData){

    var _url="";
    var _requestType="";
    var _isAsync=true;
    var _initialized=false;
    var _xmlHttpObject=false;
    var _valueStr="";
    var _requestData=new Object();
    var _debugMode=false;
    var _responseHandler=function(obj){};
    var _errMsg = "";
        
    var debugMsg = function(msg)
    {
        if(_debugMode)
        {
            alert(msg);
        }
    }
    
    var trim = function(str)
    {
           return str.replace(/^\s*|\s*$/g,"");
    }
    
    var createRequestValueString = function ()
    {
        var str=new String();
        var aObject = _requestData;
        
        for(var key in aObject)
        str=str+"&"+key+"="+aObject[key];
        
        if(_requestType=="GET")
        str="?"+str;

        return encodeURI(str);
    }
            
    var createXmlHttpObject = function ()
    {
        
        if(window.XMLHttpRequest && !(window.ActiveXObject)) 
        {// FF , mozilla and safari 
            try 
            {
                req = new XMLHttpRequest();
            
            } 
            catch(e) 
            {
                req = false;
            }
        } 
        else if(window.ActiveXObject) 
        {// IE Windows ActiveX version
               try 
            {
                req = new ActiveXObject("Msxml2.XMLHTTP");
              } 
            catch(e) 
            {
                try 
                {
                      req = new ActiveXObject("Microsoft.XMLHTTP");
                } 
                catch(e) 
                {
                      req = false;
                }
            }
        }
        return req;
    }
    
    var init = function(url,requestType,isAsync,requestData)
    {
        
        if(url.length>11 && requestType.length>2)
        {
            _url=encodeURI(url);
            _requestType=requestType.toUpperCase();
            _initialized=true;
            _isAsync=isAsync;
            _xmlHttpObject = createXmlHttpObject();
            _requestData = requestData;
            _valueStr = createRequestValueString();
        } 
        else
        {
            debugMsg("Initialization data is not correct!");
        }
        
    }
    
    init(url,requestType,isAsync,requestData);
    
    var sendGetRequest = function()
    {
            if(_xmlHttpObject)
        {    
            _xmlHttpObject.onreadystatechange = function(){_responseHandler(_xmlHttpObject);};
            try
            {
                _xmlHttpObject.open(_requestType, _url+_valueStr, _isAsync);
                _xmlHttpObject.send(null);
            }
            catch(e)
            {
                _errMsg = e;
            }
        }
        return _errMsg;
    }
    
    var sendPostRequest = function()
    {
        if(_xmlHttpObject)
        {    
            _xmlHttpObject.onreadystatechange = function(){_responseHandler(_xmlHttpObject);};
            try
            {
                _xmlHttpObject.open(_requestType, _url, _isAsync);
                _xmlHttpObject.send(_valueStr);
            }
            catch(e)
            {
                _errMsg = e;
            }
        }
        return _errMsg;
    }
    
    var sendHeadRequest = function()
    {
        if(_xmlHttpObject)
        {
            _xmlHttpObject.onreadystatechange = function(){_responseHandler(_xmlHttpObject);};
        try
        {    
            _xmlHttpObject.open(_requestType, _url, _isAsync);
            _xmlHttpObject.send(null);
        }
        catch(e)
        {
            _errMsg = e;
        }
        }
        return _errMsg;
    }

    var alertAll = function()
    {
        if(_debugMode)
        {
            alert("_url = "+ _url + "\n _requestType= " + _requestType + "\n _isAsync= " + _isAsync);
            alert("_initialized " + _initialized + "\n _xmlHttpObject " +_xmlHttpObject + "\n _valueStr " +_valueStr);
        }
    }
    
    alertAll();
    
    return {
        
        abortRequest : function()
        {
            if(_xmlHttpObject.readyState!=4)
            {
                _xmlHttpObject.onreadystatechange = function (){};
                _xmlHttpObject.abort();
            }
        },
        
        getXmlHttpObject : function() {
            return createXmlHttpObject();
        },
        
        init : function(url,requestType,isAsync,requestData) {
            init(url,requestType,isAsync,requestData);
        },
        
        sendRequest : function() 
        {
            switch (_requestType)
            {
                case "GET":
                    sendGetRequest();
                    break;
                case "POST":
                    sendPostRequest();
                    break;
                case "HEAD":
                    sendHeadRequest();
                    break;
                default:
                    debugMsg(_requestType + " : request type not found");
            }
                        
            return _errMsg;
        },
        
        setResponseHandler : function(functionObj)
        {
            if((typeof functionObj)=="function"){
                _responseHandler = functionObj;
            }
        },
        
        setDebugMode : function(debug)
        {
            if(typeof(debug)=="boolean"){
                _debugMode=debug;    
            }
        }
            
    };//end return
} //end Xlib

/*Start:  JS code for the News Photogallery*/
//global news photogallery object loaded with default values,
//needs to be overridden on per module instance basis
    
var pgGlbObject = function() {
    this.pgTotalImages = 0;
    this.pgGalleryId = 0;
    this.glbPgTimer = 0;
    this.glbCurrentImg = 1;
    this.navAction = '';
    this.omnitureURL = 'omni_track';
    this.xmlUrl = 'common/photogallery/response.xml?&id=3&index=2&feedtype=news&navAction=next';
    this.feedType = 'news';
    this.magicNumber = 0;
    this.adContinue = 'See More Pictures';
    this.adCaption = 'ADVERTISEMENT';
    this.isAd = 0;
    this.gallerySize = '';
    this.adSpot = '';
    this.photoPage = 0;
}

function appInit(modId){
    var debugMode = false;
    mI = window[modId];
    var queryParam = new Object();
    var requestParameters = new String();
    var today = new Date();
    
    if(mI.isAd == 0) {
       updateTallyNumber(modId);
    }
    
    queryParam['id'] = mI.pgGalleryId;
    queryParam['index'] = mI.glbCurrentImg;
    queryParam['feedtype'] = mI.feedType;
    queryParam['navAction'] = mI.navAction;
    queryParam['magicnumber'] = mI.magicNumber;
    queryParam['ts'] = today.getSeconds();
    queryParam['isAd'] = mI.isAd;
    queryParam['gallerySize'] = mI.gallerySize;
    url = mI.xmlUrl;

    reqType='GET';

    if(debugMode) {
        alert('id = '+mI.pgGalleryId + ' index= ' + mI.glbCurrentImg + ' feedtype= '+mI.feedType+' navAction= '+mI.navAction+' isAd= '+mI.isAd+' gallerySize= '+mI.gallerySize);
    }
    var objLap = new xL(url,reqType,true,queryParam);
                
    var serverErrorHandler = function(statusCode,statusMsg)
    {
        if(debugMode) {
            alert("Error Code : " + statusCode + " Message : " + statusMsg);
        }
    }
    
    var responseHandler = function(req) 
    {
        if(mI.glbPgTimer==0)
        {
            var timeOutErr = function() 
            {
                clearTimeout(mI.glbPgTimer);
                objLap.abortRequest();
            }
            mI.glbPgTimer = setTimeout(timeOutErr,5000);
        }
        // only if req shows "loaded"
        if (req.readyState == 4)
        {
            if (req.status == 200) 
            {
                resXML = req.responseXML;
                resTxt = req.responseText;
                uaStr = navigator.userAgent.toLowerCase();
               // Firefox has issue reading the xml returned from server
               if(uaStr.indexOf('firefox') != -1) {
                   if (document.implementation.createDocument && typeof(window.DOMParser) != "undefined") {
                       var parser = new DOMParser();
                       resXML = parser.parseFromString(resTxt, "text/xml");
                   }
               } 
                updateGallery(resXML,modId);
            } else {
                if(debugMode) {
                    alert("Error : "+req.getAllResponseHeaders());
                }
            }
        }
        //end main if else
    }       
    
    objLap.setResponseHandler(responseHandler);
    
    err=objLap.sendRequest();
    
    if(err.length>0 && debugMode==true)
    {
        alert(err);
    }
}

function updateGallery(resXML,modId) {
    var debugMode = false;
    var i = 0;
    var mod = "_" + modId;
    var mI = window[modId];
    var root = document.getElementById('newsmaker_'+modId);
 
    //only if the proper data is returned 
    if(resXML.getElementsByTagName("img")[0]) {
        document.getElementById('ad'+mod).style.display='none';

        //set the required values from xml fragment
        var isAd = getNodeValue(resXML.getElementsByTagName("isAd")[0]);
        if (isAd != "1") {
            var pgCredit = getNodeValue(resXML.getElementsByTagName("pgcredits")[0]);
            var photoCaption = getNodeValue(resXML.getElementsByTagName("photocaption")[0]);
            var imgSrc = resXML.getElementsByTagName("img")[0].getAttribute('src');
            var imgAlt = resXML.getElementsByTagName("img")[0].getAttribute('alt');
            var imgWidth = resXML.getElementsByTagName("img")[0].getAttribute('photoWidth');
            var imgHeight = resXML.getElementsByTagName("img")[0].getAttribute('photoHeight');

            if(debugMode) {
                alert('isAd='+isAd+'pgCredit='+pgCredit+'photoCaption='+photoCaption+'imgSrc='+imgSrc);
            }
            //sprint2.5 updates
            if (mI.photoPage == 1)
                {
                    if (imgHeight > imgWidth) {
                        className = 'vertical_img';
                    } else{
                        className = 'horizontal_img';
                    }
            document.getElementById('pg_ImgMain'+ mod).height = imgHeight;
            document.getElementById('pg_ImgMain'+ mod).width = imgWidth;
            document.getElementById('pg_ImgMain' + mod).className = className;
            }
            //update the dom information
            document.getElementById('pg_ImgMain'+ mod).style.display="block";
            document.getElementById('pg_ImgMain'+ mod).src = imgSrc;
            document.getElementById('pg_ImgMain'+ mod).alt = imgAlt;
            document.getElementById('pg_credits' + mod).innerHTML = pgCredit;
            document.getElementById('center_pic_cont' + mod).innerHTML = photoCaption;
            
            if(mI.navAction == 'next') {
                document.getElementById('newsmakerTally' + mod).innerHTML = mI.glbCurrentImg + " of " + mI.pgTotalImages;
                sendOmnitureData(resXML,modId);
            }

            if(mI.navAction == 'prev') {
                 sendOmnitureData(resXML,modId);
                 document.getElementById('newsmakerTally' + mod).innerHTML = mI.glbCurrentImg + " of " + mI.pgTotalImages;
            }

            //ad refresh on image change
            galleryAdRefresh(mI.adSpot);
        }
    }// end main if

   // if the isAd parameter in response xml is 1 
    if(getNodeValue(resXML.getElementsByTagName("isAd")[0])==1) {
        try { 
            document.getElementById('pg_ImgMain'+ mod).style.display="none";
            document.getElementById('pg_credits' + mod).innerHTML = mI.adCaption.toUpperCase();
            document.getElementById('newsmakerTally' + mod).innerHTML = mI.adContinue;
            document.getElementById('center_pic_cont' + mod).innerHTML = "";
            var adCont = document.getElementById('ad'+mod);
            
            if(!document.getElementById('ifr'+mod)) {
                var ifr = document.createElement('iframe');
                ifr.setAttribute('id','ifr'+mod);
                ifr.style.height='250px';
                ifr.style.widht='300px';
                ifr.style.overflow='hidden';
                ifr.frameBorder='0';
                if(ifr.scrolling){
                   ifr.scrolling='no';
                }
            } else{
              ifr = document.getElementById('ifr'+mod);
            }
            var adURL = mI.adURL + mI.magicNumber;
            ifr.src = adURL;
            adCont.appendChild(ifr);
            adCont.style.display='block';
        } catch(e) {
          if(debugMode)
             alert(e);
        }
        
    }

    //set the isAd value in module object, this is needed to prevent the ad fromo looping
    mI.isAd = getNodeValue(resXML.getElementsByTagName("isAd")[0]);
}// end updateGallery

// Ad Refresh on Image Change
function galleryAdRefresh(adSpot) {
    try {
        if (adSpot != null && adSpot != 'undefined' && adSpot != '') {
            top.ch_refresher.refresh_ads_by_spot(adSpot);
        }
    } catch(e) {}
    return true;
}

function updateTallyNumber(modId) {
    var mI = window[modId];
    if(mI.navAction == 'next') {
    
        if(mI.glbCurrentImg < mI.pgTotalImages) {
            ++mI.glbCurrentImg;
            mI.navAction = 'next';
        } else {
            mI.glbCurrentImg=1;
            mI.navAction = 'next';
        }
    
    } 

    if(mI.navAction == 'prev') {

        if(mI.glbCurrentImg > 1) {
             --mI.glbCurrentImg;
            mI.navAction = 'prev';
        }
        else 
        {
            mI.glbCurrentImg=mI.pgTotalImages;
            mI.navAction = 'prev';
        }

    }
} // end updateTallyNumber

function getNodeValue(node) {
    var val = "";

    if (node != undefined || node != null){ 
        if(node.nodeValue == null || node.nodeValue == undefined){
            try {
                val = node.firstChild.nodeValue;
        } catch (e){}
      }
  }

    return val;
}

 function sendOmnitureData(resXML,modId) {
    var date = new Date();
    var time = date.getTime(); 
    var mI = window[modId];
    var omniUrl = mI.omnitureURL;
    var reqType= "GET";
    var qp = new Object();
    str = "?ts="+time;
    qp['id'] = mI.pgGalleryId;
    qp['index'] = mI.glbCurrentImg;
    qp['feedtype'] = mI.feedType;
    qp['navAction'] = mI.navAction;
    qp['debug'] = 0;
    // To capture the mmx variable for omniture tracking for both h and g code
 if(typeof(s_channel) != 'undefined') {
     qp['mmx'] = s_channel;
    } else if(typeof(s_265.channel) != 'undefined'){
       qp['mmx'] = s_265.channel;
 } 
    if(document.getElementById('pgOmniIframe'+modId)) {
        ifr = document.getElementById('pgOmniIframe'+modId);
    } else {
        ifr = document.createElement('iframe');
        ifr.setAttribute('id','pgOmniIframe'+modId);
        ifr.width=0;
        ifr.height = 0;
        ifr.border = 0;
        ifr.style.visibility = 'hidden';
        document.body.appendChild(ifr);
    } 
  
    for(var key in qp)
        str=str+"&"+key+"="+qp[key];
    
    omniUrl = omniUrl + str; 
    ifr.src = omniUrl;
}

function nextImg(objId) {
    if (objId.indexOf("mod_article") > -1 || objId.indexOf("mod_synopsis") > -1) {
        dpNextImg(objId);
    } else {
        mI = window[objId];
        mI.navAction = 'next';
        appInit(objId);
        return false;
    }
}

function prevImg(objId) {
    if (objId.indexOf("mod_article") > -1 || objId.indexOf("mod_synopsis") > -1) {
        dpPrevImg(objId);
    } else{
        mI = window[objId];
        mI.navAction = 'prev';
        appInit(objId);
            return false;
    }
}

function dpNextImg(objId) {
    MasterobjId = objId;
    var ml = window[objId]; // Object
    indexMax[MasterobjId] = ml.pgTotalImages;
    
    if(typeof(photoAry[objId]) == "undefined")
        photoAry[objId] = 2;
    else {
        photoAry[objId]  = photoAry[objId] +1;
        if(photoAry[objId] > ml.pgTotalImages)
        {
        photoAry[objId] = 1;
        } 
    }
        
    var index = photoAry[objId] ;
    indexPhoto = index;
        
    var url = "/common/photogallery/dpResponse.xml?id="+ ml.pgGalleryId +"&index=" + index+"&gallerySize="+ml.gallerySize+"&pgTotalImages="+ml.pgTotalImages;   
    AJAXmakeReq(url, PG_callback, "");
    url = "/common/photogallery/dpOmniture.adp?id="+ml.pgGalleryId +"&index=" + index;
    OmnitureDPPhoto(url);
}

function dpPrevImg(objId) {
    MasterobjId = objId;
    var ml = window[objId];
    indexMax[MasterobjId] = ml.pgTotalImages;
    if(typeof(photoAry[objId]) == "undefined"){
        photoAry[objId] = ml.pgTotalImages;
        }
    else {
        photoAry[objId]  = photoAry[objId] -1;
        if(photoAry[objId] < 1)
        {
            photoAry[objId] = ml.pgTotalImages;
        } 
    }
    var index = photoAry[objId] ;
    indexPhoto = index;
    var url = "/common/photogallery/dpResponse.xml?id="+ ml.pgGalleryId +"&index=" + index+"&gallerySize="+ml.gallerySize+"&pgTotalImages="+ml.pgTotalImages;
    AJAXmakeReq(url, PG_callback, "");
    url = "/common/photogallery/dpOmniture.adp?id="+ml.pgGalleryId +"&index=" + index;
    OmnitureDPPhoto(url);
}
/*End:  JS code for the News Photogallery*/

/* hide/show for TRRI Comment Module */
function createCookie() {
     if (arguments[2]) {
         var date = new Date();
         date.setTime(date.getTime()+(arguments[2]*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
     }
    else var expires = "";
    document.cookie = arguments[0]+"="+arguments[1]+expires+"; path=/; domain=.aol.com;";
}

function readCookie() {
    var nameEQ = arguments[0] + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

var hideCmntBtn ='Turn Off Comments';
var showCmntBtn ='Turn On Comments';
var hideCmntMsg = '<span>Comments are now disabled for all articles on AOL.</span> <a  href="javascript:void(0);" onclick="toggleCmnts(\'cmnt\', \'off\');" class="showCmntsBtn">'+ showCmntBtn +'</a>';


function toggleCmnts(){
    if (arguments[1] =='on' ){
        createCookie(arguments[0], 'on', 365);
         }else {
         createCookie(arguments[0], 'off', 365);
     }
     checkCookie(arguments[0]);
}

function toggleBtn(){
     var hide = document.getElementById('hideCmnt');
     var show = document.getElementById('showCmnt');
     var cmntBtn = document.getElementById('tglCmntBtn');
     var bgOverlay = document.getElementById('overlayBG');
     var pstBtn = document.getElementById('pstCmntBtn');
     var cmntPage = document.getElementById('cmntPagination');

     if (arguments[0]){
         if(show != null){
             show.style.display='none';
             if (cmntPage != null){cmntPage.style.display='none';}

             pstBtn.style.display='none';
             cmntBtn.innerHTML = showCmntBtn;
             cmntBtn.style.borderColor = '#fff';
             hide.innerHTML = hideCmntMsg;
             bgOverlay.style.display = 'block';
             cmntBtn.onclick = function () {
             toggleCmnts('cmnt', 'off');
             }
         }else{
            cmntBtn.style.display = 'none';
             }
     }else {
         if(show != null){
             show.style.display='block';
             if (cmntPage != null){cmntPage.style.display='block';}

             pstBtn.style.display='inline';
             cmntBtn.innerHTML = hideCmntBtn;
             cmntBtn.style.borderColor = '#000';
             hide.innerHTML ="";
             bgOverlay.style.display = 'none';
             cmntBtn.onclick = function () {
                 toggleCmnts('cmnt', 'on');
             }

         }
         else{
            cmntBtn.style.display = 'none';
             }
     }
}

function checkCookie(){
     var cmtCookie = readCookie(arguments[0]);
     if (cmtCookie == 'on'){
             toggleBtn(true);}
    else {  
        toggleBtn(false);
     }
}

//This function hides the more popup on the header
function hideHeaderMore(e) {
    var targ;

    if (!e) var e = window.event;

    if (e.target) targ = e.target;
    else if (e.srcElement) targ = e.srcElement;
    
    if (targ.nodeType == 3) // defeat Safari bug
        targ = targ.parentNode;

    if(targ.id != 'smorea' && p_o('smore')) {
        var oDiv=p_o('smore');
         
        if(oDiv.style.display.toLowerCase() == "block") 
            oDiv.style.display='none';
    }
}

//This function hides the more popup on the footer
function hideFooterMore(e) {
    var targ;

    if (!e) var e = window.event;

    if (e.target) targ = e.target;
    else if (e.srcElement) targ = e.srcElement;
    
    if (targ.nodeType == 3) // defeat Safari bug
        targ = targ.parentNode;

    if(targ.id != 'smoreFta' && p_o('smoreFt')) {
        var oDiv=p_o('smoreFt');
         
        if(oDiv.style.display.toLowerCase() == "block") 
            oDiv.style.display='none';
    }
}

function hideSearchMore(e) {
    hideHeaderMore(e);
    hideFooterMore(e);
}

// Hide the more popup(s) if user clicks anywhere on the document
document.onclick = hideSearchMore;


//Light Box Gallery begins
// THIS DOES THE AJAX REQUEST 
function AJAXmakeReq(url, callbackFN, outputHere) {
   var ajax_req;

   if (window.XMLHttpRequest) { // Mozilla, Safari,...
     ajax_req = new XMLHttpRequest();
     if (ajax_req.overrideMimeType) {
       ajax_req.overrideMimeType('text/xml');
     }
   } else if (window.ActiveXObject) { // IE
     try {
       ajax_req = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
       try {
       ajax_req = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e) {}
     }
   }
   if (typeof(ajax_req) == "undefined" ) {
     alert('Giving up. Cannot create an XMLHTTP instance');
     return false;
   }
   ajax_req.onreadystatechange = outputReq;
   ajax_req.open('GET', url, true);
   ajax_req.send(null);

   function outputReq() {
     try {
       if (ajax_req.readyState == 4) {
         if (ajax_req.status == 200) {
           var response = ajax_req;
           if (typeof(outputHere) != "undefined" && outputHere != "" ) {
             callbackFN(response,outputHere);     
           } else {
             callbackFN(response);
           }
         } else {
           alert('There was a problem with the request.');
         }
       }
     }
     catch( e ) {
       alert('Caught Exception: ' + e.description);
     }
   }
}


var photoAry = new Array();
var indexPhoto = 1;
var indexMax = new Array();
var MasterobjId = "";


var PG_callback = function(response){
    var xmldoc = response.responseXML;
    var imgid = "";
    var imgsrc = "";
    var imgalt = "";
    var imgphotoHeight = "";
    var imgphotoWidth = "";
    var responsetxt = response.responseText;
    var uaStr = navigator.userAgent.toLowerCase();
    // Firefox has issue reading the xml returned from server
    if(uaStr.indexOf('firefox') != -1) {
        if (document.implementation.createDocument && typeof(window.DOMParser) != "undefined") {
            var parser = new DOMParser();
            xmldoc = parser.parseFromString(responsetxt, "text/xml");
        }
    } 

    var img = xmldoc.getElementsByTagName('img').item(0);
    if(typeof(img)!="undefined")
    {
        imgid = img.getAttribute('id');
        imgsrc = img.getAttribute('src');
        imgalt = img.getAttribute('alt');
        imgphotoHeight = img.getAttribute('photoHeight');
        imgphotoWidth = img.getAttribute('photoWidth');
    }

    var isAd = xmldoc.getElementsByTagName("isAd")[0];
    isAd=isAd?isAd.childNodes[0]:null;
    isAd=isAd?isAd.nodeValue:null;

    var pgcredits = xmldoc.getElementsByTagName("pgcredits")[0];
    pgcredits = pgcredits? pgcredits.childNodes[0]:null;
    pgcredits = pgcredits? pgcredits.nodeValue:null;

    var photocaption = xmldoc.getElementsByTagName("photocaption")[0];
    photocaption = photocaption? photocaption.childNodes[0]:null;
    photocaption = photocaption? photocaption.nodeValue:null;
    clearPhotoGallery(MasterobjId);
    if(e_id("photoImg_"+MasterobjId)){
        e_id("photoImg_"+MasterobjId).src = imgsrc;
        e_id("photoImg_"+MasterobjId).height = imgphotoHeight;
        e_id("photoImg_"+MasterobjId).width = imgphotoWidth;
        e_id("photoImg_"+MasterobjId).alt = imgalt;
    }
    if(e_id("photoCap_"+MasterobjId)){
e_id("photoCap_"+MasterobjId).innerHTML = photocaption;}
    if(e_id("photoCredit_"+MasterobjId)){
e_id("photoCredit_"+MasterobjId).innerHTML = pgcredits;}
    if(e_id("photoTally_"+MasterobjId)){
e_id("photoTally_"+MasterobjId).innerHTML = photoAry[MasterobjId] +" of "+
indexMax[MasterobjId];}
    
}

e_id = function(val){
    return document.getElementById(val);
}

var clearPhotoGallery = function(objId){
    if(e_id("photoImg_"+objId)){
        e_id("photoImg_"+objId).src = "";
        e_id("photoImg_"+objId).height = 0;
        e_id("photoImg_"+objId).width = 0;
        e_id("photoImg_"+objId).alt = "";
    }
    if(e_id("photoCap_"+objId)){
        e_id("photoCap_"+objId).innerHTML = "";
    }
    if(e_id("photoCredit_"+objId)){
        e_id("photoCredit_"+objId).innerHTML = "";
    }
}

var OmnitureDPPhoto =  function(url) {
    if(e_id('lbgOmniIframe')) {
        ifr = e_id('lbgOmniIframe');
    } else {
        ifr = document.createElement('iframe');
        ifr.setAttribute('id','lbgOmniIframe');
        ifr.width=0;
        ifr.height = 0;
        ifr.border = 0;
        ifr.style.visibility = 'hidden';
        var objBody = document.getElementsByTagName("BODY").item(0);
        objBody.appendChild(ifr);
    }
    ifr.src = url;
}


var LB_callback = function(response, outputHere){
 var responsetxt = response.responseText;
      var outputDiv = document.getElementById(outputHere);
      outputDiv.innerHTML = responsetxt;
      lbg.getObjHeight('lbgActive_'+lbgModID,lbgModID);
}

// time stamp to prevent caching
var date = new Date();
var ts = date.getTime();

// light box gallery 

var lbgMn = "";
var lbgModID = "";
var lbgGalID ="";
var lbgobjO = "";
var lbgGalType ="";
var lbgGalSlot ="";
var lbgGalTemplate ="";
var lbgOrder = "";
var lbgPara = "";
var lbgArticleId = "";
var lbgDyna = false;
var objBody = document.getElementsByTagName("BODY").item(0);
var lbg = {

    open: function(modID,mn,galID,galType,template,slot) {
        var d = document;
        lbgMn = mn;
        lbgModID = modID
        lbgGalID = galID
        
        
        var modIdSplit = modID.split('_');
    
        if (modIdSplit[1] == "article" || modIdSplit[1] == "synopsis"){
            lbgDyna = true;
            lbgGalType = galType;
            lbgGalTemplate = template;
            lbgGalSlot = slot;
            lbgPara=window['mod_'+lbgModID+'paragraph'];
            lbgOrder=window['mod_'+lbgModID+'order'];
            lbgArticleId = window['mod_'+lbgModID+'articleId'];
        }
        
        var objBody = d.getElementsByTagName("BODY").item(0);
        if (d.getElementById('lbgOverlay_'+modID)) { // page overlay layer      
            var objOverlay = d.getElementById('lbgOverlay_'+modID);
            objOverlay.onclick = function() { lbg.close(); }
        }
        
        var objLBGChild = d.getElementById("lbgChild_"+modID);
        
        objBody.className = "lbgOn";

        hideSelectBoxes();
        hideFlash();

        // stretch overlay to fill page and fade in
        var arrayPageSize = getPageSize();
        var arrayPageScroll = getPageScroll();

        // calculate top and left offset for the lbgChild 
        var lbgChildTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
        var lbgChildLeft = arrayPageScroll[0];
        
        var offsetLeft = d.body.offsetLeft;

        // browsers treat margin on BODY differently 
        // this code is based on a 980 wide body

        objOverlay.style.width= arrayPageSize[0]+"px";
        objOverlay.style.height= arrayPageSize[1]+"px";

        if ((offsetLeft == 0) && (arrayPageSize[0] > 980)) {  // FF 
            var negativPos = ((arrayPageSize[0] - 980)/ 2);
            objOverlay.style.left= "-"+negativPos+"px";
        } else if ((offsetLeft == 0) && (arrayPageSize[0] == 980) && (arrayPageSize[2] > 980)) {  // Safari  
            var negativPos = ((arrayPageSize[2] - 980)/ 2);
            objOverlay.style.width= arrayPageSize[2]+"px";
            objOverlay.style.left= "-"+negativPos+"px";
        } else if ((offsetLeft != 0) && (arrayPageSize[0] == 980) && (arrayPageSize[2] > 980)) {  // IE  
            var negativPos = ((arrayPageSize[2] - 980)/ 2);
            objOverlay.style.width= arrayPageSize[2]+"px";
            objOverlay.style.left= "-"+negativPos+"px";
        }

        function detectMacXFF() {
            var userAgent = navigator.userAgent.toLowerCase();
            if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
              return true;
            }
        }

        objLBGChild.style.top= lbgChildTop+"px";
        objLBGChild.style.left= lbgChildLeft+"px";
        // ajax call 
        if (lbgDyna != true){ 
            var modReqURL = "/mod.adp?_mo=1&_miid=" + modID + "&lbgReq=1&lbgIndex=1&lbgGalId="+lbgGalID;
        } else {
            var modReqURL = "/common/photogallery/dpResponse.xml?lbgal=true&id="+lbgGalID+"&index=1&galType="+lbgGalType+"&galTemplate="+lbgGalTemplate+"&galSlot="+lbgGalSlot+"&articleId="+lbgArticleId+"&para="+lbgPara+"&order="+lbgOrder;
        }
        
        AJAXmakeReq(modReqURL,LB_callback,"lbgL_"+modID);
        
        var d = detectMacXFF();
        if (d) {
            //osx ff css opacity + flash wmode transparent doesn't work
            objOverlay.style.backgroundImage= "url(http://www.aolcdn.com/aol/lbg-overlay.png)";
            objOverlay.style.backgroundRepeat="repeat";
            objOverlay.style.display = 'block';
            lbg.fadeInit('lbgOverlay_'+modID,1);
        } else {
            objOverlay.style.backgroundColor='#fff';
            objOverlay.style.display = 'block';
            lbg.fadeInit('lbgOverlay_'+modID,0.40);
        }
        
        // Clearing ads on parent page
        if (adsDivs.length > -1) {
            for (i = 0; i < adsDivs.length; i++) {
                adsClrAd(adsDivs[i]);
            }
        }
    
        
        lbg.omniture(2,'next');
    },
    
    navigate: function(nav,navA,galID,galType,template,slot) {
        date = new Date();
        ts = date.getTime();
        // ajax call
        if (lbgDyna != true){ 
            var modReqURL = "/mod.adp?_mo=1&_miid=" + lbgModID + "&lbgIndex=" + nav + "&lbgReq=1";
        } else {
            lbgGalID = galID;
            lbgGalType = galType;
            lbgGalTemplate = template;
            lbgGalSlot = slot;
        
            var modReqURL = "/common/photogallery/dpResponse.xml?lbgal=true&id=" + galID + "&index=" + nav +"&galType="+galType+"&galTemplate="+lbgGalTemplate+"&galSlot="+lbgGalSlot+"&articleId="+lbgArticleId+"&para="+lbgPara+"&order="+lbgOrder;   
        }
        
        AJAXmakeReq(modReqURL,LB_callback,"lbgL_"+lbgModID);
        lbg.adCall(); 
        lbg.omniture(nav,navA);
    },

    omniture: function(ind,nav) {

        var d = document;
        var l = d.location.toString();
        var g='', c='', a='';
        
        if ((window['mod_'+lbgModID+'galleryID']) != '') {
            g = (window['mod_'+lbgModID+'galleryID']);
            g = 'id='+g;
        }

        if ((lbgDyna == true) && (lbgGalID != "") && (lbgGalID != "undefined")){ 
            g = lbgGalID;
            g = 'id='+g;
        }
        
        var index = '&index='+ind;
        var navA = "&navAction="+nav;

        if ((window['mod_'+lbgModID+'s_channel']) != '') {
            var c = (window['mod_'+lbgModID+'s_channel']);
            c = '&mmx='+c;
        }
        
        if ((window['mod_'+lbgModID+'s_account']) != '') {
            var a = (window['mod_'+lbgModID+'s_account']);
            a = '&s_account='+a;
        }

        l = l.replace('http://','');
        l = l.substr(0, l.indexOf('/'));
        
        if (lbgDyna != true){ 
            l = 'http://' + l + '/common/photogallery/omniture.adp?';
        } else {
            l = 'http://' + l + '/common/photogallery/dpOmniture.adp?';
        }
        
        l = l + g + index;
        l = l + '&feedtype=news';
        l = l + navA;
        l = l + '&debug=0';
        l = l + c;
        l = l + '&ts='+ts;
        l = l + a;

        var ifr = "";
        if(d.getElementById('lbgOmniIframe'+lbgModID)) {
             ifr = d.getElementById('lbgOmniIframe'+lbgModID);
        } else {
             ifr = d.createElement('iframe');
             ifr.setAttribute('id','lbgOmniIframe'+lbgModID);
             ifr.width=0;
             ifr.height = 0;
             ifr.border = 0;
             ifr.style.visibility = 'hidden';
             var objLBGChild = d.getElementById("lbgChild_"+lbgModID);
            objLBGChild.appendChild(ifr);
        } 
        ifr.src = l;
    },

    close: function() {
        var d = document;
        var objBody= d.getElementsByTagName("BODY").item(0);
        var objOverlay = d.getElementById('lbgOverlay_'+lbgModID);
        var objLBGChild = d.getElementById('lbgChild_'+lbgModID);
        var lbgIframeAd = d.getElementById("lbgIframe_"+lbgModID);
        objOverlay.style.display = 'none';
        objLBGChild.style.visibility = 'hidden';
        objLBGChild.style.left= "-2000px";
        objBody.className = "lbgOff";
        
        showSelectBoxes();
        showFlash();
        
        // make new ad calls to the ads on the parent page
        adsReloadAll();
        
        lbgIframeAd.src = "";
        lbgModID = "";
        lbgGalID = "";

    },

    getObjHeight: function(obj) {
        var boxHeight = document.getElementById(obj).offsetHeight;
        lbg.setShadowHeight(boxHeight);
    },

    setShadowHeight: function(objHeight) {
        var lbgDSLt = document.getElementById("lbgDSLtL_"+lbgModID);
        var lbgDSRt = document.getElementById("lbgDSRt_"+lbgModID);

        lbgDSLt.style.height= objHeight+"px";
        lbgDSRt.style.height= objHeight+"px";
    },
    
    fadeInit: function(obj,opLvl) {
        lbgobjO = document.getElementById(obj);
        lbgobjO.xOpacity = 0;
        lbg.setOpacity(lbgobjO);
        lbgobjO.style.display = "block";
        setTimeout(function(){lbg.fade(lbgobjO,opLvl)},1);
    },

    fade: function(objO,opLvl) {
        var d = document;
        cOpacity = objO.xOpacity;
        nOpacity = objO.xOpacity;
        nOpacity+=.25; //how much increase per cycle
        objO.xOpacity = nOpacity;
    
        lbg.setOpacity(objO);
    
        if((objO.id == "lbgChild_"+lbgModID) && (cOpacity>=opLvl)) {
            lbg.adCall();
        } else if(cOpacity<=opLvl) { 
            setTimeout(function(){lbg.fade(objO,opLvl)},1);
        } else if ((objO.id != "lbgChild_"+lbgModID) && !is_IE) {
            var objLBGChild = d.getElementById("lbgChild_"+lbgModID);
            objLBGChild.style.visibility = 'visible';
            lbg.fadeInit("lbgChild_"+lbgModID,1);
        } else if ((objO.id != "lbgChild_"+lbgModID) && is_IE) {
            var objLBGChild = d.getElementById("lbgChild_"+lbgModID);
            objLBGChild.style.visibility = 'visible';
            objLBGChild.style.display = 'block';
            lbg.adCall();
        } 
    },
    
    setOpacity: function(objO) {      
        objO.style.opacity = objO.xOpacity;
        objO.style.MozOpacity = objO.xOpacity;
        objO.style.filter = "alpha(opacity=" + (objO.xOpacity*100) + ")";
    },
    
    adCall: function() {
        var d = document;
        var lbgIframeAd = d.getElementById("lbgIframe_"+lbgModID);
        var adURL = "/common/photogallery/ad_page.html?debug=0&magicnumber="+lbgMn+"&ts="+ts;
        lbgIframeAd.src = adURL;
    }
}
function showSelectBoxes(){
    var selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
        selects[i].style.visibility = "visible";
    }
}
function hideSelectBoxes(){
    var selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
        selects[i].style.visibility = "hidden";
    }
}
function showFlash(){
    var flashObjects = document.getElementsByTagName("object");
    for (i = 0; i < flashObjects.length; i++) {
        flashObjects[i].style.visibility = "visible";
    }
    var flashEmbeds = document.getElementsByTagName("embed");
    for (i = 0; i < flashEmbeds.length; i++) {
        flashEmbeds[i].style.visibility = "visible";
    }
}
function hideFlash(){
    var flashObjects = document.getElementsByTagName("object");
    for (i = 0; i < flashObjects.length; i++) {
        flashObjects[i].style.visibility = "hidden";
    }
    var flashEmbeds = document.getElementsByTagName("embed");
    for (i = 0; i < flashEmbeds.length; i++) {
        flashEmbeds[i].style.visibility = "hidden";
    }
}

// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
function getPageScroll(){
    var d = document;
    var xScroll, yScroll;

    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
        xScroll = self.pageXOffset;
    } else if (d.documentElement && d.documentElement.scrollTop){    // Explorer 6 Strict
        yScroll = d.documentElement.scrollTop;
        xScroll = d.documentElement.scrollLeft;
    } else if (d.body) {// all other Explorers
        yScroll = d.body.scrollTop;
        xScroll = d.body.scrollLeft;    
    }

    arrayPageScroll = new Array(xScroll,yScroll) 
    return arrayPageScroll;
}

function getPageSize(){
    var d = document;
    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {  
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (d.body.scrollHeight > d.body.offsetHeight){ // all but Explorer Mac
        xScroll = d.body.scrollWidth;
        yScroll = d.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = d.body.offsetWidth;
        yScroll = d.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;

    if (self.innerHeight) { // all except Explorer
        if(d.documentElement.clientWidth){
            windowWidth = d.documentElement.clientWidth; 
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else if (d.documentElement && d.documentElement.clientHeight) { 
        windowWidth = d.documentElement.clientWidth;
        windowHeight = d.documentElement.clientHeight;
    } else if (d.body) { // other Explorers
        windowWidth = d.body.clientWidth;
        windowHeight = d.body.clientHeight;
    }   
    
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else { 
        pageHeight = yScroll;
    }

    if(xScroll < windowWidth){  
        pageWidth = xScroll;        
    } else {
        pageWidth = windowWidth;
    }

    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
    return arrayPageSize;
}

// End Light Box Gallery

// THIS DOES THE AJAX REQUEST 
var ajax_req = false;

function makeReq(url,outputHere) {
    ajax_req = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        ajax_req = new XMLHttpRequest();
        if (ajax_req.overrideMimeType) {
            ajax_req.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            ajax_req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            ajax_req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!ajax_req) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    ajax_req.onreadystatechange = outputReq;
    ajax_req.open('GET', url, true);
    ajax_req.send(null);

    function outputReq() {
        try {
            if (ajax_req.readyState == 4) {
                if (ajax_req.status == 200) {
                    var responce = ajax_req.responseText;
                    var outputDiv = document.getElementById(outputHere);
                    outputDiv.innerHTML = responce;
                } else {
                    alert('There was a problem with the request.');
                }
            }
        }
        catch( e ) {
            alert('Caught Exception: ' + e.description);
        }
    }
}

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}



//begin submit while you type code
//Filter Code Starts             
var filter = {
    timer: null,
    chkTimer_fnRef: null,
    timeOutTime: 100,
    
    baseUrl: null,
    targetId: null,
    searchTermId: null,
    searchTermParam: null,
    
    clicker: function(base, target, searchField, searchParam) {
        this.timer = 200;   
        this.baseUrl = base;
        this.targetId = target;
        this.searchTermId = searchField;
        this.searchTermParam = searchParam;
        
        if ('undefined' != typeof(this.chkTimer_fnRef)) {
            window.clearTimeout(this.chkTimer_fnRef);
        }            
        this.chkTimer_fnRef = window.setTimeout('filter.chkTimer()', this.timeOutTime);
    },
    
    chkTimer: function() {
        if ('undefined' != typeof(this.searchTermId)) {
        
            var qryObjId = document.getElementById(this.searchTermId);          
            if (0 < this.timer) {
                this.timer = this.timer - 50;
                if (qryObjId != '') {
                    this.chkTimer_fnRef = window.setTimeout('filter.chkTimer()', this.timeOutTime);
                }
                return;
            }
            if (this.timer == 0) {              
                this.getGameAssetResult();
            }
        
        }
    },
    
    getGameAssetResult: function() {
        if (('undefined' != typeof(this.searchTermId)) && ('undefined' != typeof(this.baseUrl)) && ('undefined' != typeof(this.searchTermParam)) && ('undefined' != typeof(this.targetId))) {
            var gameAssetSrchQry = document.getElementById(this.searchTermId).value;
            document.getElementById(this.targetId).src = this.baseUrl + "&" + this.searchTermParam + "=" + gameAssetSrchQry;
            adRefresh();
        }
    }

};
//Filter Code Ends
// end submit while you type code
    

// THIS BLOCK IS FOR THE BROWSE GAMES TABBED MOD 
function gameIndexSet(pID){ //ADDS ONCLICK TO DISPLAY TABS
    if (document.getElementById("gameIndexTbs"+pID)) {
        var objA = document.getElementById("gameIndexTbs"+pID).getElementsByTagName("A");
        var i = objA.length; 
        while(i-->0) {   // LOOP THROUGH THE A's
            objA[i].onclick = function() {gameIndexGet(this.id,pID); updateMmx('top games'); return false;} // ADD ONCLICK FUNCTION
        }
    }
}

function gameIndexGet(obj,pID) {
    if (document.getElementById("gameIndexTbs"+pID)) {
        var objOn = document.getElementById(obj);
        var objA = document.getElementById("gameIndexTbs"+pID).getElementsByTagName("A");
        var i = objA.length; 
        while(i-->0) {   // LOOP THROUGH THE A's
            objA[i].className = "off"; // turn off tabs
        }
        objOn.className = "active"; // turn on tab
        
        var modReqURL = "/mod.adp?_mo=1&_miid=" + obj;
        var CntD = "gameIndexCntD" + pID;
        makeReq(modReqURL,CntD);
    }
}
// THIS ENDS THE BLOCK FOR THE BROWSE GAMES TABBED MOD 



function getElementByClass(classname){
    var partscollect=new Array();
    var inc=0;
    var alltags=document.all? document.all.tags("DIV") : document.getElementsByTagName("*");
    for (i=0; i<alltags.length; i++){
        if (alltags[i].className==classname) { partscollect[inc++]=alltags[i];}
    }
    return partscollect;
}

/*function navigateGallery(gal, galLbl, dir, imgs) {
    var max = imgs.length;
    var gallery = document.getElementById(gal);
    var galleryLabel = document.getElementById(galLbl);
    var index = galleryLabel.innerHTML;

    if ((dir == 'prev') && (index != 1)) {index--;}
    else if ((dir == 'next') && (index != max)) {index++;}
    
    gallery.src = imgs[(index-1)];
    galleryLabel.innerHTML = index;

    if (index > 1) {
        gallery.setAttribute('class','alt'); // FF & Safari
        gallery.className = 'alt'; // IE
    } else {
        gallery.setAttribute('class',''); // FF & Safari
        gallery.className = ''; // IE
    }
}*/

function toggleText(mode,txtDivName,txtType,shortTxtName,fullTxtName){
    var txtDiv = eval(txtDivName);
    if (mode == 'hide') {
        var shortTxt = eval(shortTxtName);
        txtDiv.innerHTML = shortTxt + "... <a href=\"javascript:void(0)\" onclick=\"toggleText('show','"+txtDivName+"','"+txtType+"','"+shortTxtName+"','"+fullTxtName+"');\" return false;\">Read Full Game "+ txtType + " &rsaquo;</a>";
    } else if (mode == 'show') {
        var fullTxt = eval(fullTxtName);
        txtDiv.innerHTML = fullTxt + " <a href=\"javascript:void(0)\" onclick=\"toggleText('hide','"+txtDivName+"','"+txtType+"','"+shortTxtName+"','"+fullTxtName+"');\" return false;\">&lsaquo; Hide Full Game " + txtType +"</a>";
    }
}

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft,curtop];
}

function toggleToolTip(mode, linkObj, ttObj, xOffset, yOffset, yPos){
 var x = 15;
 var y = 15;
 var ie=document.compatMode && document.all;
 if ((xOffset != undefined) && (typeof(xOffset) == "number")) {x = xOffset;}
 if ((yOffset != undefined) && (typeof(yOffset) == "number")) {y = yOffset;}
 var to = document.getElementById(ttObj); 
 if (mode == 'show') {
      var coors = findPos(linkObj);        
      to.style.display = '';  
  if (yPos=='above') {
   to.style.top = coors[1] + y - to.offsetHeight + 'px';
  }
  else {
   to.style.top = coors[1] + y + 'px';
  }
  if(!ie){
   to.style.left =coors[0]+ x + 'px';
  }
  else if(navigator.appVersion.indexOf("MSIE 7") !=-1){
   if(ttObj=='tooltip_sysreqs_online')
   {
    to.style.left =coors[0] - 10 + x + 'px'; to.style.top = coors[1] + 16 + x + 'px';
   }
   else if(ttObj=='tooltip_prntrating')
   {
     to.style.left =coors[0] - 135 + x + 'px'; to.style.top = coors[1] + x + 'px';
   }
   else{
    to.style.left =coors[0] - 10 + x + 'px';
   }
  }
  else{
   if(ttObj=='tooltip_prntrating')
   {
    to.style.left =coors[0] - 135 + x + 'px'; to.style.top = coors[1] - 10 + x + 'px';
   }
   else if(ttObj=='tooltip_sysreqs_online')
   {
    to.style.left =coors[0] - 10 + x + 'px'; to.style.top = coors[1] + 6 + x + 'px';
   }
   else if(ttObj=='tooltip_esrb')
   {
    to.style.left =coors[0] - 10 + x + 'px'; to.style.top = coors[1] - 8 + x + 'px';
   }
   else{
    to.style.left =coors[0] - 10 + x + 'px';
   }
     
  }
 }
 else if (mode == 'hide') {
  to.style.display = 'none';
 }
}


function iterateHover(mode, curNum, selectedNum, linkId) {
    for (var n=1; n <= selectedNum; n++) {
        var linkObj= document.getElementById(linkId+n);
        var c;
        if (mode == 'over') {
            c = 'over';
        } else if (mode == 'out') {
            (n <= curNum) ? (c = 'on') : (c = 'off')
        }
        linkObj.setAttribute('class',c); // FF & Safari
        linkObj.className = c; // IE
    } 
}

function submitValue(msg, screenName, formName, paramName, paramValue) {
    if ((screenName != '') && (screenName != 'null') && (screenName !== null)) {
        alert(msg);
        if (paramValue != '') {
            eval('document.' + formName + '.' + paramName + '.value=' + paramValue);
        }
        eval('document.' + formName + '.submit()');
    } else { 
        alert('Please sign in.');
    }
}

function switchTab(moduleType, numTabs, activeTabNum, numSubTabs, activeSubTabNum) {
    
    //deactivate other tab(s)
    for (var i=1; i<numTabs; i++) {
        var otherTabnum = (activeTabNum + i) % numTabs;
        if (otherTabnum == 0) { otherTabnum = numTabs; }
        var otherTab = document.getElementById(moduleType+'_tab'+otherTabnum);
        var otherTabclassName = otherTab.className;
        otherTabclassName = otherTabclassName.replace(/active/gi, ' ');
        otherTab.className = otherTabclassName;
        document.getElementById(moduleType+'_tabcontent'+otherTabnum).style.display = 'none';
    }

    //activate selected tab
    var activeTab = document.getElementById(moduleType+'_tab'+activeTabNum);
    var activeTabclassName = activeTab.className;
    activeTabclassName = activeTabclassName.replace(/active/gi, '');
    activeTabclassName = activeTabclassName + ' active';
    activeTab.className = activeTabclassName;
    document.getElementById(moduleType+'_tabcontent'+activeTabNum).style.display = '';

    // check for subtabs
    if (numSubTabs) {
        //deactivate other subtab(s)
        for (var i=1; i<numSubTabs; i++) {
            var otherSubTabnum = (activeSubTabNum + i) % numSubTabs;
            if (otherSubTabnum == 0) { otherSubTabnum = numSubTabs; }
            var otherSubTab = document.getElementById(moduleType+'_tab'+activeTabNum+'_sub'+otherSubTabnum);
            var otherSubTabclassName = otherSubTab.className;
            otherSubTabclassName = otherSubTabclassName.replace(/active/gi, '');
            otherSubTab.className = otherSubTabclassName;
            document.getElementById(moduleType+'_tabcontent'+activeTabNum+'_sub'+otherSubTabnum).style.display = 'none';
        }

        //activate selected subtab
        var activeSubTab = document.getElementById(moduleType+'_tab'+activeTabNum+'_sub'+activeSubTabNum);
        var activeSubTabclassName = activeSubTab.className;
        activeSubTabclassName = activeSubTabclassName.replace(/active/gi, '');
        activeSubTabclassName = activeSubTabclassName + ' active';
        activeSubTab.className = activeSubTabclassName;
        document.getElementById(moduleType+'_tabcontent'+activeTabNum+'_sub'+activeSubTabNum).style.display = '';
    }
}


function switchTabs(moduleType, numTabs, activeTabNum, numSubTabs, activeSubTabNum) {
    
    //deactivate other tab(s)
    for (var i=1; i<numTabs; i++) {
        var otherTabnum = (activeTabNum + i) % numTabs;
        if (otherTabnum == 0) { otherTabnum = numTabs; }
        var otherTab = document.getElementById(moduleType+'_tab'+otherTabnum);
        var otherTabclassName = otherTab.className;
        otherTabclassName = otherTabclassName.replace(/_active/gi, '');
        otherTab.className = otherTabclassName;
        document.getElementById(moduleType+'_tabcontent'+otherTabnum).style.display = 'none';
    }

    //activate selected tab
    var activeTab = document.getElementById(moduleType+'_tab'+activeTabNum);
    var activeTabclassName = activeTab.className;
    activeTabclassName = activeTabclassName.replace(/_active/gi, '');
    activeTabclassName = activeTabclassName + '_active';
    activeTab.className = activeTabclassName;
    document.getElementById(moduleType+'_tabcontent'+activeTabNum).style.display = '';

}



function bookmarkPage(url,title) {
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url,"");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite( url, title);
    } else if(window.opera && window.print) { // Opera Hotlist
        return true; 
    }
}

function mailForm(formName, to, subject, fieldLabels, fieldIds, url, misc) {
    eval('var oForm = document.forms.'+ formName);
    
    eval('var ids = new Array' + fieldIds); 
    eval('var labels = new Array' + fieldLabels); 

    var msg = 'URL: ' + url + '%0D%0D';
    for (var i=0; i < ids.length; i++) {
        var id = ids[i];
        var label = labels[i];
        msg += label + ': ';
        eval('msg += escape(oForm.'+id+'.value)');
        msg += '%0D%0D'
    }
    msg += misc;
    
    var strMailto = "mailto:";
    strMailto += to + "?";
    strMailto += "subject=" + escape(subject);
    strMailto += "&body=" + msg;
    
    document.location.href = strMailto;
}


function checkMaxLength(textareaObj) {
    // Check if we have words longer than maxLongChar chars and break them up
    var maxLongChar = 68; //NOTE: Must be an even number
    var objText = textareaObj.value;
    var regStrLength = new RegExp("([^\\s]{"+maxLongChar+"})", "i");
    var ar = regStrLength.exec(objText);
    if (ar) {
        var longWord = textareaObj.value.substring(ar.index,ar.index+maxLongChar+1);
        var halfWordLength = maxLongChar / 2;
        var firstHalf = longWord.substring(0,halfWordLength-1);
        var lastHalf = longWord.substring(halfWordLength-1,maxLongChar-1);
        var newWord = firstHalf + "- " + lastHalf;
        objText = objText.replace(longWord,newWord);
        textareaObj.value = objText;
    }

    // Enforce textarea maxLength
    var maxLength = textareaObj.getAttribute('maxlength');
    var currentLength = textareaObj.value.length;
    if (currentLength > maxLength)
        textareaObj.value=textareaObj.value.substring(0,maxLength)

    // Update counter object content with current character count
    var counter = document.getElementById(textareaObj.getAttribute('counter'));
    counter.firstChild.nodeValue = currentLength + '/' + maxLength;
}





function updateMmx(type) {
    var title = s_265.pageName;
    if ((type != undefined) && (type.length > 0)) {title += ' : ' + type;}
    var d = new Date();
    var cbts = d.getTime(); //cache busting timestamp
    var trackingUrl = 'http://' + location.host + '/mm_track/' + escape(s_265.prop1) + '/' + escape(s_265.prop2) + '/?title=' + escape(title) +'&omni=1&cbts=' + cbts;
    document.getElementById('mmx').src = trackingUrl;
}


// cott.init OVERRIDE
cott.init = function() {
        var topLink = document.getElementById("toplink");
        var links = topLink.getElementsByTagName("A");
        cott.maxLink = links.length;
        if (links.length == 0) { return; }
        for(var i=0;i<links.length;i++) {
            links[i].style.background = 'url(http://www.aolcdn.com/ch_games/games-sprite28.png) 0 -282px no-repeat';
            links[i].style.zoom = 1;
            if (i>0) { links[i].style.display = 'none'; }
        }
        setTimeout("cott.rotateLink(2)", cott.timeout); 
    };


function checkReqs(requiresJS, requiresIE, requiresJava, requiresFlash) {
    var failedArr = new Array(requiresJS,requiresIE,requiresJava,requiresFlash);

    if (requiresJS) {
        // JS is obviously working if we got here
        failedArr[0] = 0;
    }

    if (requiresIE) {
        if (navigator.appName=="Microsoft Internet Explorer") {
            failedArr[1] = 0;
        }
    }

    if (requiresJava) {
        if (navigator.javaEnabled()) { failedArr[2] = 0; }
    }

    if (requiresFlash) {
        var flashCanPlay = 0;
        if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) {
            if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
                flashCanPlay = 1;
            }
        } else {
            try {
                var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
                if (ax) { flashCanPlay = 1; }
            } catch(e) {}
        }
        if (flashCanPlay) { failedArr[3]=0; }
    }

    return failedArr;
}

function toggleListItem(itemId, valueId) {
    var i = document.getElementById(itemId);
    var v = document.getElementById(valueId);
    if (i.className == 'open') {
        i.className = 'close';
        v.style.display = 'none';
    } else {
        i.className = 'open';
        v.style.display = '';
    }
}



/**
 * Utility Panel Object
 **/
var upanel = {
   sendAim: function (pageurl){
    // need hyperlink
    // var _message = "Check out &lt\;a href=\"http:\/\/music.aol.com\/artist\/\"" + artist + "\/" + aolId + "\"&gt\;" + artist + ":  http:\/\/music.aol.com\/artist\/" + artist + "\/" + aolId + "&lt\;\/a&gt\;";
    var _message = "Check out " + pageurl;
    window.location = 'aim:GoIm?message=' + _message;
    },
    
    
    /** * Aol Bookmarks */
   myAol: function() {
   
     var url = "http://favorites.my.aol.com/ffclient/AddBookmark?"; 
     url += "title=" + encodeURIComponent(document.title) + "&"; 
     url += "url=" + encodeURIComponent(location.href) + "&"; 
     url += "favelet=true"; 
     var _706 = "scrollbars=0,resizable=1,width=756,height=661,directories=0,menubar=0,location=0,status=0,toolbar=0"; 
     var _707 = (new Date).getTime(); 
     open(url, "addAolBookmark" + _707, _706); 
     setTimeout("window.blur();", 0);
   
   }, 

 
    shareMail: function(formName, toFieldName, msgFieldName, defaultTo, subject, url) {
    var bolSend = true;
    eval('var oShareForm = document.forms.'+ formName);
    eval('var shToEmail = oShareForm.' + toFieldName + '.value');
    if ( (shToEmail == '') || (shToEmail == defaultTo) ) {
        alert("Please enter a destination email address.");
        eval('oShareForm.'+ toFieldName + '.focus()');
        bolSend = false;
    }
    
    eval('var shMsg = oShareForm.'+msgFieldName+'.value');
    
    var strMailto = "mailto:";
    strMailto += shToEmail + "?";
    
    strMailto += "subject=" + escape(subject);
    strMailto += "&body=" + escape(url) + "%0D%0D" + escape(shMsg);
    
    if (bolSend) { document.location.href = strMailto; }
    }
        
};

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

