/*------------------------------------------------------------------------------
| Copyright Notice: AOL Inc., 2010
| @(#)
| Description: AOL Games - JS [20110912.1]
|------------------------------------------------------------------------------*/

if( typeof gmJsObj == "undefined" ) { var gmJsObj = {}; }
if( typeof gmJsObj.header == "undefined" ) {  gmJsObj.header = {}; }
if( typeof gmJsObj.header.dropdown == "undefined" ) {  gmJsObj.header.dropdown = {}; }
	
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;
}


// 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 (numItems > 1) {
	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) + '&s_account='+ escape(s_265.account) + '&s_channel=' + escape(s_265.channel)+ '&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") {
		if ((is_ie) && (!is_ie6)) {
            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 = '';
    }
}

function setIframeHeight(iframeId) {
	var f = document.getElementById(iframeId);
	if (f.contentWindow.document && f.contentWindow.document.body.scrollHeight) {
		f.style.height = f.contentWindow.document.body.scrollHeight + 'px';
	} else if (f.contentDocument && f.contentDocument.body.offsetHeight) {
		f.style.height = f.contentDocument.body.offsetHeight + 'px'; 
	}
}

function getUrlAbsolute(url){
	var urlAbsolute = url;
	
	// check if url already has protocol
	var pattern1 = new RegExp("^((http)://).*$");
    if (!pattern1.test(url)) {
        urlAbsolute = "http://"+location.hostname+":"+location.port;
        
        // check if url already begins with a '/'
        var pattern2 = new RegExp("^(/).*$"); 
        if (!pattern2.test(url)) {
           urlAbsolute += "/";
        }
        
        urlAbsolute += url;
    }
    
    return urlAbsolute;
}

/**
 * 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();
    }
  }
}
 
// begin Header DropDown
gmJsObj.header.dropdown = {
    'parentContainer':"",
    'menuId': '',
    'menuSubClass': ''
};
gmJsObj.header.dropdown.init = function() {

    var newDiv = document.createElement('div');
    newDiv.setAttribute('id','allGenresMenu');
    newDiv.className = 'tooltip';
    newDiv.innerHTML = '<div class="body"><ul><li><a href="/browse-games/arcade-and-sports">Action</a></li><li><a href="/browse-games/arcade-and-sports">Arcade &amp; Sports</a></li><li><a href="/browse-games/card-and-board">Card &amp; Board</a></li><li><a href="/browse-games/free-casino">Free Casino</a></li><li><a href="/browse-games/facebook">Facebook</a></li></ul><ul><li><a href="/browse-games/time-management">Time Management</a></li><li><a href="/browse-games/word">Word</a></li><li><a href="/browse-games/puzzle">Puzzle</a></li><li><a href="/browse-games/puzzle/match-3">Match 3</a></li><li><a href="/browse-games/free-casino/poker/">Poker</a></li></ul><ul><li><a href="/browse-games/all/shooter/">Shooters</a></li><li><a href="/browse-games/all/solitaire">Solitaire</a></li><li><a href="/browse-games/puzzle/hidden-object/">Hidden Object</a></li></ul></div><div class="footer"><a href="/browse-games/">Browse All Genres</a></div>';
    
     newDiv.style.display = 'none';

    var header= document.getElementById('header');
     header.appendChild(newDiv);
         var allGenresMenu = $('#allGenresMenu');
         var headNavLinks = $("#header a[title*='All Genres']");
	 headNavLinks.css('background','url(http://o.aolcdn.com/casualgames/images/Main/1-downarrow.gif) right center no-repeat');
	 headNavLinks.css('paddingRight','8px');
	 headNavLinks.mouseover(function() { allGenresMenu.show(); gmDownloadMenu.hide(); });
	 allGenresMenu.mouseenter(function() { allGenresMenu.show(); gmDownloadMenu.hide(); });
	 allGenresMenu.mouseleave(function() { allGenresMenu.hide(); });


    var newDivMenuItemDownload = document.createElement('div');
    newDivMenuItemDownload.setAttribute('id','gmDownloadMenu');
    newDivMenuItemDownload.className = 'tooltip';
    newDivMenuItemDownload.innerHTML = '<div class="body"><ul><li><a href="http://download.games.com/t_01ac1/filter-casual/s1/DownloadableGames">PC Games</a></li><li><a href="http://download.games.com/t_01ac1/s6/MacGames">Mac Games</a></li><li><a href="http://download.games.com/t_01ac1/filter-core/s1/DownloadableGames">Video Games</a></li><li><a href="http://toolbar.aol.com/games/download.html" target="_blank">Toolbar</a></li></ul></div>';

    newDivMenuItemDownload.style.display = 'none';

    var header= document.getElementById('header');
     header.appendChild(newDivMenuItemDownload);
         var gmDownloadMenu = $('#gmDownloadMenu');
         var headNavDlLinks = $("#header a[title*='Downloads']");
	 headNavDlLinks.css('background','url(http://o.aolcdn.com/casualgames/images/Main/1-downarrow.gif) right center no-repeat');
	 headNavDlLinks.css('paddingRight','8px');
	 headNavDlLinks.mouseover(function() { gmDownloadMenu.show(); allGenresMenu.hide(); });
	 gmDownloadMenu.mouseenter(function() { gmDownloadMenu.show(); allGenresMenu.hide(); });
	 gmDownloadMenu.mouseleave(function() { gmDownloadMenu.hide(); });
         $('body').click(function() { allGenresMenu.hide(); gmDownloadMenu.hide();}); 
/* var header= document.getElementById('header');
    gmJsObj.header.dropdown.generate($(gmJsObj.header.dropdown.parentContainer), 
				     gmJsObj.header.dropdown.menuId, 
				     gmJsObj.header.dropdown.menuSubClass);
*/
};	
gmJsObj.header.dropdown.generate = function(parentContainer, menuId, menuSubClass) {
    $('<div/>', { 'id': menuId, 'class': 'tooltip', 'style': 'display:block;' }).appendTo(parentContainer);
    $('<div/>', { 'class': menuSubClass }).appendTo($('#'+menuId));
    $('<ul/>').appendTo($('#'+ menuId + ' .' + menuSubClass));
    
};


// end   Header DropDown   

/*------------------------------------------------------------------------------
| Copyright Notice:America Online, 2011
| @(#)
| Description:AOL Games - CSS [20110803.1]
|------------------------------------------------------------------------------*/

var GAMES = {};
GAMES.init = function () {
    /*
     * Main DL
     */
    if($('.dl-main ul').length > 0)
    {
	$('.dl-main ul').cycle({
	    fx: 	'scrollHorz',
	    speed:  400,
	    timeout: 5000,			
	    next:   '.dl-main .dl-controls .next',
	    prev:   '.dl-main .dl-controls .back'								
	});

	$('.dl-main .dl-controls .playback').click(function() 
						   {
						       if ($(this).hasClass('pause')) 
						       {
							   $('.dl-main ul').cycle('pause');
							   $(this).removeClass('pause').addClass('play');
						       }
						       else
						       {
							   $('.dl-main ul').cycle('resume');
							   $(this).removeClass('play').addClass('pause');
						       }
						       return false;
						   });			

	// Toggle slide description visibility
	$('.dl-main').hover(function()
			    {			
				$('.dl-description', this).slideDown(200);
			    }, 
			    function()
			    {
				$('.dl-description', this).slideUp(200, function(){
				    $(this).hide();				
				})
			    })

	$('.dl-main .dl-description').hide();		
    }// end Main DL
} // end GAMES.init

// set cookie handling 
GAMES.cookie = {
    'cookieName':"",
    'popupName':"",
    'buttonId':"",	
    'urlLocation':"",
    'popupDiv':"",
	'cookieTime':7,
    'cookieValue':'social media'
};
GAMES.cookie.init = function() {
	GAMES.cookie.bind();
};	

GAMES.cookie.handleCookie = function() {
        thisAnchorText=$(GAMES.cookie.buttonId).text();
        thisAnchorRel=$(GAMES.cookie.buttonId).attr('rel');
        if (thisAnchorText.toLowerCase().indexOf("all") >= 0) {		
            $(GAMES.cookie.buttonId).text('Click here if you just want to see '+thisAnchorRel+' updates');
	    GAMES.cookie.set(GAMES.cookie.cookieName,'',0);
	  }
	else 
	  {
            $(GAMES.cookie.buttonId).text('Click here if you just want to see all updates');
	    GAMES.cookie.set(GAMES.cookie.cookieName,thisAnchorRel,365);
	  }	
};

GAMES.cookie.bind = function() {
    $(GAMES.cookie.buttonId).click(function (event) {
		event.preventDefault();
		GAMES.cookie.handleCookie();
    });
};

GAMES.cookie.check = function(page) {
    if (page == 'home') {
	thisCookie=GAMES.cookie.get(GAMES.cookie.cookieName);
	if (thisCookie!=null && thisCookie!="") {	
	    top.location='http://blog.games.com/category/' + thisCookie.toLowerCase();
	}
        popupCookie=GAMES.cookie.get(GAMES.cookie.popupName);
	if (popupCookie!=null && popupCookie!="") {	
        } else {
            GAMES.cookie.set(GAMES.cookie.popupName,GAMES.cookie.cookieValue,GAMES.cookie.cookieTime);	  
	    $(document).ready(function() {
		$("a#syndicatelightbox").click();
	    });
        }
    } else if (page = 'category') {
        thisAnchorText=$(GAMES.cookie.buttonId).text();
        thisAnchorRel=$(GAMES.cookie.buttonId).attr('rel');
        if (thisAnchorText.toLowerCase().indexOf("all") >= 0) {		
            $(GAMES.cookie.buttonId).text('Click here if you just want to see '+thisAnchorRel+' updates');
	  }
	else 
	  {
            $(GAMES.cookie.buttonId).text('Click here if you just want to see all updates');
	  }	
    }
	
};	
    	
GAMES.cookie.set = function(c_name,value,expiredays) {
    var exdate=new Date();
    var path = "/";
    exdate.setDate(exdate.getDate()+expiredays);
    var c_value=escape(value) + ((expiredays==null) ? "" : "; expires="+exdate.toUTCString() + (";path=/"));
    document.cookie=c_name + "=" + c_value;	
};

GAMES.cookie.get= function(c_name) {
    if (document.cookie.length>0)
    {
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1)
	{
	    c_start=c_start + c_name.length+1;
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	}
    }
    return "";	
};  // end cookie handling

//Header
var cg_header ={

dropdown:function(){

 var links = '<ul id="subnav" class="col1">';
for(i=0;i<navname.length;i++){
 if(navname[i] != undefined){
   links += "<li><a href='"+navhref[i]+"' title='"+navname[i]+"'>"+navname[i]+"</a></li>";
  }

}
links = links + "</ul>";

var linksd = '<ul id="subnav" class="col11">';
for(i=0;i<navnamedownload.length;i++){
 if(navnamedownload[i] != undefined){
   linksd += "<li><a href='"+navhrefdownload[i]+"' title='"+navnamedownload[i]+"'>"+navnamedownload[i]+"</a></li>";
  }

}
linksd = linksd + "</ul>";
//cash games
$("#headerBottom li").eq(9).append(links);
$("#headerBottom li").eq(9).addClass("subnav");
//downloads
$("#headerBottom li").eq(8).append(linksd);
$("#headerBottom li").eq(8).addClass("subnav");

var links = navallgenre;
//all genre
$("#headerBottom li").eq(2).append(links);
$("#headerBottom li").eq(2).addClass("subnav");


}};
