/*
 Rev:$Revision: 146043 $
*/


function sendLinkEvent()
{
}

/* header functions */
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 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;
}

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))+'px';
        oDiv.style.top=(posY+oLnk.offsetHeight/2)+'px';
}

/* Utility trim string */
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

/* Prevent IE flickr */
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

/* Figure out where mouse is upon a click */
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 : 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 searchTarget(url, newWindow, newTarget) {
    // Set the target for the form
    document.dp_topform.action = url;
    if (newWindow) {
        document.dp_topform.target = '_blank';
    } else {
        document.dp_topform.target = '';
    }

    // Update the tabs classes to allow highlighting of the selected
//    var arrElements = getElementsByClassName ('searchCatBg', 'li');
    var arrElements = getElementsByClassName ('searchTabBg', 'li');
    for (var i=0; i<arrElements.length; i++) {
        arrElements[i].className = '';
    }
//    document.getElementById(newTarget).className = 'searchCatBg';
    document.getElementById(newTarget).className = 'searchTabBg';
	if(document.dp_topform.query.value!="") {
	  submitHeaderSearch('onclick');
	}
    return false;
}

	/*  functions for old BigBowl Footer  */
	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;
	}
	/* end: old bigbowl footer search */

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;
}

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 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;
}
/* end header functions */

//Prevent IE flickr
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

/* Sonar v2 */
sonar={v:2,d:0,ae:function(a,b,c){if(a.addEventListener){a.addEventListener(b,c,false)}else{if(a.attachEvent){a.attachEvent("on"+b,c)}}},re:function(a,b,c){if(a.removeEventListener){a.removeEventListener(b,c,false)}else{if(a.detachEvent){a.detachEvent("on"+b,c)}}},b:"",detect:function(c,a){if(sonar.b==""){sonar.b=document.getElementsByTagName("body")[0]}var g=document,h=window,i=c,k=0,j=sonar.b.offsetHeight,e=h.innerHeight||g.documentElement.clientHeight||g.body.clientHeight||0,f=g.documentElement.scrollTop||h.pageYOffset||g.body.scrollTop||0,b=c.offsetHeight;a=a||sonar.d;if(!c.__top||c.__bh!=j){if(i.offsetParent){do{k+=i.offsetTop}while(i=i.offsetParent)}c.__top=k;c.__bh=j}if((c.__top+b)<(f-a)||(c.__top)>(f+e+a)){return false}return true},c:[],add:function(a){if(typeof a.obj=="object"&&typeof a.call=="function"){if(sonar.detect(a.obj,(a.px||sonar.d))){a.call(a.obj);return}else{if(!window.__sonarBlip){sonar.ae(window,"scroll",sonar._poll);window.__sonarBlip=1}sonar.c.push(a)}}},_poll:function(){var d,c=sonar.c,b,a=c.length,e;for(b=0;b<a;b++){d=c[b];if(!d){continue}e=d.px||sonar.d;if(sonar.detect(d.obj,e)){d.call(d.obj);sonar.c.splice(b,1);if(sonar.c.length==0){sonar.re(window,"scroll",sonar._poll);window.__sonarBlip=0}}}}};
/* Sonar Ion v2 */
sonar.ion=function(f){var e=0,a=document.getElementsByTagName("img"),d="http://o.aolcdn.com/js/x.gif",c,b=a.length;f=f||e;for(c=0;c<b;c++){if(sonar.detect(a[c],f)){continue}a[c].__src=a[c].src;a[c].src=d;sonar.add({obj:a[c],px:f,call:function(g){g.src=g.__src;g.__src=undefined}})}};


// Feed Module Mouse Over Popup Functions - Starts
function createPop()
{
    var popRef = document.createElement("p");
    popRef.className = 'feedPop';
    popRef.setAttribute('id','feedPop');
    document.body.appendChild(popRef);
    popRef.style.display = 'none';

}

function showPop(e,trgElement,textPopup)
{
    var elHt = trgElement.offsetHeight;//this is the element height
    var elWt = trgElement.offsetWidth;//this is the element height
    createPop();
        posY = findMousePos(e)
    if(document.getElementById('feedPop').style.display.indexOf('none')==0)
    {
        popRef = document.getElementById('feedPop');
        var txtNode = document.createTextNode(textPopup);
        var arrPos = findPos(trgElement);
        popRef.style.display = "block";
        popRef.style.left = arrPos[0] + "px";
    popRef.style.top = parseInt(posY+elHt/2)+ "px";

        try
        {
            popRef.removeChild(popRef.firstChild);
        }
        catch(e){}
        popRef.appendChild(txtNode);
    }
}

function hidePop()
{
    try
    {
        var popRef = document.getElementById('feedPop');
        document.body.removeChild(popRef);
        popRef=null;
    }catch(e){}
}

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;
        }
    }
    else if(obj.x)curleft+=obj.x;

    if(document.all)
        curleft-=document.getElementsByTagName("body")[0].offsetLeft;

    if(navigator.userAgent.indexOf('Safari')!=-1)
        curleft-=document.getElementsByTagName("body")[0].offsetLeft;

    return [curleft,curtop];
}

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;
}
// Feed Module Mouse Over Popup Functions - Ends

function chportfolio(formName,ctrlName,formSubmit) {
        var formName = 'document.'+formName+'.'+ctrlName;
        if (formSubmit == 0) {var ctrlValue = eval(formName).options[eval(formName).selectedIndex].value;}
        window.open(ctrlValue);
}

function nav_focus (formname,fieldname) {
        document.forms[formname].elements[fieldname].focus();
}

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();}
}


// for use in the header
function goQuotes(daform)
{
    if (!validateSym(daform.sym.value)) {
        alert("There are characters in the symbol that are not allowed.");
        return;
    }

    var exch = daform.exch.value;
    var sym = whichEncode(daform.sym.value);
    var url = "http://finance.aol.com/usw/quotes/quotesandnews" + "?sym=" + sym + "&exch=" + exch;

    window.location = url;
}

function validateSym(str) {
    var invalids = ":<";

    for (i=0; i<invalids.length; i++) {
        if (str.indexOf(invalids.charAt(i)) >= 0) {
            return false;
        }
    }
    return true;
}

function whichEncode(fld) {
        //if (fld == "") return false;
        var encodedField = "";
        var s = fld;
        if (typeof encodeURIComponent == "function")
        {
                // Use JavaScript built-in function
                // IE 5.5+ and Netscape 6+ and Mozilla
                encodedField = encodeURIComponent(s);
        }
        else
        {
                // Need to mimic the JavaScript version
                // Netscape 4 and IE 4 and IE 5.0 etc
                encodedField = encodeURIComponentNew(s);
        }
        return encodedField;
}

//Functions for Boxley buttons
function artzOvr(o){
    o.className = o.className.substr(0,15) + " " + o.className.substr(8,15) + "Hov"
}

function artzOff(o){
    o.className = o.className.substr(0,15)
}


function artzClk(o){
    o.className = o.className.substr(0,15) + " " + o.className.substr(8,15) + "Clk"
}


//general function to get cookie
function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {
        begin = document.cookie.indexOf(NameOfCookie+"=");
        if (begin != -1) {
            begin += NameOfCookie.length+1;
            end = document.cookie.indexOf(";", begin);
            if (end == -1) end = document.cookie.length;
                return unescape(document.cookie.substring(begin, end));
        }
    }
    return null;
}

//general function to set cookie
function setCookie(NameOfCookie, value, expiredays) {
    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

    document.cookie = NameOfCookie + "=" + escape(value) +
    ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) {
    if (getCookie(NameOfCookie)) {
        document.cookie = NameOfCookie + "=" +
        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


var clickTrack = "aolpf";
// Start:  SHARE THIS WIDGET JS

var sharePopFlag = true;                             //variable for onclick popup

function showShareThisPop(topDivId, botDivId)        //function to call the popup onclick
{
    if (sharePopFlag)
    {
        document.getElementById('shareLeftIDBB').style.borderBottom = "1px solid #000";
        document.getElementById(botDivId).style.display = "block";
        document.getElementById(topDivId).className = "share_right_on";
    }
    else
    {
        document.getElementById('shareLeftIDBB').style.borderBottom = "none";
        document.getElementById(botDivId).style.display = "none";
        document.getElementById(topDivId).className = "share_right";
    }
    sharePopFlag = !sharePopFlag;
}

function shareOperation(iOperation, strUrl, strTitle)
{
    var staf_obj = new staf_SE();
    staf_obj.setLang("en-US");
    if (strUrl != "")
    {
        staf_obj.setURL(strUrl);
    }
    if (strTitle != "")
    {
        staf_obj.setTitle(strTitle);
    }
    if (iOperation == 1) // IM This
    {
        staf_obj.sendIM();
    }
    else
    {
        staf_obj.sendEmail();
    }
}

function mouseoverup()
{
    document.getElementById("thumbsup").className="thumbsup_on";
}

function mouseoutup()
{
    document.getElementById("thumbsup").className="thumbsup";
}

function mouseoverdown()
{
    document.getElementById("thumbsdown").className="thumbsdown_on";
}

function mouseoutdown()
{
    document.getElementById("thumbsdown").className="thumbsdown";
}

// End: SHARE THIS WIDGET JS

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + function sortString                                      +
// + A generic function to sort comma delimeted strings       +
// + through conversion to array and then back to string      +
// + after sorting.                                           +
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function sortString(string) {

    string = trimAll(string);

    var strSortString;
    var arrSortStringArray;

    /* convert the string to an array */
    arrSortStringArray = string.split(",");

    /* sort the array */
    arrSortStringArray.sort();

    /* convert the sorted array back into a string */
    strSortString = arrSortStringArray.join(",");
    strSortString = "," + strSortString  + ",";

    /* return the string so we can use it. */
    return strSortString;

}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( getCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}



//walletpop cott module
function walletpop_cott_next(){
        if(cottIndex + 2 < cottMax){
                document.getElementById("section"+cottIndex).style.display = 'none';
                document.getElementById("section"+(cottIndex+3)).style.display = 'block';
                cottIndex++;
        } else {
          for(i=1;i<=cottMax;i++){              document.getElementById("section"+i).style.display = 'none';
          }
          cottIndex = 1;
          document.getElementById("section1").style.display = 'block';
          document.getElementById("section2").style.display = 'block';
          document.getElementById("section3").style.display = 'block';
        }
}
function walletpop_cott_pre(){
        if(cottIndex > 1){
                cottIndex--;
                document.getElementById("section"+(cottIndex+3)).style.display = 'none';
                document.getElementById("section"+(cottIndex)).style.display = 'block';

        } else {
          for(i=1;i<=cottMax;i++){              document.getElementById("section"+i).style.display = 'none';
          }
          cottIndex = cottMax - 2;
          document.getElementById("section"+cottIndex).style.display = 'block';
          document.getElementById("section"+(cottIndex +1)).style.display = 'block';
          document.getElementById("section"+(cottIndex +2)).style.display = 'block';
        }
}
function hoverstate(elemNum){
    document.getElementById("cott_img_" +elemNum).setAttribute("class", "activeSection");
    document.getElementById("cott_img_" +elemNum).setAttribute("className", "activeSection");
}
function hoverOutstate(elemNum){
    document.getElementById("cott_img_" +elemNum).setAttribute("class", "cott_img_box");
    document.getElementById("cott_img_" +elemNum).setAttribute("className", "cott_img_box");
}

function walletpop_daily_next(){
        if(dailyIndex < dailyMax){
                document.getElementById("daily_section"+dailyIndex).style.display = 'none';
                document.getElementById("daily_section"+(dailyIndex+1)).style.display = 'block';
                dailyIndex++;
        } else {
          document.getElementById("daily_section"+dailyIndex).style.display = 'none';
          document.getElementById("daily_section1").style.display = 'block';
          dailyIndex = 1;
        }
}
function walletpop_daily_pre(){
        if(dailyIndex > 1){
                document.getElementById("daily_section"+(dailyIndex)).style.display = 'none';
                document.getElementById("daily_section"+(dailyIndex-1)).style.display = 'block';
                dailyIndex--;

        } else {
          document.getElementById("daily_section"+dailyIndex).style.display = 'none';
          document.getElementById("daily_section"+(dailyMax)).style.display = 'block';
          dailyIndex = dailyMax;
        }
}
function hoverstate_dailyL(){
    document.getElementById("daily_left_arrow").setAttribute("class", "activeSectionL");
    document.getElementById("daily_left_arrow").setAttribute("className", "activeSectionL");
}
function hoverOutstate_dailyL(){
    document.getElementById("daily_left_arrow").setAttribute("class", "left_arrow");
    document.getElementById("daily_left_arrow").setAttribute("className", "left_arrow");
}
function hoverstate_dailyR(){
    document.getElementById("daily_right_arrow").setAttribute("class", "activeSectionR");
    document.getElementById("daily_right_arrow").setAttribute("className", "activeSectionR");
}
function hoverOutstate_dailyR(){
    document.getElementById("daily_right_arrow").setAttribute("class", "right_arrow");
    document.getElementById("daily_right_arrow").setAttribute("className", "right_arrow");
}


// For tabbed module v2
var ccob = new cob();
function p(j){return document.getElementById(j)}
function ob(j){return document.getElementById(j)}

function cob() {
    var cache = new Array();

    // methods
    this.add     = function add(key,data) {cache[key] = data}
    this.getData = function getData(key) {return cache[key]}
    this.getKeys = function getKeys() {
        var keys = new Array();
    var ix = 0;
        for (var i in  cache) {
            keys[ix] = i;
      ix++;
        }
        return keys;
    }
    this.hvDat = function hvDat(key) {
     if (cache[key] || cache[key] == 0){return 1}
      return 0;
    }
}

function tbmd_set(mod,t) {

    // get all the li tags from the parent ul
    lis = ob('tbsid' + mod).getElementsByTagName('UL').item(0).getElementsByTagName('LI');

    // if data key is in the cache object then use it to turn off tab
    key = 'curidx' + mod;
    if (ccob.hvDat(key)) {
        aObj = lis.item(ccob.getData(key)).getElementsByTagName('A').item(0);
        aObj.className = '';
 aObj.style.display = 'block';
    }

    // turn on clicked tab current tab if
    if (lis.length >= t) {
        aObj = lis.item(t).getElementsByTagName('A').item(0);
        aObj.className = 'selected';
        aObj.style.display = 'block';
        ccob.add(key,t);
    }
}
function getData(tbmid,mod,t) {

    // if data for tab is not it cache the get item
    key = tbmid + '_' + t;
    tbd = '';

 if (ccob.hvDat(key)) {
     tbd = ccob.getData(key);

     tbmd_set(tbmid,t);

            // get content div object
            modObj = ob('cntd' + tbmid);

     modObj.innerHTML = tbd;
 } else {
            // get iframe div
            tbfObj = ob('tbf' + tbmid);

            // store iframe src url
            tbfUrl = '/mod.adp?_miid=' + mod + '&_tbmid=' + tbmid + '&_mtb=' + t;

            // append current query params, they may be needed by module being output via mod.adp
            tbfQry = document.location.search;
            if(tbfQry) {tbfUrl += '&' + tbfQry.substring(1)}

            // append current url and the idx of tab clicked, some modules will use this for a redir
            defTab = "_deftb" + tbmid;
            tbfTmp = location.href;

            // rebuild params without "_deftab{instanceid}"
            if(tbfTmp.indexOf(defTab) > 1) {
                aTmp = new Array();
                aQps = tbfQry.substring(1,tbfQry.length).split('&');
                for (i=0;i < aQps.length;i++) {
                    if (aQps[i].indexOf(defTab) == -1) {
                       aTmp.push(aQps[i]);
                    }
                }
                tbfTmp = tbfTmp.substring(0,tbfTmp.indexOf('?') + 1) + aTmp.join('&');
            }
            // append the default tab with the idx of the tab clicked
            if(tbfTmp.indexOf('?') == -1) {tbfTmp += '?'} else {tbfTmp += '&'}
            tbfUrl += '&_tbdref=' + encodeURIComponent(tbfTmp + defTab + '=' + (t + 1));

            // stuff iframe div then set update src
            tbfHtm = '<iframe class=\"tbf\" id=\"tbdframe\" src=\"\"></iframe>';
            tbfObj.innerHTML = tbfHtm;
            tbfObj.getElementsByTagName('iframe').item(0).src = tbfUrl;
    }
    return false;
}
function fillFromHttp(req,a) {
    // confirm data recieved successfully
 tbd = '';
    if(req) {
        key = a.key;
 tbd = req
        ccob.add(key,tbd)
    } else {
        tbd = '0';
    }

    // flip tabs
    tbmd_set(a.mod,a.t);

    // fillDiv
    ob('cntd' + a.mod).innerHTML = tbd;
}

function toggleArticleDrawer(obj,id) {
 var pObj = document.getElementById(id);
 if (obj.className == "off") {
  obj.className = "on";
  if(pObj.className.match("wrap")) {
   pObj.className = "artDrawer on wrap";
  } else {
   pObj.className = "artDrawer on";
  }
 }
 else {
  obj.className = "off";
  if(pObj.className.match("wrap")) {
   pObj.className = "artDrawer off wrap";
  } else {
   pObj.className = "artDrawer off";
  }
 }
}

function toggleClassName(id,stateOne,stateTwo) {
 var obj = document.getElementById(id);
 if (obj.className == stateOne) {
  obj.className = stateTwo;
 } else {
  obj.className = stateOne;
 }
}
// END For tabbed module v2

/* dyna walletpop html photo gallery :  v1.0 - 20090429 */
function getElementsByClass(node,searchClass,tag) {
	var classElements = new Array();
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("\\b"+searchClass);
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

var numSlides = null;
var slideNum = null;
var modInstId = document.title + " -pg";
var zfTot;

var docRef=document.referrer;
var refSpl=docRef.indexOf('?');
if(refSpl>0){
	var refUrl=docRef.substring(0,refSpl);
} else {
	var refUrl=docRef;
}
var refVal="mmx_" + refUrl;

function hpg_deeplink(p) {
	var el = getElementsByClass(document.getElementById('hpgContainer'),'content_','div');
	numSlides=el.length;
	el[0].className = el[0].className + " hidden";
	slideNum = parseFloat(p);
	elNum = p-1;
	hpgCount();
	el[elNum].className = "content_" + elNum;
	return false;
}

function hpg_next(){
	var el = getElementsByClass(document.getElementById('hpgContainer'),'content_','div');
	numSlides=el.length;
	if(slideNum==null){slideNum = 1;}
	el[slideNum-1].className = el[slideNum-1].className + " hidden";
	if(slideNum == numSlides){slideNum = 1;} else {slideNum = slideNum+1;}
	hpgCount();
	el[slideNum-1].className = "content_" + slideNum;
	adsReloadIframe('adsF0');
	mmx_track(slideNum);
	return false;
}

function hpg_prev(){
	var el = getElementsByClass(document.getElementById('hpgContainer'),'content_','div');
	numSlides=el.length;
	if(slideNum==null){slideNum = 1;}
	el[slideNum-1].className = el[slideNum-1].className + " hidden";
	slideNum = slideNum-1;
	if(slideNum == 0){slideNum = numSlides;}
	hpgCount();
	el[slideNum-1].className = "content_" + slideNum;
	adsReloadIframe('adsF0');
	mmx_track(slideNum);
	return false;
}

function hpgCount() {
	document.getElementById('selectNav1').innerHTML = slideNum + " of " + numSlides;
	document.getElementById('selectNav2').innerHTML = slideNum + " of " + numSlides;
}

function hpgInit() {
	if(!document.getElementById('hpgContainer')){return false;}
	s_265.pageName = s_265.pageName + ' - HTML Gallery';
	var el = getElementsByClass(document.getElementById('hpgContainer'),'content_','div');
	numSlides=el.length;
	slideNum=1;
	hpgCount();
	theUrl = document.URL;
	deepUrl = theUrl.split('?photo=');
	theSlide = deepUrl[1];
	if(theSlide>0){
		if(theSlide <= numSlides){
			hpg_deeplink(deepUrl[1]);
		}
	}
	zfTot = zeroFill(numSlides);
}

function zeroFill(numl) {
	var n2s = "" + numl;
	while(n2s.length < 3) {n2s = "0" + n2s;}
	return n2s;
}

function mmx_track(currImage)
{
	var zfSlide=zeroFill(currImage);
	var zfTotal = zfTot;
	s_265.prop6=refVal;
	s_265.prop7='mmx_'+zfSlide+'_'+zfTotal;
	s_265.prop8='mmx_HTML';
	s_265.prop9='';
	s_265.t();
	var f = document.getElementById('mm_track');
	var d = new Date();
	var cbts = d.getTime();
	/* DEV set this only during DEV testing using PF dev until walletpop dev exists
	var DEVmmxurl = "http://pf.channel.office.aol.com/mm_track/info_htmlphotogallery/"+modInstId+"-"+currImage+"-"+cbts;
	f.src = DEVmmxurl;
	*/
	/* PROD will look for mm_track page on root domain */
	var mmxurl = "/mm_track/info_htmlphotogallery/"+modInstId+"-"+currImage+"-"+cbts;
	f.src = mmxurl;
}

window.addEventListener?window.addEventListener("load",hpgInit,false):window.attachEvent("onload",hpgInit);
/*  end: html photo gallery  */
function p_o(o){return document.getElementById(o);}


function selectResult(){_selectResult(this);}


function _selectResult(item)
{
	var quoteUrl;
	item.className=highlightClass;
	var selNum=getSelectedSpanNum(document.getElementById("TBL_SMARTBOX"));
	var symbol=resultsObj.ss[selNum].s;
	var exch=(resultsObj.ss[selNum].x).toLowerCase();

	quoteUrl = "http://finance.aol.com/quotes" + "/" + symbol + "/" + exch;
	window.location=quoteUrl;
	hideDropdownBox();
}

function highlightResult(){_highlightResult(this);}

function _highlightResult(item){var symbol=item.firstChild.innerHTML;item.className=highlightClass;}

function unhighlightResult(){_unhighlightResult(this);}

function _unhighlightResult(item){var origCl=item.getAttribute('origCl');item.className=origCl;}

function getSelectedSpanNum(div)
{
	var count=-1;
	var tbodyResults=div.getElementsByTagName("tbody");
	var spans=tbodyResults[0].getElementsByTagName("tr");
	if(spans)
	{
		for(var i=0;i<spans.length;i++)
		{
			count++;
			if(spans[i].className==highlightClass){return count;}
		}
	}
	return-1;
}

function setSelectedSpan(div,spanNum)
{
	var count=-1;
	var thisSpan;
	var tbodyResults=div.getElementsByTagName("tbody");
	var spans=tbodyResults[0].getElementsByTagName("tr");
	if(spans)
	{
		for(var i=0;i<spans.length;i++)
		{
			if(++count==spanNum){_highlightResult(spans[i]);thisSpan=spans[i];}
			else{_unhighlightResult(spans[i]);}
		}
	}
	return thisSpan;
}

function showDropdownBox()
{
	cancelCloseTime();
	if(document.layers){document.layers[dropdownBox].display="block";}
	else{document.getElementById(dropdownBox).style.display="block";}
	var ticker=document.getElementById("flashcontent2");
	if(ticker){ticker.style.zIndex=3;}
}

function hideDropdownBox(){if(document.getElementById(dropdownBox)){if(document.layers)document.layers[dropdownBox].display="none";else document.getElementById(dropdownBox).style.display="none";}
var ticker=document.getElementById("flashcontent2");if(ticker){ticker.style.zIndex=2;}}

function closeTime(){closeTimeoutID=window.setTimeout(hideDropdownBox,closeDropdownTimeout);}

function cancelCloseTime(){if(closeTimeoutID){window.clearTimeout(closeTimeoutID);closeTimeoutID=null;}}

function get_firstchild(n)
{
	x=n.firstChild.nextSibling;
	while(x.nodeType!=1){x=x.nextSibling;}
	return x;
}
//walletpop cott module

function walletpop_cott_next(){
        if(cottIndex + 2 < cottMax){
                document.getElementById("section"+cottIndex).style.display = 'none';
                document.getElementById("section"+(cottIndex+3)).style.display = 'block';
                cottIndex++;
        } else {
          for(i=1;i<=cottMax;i++){              document.getElementById("section"+i).style.display = 'none';
          }
          cottIndex = 1;
          document.getElementById("section1").style.display = 'block';
          document.getElementById("section2").style.display = 'block';
          document.getElementById("section3").style.display = 'block';
        }
}
function walletpop_cott_pre(){

       if(cottIndex > 1){
                cottIndex--;
                document.getElementById("section"+(cottIndex+3)).style.display = 'none';
                document.getElementById("section"+(cottIndex)).style.display = 'block';

        } else {

              for(i=1;i<=cottMax;i++){
                   document.getElementById("section"+i).style.display = 'none';
               }

           cottIndex = cottMax - 2;
          document.getElementById("section"+cottIndex).style.display = 'block';
          document.getElementById("section"+(cottIndex +1)).style.display = 'block';
          document.getElementById("section"+(cottIndex +2)).style.display = 'block';
     }
}
function hoverstate(elemNum){
    document.getElementById("cott_img_" +elemNum).setAttribute("class", "activeSection");
    document.getElementById("cott_img_" +elemNum).setAttribute("className", "activeSection");
}
function hoverOutstate(elemNum){
    document.getElementById("cott_img_" +elemNum).setAttribute("class", "cott_img_box");
    document.getElementById("cott_img_" +elemNum).setAttribute("className", "cott_img_box");
}

