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;
var is_IE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -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) {}


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

//******************************************************************
// Begin: AD REFRESH (http://cdn.channel.aol.com/_media/channels/ad_refresher.js)

// Create and instantiate the class only if not already created:
try {
if(top.channels_refresher == null) {

    // channels_refresher constructor:
     top.channels_refresher = function() {
        this.add_impression.domains = new Object();
        this.ads_list = new Array();
        var body = top.document.body;
        var inner_elem = body;
        while((inner_elem = inner_elem.lastChild).tagName.toLowerCase() != "script");
        var container_elem = inner_elem.parentNode;
        while(container_elem.tagName.toLowerCase() != "div" 
                            && container_elem.tagName.toLowerCase() != "body") {
            container_elem = inner_elem.parentNode;
        }
        this.container = container_elem;
    }
    
    top.channels_refresher.prototype = {
        /** 
         * add_ad
         * @param index - ZERO-BASED number indicating the declared order of the ad.
         * @param id    - Magic Number of the ad
         * @param w     - width of the ad in pixels
         * @param h     - height of the ad in pixels
         * @param s     - spot of the ad in string (e.g. 300x250_2)
         *        Special values: 0 (Default) - always refresh, -1 - do not refresh
         */
        add_ad:function(id, w, h, index, s) {
            if(s == null) {
                s = 0;
            }
            if(index == null) {
                this.ads_list.push({id:id, width:w, height:h, spot:s});
            } else {
                this.ads_list[index] = {id:id, width:w, height:h, spot:s};
            }
        },
        
        // add_impression
        add_impression:function(url) {
            var domains = this.add_impression.domains;
            var make_sequential_name = function(name) {
                if(domains[name] == null) {
                    domains[name] = true;
                    return name;
                } else {
                    var seq = 0;
                    var _name = name + "_" + (++seq);
                    while(domains[_name] != null) {
                        _name = name + "_" + (++seq);
                    }
                    domains[_name] = true;
                    return _name;
                }
            }
            if(url != null && url.length) {
                var frame_name = make_sequential_name("frame_" + new Date().getTime());
                var i_frame = top.document.createElement("iframe");
                i_frame.id = frame_name;
                i_frame.width = 1;
                i_frame.height = 1;
                i_frame.style.position = "absolute";
                i_frame.style.top = "-10px";
                i_frame.style.left = "-10px";
                i_frame.style.visibility = "hidden";
                i_frame.src = url;
                this.container.appendChild(i_frame);
                return frame_name;
            }
        },
        
        // add_url
        add_url:function(f_name, url) {
            //  If the target_frames object is null, create it:
            if(!this.target_frames) this.target_frames = new Object();
            //  If this frame name has not been used before, then...
            if(!this.target_frames[f_name]) {
                //  Create a new frame repository:
                this.target_frames[f_name] = new Object();
                //  Create a new list for frame urls:
                this.target_frames[f_name].urls = new Array();
                //  Create a default index of zero for this frame:
                this.target_frames[f_name].current_index = 0;
            }
            //  Add the url to the frame's url list:
            if(url && url.length) this.target_frames[f_name].urls.push(url);
        },
        
        // refresh_ads
        refresh_ads:function() {    
                adsReloadIframeAll();
        },
        
        // refresh_ad
        refresh_ad:function(index) {
            if(this.ads_list[index] != null) {
                try {
                        adsReloadIframe('adsF'+i);
                } catch(e) {}
            }
        },
        
        // refresh_ads_string
        refresh_ads_string:function(str) {
            var ads = str.split(",");
            for(var i = 0; i < ads.length; i++) {
                var index = parseInt(ads[i]);
                if(!isNaN(index) && index >= 0 && index < this.ads_list.length) {
                    this.refresh_ad(index);
                }
            }
        },
        
        // refresh_ads_by_spot
        refresh_ads_by_spot:function(str) {
            if (str == '-1') return;
            var spots = new Array();
            if (str == null || str == 'undefined' || str == '0') {
                for(var i = 0; i < this.ads_list.length; i++) {
                    spots.push(this.ads_list[i].spot);
                }
            } else {
                spots = str.split(",");
            }
            spots = spots.sort();
            var oldVar = '';
            for(var i = 0; i < spots.length; i++) {
                var spot = spots[i];
                if (oldVar == spot) break;
                oldVar = spot;
                for(var j = 0; j < this.ads_list.length; j++) {
                    if (spot == this.ads_list[j].spot) {
                        this.refresh_ad(j);
                        break;
                    }
                }
            }
        },

        // refresh_all
        refresh_all:function() {
            //  Loop through the ads and refresh them:
            this.refresh_ads();
            //  If there are target_frames:
            this.refresh_frames();
        },
        
        // refresh_all
        refresh_frames:function() {
            if(this.target_frames) {
                for(var f in this.target_frames) {
                    var frame = this.target_frames[f];
                    var i_frame = top.document.getElementById(f);
                    if(frame.urls.length) {
                        var url = frame.urls[frame.current_index++];
                        if(frame.current_index >= frame.urls.length) frame.current_index = 0;
                        this.refresh_frame(f, url); 
                    }
                }
            }
        },
        
        // refresh_frame
        refresh_frame:function(f_name, url) {
            if(url != null && url.length) {
                var elem = (top.frames[f_name] 
                        || top.document.getElementById(f_name).contentWindow 
                        || top.document.getElementById(f_name));
                try {
                    if(elem.location) {
                        if((url == elem.location.href) && elem.location.reload) {
                            elem.location.reload(true);
                        } else {
                            elem.location.href = url;
                        }
                    } else {
                        elem.src = url;
                    }
                    
                } catch(e) {}
            }
        }
    
    }
    
    // Instantiate the default refresher
    window.ch_refresher = new channels_refresher();
}
} catch(e) {}

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

// End: AD REFRESH
//******************************************************************

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

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

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

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

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 navigateGallery(moduleId, numItems, direction) {
    var galleryItemNumberObject = document.getElementById(moduleId+'GalleryItemNumber');
    var activeItemNum = galleryItemNumberObject.innerHTML;
    
    if ((direction == 'prev') && (activeItemNum != 1)) {activeItemNum--;}
    else if ((direction == 'prev') && (activeItemNum == 1)) {activeItemNum = numItems;}
    else if ((direction == 'next') && (activeItemNum != numItems)) {activeItemNum++;}
    else if ((direction == 'next') && (activeItemNum == numItems)) {activeItemNum = 1;}
    
    galleryItemNumberObject.innerHTML = activeItemNum;
    
    //deactivate other gallery item(s)
    for (var i=1; i<numItems; i++) {
        var otherItemNum = (activeItemNum + i) % numItems;
        if (otherItemNum == 0) { otherItemNum = numItems; }
        document.getElementById(moduleId+'GalleryItem'+otherItemNum).style.display = 'none';
    }

    //activate selected gallery item
    document.getElementById(moduleId+'GalleryItem'+activeItemNum).style.display = '';
}


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 isOnScreen(obj) {
    var isOnScreen = false;
    var objCoors = findPos(obj);
    var objX = objCoors[0];
    var objY = objCoors[1];
    var screenCoors = getPageScroll();
    var screenX = screenCoors[0];
    var screenY= screenCoors[1];
    var pageSize = getPageSize();
    var pageW = pageSize[0];
    var pageH = pageSize[1];
    
    if ((objX >= screenX) && (objX <= screenX + pageW)  && (objY >= screenY) && (objY <= screenY + pageH) ) { isOnScreen = true;}
    
    return isOnScreen;
}

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(moduleId, numTabs, activeTabNum, numSubTabs, activeSubTabNum, skipTabContent) {
    
    //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(moduleId+'_tab'+otherTabnum);
        var otherTabClassName = otherTab.className;
        otherTabClassName = otherTabClassName.replace(/active/gi, '');
        otherTab.className = otherTabClassName;
        if (!skipTabContent) document.getElementById(moduleId+'_tabcontent'+otherTabnum).style.display = 'none';
    }

    //activate selected tab
    var activeTab = document.getElementById(moduleId+'_tab'+activeTabNum);
    var activeTabClassName = activeTab.className;
    activeTabClassName = activeTabClassName.replace(/active/gi, '');
    activeTabClassName = activeTabClassName + ' active';
    activeTab.className = activeTabClassName;
    if (!skipTabContent) document.getElementById(moduleId+'_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;
            if (!skipTabContent) 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;
        if (!skipTabContent) 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;
}

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

/**
 * Dynamic Iframe Resizing
 **/
    var fnCalDiv = {
        iframes: {},
        oldchgHeight: null,
        ready: false,
        size: [-1,-1],
        intCount: 0,
        // Calculate size 
        calSize: function(d) {
            var w=200, h=200, scr_h, off_h;
            if( d.height ) { return [d.width,d.height]; }
            with( d.body ) {
                if( scrollHeight ) { h=scr_h=scrollHeight; w=scrollWidth; }
                if( offsetHeight ) { h=off_h=offsetHeight; w=offsetWidth; }
                if( scr_h && off_h ) h=Math.max(scr_h, off_h);
            }
            
            return [w,h];
            
        },
        
        onchgHeight: function() {
            // Invoke any previously installed onchgHeight handler.
            if( typeof this.oldchgHeight == 'function' ) { this.oldchgHeight(); }
            // Check if the document dimensions really changed.
            var size = this.calSize(document);
            if( this.size[0] == size[0] && this.size[1] == size[1] ) return;
            // Defer the chgHeight action to prevent endless loop in quirksmode.
            if( this.intCount ) return;
            this.intCount = setTimeout('fnCalDiv.delay_chgHeight();', 10);
        },
    
        delay_chgHeight: function() {
            // Walk the list of known iframe to see if they need to be chgHeightd.
            for( var el in this.iframes ) this.chgHeight(el);
            // Store resulting document dimensions.
            this.size = this.calSize(document);
            
            // Clear the timer flag.
            this.intCount = 0;
        },
    
        chgHeight: function(el) {
            // compatiple browser?
            if( !window.frames || !window.frames[el] || !document.getElementById || !document.body )
                return;
            var iframe = window.frames[el];
            var div = document.getElementById(el);
            if( !div ) return;
            if( !this.iframes[el] ) {
                this.iframes[el] = true;
            }
            if( !this.ready ) {
                this.ready = true;
                this.oldchgHeight = window.onchgHeight;
                window.onchgHeight = new Function('fnCalDiv.onchgHeight();');
            }
            // chgHeight the IFrame container
            var size = this.calSize(iframe.document);
            if( document.all ) {
              // for ie
              div.style.height = '0px';
              div.style.height = (size[1]+20) + 'px';
            } else {
              div.style.height = (size[1]+75) + 'px';
            } 
        }
    };   
    


/**
 * 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();
    }
  }
}

// // // DOM READY Function 

(function(){

    var DomReady = window.DomReady = {};

    // Everything that has to do with properly supporting our document ready event. Brought over from the most awesome jQuery. 

    var userAgent = navigator.userAgent.toLowerCase();

    // Figure out what browser is being used
    var browser = {
        version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
        safari: /webkit/.test(userAgent),
        opera: /opera/.test(userAgent),
        msie: (/msie/.test(userAgent)) && (!/opera/.test( userAgent )),
        mozilla: (/mozilla/.test(userAgent)) && (!/(compatible|webkit)/.test(userAgent))
    };    

    var readyBound = false; 
    var isReady = false;
    var readyList = [];

    // Handle when the DOM is ready
    function domReady() {
        // Make sure that the DOM is not already loaded
        if(!isReady) {
            // Remember that the DOM is ready
            isReady = true;
        
            if(readyList) {
                for(var fn = 0; fn < readyList.length; fn++) {
                    readyList[fn].call(window, []);
                }
            
                readyList = [];
            }
        }
    };

    // From Simon Willison. A safe way to fire onload w/o screwing up everyone else.
    function addLoadEvent(func) {
      var oldonload = window.onload;
      if (typeof window.onload != 'function') {
        window.onload = func;
      } else {
        window.onload = function() {
          if (oldonload) {
            oldonload();
          }
          func();
        }
      }
    };

    // does the heavy work of working through the browsers idiosyncracies (let's call them that) to hook onload.
    function bindReady() {
        if(readyBound) {
            return;
        }
    
        readyBound = true;

        // Mozilla, Opera (see further below for it) and webkit nightlies currently support this event
        if (document.addEventListener && !browser.opera) {
            // Use the handy event callback
            document.addEventListener("DOMContentLoaded", domReady, false);
        }

        // If IE is used and is not in a frame
        // Continually check to see if the document is ready
        if (browser.msie && window == top) (function(){
            if (isReady) return;
            try {
                // If IE is used, use the trick by Diego Perini
                // http://javascript.nwbox.com/IEContentLoaded/
                document.documentElement.doScroll("left");
            } catch(error) {
                setTimeout(arguments.callee, 0);
                return;
            }
            // and execute any waiting functions
            domReady();
        })();

        if(browser.opera) {
            document.addEventListener( "DOMContentLoaded", function () {
                if (isReady) return;
                for (var i = 0; i < document.styleSheets.length; i++)
                    if (document.styleSheets[i].disabled) {
                        setTimeout( arguments.callee, 0 );
                        return;
                    }
                // and execute any waiting functions
                domReady();
            }, false);
        }

        if(browser.safari) {
            var numStyles;
            (function(){
                if (isReady) return;
                if (document.readyState != "loaded" && document.readyState != "complete") {
                    setTimeout( arguments.callee, 0 );
                    return;
                }
                if (numStyles === undefined) {
                    var links = document.getElementsByTagName("link");
                    for (var i=0; i < links.length; i++) {
                        if(links[i].getAttribute('rel') == 'stylesheet') {
                            numStyles++;
                        }
                    }
                    var styles = document.getElementsByTagName("style");
                    numStyles += styles.length;
                }
                if (document.styleSheets.length != numStyles) {
                    setTimeout( arguments.callee, 0 );
                    return;
                }
            
                // and execute any waiting functions
                domReady();
            })();
        }

        // A fallback to window.onload, that will always work
        addLoadEvent(domReady);
    };

    // This is the public function that people can use to hook up ready.
    DomReady.ready = function(fn, args) {
        // Attach the listeners
        bindReady();
    
        // If the DOM is already ready
        if (isReady) {
            // Execute the function immediately
            fn.call(window, []);
        } else {
            // Add the function to the wait list
            readyList.push( function() { return fn.call(window, []); } );
        }
    };
    
    bindReady();
    
})();


