﻿
/** watchlist_scripts.js **/

function BrowserDetect(){var ua=navigator.userAgent.toLowerCase();this.isGecko=(ua.indexOf('gecko')!=-1&&ua.indexOf('safari')==-1);this.isAppleWebKit=(ua.indexOf('applewebkit')!=-1);this.isKonqueror=(ua.indexOf('konqueror')!=-1);this.isSafari=(ua.indexOf('safari')!=-1);this.isOmniweb=(ua.indexOf('omniweb')!=-1);this.isOpera=(ua.indexOf('opera')!=-1);this.isIcab=(ua.indexOf('icab')!=-1);this.isAol=(ua.indexOf('aol')!=-1);this.isIE=(ua.indexOf('msie')!=-1&&!this.isOpera&&(ua.indexOf('webtv')==-1));this.isMozilla=(this.isGecko&&ua.indexOf('gecko/')+14==ua.length);this.isFirefox=(ua.indexOf('firefox/')!=-1||ua.indexOf('firebird/')!=-1);this.isNS=((this.isGecko)?(ua.indexOf('netscape')!=-1):((ua.indexOf('mozilla')!=-1)&&!this.isOpera&&!this.isSafari&&(ua.indexOf('spoofer')==-1)&&(ua.indexOf('compatible')==-1)&&(ua.indexOf('webtv')==-1)&&(ua.indexOf('hotjava')==-1)));this.isIECompatible=((ua.indexOf('msie')!=-1)&&!this.isIE);this.isNSCompatible=((ua.indexOf('mozilla')!=-1)&&!this.isNS&&!this.isMozilla);this.geckoVersion=((this.isGecko)?ua.substring((ua.lastIndexOf('gecko/')+6),(ua.lastIndexOf('gecko/')+14)):-1);this.equivalentMozilla=((this.isGecko)?parseFloat(ua.substring(ua.indexOf('rv:')+3)):-1);this.appleWebKitVersion=((this.isAppleWebKit)?parseFloat(ua.substring(ua.indexOf('applewebkit/')+12)):-1);this.versionMinor=parseFloat(navigator.appVersion);if(this.isGecko&&!this.isMozilla){this.versionMinor=parseFloat(ua.substring(ua.indexOf('/',ua.indexOf('gecko/')+6)+1));}
else if(this.isMozilla){this.versionMinor=parseFloat(ua.substring(ua.indexOf('rv:')+3));}
else if(this.isIE&&this.versionMinor>=4){this.versionMinor=parseFloat(ua.substring(ua.indexOf('msie ')+5));}
else if(this.isKonqueror){this.versionMinor=parseFloat(ua.substring(ua.indexOf('konqueror/')+10));}
else if(this.isSafari){this.versionMinor=parseFloat(ua.substring(ua.lastIndexOf('safari/')+7));}
else if(this.isOmniweb){this.versionMinor=parseFloat(ua.substring(ua.lastIndexOf('omniweb/')+8));}
else if(this.isOpera){this.versionMinor=parseFloat(ua.substring(ua.indexOf('opera')+6));}
else if(this.isIcab){this.versionMinor=parseFloat(ua.substring(ua.indexOf('icab')+5));}
this.versionMajor=parseInt(this.versionMinor);this.isDOM1=(document.getElementById);this.isDOM2Event=(document.addEventListener&&document.removeEventListener);this.mode=document.compatMode?document.compatMode:'BackCompat';this.isWin=(ua.indexOf('win')!=-1);this.isWin32=(this.isWin&&(ua.indexOf('95')!=-1||ua.indexOf('98')!=-1||ua.indexOf('nt')!=-1||ua.indexOf('win32')!=-1||ua.indexOf('32bit')!=-1||ua.indexOf('xp')!=-1));this.isMac=(ua.indexOf('mac')!=-1);this.isUnix=(ua.indexOf('unix')!=-1||ua.indexOf('sunos')!=-1||ua.indexOf('bsd')!=-1||ua.indexOf('x11')!=-1)
this.isLinux=(ua.indexOf('linux')!=-1);this.isNS4x=(this.isNS&&this.versionMajor==4);this.isNS40x=(this.isNS4x&&this.versionMinor<4.5);this.isNS47x=(this.isNS4x&&this.versionMinor>=4.7);this.isNS4up=(this.isNS&&this.versionMinor>=4);this.isNS6x=(this.isNS&&this.versionMajor==6);this.isNS6up=(this.isNS&&this.versionMajor>=6);this.isNS7x=(this.isNS&&this.versionMajor==7);this.isNS7up=(this.isNS&&this.versionMajor>=7);this.isIE4x=(this.isIE&&this.versionMajor==4);this.isIE4up=(this.isIE&&this.versionMajor>=4);this.isIE5x=(this.isIE&&this.versionMajor==5);this.isIE55=(this.isIE&&this.versionMinor==5.5);this.isIE5up=(this.isIE&&this.versionMajor>=5);this.isIE6x=(this.isIE&&this.versionMajor==6);this.isIE6up=(this.isIE&&this.versionMajor>=6);this.isIE4xMac=(this.isIE4x&&this.isMac);}
var browser=new BrowserDetect();var iex=browser.isIE||browser.isOpera;var nav=(document.layers);var old=browser.isNS&&(!document.layers&&!document.getElementById);var n_6=browser.isNS6up;var op=browser.isOpera;if(browser.isSafari||browser.isFirefox||browser.isMozilla||browser.isKonqueror||browser.isGecko)n_6=true;if(window.addEventListener)
{window.addEventListener('load',function(){var winBody=document.getElementsByTagName('body');if(winBody[0]!=null){var divNode=document.createElement("div");divNode.setAttribute('id','pup');divNode.style.visibility="hidden";divNode.style.display="none";winBody[0].appendChild(divNode);}},false);}
else if(window.attachEvent)
{window.attachEvent('onload',function(){var winBody=document.getElementsByTagName('body');if(winBody[0]!=null){var divNode=document.createElement("div");divNode.setAttribute('id','pup');divNode.style.visibility="hidden";divNode.style.display="none";winBody[0].appendChild(divNode);}});}
var skin=null;var minMarginToBorder=15;var popwidth=0;function assignSkin(){if(nav)skin=document.pup;if(iex)skin=document.getElementById('pup').style;if(n_6)skin=document.getElementById("pup").style;}
function assignPopWidth(){if(iex&&!op)popwidth=parseInt(document.getElementById("pup").currentStyle.width);if(op)popwidth=parseInt(document.defaultView.getComputedStyle(document.getElementById('pup'),null).width);if(n_6)popwidth=parseInt(document.defaultView.getComputedStyle(document.getElementById("pup"),null).getPropertyValue('width'));}
function get_mouse(e)
{if(document.getElementById("pup")==null){return;}
var x,y;var scroll_x_y=getScrollXY(e);if(iex)x=Number(scroll_x_y[0]);if(nav||n_6)x=e.pageX;if(iex){}
if(iex)y=Number(scroll_x_y[1]);if(nav||n_6)y=e.pageY;if(popwidth==0)assignPopWidth();if(null===skin)assignSkin();scroll_x_y[0]+=15;var x_y=nudge(scroll_x_y[0],scroll_x_y[1],e);if(isNaN(x_y[0]))x_y[0]=0;if(isNaN(x_y[1]))x_y[1]=0;if(nav||iex){skin.left=x_y[0];skin.top=x_y[1];}else if(n_6){skin.left=x_y[0]+"px";skin.top=x_y[1]+"px";}}
function nudge(x,y,e)
{var dims=getInnerWindowDimensions();var xtreme=dims[0]-popwidth-minMarginToBorder;if(n_6||nav)xtreme-=25;if(x>xtreme){x-=(parseInt(popwidth)+minMarginToBorder+20);}
if(x<1)x-=x-1;est_lines=parseInt(document.getElementById("pup").innerHTML.length/(parseInt(skin.width)/15));est_lines_to_decide=max(est_lines,2);if((y+parseInt(est_lines_to_decide*20))>(dims[1]+y)){y-=parseInt(est_lines*20)+20;}
return[x,y];}
function popup(msg,id)
{if(nav)document.getElementById(id).captureEvents(Event.MOUSEMOVE);if(n_6)document.getElementById(id).addEventListener("mousemove",get_mouse,true);if(nav||iex)document.getElementById(id).onmousemove=get_mouse;if(popwidth===0)assignPopWidth();if(null===skin)assignSkin();if(null!==skin){if(old){alert(msg);return;}
if(!isNaN(popwidth)){if(iex||nav)skin.width=popwidth;if(n_6)skin.width=popwidth+"px";}else{if(iex||nav)skin.width=300;if(n_6)skin.width=300+"px";}
if(nav){skin.document.open();skin.document.write(msg);skin.document.close();}
document.getElementById("pup").innerHTML=msg;skin.visibility="visible";skin.display="block";}}
function kill(id)
{if(!old){if(nav)document.getElementById(id).releaseEvents(Event.MOUSEMOVE);if(n_6)document.getElementById(id).removeEventListener("mousemove",get_mouse,true);if(nav||iex)document.getElementById(id).onmousemove=null;skin.visibility="hidden";skin.display="none";}}
function getScrollXY(e)
{var posx=0;var posy=0;if(!e)var e=window.event;if(e.clientX||e.clientY){posx=e.clientX+document.body.scrollLeft
+document.documentElement.scrollLeft;posy=e.clientY+document.body.scrollTop
+document.documentElement.scrollTop;}else if(e.pageX||e.pageY){posx=e.pageX;posy=e.pageY;}
var poppop=document.getElementById("pup").parentNode;posx=posx-findPosLeft(poppop);posy=posy-findPosTop(poppop);return[posx,posy];}
function getInnerWindowDimensions(){var A;if(window.innerHeight!==undefined)A=[window.innerWidth,window.innerHeight];else{var D=(document.documentElement.clientWidth==0)?document.body:document.documentElement;A=[D.clientWidth,D.clientHeight];}
return A;}
function max(a,b){if(a>b)return a;else return b;}
function findPosLeft(pupobj){var curleft=0;if(pupobj.offsetParent){curleft=pupobj.offsetLeft
while(pupobj=pupobj.offsetParent){curleft+=pupobj.offsetLeft}}
return curleft;}
function findPosTop(pupobj){var curtop=0;if(pupobj.offsetParent){curtop=pupobj.offsetTop
while(pupobj=pupobj.offsetParent){curtop+=pupobj.offsetTop}}
return curtop;}
var image_up="wl_sortup";var image_down="wl_sortdown";var image_none="wl_sortneutral";var europeandate=false;var alternate_row_colors=true;addEvent(window,"load",sortables_init);var SORT_COLUMN_INDEX;var thead=false;function postSortInit(){}
function sortables_init(tableID,headerID){if((document.getElementById(tableID))&&(document.getElementById(headerID)))
{tbls=document.getElementById(tableID);hdrs=document.getElementById(headerID);ts_makeSortable(tbls,hdrs);}}
function ts_makeSortable(t,h){if(h.rows&&h.rows.length>0){if(h.tHead&&h.tHead.rows.length>0){var firstRow=h.tHead.rows[h.tHead.rows.length-1];thead=true;}else{var firstRow=h.rows[0];}}
if(!firstRow)return;for(var i=0;i<firstRow.cells.length;i++){var cell=firstRow.cells[i];var txt=ts_getInnerText(cell);if(cell.className!="unsortable"&&cell.className.indexOf("unsortable")==-1){cell.innerHTML='<a href="#" class="sortheader" onclick="ts_resortTable(this, '+i+',\''+t.id+'\');return false;">'+txt+'<span class="sortarrow">&nbsp;&nbsp;<div class="'+image_none+'"></div></span></a>';}}
if(alternate_row_colors){alternate(t);}}
function ts_getInnerText(el){if(typeof el=="string")return el;if(typeof el=="undefined"){return el};if(el.innerText)return el.innerText;var str="";var cs=el.childNodes;var l=cs.length;for(var i=0;i<l;i++){switch(cs[i].nodeType){case 1:str+=ts_getInnerText(cs[i]);break;case 3:str+=cs[i].nodeValue;break;}}
return str;}
function ts_resortTable(lnk,clid,lnkid){var span;for(var ci=0;ci<lnk.childNodes.length;ci++){if(lnk.childNodes[ci].tagName&&lnk.childNodes[ci].tagName.toLowerCase()=='span')span=lnk.childNodes[ci];}
var spantext=ts_getInnerText(span);var column=clid;var t=document.getElementById(lnkid);if(t.rows.length<=1)return;var itm="";var i=0;while(itm==""&&i<t.tBodies[0].rows.length){var itm=ts_getInnerText(t.tBodies[0].rows[i].cells[column]);itm=trim(itm);if(itm.substr(0,4)=="<!--"||itm.length==0){itm="";}
i++;}
if(itm=="")return;sortfn=ts_sort_caseinsensitive;if(itm.match(/^\d\d[\/\.-][a-zA-z][a-zA-Z][a-zA-Z][\/\.-]\d\d\d\d$/))sortfn=ts_sort_date;if(itm.match(/^\d\d[\/\.-]\d\d[\/\.-]\d\d\d{2}?$/))sortfn=ts_sort_date;if(itm.match(/^-?[£$€Û¢´]\d/))sortfn=ts_sort_numeric;if(itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?$/))sortfn=ts_sort_numeric;SORT_COLUMN_INDEX=column;var firstRow=new Array();var newRows=new Array();for(k=0;k<t.tBodies.length;k++){for(i=0;i<t.tBodies[k].rows[0].length;i++){firstRow[i]=t.tBodies[k].rows[0][i];}}
for(k=0;k<t.tBodies.length;k++){if(!thead){for(j=1;j<t.tBodies[k].rows.length;j++){newRows[j-1]=t.tBodies[k].rows[j];}}else{for(j=0;j<t.tBodies[k].rows.length;j++){newRows[j]=t.tBodies[k].rows[j];}}}
newRows.sort(sortfn);if(span.getAttribute("sortdir")=='down'){ARROW='&nbsp;&nbsp;<div class="'+image_down+'"></div>';newRows.reverse();span.setAttribute('sortdir','up');}else{ARROW='&nbsp;&nbsp;<div class="'+image_up+'"></div>';span.setAttribute('sortdir','down');}
for(i=0;i<newRows.length;i++){if(!newRows[i].className||(newRows[i].className&&(newRows[i].className.indexOf('sortbottom')==-1))){t.tBodies[0].appendChild(newRows[i]);}}
for(i=0;i<newRows.length;i++){if(newRows[i].className&&(newRows[i].className.indexOf('sortbottom')!=-1))
t.tBodies[0].appendChild(newRows[i]);}
var allspans=document.getElementsByTagName("span");for(var ci=0;ci<allspans.length;ci++){if(allspans[ci].className=='sortarrow'){if(getParent(allspans[ci],"table")==getParent(lnk,"table")){allspans[ci].innerHTML='&nbsp;&nbsp;<div class="'+image_none+'"></div>';}}}
span.innerHTML=ARROW;alternate(t);postSortInit();}
function getParent(el,pTagName){if(el==null){return null;}else if(el.nodeType==1&&el.tagName.toLowerCase()==pTagName.toLowerCase()){return el;}else{return getParent(el.parentNode,pTagName);}}
function sort_date(date){dt="00000000";if(date.length==11){mtstr=date.substr(3,3);mtstr=mtstr.toLowerCase();switch(mtstr){case"jan":var mt="01";break;case"feb":var mt="02";break;case"mar":var mt="03";break;case"apr":var mt="04";break;case"may":var mt="05";break;case"jun":var mt="06";break;case"jul":var mt="07";break;case"aug":var mt="08";break;case"sep":var mt="09";break;case"oct":var mt="10";break;case"nov":var mt="11";break;case"dec":var mt="12";break;}
dt=date.substr(7,4)+mt+date.substr(0,2);return dt;}else if(date.length==10){if(europeandate==false){dt=date.substr(6,4)+date.substr(0,2)+date.substr(3,2);return dt;}else{dt=date.substr(6,4)+date.substr(3,2)+date.substr(0,2);return dt;}}else if(date.length==8){yr=date.substr(6,2);if(parseInt(yr)<50){yr='20'+yr;}else{yr='19'+yr;}
if(europeandate==true){dt=yr+date.substr(3,2)+date.substr(0,2);return dt;}else{dt=yr+date.substr(0,2)+date.substr(3,2);return dt;}}
return dt;}
function ts_sort_date(a,b){dt1=sort_date(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));dt2=sort_date(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));if(dt1==dt2){return 0;}
if(dt1<dt2){return-1;}
return 1;}
function ts_sort_numeric(a,b){var aa=ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);aa=clean_num(aa);var bb=ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);bb=clean_num(bb);return compare_numeric(aa,bb);}
function compare_numeric(a,b){var a=parseFloat(a);a=(isNaN(a)?0:a);var b=parseFloat(b);b=(isNaN(b)?0:b);return a-b;}
function ts_sort_caseinsensitive(a,b){aa=ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();bb=ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();if(aa==bb){return 0;}
if(aa<bb){return-1;}
return 1;}
function ts_sort_default(a,b){aa=ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);bb=ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);if(aa==bb){return 0;}
if(aa<bb){return-1;}
return 1;}
function addEvent(elm,evType,fn,useCapture)
{if(elm.addEventListener){elm.addEventListener(evType,fn,useCapture);return true;}else if(elm.attachEvent){var r=elm.attachEvent("on"+evType,fn);return r;}else{alert("Handler could not be removed");}}
function clean_num(str){str=str.replace(new RegExp(/[^-?0-9.]/g),"");return str;}
function trim(s){return s.replace(/^\s+|\s+$/g,"");}
function alternate(table){var tableBodies=table.getElementsByTagName("tbody");for(var i=0;i<tableBodies.length;i++){var tableRows=tableBodies[i].getElementsByTagName("tr");for(var j=0;j<tableRows.length;j++){if((j%2)==0){if(!(tableRows[j].className.indexOf('odd')==-1)){tableRows[j].className=tableRows[j].className.replace('odd','even');}else{if(tableRows[j].className.indexOf('even')==-1){tableRows[j].className+=" even";}}}else{if(!(tableRows[j].className.indexOf('even')==-1)){tableRows[j].className=tableRows[j].className.replace('even','odd');}else{if(tableRows[j].className.indexOf('odd')==-1){tableRows[j].className+=" odd";}}}}}}


/** basewatchlist.js **/


BaseWLView=Class.create();BaseWLView.prototype=Object.extend(new BaseView,{initialize:function(controllers,uicontrols,msgs){this.controllers=controllers;this.uicontrols=uicontrols;this.msgs=msgs;this.adminToggle='';this.currentWL='';this.refreshQuoteInt=null;this.showError=true;},onDataEvent:function(event,data){if(!this.isNull(event))
{switch(event.getType())
{case WLEvent.Type.GETWLNAMES:this.onGetWLNames(event.getState(),data);break;case WLEvent.Type.GETWL:this.onGetWL(event.getState(),data);break;case WLEvent.Type.UPDATEWL:this.onUpdateWL(event.getState(),data);break;case WLEvent.Type.DELETEWL:this.onDeleteWL(event.getState(),data);break;case WLEvent.Type.CREATEWL:this.onCreateWL(event.getState(),data);break;case WLEvent.Type.GETQUOTES:this.onGetQuotes(event.getState(),data);break;case WLEvent.Type.GETGUESTALERT:this.onGetGuestAlerts(event.getState(),data);break;case WLEvent.Type.SAVESORTWL:this.onGetSaveSort(event.getState(),data);break;case WLEvent.Type.EXPORTTOPORTFOLIO:this.onExportWLToPortfolio(event.getState(),data);break;case WLEvent.Type.EDITINPORTFOLIO:this.onEditWLInPortfolio(event.getState(),data);break;}}},defaultOnFunction:function(state,data){if(!this.isNull(event)){switch(event.getType())
{case BaseRequestor.State.INITIALIZE:break;case BaseRequestor.State.SUCCESS:break;case BaseRequestor.State.ERROR:this.displayError(state,data,"");break;case BaseRequestor.State.TIMEOUT:this.displayError(state,data,"");break;default:break;}}},onGetWLNames:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:this.initMenu();var wlDrop=document.getElementById(this.uicontrols.droplist);var optn=document.createElement("OPTION");var loadOptn=this.msgs.loadDrop;wlDrop.length=0;optn.text=loadOptn;optn.value=loadOptn;wlDrop.options.add(optn);var txt="Retrieving Watchlists...";this.showLoaderGraphic(txt);return;case BaseRequestor.State.SUCCESS:this.hideLoaderGraphic();this.loadDropDown(this.uicontrols.droplist,data);this.activeMenu(data);this.watchlistSelected(data);return;default:this.hideLoaderGraphic();this.displayError(state,data,'onGetWLNames');}},onGetWL:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:this.initMenu();clearInterval(this.refreshQuoteInt);var txt="Retrieving Watchlist...";this.showLoaderGraphic(txt);return;case BaseRequestor.State.SUCCESS:this.hideLoaderGraphic();var wl0=null;if(!this.isWLNull(data.currentWatchlists))
wl0=data.currentWatchlists[0];if(wl0!=null)
{this.createSymbolsView(data);this.initTimedRefresh(data);this.activeMenu(data);}
return;default:this.hideLoaderGraphic();this.displayError(state,data,"onGetWL");}},onUpdateWL:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:var txt="Updating Watchlist...";this.showLoaderGraphic(txt);return;case BaseRequestor.State.SUCCESS:var flashMsgArray=data.getFlashMsgs();var flashMsgArrayInvalid='';if(flashMsgArray instanceof Array)
{flashMsgArrayInvalid=flashMsgArray.findAll(function(s){return s.match('Invalid');});}
if(flashMsgArrayInvalid==''){this.watchlistSelected(data);}else{this.displayError(state,data,this.msgs.symInvalid+flashMsgArrayInvalid.join("<br/>"));}
this.hideLoaderGraphic();return;default:this.hideLoaderGraphic();this.displayError(state,data,"onUpdateWL");}},onDeleteWL:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:break;case BaseRequestor.State.SUCCESS:var txt="Deleting Watchlist...";this.showLoaderGraphic(txt);this.closeWatchAdmin();this.controllers.wlController.getWatchlists();return;default:this.hideLoaderGraphic();this.displayError(state,data,"onDeleteWL");}},onCreateWL:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:break;case BaseRequestor.State.SUCCESS:var txt="Creating Watchlist...";this.showLoaderGraphic(txt);this.closeWatchAdmin();if(!this.isWLNull(data.currentWatchlists))
this.controllers.wlController.getWatchlist([data.currentWatchlists[0].getId()]);return;default:this.hideLoaderGraphic();this.displayError(state,data,"onCreateWL");}},onGetQuotes:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:break;case BaseRequestor.State.SUCCESS:this.updateSymbolsView(data);this.updateAlertsView(data);return;default:this.hideLoaderGraphic();if(this.showError){this.displayError(state,data,"onGetQuotes");}}},onGetGuestAlerts:function(state,data){switch(state){case BaseRequestor.State.INITIALIZE:break;case BaseRequestor.State.SUCCESS:this.updateAlertsView(data,'GuestAlert');return;default:this.hideLoaderGraphic();if(this.showError){this.displayError(state,data,"onGetGuestAlerts");}}},onGetSaveSort:function(state,data){this.defaultOnFunction(state,data);},onExportWLToPortfolio:function(state,data){},onEditWLInPortfolio:function(state,data){},showLoaderGraphic:function(label){var loader=document.getElementById(this.uicontrols.lookupLoader);var html="<br\/><br\/>"+label+"<br\/>";html+='<img src="'+this.uicontrols.lookupLoaderIMG+'"/>';loader.innerHTML=html;loader.style.display='block';},hideLoaderGraphic:function(){var loader=document.getElementById(this.uicontrols.lookupLoader);var html='';loader.innerHTML=html;loader.style.display='none';var wlTable=document.getElementById(this.uicontrols.wlTable);var html='<div class="'+this.uicontrols.wlTableLoaderIMG+'"/>';wlTable.innerHTML=html;},displayError:function(state,data,msg){alert(state+' - '+data+' \n'+msg);},drawMenuView:function(){},isWLNull:function(watchlist)
{var nullValue=true;if(!this.isNull(watchlist))
{nullValue=this.isNull(watchlist[0]);}
return nullValue;},watchlistSelected:function(data)
{var newWLId='';if(this.currentWL!='')
{newWLId=this.currentWL;}else{newWLId=document.getElementById(this.uicontrols.adminName).value;}
this.controllers.symlookupSuggester.hideSymSuggest();this.clearField(this.uicontrols.lookupField);if(newWLId!='')
{this.controllers.wlController.getWatchlist([newWLId]);}
else
{if(data.currentWatchlists!=undefined&&data.currentWatchlists[0]!=undefined){this.controllers.wlController.getWatchlist([data.currentWatchlists[0].getId()]);}
else if(data.allWatchlists!=undefined&&data.allWatchlists[0]!=undefined){this.controllers.wlController.getWatchlist([data.allWatchlists[0].getId()]);}}},getWatchlists:function(){if(!this.isNull(this.controllers.wlController)){this.controllers.wlController.getWatchlists();}},getWatchlist:function(data){if(!this.isNull(this.controllers.wlController)){this.controllers.wlController.getWatchlist(data);}},deleteWatchlist:function(){if(!this.isNull(this.controllers.wlController)){var data=this.controllers.wlController.data;this.controllers.wlController.deleteWatchlist([data.currentWatchlists[0].getId()])}},loadDropDown:function(dropName,data)
{var allWatchlists=data.getAllWatchlists();var currentWLId=null;if(this.currentWL!='')
{currentWLId=this.currentWL;}else if(!this.isNull(data.currentWatchlists)&&data.currentWatchlists.length>0)
{currentWLId=data.currentWatchlists[0].getId();}
var wlDrop=document.getElementById(dropName);wlDrop.length=0;for(x=0;x<allWatchlists.length;x++){var optn=document.createElement("OPTION");optn.text=allWatchlists[x].name;optn.value=allWatchlists[x].id;if(allWatchlists[x].id==currentWLId)
{optn.selected=true;}else{optn.selected=false;}
wlDrop.options.add(optn);}},clearField:function(id)
{var panel=document.getElementById(id);panel.value='';panel.focus();},togglehide:function(popUp)
{var popUp=document.getElementById(popUp);if(popUp.style.display!='none')
{popUp.style.display='none'}
else
{popUp.style.display='block'}},disableAnchor:function(obj,disable,disColor,actColor)
{if(disable)
{var href=obj.getAttribute("href");var onclick=obj.getAttribute("onclick");if(href&&href!=""&&href!=null)
{obj.setAttribute('href_bak',href);}
if(onclick!=null)
{obj.setAttribute('onclick_bak',onclick);obj.setAttribute('onclick',"void(0);");}
obj.removeAttribute('href');obj.style.color=disColor;}else{if(obj.attributes['onclick_bak']!=null)
obj.setAttribute('onclick',obj.attributes['onclick_bak'].nodeValue);if(obj.attributes['href_bak']!=null)
obj.setAttribute('href',obj.attributes['href_bak'].nodeValue);obj.style.color=actColor;}},expandFund:function(expanderID,expandableID,imgPlus,imgMinus){var expander=document.getElementById(expanderID);var expandable=document.getElementById(expandableID);if(expandable.style.display!='none'){expandable.style.display='none';expander.src=imgPlus;}else{expandable.style.display='block';expander.src=imgMinus;}},createWL:function()
{var form=document.getElementById(this.uicontrols.adminForm);var symArray=new Array();var i=0;for(x=0;x<form.elements.length;x++)
{if((form.elements[x].name.match('symbol')!=null)&&(form.elements[x].value!=''))
{symArray[i]=form.elements[x].value;i++;}}
var watchlist=new WLWatchlist();watchlist.setName(document.getElementById(this.uicontrols.adminName).value);watchlist.setSymbols(symArray);this.controllers.wlController.createWatchlist(watchlist);},updateWL:function(data)
{var form=document.getElementById(this.uicontrols.adminForm);var symArray=new Array();var i=0;for(x=0;x<form.elements.length;x++)
{if((form.elements[x].name.match('symbol')!=null)&&(form.elements[x].value!=''))
{symArray[i]=form.elements[x].value;i++;}}
var watchlist=new WLWatchlist();watchlist.setId(data.currentWatchlists[0].getId());watchlist.setName(data.currentWatchlists[0].getName());watchlist.setSymbols(symArray);this.controllers.wlController.updateWatchlist(watchlist,document.getElementById(this.uicontrols.adminName).value);},adminFormSubmit:function(){document.getElementById(this.uicontrols.droplist).style.display="none";var formWLName=document.getElementById(this.uicontrols.adminName).value;if((formWLName!='')&&(formWLName!=null))
{if(this.adminToggle=='create')
{this.createWL();}else if(this.adminToggle=='edit')
{if(!this.isNull(this.controllers.wlController)){this.updateWL(this.controllers.wlController.data);}}}else{this.displayError('Watchlist Name Field is','Blank','Please give your Watchlist a name.');}},closeWatchAdmin:function()
{document.getElementById(this.uicontrols.droplist).style.display="block";var adminWin=document.getElementById(this.uicontrols.admin);if(adminWin.style.display!='none')
{adminWin.style.display='none';document.getElementById(this.uicontrols.adminDel).style.display='none';}
var form=document.getElementById(this.uicontrols.adminForm);this.adminToggle='';form.reset();document.getElementById(this.uicontrols.wlTable).style.display='block';document.getElementById(this.uicontrols.lookup).style.display='block';},toggleAdmin:function(choice)
{if(choice=='edit'){if(!this.isNull(this.controllers.wlController)){var data=this.controllers.wlController.data;if(!this.isWLNull(data.currentWatchlists)&&data.currentWatchlists[0].isImmutable()!=true){this.togglehide(this.uicontrols.admin);document.getElementById(this.uicontrols.adminDel).style.display='block';document.getElementById(this.uicontrols.wlTable).style.display='none';document.getElementById(this.uicontrols.lookup).style.display='none';this.loadEditAdmin(data);}else{alert(this.msgs.editPreDefined);}}}else if(choice=='create'){this.togglehide(this.uicontrols.admin);document.getElementById(this.uicontrols.adminDel).style.display='none';document.getElementById(this.uicontrols.wlTable).style.display='none';document.getElementById(this.uicontrols.lookup).style.display='none';}
this.adminToggle=choice;},loadEditAdmin:function(data)
{var form=document.getElementById(this.uicontrols.adminForm);document.getElementById(this.uicontrols.adminName).value=data.currentWatchlists[0].getName();var symbolsArray=data.currentWatchlists[0].getSymbols();var i=1;for(x=0;x<symbolsArray.length;x++){if(form.elements[i].name.indexOf('symbol')>-1){form.elements[i].value=symbolsArray[x];i++;}}
document.getElementById(this.uicontrols.adminDel).style.display='block';},initMenu:function()
{this.disableAnchor(document.getElementById(this.uicontrols.adminBarEdit),true,this.uicontrols.anchorEnabledCLR,this.uicontrols.anchorDisabledCLR);this.disableAnchor(document.getElementById(this.uicontrols.adminBarCreate),true,this.uicontrols.anchorEnabledCLR,this.uicontrols.anchorDisabledCLR);},activeMenu:function(data)
{if(!this.isWLNull(data.currentWatchlists)&&!data.currentWatchlists[0].isImmutable())
{this.disableAnchor(document.getElementById(this.uicontrols.adminBarEdit),false,this.uicontrols.anchorEnabledCLR,this.uicontrols.anchorDisabledCLR);}
this.disableAnchor(document.getElementById(this.uicontrols.adminBarCreate),false,this.uicontrols.anchorEnabledCLR,this.uicontrols.anchorDisabledCLR);},addSymLookUp:function()
{if(!this.isNull(this.controllers.wlController)){var data=this.controllers.wlController.data;if(!this.isWLNull(data.currentWatchlists)&&data.currentWatchlists[00].isImmutable()!=true)
{var symArray=data.currentWatchlists[0].getSymbols();var InputSymbols=document.getElementById(this.uicontrols.lookupField).value.replace(/ /g,"");var symbols_split=InputSymbols.split(",");for(s=0;s<symbols_split.length;s++)
symArray.push(symbols_split[s]);var wlId=data.currentWatchlists[0].getId();var wlName=data.currentWatchlists[0].getName();var watchlist=new WLWatchlist();watchlist.setId(wlId);watchlist.setName(data.currentWatchlists[0].getName());watchlist.setSymbols(symArray);this.controllers.wlController.updateWatchlist(watchlist,wlName);document.getElementById(this.uicontrols.lookupField).value='';return false;}else{this.displayError('Predefined Watchlist','isImmutable',this.msgs.addPreDefined);return false;}}},saveSortOrder:function(tableName)
{if(!this.isNull(this.controllers.wlController)){var data=this.controllers.wlController.data;if(!this.isWLNull(data.currentWatchlists)&&data.currentWatchlists[000]!=undefined&&!data.currentWatchlists[000].isImmutable())
{var wlTable=document.getElementById(tableName);var symArray=new Array();for(i=0;i<wlTable.tBodies[0].rows.length;i++)
{symArray[i]=wlTable.tBodies[0].rows[i].cells[0].childNodes[0].childNodes[0].nodeValue;}
data.currentWatchlists[000].setSymbols(symArray);var watchlist=new WLWatchlist();watchlist.setName(data.currentWatchlists[000].getName());watchlist.setSymbols(symArray);this.controllers.wlController.saveSortWatchlist(watchlist);}}},createSymbolsView:function(data)
{this.drawSymbolsView(data);this.fetchSymbolsData(data);},fetchSymbolsData:function(data){var wlModel=data||null;if(wlModel==null){if(!this.isNull(this.controllers.wlController)){wlModel=this.controllers.wlController.data;}}
var symbols=wlModel.currentWatchlists[0].getSymbols();this.controllers.quoteController.getQuoteData(symbols);},drawSymbolsView:function(data)
{},updateAlertsView:function(data,alertType)
{},updateSymbolsView:function(data)
{},initTimedRefresh:function(data)
{},clearAllFields:function()
{},init:function()
{}});BaseWLController=Class.create();BaseWLController.prototype=Object.extend(new BaseController,{initialize:function(data,requestor,parser){this.data=data;this.requestor=requestor
this.parser=parser;},getWatchlists:function(){},getWatchlist:function(watchlists){},updateWatchlist:function(watchlists,newSymbols,newWatchlist){},deleteWatchlist:function(watchlists){},createWatchlist:function(watchlists,newSymbols){}});BaseWLQuoteController=Class.create();BaseWLQuoteController.prototype=Object.extend(new BaseController,{initialize:function(data,requestor,parser){this.data=data;this.requestor=requestor
this.parser=parser;},getQuoteData:function(symbols,extraparams){if(symbols.length!=""){var symbolsParam=this.fromArrayToString(symbols,"|");var URL="http://quote.cnbc.com/quote-html-webservice/quote.htm";var params="partnerId="+this.data.partnerID+"&callerapp=PWLCOMP&noform=1&output=json&realtime=1&exthrs=1&fund=1&requestMethod=extended&extendedMask=30&symbols="+escape(symbolsParam);if(!this.isNull(extraparams))
params+="&"+extraparams;this.execute(URL,params,{event:WLEvent.Type.GETQUOTES,method:'GET',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:10000});}},streamQuoteData:function(){var symbolsParam=this.fromQuoteModelToString("|");var URL="http://quote.cnbc.com/quote-html-webservice/quote.htm";var params="partnerId="+this.data.partnerID+"&callerapp=PWLCOMP&noform=1&output=json&realtime=1&exthrs=1&fund=1&symbols="+escape(symbolsParam);this.execute(URL,params,{event:WLEvent.Type.GETQUOTES,method:'GET',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:10000});},fromQuoteModelToString:function(delimeter){var value="";var separator=delimeter||",";if(((typeof this.data.quoteMap)!='undefined')&&(this.data.quoteMap!=null))
{for(var prop in this.data.quoteMap)
{if((typeof this.data.quoteMap[prop])=='object')
{if(value!=""){value+=separator;}
value+=this.data.getQuote(prop).getSymbol();}}}
return value;}});BaseWLAlertController=Class.create();BaseWLAlertController.prototype=Object.extend(new BaseController,{initialize:function(data,requestor,parser,urlBuilder,paramsBuilder,alertType){this.data=data;this.requestor=requestor
this.parser=parser;this.urlBuilder=urlBuilder;this.paramsBuilder=paramsBuilder;this.alertType=alertType},getURL:function(){return this.url;},getAlerts:function(symbols){if(!this.isNull(symbols))
{for(var i=0;i<symbols.length;i++){var symbol=symbols[i];if((typeof symbol)==(typeof"")){var URL=this.urlBuilder(symbol);var params="partnerId="+this.data.partnerID+"&"+this.paramsBuilder(symbol);this.execute(URL,params,{event:this.alertType,method:'POST',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:15000});}}}}});WLAlert=Class.create();WLAlert.prototype={initialize:function(){this.symbol='';this.title='';this.description='';this.link='';this.source='';this.show='';this.pubTime='';this.thumbnail='';},getSymbol:function(){return this.symbol;},getTitle:function(){return this.title;},getDescription:function(){return this.description;},getLink:function(){return this.link;},getSource:function(){return this.source;},getShow:function(){return this.show;},getPubTime:function(){return this.pubTime;},getThumbnail:function(){return this.thumbnail;},setSymbol:function(symbol){this.symbol=symbol;},setTitle:function(title){this.title=title;},setDescription:function(description){this.description=description;},setLink:function(link){this.link=link;},setSource:function(source){this.source=source;},setShow:function(show){this.show=show;},setPubTime:function(pubTime){this.pubTime=pubTime;},setThumbnail:function(thumbnail){this.thumbnail=thumbnail;}};WLAlertModel=Class.create();WLAlertModel.prototype=Object.extend(new BaseModel,{initialize:function(views){this.views=views||[];this.alertMap=[];this.partnerID='';},getAlertMap:function(){return this.alertMap;},setAlertMap:function(alertMap){this.alertMap=alertMap;},getPartnerID:function(){return this.partnerID;},setPartnerID:function(partnerID){this.partnerID=partnerID;},getAlert:function(symbol){return(((typeof this.alertMap[symbol])!='undefined')&&(this.alertMap[symbol]!=null))?this.alertMap[symbol].alert:null;},setAlert:function(alert){if(((typeof alert)!='undefined')&&(alert!=null))
{var symbol=alert.getSymbol();if(((typeof this.alertMap[symbol])=='undefined')||(this.alertMap[symbol]==null))
{this.alertMap[symbol]=[];this.alertMap[symbol].refcount=0;}
this.alertMap[symbol].alert=alert;this.alertMap[symbol].refcount++;}},deleteAlert:function(symbol){if(((typeof this.alertMap[symbol])!='undefined')&&(this.alertMap[symbol]!=null))
{this.alertMap[symbol].refcount--;if(this.alertMap[symbol].refcount<=0)
{delete this.alertMap[symbol];}}},applyData:function(event,data){if(((typeof event)!='undefined')&&(event!=null)&&((typeof data)!='undefined')&&(data!=null))
{try
{switch(event.getState())
{case BaseRequestor.State.ERROR:case BaseRequestor.State.TIMEOUT:return data;break;default:var updateModel=new WLAlertModel();for(var i=0;i<data.alertMap.length;++i)
{updateModel.setAlert(data.alertMap[i]);this.setAlert(data.alertMap[i]);}
return updateModel;break;}}
catch(e)
{event.setState(BaseRequestor.State.ERROR);return e.message;}}
return this;}});WLStatusMsg=Class.create();WLStatusMsg.prototype={initialize:function(){this.statusCode='';this.statusDesc='';},getStatusCode:function(){return this.statusCode;},getStatusDesc:function(){return this.statusDesc;},setStatusCode:function(statusCode){this.statusCode=statusCode;},setStatusDesc:function(statusDesc){this.statusDesc=statusDesc;}};WLCurrency=Class.create();WLCurrency.prototype={initialize:function(){this.currencyCode='';this.currencySymbol='';this.countryCode='';},getCurrencyCode:function(){return this.currencyCode;},getCurrencySymbol:function(){return this.currencySymbol;},getCountryCode:function(){return this.countryCode;},setCurrencyCode:function(currencyCode){this.currencyCode=currencyCode;},setCurrencySymbol:function(currencySymbol){this.currencySymbol=currencySymbol;},setCountryCode:function(countryCode){this.countryCode=countryCode;}};WLQuote=Class.create();WLQuote.prototype={initialize:function(){this.code='';this.symbol='';this.name='';this.last=0.0;this.lastTime='';this.open=0.0;this.close=0.0;this.change=0.0;this.change_pct=0.0;this.low=0.0;this.high=0.0;this.volume=0;this.realtime=true;this.source='';this.exchange='';this.timezone='';this.currency=null;this.fundData=[];this.newsAlerts=[];this.videoAlerts=[];this.guestAlerts=[];},getCode:function(){return this.code;},getSymbol:function(){return this.symbol;},getName:function(){return this.name;},getLast:function(){return this.last;},getLastTime:function(){return this.lastTime;},getOpen:function(){return this.open;},getClose:function(){return this.close;},getChange:function(){return this.change;},getChange_pct:function(){return this.change_pct;},getLow:function(){return this.low;},getHigh:function(){return this.high;},getVolume:function(){return this.volume;},getRealtime:function(){return this.realtime;},getSource:function(){return this.source;},getExchange:function(){return this.exchange;},getTimezone:function(){return this.timezone;},getCurrency:function(){return this.currency;},getFundData:function(){return this.fundData;},getNewsAlerts:function(){return this.newsAlerts;},getVideoAlerts:function(){return this.videoAlerts;},getGuestAlerts:function(){return this.guestAlerts;},setCode:function(code){this.code=code;},setSymbol:function(symbol){this.symbol=symbol;},setName:function(name){this.name=name;},setLast:function(last){this.last=last;},setLastTime:function(lastTime){this.lastTime=lastTime;},setOpen:function(open){this.open=open;},setClose:function(close){this.close=close;},setChange:function(change){this.change=change;},setChange_pct:function(change_pct){this.change_pct=change_pct;},setLow:function(low){this.low=low;},setHigh:function(high){this.high=high;},setVolume:function(volume){this.volume=volume;},setRealtime:function(realtime){this.realtime=realtime;},setSource:function(source){this.source=source;},setExchange:function(exchange){this.exchange=exchange;},setTimezone:function(timezone){this.timezone=timezone;},setCurrency:function(currency){this.currency=currency;},setFundData:function(fundData){this.fundData=fundData;},setNewsAlerts:function(newsAlerts){this.newsAlerts=newsAlerts;},setVideoAlerts:function(videoAlerts){this.videoAlerts=videoAlerts;},setGuestAlerts:function(guestAlerts){this.guestAlerts=guestAlerts;}};WLQuoteModel=Class.create();WLQuoteModel.prototype=Object.extend(new BaseModel,{initialize:function(views){this.views=views||[];this.vuid='';this.partnerID='';this.quoteMap=[];},getVuid:function(){return this.vuid;},getPartnerID:function(){return this.partnerID;},setVuid:function(vuid){this.vuid=vuid;},setPartnerID:function(partnerID){this.partnerID=partnerID;},getQuote:function(symbol){return(((typeof this.quoteMap[symbol])!='undefined')&&(this.quoteMap[symbol]!=null))?this.quoteMap[symbol].quote:null;},setQuote:function(quote){if(((typeof quote)!='undefined')&&(quote!=null))
{var symbol=quote.getSymbol();if(((typeof this.quoteMap[symbol])=='undefined')||(this.quoteMap[symbol]==null))
{this.quoteMap[symbol]=[];this.quoteMap[symbol].refcount=0;}
this.quoteMap[symbol].quote=quote;this.quoteMap[symbol].refcount++;}},deleteQuote:function(symbol){if(((typeof this.quoteMap[symbol])!='undefined')&&(this.quoteMap[symbol]!=null))
{this.quoteMap[symbol].refcount--;if(this.quoteMap[symbol].refcount<=0)
{delete this.quoteMap[symbol];}}},applyData:function(event,data){if(((typeof event)!='undefined')&&(event!=null)&&((typeof data)!='undefined')&&(data!=null))
{try
{switch(event.getState())
{case BaseRequestor.State.ERROR:case BaseRequestor.State.TIMEOUT:return data;break;default:var updateModel=new WLQuoteModel();for(var i=0;i<data.quoteMap.length;++i)
{updateModel.setQuote(data.quoteMap[i]);this.setQuote(data.quoteMap[i]);}
return updateModel;break;}}
catch(e)
{event.setState(BaseRequestor.State.ERROR);return e.message;}}
return this;}});WLQuoteParser=Class.create();WLQuoteParser.prototype=Object.extend(new BaseModelParser,{initialize:function(){},load:function(request){if(((typeof request)!='undefined')&&(request!=null))
{var content=request.responseText;var content=eval('('+content+')');var data=[];data.quoteMap=new Array();var extQuoteNodes=content.ExtendedQuoteResult.ExtendedQuote;if(((typeof extQuoteNodes.length)!='undefined')&&(extQuoteNodes.length!=null)&&(extQuoteNodes.length!=0))
{for(m=0;m<extQuoteNodes.length;m++)
{var quoteNodes=extQuoteNodes[m].QuickQuote;var iterateQuoteObj=new WLQuote();var tickersymbol=quoteNodes.symbol;iterateQuoteObj.code=quoteNodes.code;iterateQuoteObj.symbol=tickersymbol;if(iterateQuoteObj.code!='1')
{iterateQuoteObj.name=quoteNodes.name;iterateQuoteObj.last=parseFloat(quoteNodes.last);iterateQuoteObj.lastTime=quoteNodes.last_time;iterateQuoteObj.open=parseFloat(quoteNodes.open);iterateQuoteObj.change=parseFloat(quoteNodes.change);iterateQuoteObj.change_pct=parseFloat(quoteNodes.change_pct);iterateQuoteObj.low=parseFloat(quoteNodes.low);iterateQuoteObj.high=parseFloat(quoteNodes.high);iterateQuoteObj.volume=parseInt(quoteNodes.volume);if((typeof quoteNodes.FundamentalData)!='undefined')
{iterateQuoteObj.fundData=quoteNodes.FundamentalData;}
var videoAlertNode=extQuoteNodes[m].VideoAlerts;if((typeof videoAlertNode)!='undefined')
{iterateQuoteObj.videoAlerts=videoAlertNode.VideoAlert;}
var newsAlertNode=extQuoteNodes[m].NewsAlerts;if((typeof newsAlertNode)!='undefined')
{iterateQuoteObj.newsAlerts=newsAlertNode.NewsAlert;}}
data.quoteMap.push(iterateQuoteObj);}}else{var quoteNodes=extQuoteNodes.QuickQuote;var iterateQuoteObj=new WLQuote();var tickersymbol=quoteNodes.symbol;iterateQuoteObj.code=quoteNodes.code;iterateQuoteObj.symbol=quoteNodes.symbol;if(iterateQuoteObj.code!='1')
{iterateQuoteObj.name=quoteNodes.name;iterateQuoteObj.last=parseFloat(quoteNodes.last);iterateQuoteObj.lastTime=quoteNodes.last_time;iterateQuoteObj.open=parseFloat(quoteNodes.open);iterateQuoteObj.change=parseFloat(quoteNodes.change);iterateQuoteObj.change_pct=parseFloat(quoteNodes.change_pct);iterateQuoteObj.low=parseFloat(quoteNodes.low);iterateQuoteObj.high=parseFloat(quoteNodes.high);iterateQuoteObj.volume=parseInt(quoteNodes.volume);if((typeof quoteNodes.FundamentalData)!='undefined')
{iterateQuoteObj.fundData=quoteNodes.FundamentalData;}
var videoAlertNode=extQuoteNodes.VideoAlerts;if((typeof videoAlertNode)!='undefined')
{if(((typeof videoAlertNode.VideoAlert.length)!='undefined')&&(videoAlertNode.VideoAlert.length!=null))
{iterateQuoteObj.videoAlerts=videoAlertNode.VideoAlert[0];}else{iterateQuoteObj.videoAlerts=videoAlertNode.VideoAlert;}}
var newsAlertNode=extQuoteNodes.NewsAlerts;if((typeof newsAlertNode)!='undefined')
{if(((typeof newsAlertNode.NewsAlert.length)!='undefined')&&(newsAlertNode.NewsAlert.length!=null))
{iterateQuoteObj.newsAlerts=newsAlertNode.NewsAlert[0];}else{iterateQuoteObj.newsAlerts=newsAlertNode.NewsAlert;}}}
data.quoteMap.push(iterateQuoteObj);}
return data;}
return null;}});WLPartner=Class.create();WLPartner.prototype={initialize:function(){this.attributionTxt='';this.refreshQuoteSeconds=30;},getAttributionTxt:function(){return this.attributionTxt;},getRefreshQuoteSeconds:function(){return this.refreshQuoteSeconds;},setAttributionTxt:function(attributionTxt){this.attributionTxt=attributionTxt;},setRefreshQuoteSeconds:function(refreshSeconds){this.refreshQuoteSeconds=refreshSeconds;}};WLWatchlist=Class.create();WLWatchlist.prototype={initialize:function(){this.id='';this.name='';this.source='';this.desc='';this.createDate='';this.updateDate='';this.symbols=[];this.immutable=true;},getId:function(){return this.id;},getName:function(){return this.name;},getSource:function(){return this.source;},getDesc:function(){return this.desc;},getCreateDate:function(){return this.createDate;},getUpdateDate:function(){return this.updateDate;},getSymbols:function(){return this.symbols;},isImmutable:function(){return this.immutable;},setId:function(id){this.id=id;},setName:function(name){this.name=name;},setSource:function(source){this.source=source;},setDesc:function(desc){this.desc=desc;},setCreateDate:function(createDate){this.createDate=createDate;},setUpdateDate:function(updateDate){this.updateDate=updateDate;},setSymbols:function(symbols){this.symbols=symbols;},setImmutable:function(isImmutable){this.immutable=isImmutable;}};WLWatchlist.Source=[];WLWatchlist.Source.CNBC="cnbc";WLWatchlist.Source.PRE="PRE";WLModel=Class.create();WLModel.prototype=Object.extend(new BaseModel,{initialize:function(views){this.views=views||[];this.vuid='';this.partnerID='';this.currentWatchlists=[];this.allWatchlists=[];this.partner=null;this.authKey='';this.flashMsgs=[];this.statusMsgs=null;this.uri='';},getVuid:function(){return this.vuid;},getPartnerID:function(){return this.partnerID;},getCurrentWatchlists:function(){return this.currentWatchlists;},getAllWatchlists:function(){return this.allWatchlists;},getPartner:function(){return this.partner;},getAuthKey:function(){return this.authKey;},getFlashMsgs:function(){return this.flashMsgs;},getStatusMsgs:function(){return this.statusMsgs;},getUri:function(){return this.uri;},setVuid:function(vuid){this.vuid=vuid;},setPartnerID:function(partnerID){this.partnerID=partnerID;},setCurrentWatchlists:function(currentWatchlists){this.currentWatchlists=currentWatchlists;if(!this.isNull(this.currentWatchlists))
{for(var n=0;n<this.currentWatchlists.length;n++)
{var current=this.currentWatchlists[n];if(!this.isNull(current)&&!this.isNull(this.allWatchlists))
{for(var i=0;i<this.allWatchlists.length;++i)
{var allCurrent=this.allWatchlists[i];if(!this.isNull(allCurrent))
{if(current.getId()==allCurrent.getId())
{allCurrent=current;break;}}}}}}},setAllWatchlists:function(allWatchlists){this.allWatchlists=allWatchlists;},setPartner:function(partner){this.partner=partner;},setAuthKey:function(authKey){this.authKey=authKey;},setFlashMsgs:function(flashMsgs){this.flashMsgs=flashMsgs;},setStatusMsgs:function(statusMsgs){this.statusMsgs=statusMsgs;},setUri:function(url){this.uri=url;},applyData:function(event,data){if((!this.isNull(event))&&(!this.isNull(data)))
{try
{switch(event.getState())
{case BaseRequestor.State.ERROR:case BaseRequestor.State.TIMEOUT:return data;break;default:var updateModel=new WLModel();updateModel.setAllWatchlists(data.allWatchlists);updateModel.setCurrentWatchlists(data.currentWatchlists);updateModel.setPartner(data.partner);updateModel.setAuthKey(data.authKey);updateModel.setFlashMsgs(data.flashMsgs);updateModel.setStatusMsgs(data.statusMsgs);updateModel.setUri(data.uri);if(!this.isNull(data.allWatchlists))
this.setAllWatchlists(data.allWatchlists);if(!this.isNull(data.currentWatchlists))
this.setCurrentWatchlists(data.currentWatchlists);if(!this.isNull(data.partner))
this.setPartner(data.partner);if(!this.isNull(data.authKey))
this.setAuthKey(data.authKey);if(!this.isNull(data.flashMsgs))
this.setFlashMsgs(data.flashMsgs);if(!this.isNull(data.statusMsgs))
this.setStatusMsgs(data.statusMsgs);if(!this.isNull(data.uri))
this.setStatusMsgs(data.uri);return updateModel;break;}}
catch(e)
{event.setState(BaseRequestor.State.ERROR);return e.message;}}
return this;}});WLModelParser=Class.create();WLModelParser.prototype=Object.extend(new BaseModelParser,{initialize:function(){},load:function(request){if(((typeof request)!='undefined')&&(request!=null))
{var content=request.responseText.replace(/^\s*|\s*$/g,'');content=eval('('+content+')');var data=[];data.partner=new WLPartner();data.authKey=content.authKey;data.flashMsgs=content.flashMessages;data.uri=content.uri;data.statusMsgs=new WLStatusMsg();data.statusMsgs.setStatusCode(content.statusCode);data.statusMsgs.setStatusDesc(content.statusDesc);if(!this.isNull(content.allWatchlists))
{data.allWatchlists=new Array();var watchlistCount=content.allWatchlists.watchlist.length;if(!this.isNull(watchlistCount))
{for(var m=0;m<watchlistCount;m++)
{var iterateWLObj=new WLWatchlist();iterateWLObj.id=content.allWatchlists.watchlist[m].id;iterateWLObj.name=content.allWatchlists.watchlist[m].name;iterateWLObj.source=content.allWatchlists.watchlist[m].source;data.allWatchlists[m]=iterateWLObj;}}
else if(!this.isNull(content.allWatchlists.watchlist.id))
{data.currentWatchlists=new Array();var iterateWLObj=new WLWatchlist();iterateWLObj.id=content.allWatchlists.watchlist.id;iterateWLObj.name=content.allWatchlists.watchlist.name;iterateWLObj.source=content.allWatchlists.watchlist.source;iterateWLObj.immutable=content.allWatchlists.watchlist.immutable=="true";data.currentWatchlists[0]=iterateWLObj;}}
else if(!this.isNull(content.id))
{data.currentWatchlists=new Array();var iterateWLObj=new WLWatchlist();iterateWLObj.id=content.id;iterateWLObj.name=content.name;iterateWLObj.source=content.source;iterateWLObj.immutable=content.immutable=="true";iterateWLObj.symbols=new Array();if(content.symbols!=undefined&&content.symbols!=null){var currentSymbols=content.symbols.symbol;if((typeof currentSymbols.length)!='undefined')
{for(var si=0;si<currentSymbols.length;si++)
{if(!this.isNull(currentSymbols[si].name))
iterateWLObj.symbols[si]=currentSymbols[si].name;}}else{if(!this.isNull(currentSymbols.name))
iterateWLObj.symbols[0]=currentSymbols.name;}}
data.currentWatchlists[0]=iterateWLObj;}
return data;}
return null;}});WLModelXMLParser=Class.create();WLModelXMLParser.prototype=Object.extend(new BaseModelParser,{initialize:function(){},load:function(request){if(((typeof request)!='undefined')&&(request!=null))
{var content=request.responseXML;var data=[];var partnerObj=new WLPartner();var statusObj=new WLStatusMsg();data.allWatchlists=new Array();data.flashMsgs=new Array();data.currentWatchlists=new Array();partnerObj.attributionTxt=this.nodeEmptyChk(content.getElementsByTagName("attributionText")[0]);partnerObj.refreshQuoteSeconds=this.nodeEmptyChk(content.getElementsByTagName("refreshQuoteSeconds")[0]);statusObj.statusCode=this.nodeEmptyChk(content.getElementsByTagName("statusCode")[0]);statusObj.statusDesc=this.nodeEmptyChk(content.getElementsByTagName("statusDesc")[0]);data.statusMsgs=statusObj;data.partner=partnerObj;data.authKey=this.nodeEmptyChk(content.getElementsByTagName("authKey")[0]);for(m=0;m<content.getElementsByTagName("allWatchlists")[0].getElementsByTagName("watchlist").length;m++)
{data.allWatchlists[m]=content.getElementsByTagName("allWatchlists")[0].getElementsByTagName("watchlist")[m].childNodes[0].nodeValue;}
for(m=0;m<content.getElementsByTagName("flashMessages")[0].getElementsByTagName("String").length;m++)
{data.flashMsgs[m]=content.getElementsByTagName("flashMessages")[0].getElementsByTagName("String")[m].childNodes[0].nodeValue;}
for(m=0;m<content.getElementsByTagName("currentWatchlists")[0].childNodes.length;m++)
{var iterateWLObj=new WLWatchlist();var iterateWLIndex=content.getElementsByTagName("currentWatchlists")[0].getElementsByTagName("WatchList")[m];iterateWLObj.name=this.nodeEmptyChk(iterateWLIndex.getElementsByTagName("name")[0]);iterateWLObj.desc=this.nodeEmptyChk(iterateWLIndex.getElementsByTagName("desc")[0]);iterateWLObj.createDate=this.nodeEmptyChk(iterateWLIndex.getElementsByTagName("createDate")[0]);iterateWLObj.updateDate=this.nodeEmptyChk(iterateWLIndex.getElementsByTagName("updateDate")[0]);iterateWLObj.symbols=new Array();if(iterateWLIndex.getElementsByTagName("symbols")[0].hasChildNodes())
{for(n=0;n<iterateWLIndex.getElementsByTagName("symbols")[0].childNodes.length;n++)
{iterateWLObj.symbols[n]=this.nodeEmptyChk(iterateWLIndex.getElementsByTagName("symbols")[0].childNodes[n].getElementsByTagName("symbolName")[0]);}}
iterateWLObj.isImmutable=(iterateWLIndex.getElementsByTagName("immutable")[0].childNodes[0].nodeValue=="true")?true:false;data.currentWatchlists[m]=iterateWLObj;}
return data;}
return null;},nodeEmptyChk:function(XMLnode)
{var str="";if(XMLnode.hasChildNodes()){str=XMLnode.childNodes[0].nodeValue;}
return str;}});WLEvent=Class.create();WLEvent.prototype=Object.extend(new Event,{initialize:function(type,state){this.type=type;this.state=state;}});WLEvent.Type=[];WLEvent.Type.GETWLNAMES="GETWLNAMES";WLEvent.Type.GETWL="GETWL";WLEvent.Type.UPDATEWL="UPDATEWL";WLEvent.Type.DELETEWL="DELETEWL";WLEvent.Type.CREATEWL="CREATEWL";WLEvent.Type.GETQUOTES="GETQUOTES";WLEvent.Type.GETGUESTALERT="GETGUESTALERT";WLEvent.Type.SAVESORTWL="SAVESORTWL";WLEvent.Type.EXPORTTOPORTFOLIO="EXPORTTOPORTFOLIO";WLEvent.Type.EDITINPORTFOLIO="EDITINPORTFOLIO";

/** watchlist.js **/



CNBCGadgetView=Class.create();CNBCGadgetView.prototype=Object.extend(new BaseWLView,{initialize:function(id,controllers,uicontrols,msgs,userstate,wlserviceurl,maxsymbols){this.id=id;this.controllers=controllers;this.uicontrols=uicontrols;this.msgs=msgs;this.userstate=userstate;this.wlserviceurl=wlserviceurl||"http://watchlist.cnbc.com/main.do";this.adminToggle="";this.refreshQuoteInt=null;this.wlCookie="cnbc_pwl_id";this.currentWL=this.readWatchlistCookie(this.wlCookie)||'';this.showError=false;this.showWLError=true;this.maxsymbols=30||maxsymbols;this.init();},onGetWL:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:this.initMenu();clearInterval(this.refreshQuoteInt);var txt="Retrieving Watchlist...";this.showLoaderGraphic(txt);this.showWLError=true;return;case BaseRequestor.State.SUCCESS:this.hideLoaderGraphic();this.showWLError=false;var wl0=null;if(!this.isWLNull(data.currentWatchlists))
wl0=data.currentWatchlists[0];this.currentWL=data.currentWatchlists[0].getId();this.createWatchlistCookie(this.wlCookie,this.currentWL);if(wl0!=null)
{var Symbols=data.currentWatchlists[0].getSymbols();this.controllers.settings.setCount(Symbols.length);this.createSymbolsView(data);this.initTimedRefresh(data);this.activeMenu(data);var source='';if(!this.isWLNull(data.currentWatchlists)){var source=data.currentWatchlists[0].getSource();if(source=='portfolio'||source=='pre'||source=='editorialpicks'){this.toggleExportLinks('portfolio');}else if(source=='cnbc'){this.toggleExportLinks('watchlist');}}}
return;default:this.hideLoaderGraphic();if(this.showWLError){this.displayError(state,data,"onGetWL");}}},onCreateWL:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:this.disableOnSubmit();var txt="Creating Watchlist...";this.showLoaderGraphic(txt);break;case BaseRequestor.State.SUCCESS:this.disableAdminMenuListeners();this.enableOnEditMenu();this.hideLoaderGraphic();var statusArray=data.getStatusMsgs();if(statusArray.statusCode!='OK')
{this.displayError('StatusError',"",statusArray.statusDesc);return;}
var newWL=(!this.isNull(data)&&!this.isWLNull(data.currentWatchlists))?data.getCurrentWatchlists()[0]:null;if(!this.isNull(newWL))
{var wlModel=this.controllers.wlController.data;if(!this.isNull(wlModel))
{var allWatchlists=wlModel.getAllWatchlists();if(!this.isNull(allWatchlists))
allWatchlists.push(newWL);}
this.currentWL=newWL.getId();this.createWatchlistCookie(this.wlCookie,this.currentWL);this.controllers.wlController.getWatchlists();this.closeMenu();}else{this.controllers.wlController.getWatchlists();this.closeMenu();}
break;default:this.hideLoaderGraphic();this.displayError(state,data,"onCreateWL");break;}},onUpdateWL:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:this.disableOnSubmit();var txt="Updating Watchlist...";this.showLoaderGraphic(txt);return;case BaseRequestor.State.SUCCESS:this.enableOnEditMenu();this.hideLoaderGraphic();var statusArray=data.getStatusMsgs();if(statusArray.statusCode!='OK')
{var statusMsgArray=data.getFlashMsgs();var statusMsgArrayString=statusMsgArray.message[0];this.displayError('StatusError',"",statusMsgArrayString);return;}
var flashMsgArray=data.getFlashMsgs();var flashMsgArrayAdded=new Array();var flashMsgArrayInvalid=new Array();if(flashMsgArray instanceof Object)
{var flashMsgArrayString=flashMsgArray.message;if((typeof flashMsgArrayString)!='string')
{for(i=0;i<flashMsgArray.message.length;i++)
{if(flashMsgArray.message[i].indexOf("Added symbol ")>-1)
{var symbol=flashMsgArray.message[i].substr(flashMsgArray.message[i].indexOf("Added symbol ")+13);flashMsgArrayAdded.push(symbol);}
if(flashMsgArray.message[i].indexOf("Invalid symbol ")>-1)
{var symbol=flashMsgArray.message[i].substr(flashMsgArray.message[i].indexOf("Invalid symbol ")+15);flashMsgArrayInvalid.push(symbol);}}}else if((typeof flashMsgArrayString)=='string'){if(flashMsgArray.message.indexOf("Added symbol ")>-1)
{var symbol=flashMsgArray.message.substr(flashMsgArray.message.indexOf("Added symbol ")+13);flashMsgArrayAdded.push(symbol);}
if(flashMsgArray.message.indexOf("Invalid symbol ")>-1)
{var symbol=flashMsgArray.message.substr(flashMsgArray.message.indexOf("Invalid symbol ")+15);flashMsgArrayInvalid.push(symbol);}}}
var wlModel=this.controllers.wlController.data;if(!this.isNull(wlModel))
{var newWL=(!this.isWLNull(wlModel.currentWatchlists))?wlModel.getCurrentWatchlists()[0]:null;var allWatchlists=wlModel.getAllWatchlists();if(!this.isNull(allWatchlists)){this.currentWL=newWL.getId();this.controllers.wlController.getWatchlists();}}
if(flashMsgArrayInvalid.length!=0)
{}else{this.disableAdminMenuListeners();if(this.adminToggle=='edit')
{this.drawMenuView('update',flashMsgArrayAdded);}}
return;default:this.hideLoaderGraphic();this.displayError(state,data,"onUpdateWL");}},onDeleteWL:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:this.disableOnDelete();var txt="Deleting Watchlist...";this.showLoaderGraphic(txt);break;case BaseRequestor.State.SUCCESS:this.enableOnDeleteConfirm();this.hideLoaderGraphic();this.currentWL='';this.controllers.wlController.getWatchlists();this.closeMenu();return;default:this.hideLoaderGraphic();this.displayError(state,data,"onDeleteWL");}},onExportWLToPortfolio:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:document.getElementById(this.uicontrols.droplist).style.display="none";this.disableOnSubmit();var txt="Exporting Watchlist...";this.showLoaderGraphic(txt);break;case BaseRequestor.State.SUCCESS:document.getElementById(this.uicontrols.droplist).style.display="block";this.enableOnEditMenu();this.hideLoaderGraphic();var url=data.getUri();var portWin=window.open(url);if(!portWin)
{portWin=window.open('');portWin.location.href=url;}
this.drawMenuView('export portfolio');return;default:this.hideLoaderGraphic();this.displayError(state,data,"onExportWL");}},onEditWLInPortfolio:function(state,data){switch(state)
{case BaseRequestor.State.INITIALIZE:this.disableOnSubmit();var txt="Loading Portfolio...";this.showLoaderGraphic(txt);break;case BaseRequestor.State.SUCCESS:this.enableOnEditMenu();this.hideLoaderGraphic();var url=data.getUri();var portWin=window.open(url);if(!portWin)
{portWin=window.open('');portWin.location.href=url;}
this.drawMenuView('edit portfolio');return;default:this.hideLoaderGraphic();this.displayError(state,data,"onExportWL");}},loadDropDown:function(dropName,data)
{var allWatchlists=data.getAllWatchlists();var currentWLId=null;if(this.currentWL!=''||this.currentWL!=null)
{currentWLId=this.currentWL;}else if(!this.isNull(data.currentWatchlists)&&data.currentWatchlists.length>0)
{currentWLId=data.currentWatchlists[0].getId();var Symbols=data.currentWatchlists[0].getSymbols();this.controllers.settings.setCount(Symbols.length);}
var wlDrop=document.getElementById(dropName);wlDrop.length=0;for(x=0;x<allWatchlists.length;x++){var optn=document.createElement("OPTION");var source=allWatchlists[x].source;if(source=='portfolio'){optn.text=allWatchlists[x].name+" - Portfolio";}else{optn.text=allWatchlists[x].name;}
optn.value=allWatchlists[x].id;if(allWatchlists[x].id==currentWLId)
{optn.selected=true;}else{optn.selected=false;}
wlDrop.options.add(optn);}},watchlistSelected:function(data){var newWLId='';if(this.currentWL!=''||this.currentWL!=null)
{newWLId=this.currentWL;}else{newWLId=document.getElementById(this.uicontrols.adminName).value;}
this.controllers.symlookupSuggester.hideSymSuggest();this.clearField(this.uicontrols.lookupField);if(newWLId!='')
{this.controllers.wlController.getWatchlist([newWLId]);this.createWatchlistCookie(this.wlCookie,newWLId);}
else
{if(data.currentWatchlists!=undefined&&data.currentWatchlists[0]!=undefined){this.controllers.wlController.getWatchlist([data.currentWatchlists[0].getId()]);this.createWatchlistCookie(this.wlCookie,data.currentWatchlists[0].getId());}
else if(data.allWatchlists!=undefined&&data.allWatchlists[0]!=undefined){this.controllers.wlController.getWatchlist([data.allWatchlists[0].getId()]);this.createWatchlistCookie(this.wlCookie,data.allWatchlists[0].getId());}}},drawSymbolsView:function(data)
{var uicontrols=this.uicontrols;if(document.getElementById(this.uicontrols.wlTable))
{var wlSortTable=document.getElementById(this.uicontrols.wlSortTable);var headerhtml='<table id="wl_sort_table" class="sortable">';headerhtml+='<thead><tr class="wl_row" id="wl_row_header">';headerhtml+='<th class="wl_symbol" id="wl_symbol_header">&#160;</th>';headerhtml+='<th class="wl_alerts unsortable" id="wl_alerts_header">&#160;</th>';headerhtml+='<th class="wl_last" id="wl_last_header">&#160;</th>';headerhtml+='<th class="wl_change_icon unsortable" id="wl_change_icon_header">&nbsp;</th>';headerhtml+='<th class="wl_change" id="wl_change_header">&#160;</th>';headerhtml+='<th class="wl_change_pct" id="wl_change_pct_header">&#160;</th>';headerhtml+='</tr></thead></table>';var wlTable=document.getElementById(this.uicontrols.wlTable);var html='<table id="wl_disp_table"><thead><tr></tr></thead><tbody>';var symbols=[];var symArray=data.currentWatchlists[0].getSymbols();this.currentSymCount=symArray.length;for(i=0;i<symArray.length;i++)
{var symbol=symArray[i];html+='<tr class="wl_row" id="wl_row_'+symbol+'">';html+='<td class="wl_symbol" id="wl_symbol_'+symbol+'">';html+=symbol+'</td>';html+='<td class="wl_alerts" id="wl_alerts_'+symbol+'">';html+='<div class="wl_alerts_news" id="wl_alerts_news_'+symbol+'"></div>';html+='<div class="wl_alerts_vid" id="wl_alerts_vid_'+symbol+'"></div></td>';html+='<td class="wl_last" id="wl_last_'+symbol+'"></td>';html+='<td class="wl_change_icon" id="wl_change_icon_'+symbol+'"></td>';html+='<td class="wl_change" id="wl_change_'+symbol+'"></td>';html+='<td class="wl_change_pct" id="wl_change_pct_'+symbol+'"></td>';html+='</tr>';symbols.push(symbol);}
html+='</tbody><tfoot></tfoot></table>';wlSortTable.innerHTML=headerhtml;wlTable.innerHTML=html;sortables_init('wl_disp_table','wl_sort_table');}
return symbols;},fetchSymbolsData:function(data){this.fetchQuoteData(data);},fetchQuoteData:function(data){var wlModel=data||null;if(wlModel==null){if(((typeof this.controllers.wlController)!='undefined')&&(this.controllers.wlController!=null)){wlModel=this.controllers.wlController.data;}}
var symbols=wlModel.currentWatchlists[0].getSymbols();var wlsource=wlModel.currentWatchlists[0].getSource();var wlname=wlModel.currentWatchlists[0].getName();if(wlsource=="cnbc"||wlsource=="portfolio"){var quotesyms=new Array();if(!this.isNull(symbols))
{for(var i=0;i<symbols.length;++i)
{quotesyms[0]=symbols[i];this.controllers.quoteController.getQuoteData(quotesyms);}}}else{this.controllers.quoteController.getQuoteData(symbols,"stdpwl=1&pwlname="+wlname);}},updateAlertsView:function(data){for(var prop in data.quoteMap)
{if((typeof data.quoteMap[prop])=='object')
{var quoteObj=data.getQuote(prop);if(quoteObj.code!='1')
{var symbol=quoteObj.symbol;if(((typeof quoteObj.newsAlerts)!='undefined')&&(quoteObj.newsAlerts.length!=0))
{if(((typeof quoteObj.newsAlerts.length)!='undefined')&&(quoteObj.newsAlerts.length!=null))
{var newsAlertNode=quoteObj.newsAlerts[0];}else{var newsAlertNode=quoteObj.newsAlerts;}
if(document.getElementById('wl_alerts_news_'+symbol))
{var alertDesc=newsAlertNode.description.replace(/"/gi,'');var alertHTML='<a href="'+newsAlertNode.link+'" target="_blank"';alertHTML+='title="CNBC News for '+symbol+': '+alertDesc+'">';alertHTML+='<div class="'+this.uicontrols.imgNewsAlert+'"></div></a>';document.getElementById('wl_alerts_news_'+symbol).innerHTML=alertHTML;}}
if(((typeof quoteObj.videoAlerts)!='undefined')&&(quoteObj.videoAlerts.length!=0))
{if(((typeof quoteObj.videoAlerts.length)!='undefined')&&(quoteObj.videoAlerts.length!=null))
{var newsVideoNode=quoteObj.videoAlerts[0];}else{var newsVideoNode=quoteObj.videoAlerts;}
if(document.getElementById('wl_alerts_vid_'+symbol))
{var alertDesc=newsVideoNode.description.replace(/"/gi,'');var alertHTML='<a href="'+newsVideoNode.link+'" target="_blank"';alertHTML+='title="CNBC Video for '+symbol+': '+alertDesc+'">';alertHTML+='<div class="'+this.uicontrols.imgVideoAlert+'"></div></a>';document.getElementById('wl_alerts_vid_'+symbol).innerHTML=alertHTML;}}}}}},updateSymbolsView:function(data){for(var prop in data.quoteMap)
{if((typeof data.quoteMap[prop])=='object')
{var quoteObj=data.getQuote(prop);if(quoteObj.code!='1')
{var marketCap="N/A";var peTTM=0;var peDisplay="N/A";var WeekLow="N/A";var WeekHigh="N/A";if((typeof quoteObj.fundData)!='undefined')
{marketCap=quoteObj.fundData.mktcapView;peTTM=parseFloat(quoteObj.fundData.pe);WeekHigh=parseFloat(quoteObj.fundData.yrhiprice);WeekLow=parseFloat(quoteObj.fundData.yrloprice);}
if(((typeof marketCap)=='undefined')||(marketCap=="")){marketCap="N/A";}
if(peTTM<0){peDisplay="NEG";}else if(peTTM==0){peDisplay="N/A";}else if(peTTM<100){peDisplay=peTTM.toFixed(2);}
var quoteLast=quoteObj.last.toFixed(4);var quoteChange=quoteObj.change.toFixed(4);var quoteChange_pct=quoteObj.change_pct.toFixed(2);var testChangeTrim=/00$/;if(testChangeTrim.test(quoteLast))
{quoteLast=parseFloat(quoteLast).toFixed(2);}
if(testChangeTrim.test(quoteChange))
{quoteChange=parseFloat(quoteChange).toFixed(2);}
if(quoteObj.symbol.length>5)
{var truncSymbol=quoteObj.symbol.substring(0,5)+"...";}else{var truncSymbol=quoteObj.symbol;}
var html_sym='<a onmouseover="popup(';html_sym+="'<b>("+quoteObj.symbol.replace(/'/gi,'\\\'')+") "+quoteObj.name.replace(/'/gi,'\\\'')+"</b> <br/> 52-Week High: "+WeekHigh+" <br/> 52-Week Low: "+WeekLow+"'";html_sym+=',\'cnbcWLContainer\')" onmouseout="kill(\'cnbcWLContainer\')" title=""';html_sym+='onfocus="this.blur()"class="wl_symbol_txt" ';html_sym+='href="http://data.cnbc.com/quotes/'+quoteObj.symbol.replace(/'/gi,'\'');html_sym+='" target="_blank">'+truncSymbol+'</a>';if(document.getElementById('wl_symbol_'+quoteObj.symbol))
{var wlSymCell=document.getElementById('wl_symbol_'+quoteObj.symbol);wlSymCell.innerHTML=html_sym;}
if(document.getElementById('wl_last_'+quoteObj.symbol))
{var wlLastCell=document.getElementById('wl_last_'+quoteObj.symbol);wlLastCell.innerHTML=quoteLast;}
var wlChgImgCellHTML='';var wlChgCellHTML='';var wlChgPctCellHTML='';if(quoteChange<0){wlChgImgCellHTML='<div class="'+this.uicontrols.imgCHdwn+'"></div>';wlChgCellHTML=quoteChange;wlChgPctCellHTML=quoteChange_pct+'%';}
else if(quoteChange>0){wlChgImgCellHTML='<div class="'+this.uicontrols.imgCHup+'"></div>';wlChgCellHTML=quoteChange;wlChgPctCellHTML=quoteChange_pct+'%';}
else{wlChgImgCellHTML='---';wlChgCellHTML='UNCH';wlChgPctCellHTML='---';}
if(document.getElementById('wl_change_icon_'+quoteObj.symbol))
{document.getElementById('wl_change_icon_'+quoteObj.symbol).innerHTML=wlChgImgCellHTML;}
if(document.getElementById('wl_change_'+quoteObj.symbol))
{document.getElementById('wl_change_'+quoteObj.symbol).innerHTML=wlChgCellHTML;}
if(document.getElementById('wl_change_pct_'+quoteObj.symbol))
{document.getElementById('wl_change_pct_'+quoteObj.symbol).innerHTML=wlChgPctCellHTML;}}}}},initTimedRefresh:function(data){if(!this.isNull(data.partner.getRefreshQuoteSeconds()))
{var refreshQuoteTime=parseInt(data.partner.getRefreshQuoteSeconds())*1000;}else{var refreshQuoteTime=(60*1000);}
this.refreshQuoteInt=setInterval('cnbc_wlviews.cnbc.fetchQuoteData()',refreshQuoteTime);},showLoaderGraphic:function(label){var loader=document.getElementById(this.uicontrols.lookupLoader);var html="<br\/><br\/>"+label+"<br\/>";html+='<img src="'+this.uicontrols.lookupLoaderIMG+'"/>';loader.innerHTML=html;loader.style.display='block';},hideLoaderGraphic:function(){var loader=document.getElementById(this.uicontrols.lookupLoader);var html='';loader.innerHTML=html;loader.style.display='none';},displayError:function(state,data,msg){document.getElementById(this.uicontrols.droplist).style.display="none";if(state=="TIMEOUT"||state=="ERROR")
{var errorHTML='<div class="content_area"><div class="title">Error Encountered<\/div><br\/>Please Try Again.<\/div>';}else if(state=="StatusError"){var errorHTML='<div class="content_area">';errorHTML+='<div class="title">ERROR<\/div>';errorHTML+=msg+'<br\/>'+data+'<\/div>';}else{var errorHTML='<div class="content_area">';errorHTML+='<div class="title">'+state+'<\/div>';errorHTML+=msg+'<br\/>'+data+'<\/div>';}
errorHTML+='<div class="but_area"><a id="wl_admin_closeIMG" href="javascript:cnbc_wlviews.cnbc.closeMenuOnError();">Close<\/a><\/div>';document.getElementById(this.uicontrols.wlError).innerHTML=errorHTML;document.getElementById(this.uicontrols.wlError).style.display="block";},drawSymLookupPage:function(id)
{document.getElementById(this.uicontrols.droplist).style.display="none";var symHTML="";symHTML+='<div id="wl_symlookup_title_bar">SYMBOL LOOKUP<\/div>';symHTML+='<div id="wl_static_SymLookup">';symHTML+='<form name="wl_static_symlookup_form" id="wl_static_symLookUp_form" onsubmit="return false;" method="post" autocomplete="off">';symHTML+='<div id="wl_symlookup_Enter_label"><\/div>';symHTML+='<INPUT id="wl_static_symlookupfield" TYPE="text" NAME="wl_static_symlookupfield" value="Symbol \/ Company" ';symHTML+='onfocus="cnbc_clr_addto_wl(this.id);" \/>';symHTML+='<INPUT TYPE="submit" class="wl_GoSymButton_btn" '
symHTML+='id="wl_GoSymButton" value="" onclick="ShowResults();" \/><\/form><\/div>';symHTML+='<div id="wl_symlookup_header"> <\/div>';symHTML+='<div id="wl_static_table">';symHTML+='<div id="dd_footer">';symHTML+='</div><\/div>';symHTML+='<div id="wl_static_symlookupPag"><\/div>';symHTML+='<div id="wl_static_but_area"><a id="wl_static_cancel" href="javascript:cnbc_wlviews.cnbc.closeSymLookupMenu();">Cancel<\/a><\/div>';document.getElementById(this.uicontrols.wlSymLookupPage).innerHTML=symHTML;document.getElementById(this.uicontrols.wlSymLookupPage).style.display="block";var wl_symlookup_suggester=null;var wl_symlookup_settings=null;wl_symlookup_settings=new SymbolLookupSettings('10',',','10','');var wl_symlookup_inputNode=document.getElementById(this.uicontrols.wlSymLookupPageField);var wl_symlookup_containerNode=document.getElementById(this.uicontrols.wlSymLookupPageTable);var wl_symlookup_buttonNode=document.getElementById(this.uicontrols.wlSymLookupPageButton);var wl_symlookup_paginNode=document.getElementById(this.uicontrols.wlSymLookupPagination);var wl_symlookup_errcontentDiv="<div id=\"dd_footer\" class=\"aL\">";wl_symlookup_errcontentDiv+="<span class=\"error\">There are no results for &quot;##prefix##&quot;</span>";wl_symlookup_errcontentDiv+="</div>";wl_symlookup_settings.setErrorContent(wl_symlookup_errcontentDiv);var script='onclick="cnbc_wlviews.cnbc.controllers.wl_symlookup_suggester.getLinkPage(##current##); return false;" ';wl_symlookup_settings.setPaginationLinksMethod(script);var wl_symlookup_link_event="cnbc_wlviews.cnbc.EditAdminUpdateField(\""+id+"\", \"##param##\");";wl_symlookup_settings.setLinkEvent(wl_symlookup_link_event);wl_symlookup_suggester=new CNBCGadgetStaticSymLookup(wl_symlookup_inputNode,wl_symlookup_buttonNode,wl_symlookup_containerNode,wl_symlookup_paginNode,wl_symlookup_settings);var wl_symlookup_uicontrols={"menu":this.uicontrols.wlSymLookupPageTable,"menutext":"Loading...","showLoader":cnbc_showLoader};var wl_symlookup_views={"cnbc":new CNBCSymbolLookupView(wl_symlookup_suggester,wl_symlookup_uicontrols)};var wl_symlookup_controller=new BaseSymbolLookupController(new SymbolLookupModel(wl_symlookup_views),new FlashProxyRequestor("flashQuoteProxy","json"),new SymbolLookupParser());wl_symlookup_suggester.setController(wl_symlookup_controller);cnbc_wlviews.cnbc.controllers.wl_symlookup_suggester=wl_symlookup_suggester;},drawMenuView:function(type,symbols)
{if(type=='export portfolio'){var errorHTML="";errorHTML+='<div class="content_area">';errorHTML+='<div class="title">Update Watchlists<\/div>';errorHTML+='Update portfolio watchlist after exporting';errorHTML+='<\/div>';errorHTML+='<div class="but_area"><a id="wl_admin_updateIMG" href="javascript:cnbc_wlviews.cnbc.closeMenu();cnbc_wlviews.cnbc.getWatchlists();">Update<\/a><\/div>';document.getElementById(this.uicontrols.droplist).style.display="none";document.getElementById(this.uicontrols.wlError).innerHTML=errorHTML;document.getElementById(this.uicontrols.wlError).style.display="block";}else if(type=='edit portfolio'){this.currentWL='';var errorHTML="";errorHTML+='<div class="content_area">';errorHTML+='<div class="title">Update Watchlists<\/div>';errorHTML+='Update portfolio watchlist after editing';errorHTML+='<\/div>';errorHTML+='<div class="but_area"><a id="wl_admin_updateIMG" href="javascript:cnbc_wlviews.cnbc.closeMenu();cnbc_wlviews.cnbc.getWatchlists();">Update<\/a><\/div>';document.getElementById(this.uicontrols.droplist).style.display="none";document.getElementById(this.uicontrols.wlError).innerHTML=errorHTML;document.getElementById(this.uicontrols.wlError).style.display="block";}else if(type=='update'){var errorHTML="";errorHTML+='<div class="content_area">';errorHTML+='<div class="title">Confirmation<\/div>';errorHTML+='You have successfully updated ';var wlModel=null;if(wlModel==null){if(((typeof this.controllers.wlController)!='undefined')&&(this.controllers.wlController!=null)){wlModel=this.controllers.wlController.data;}}
var updateWLName=wlModel.currentWatchlists[0].getName();errorHTML+='<strong>'+updateWLName.toUpperCase()+'<\/strong>';errorHTML+='<\/div>';errorHTML+='<div class="but_area"><a id="wl_admin_closeIMG" href="javascript:cnbc_wlviews.cnbc.closeMenu();">Close<\/a><\/div>';document.getElementById(this.uicontrols.droplist).style.display="none";document.getElementById(this.uicontrols.wlError).innerHTML=errorHTML;document.getElementById(this.uicontrols.wlError).style.display="block";}else if(type=='delete'){var wlModel=null;if(wlModel==null){if(((typeof this.controllers.wlController)!='undefined')&&(this.controllers.wlController!=null)){wlModel=this.controllers.wlController.data;}}
var deleteWLName=wlModel.currentWatchlists[0].getName();var confirmDeleteHTML="";confirmDeleteHTML+='<div class="content_area2">';confirmDeleteHTML+='<div class="title">Deleting &#39;'+deleteWLName+'&#39;<\/div>';confirmDeleteHTML+='You are about to permanently<br\/>';confirmDeleteHTML+='delete this watchlist';confirmDeleteHTML+='<\/div>';confirmDeleteHTML+='<div class="but_area"><a id="wl_admin_confirmDelete" href="javascript:cnbc_wlviews.cnbc.deleteWatchlist();">Delete<\/a>';confirmDeleteHTML+='<a id="wl_admin_cancel" href="javascript:cnbc_wlviews.cnbc.closeMenu();">Cancel<\/a><\/div>';document.getElementById(this.uicontrols.droplist).style.display="none";document.getElementById(this.uicontrols.wlError).innerHTML=confirmDeleteHTML;document.getElementById(this.uicontrols.wlError).style.display="block";}},closeMenu:function()
{this.enableOnEditMenu();document.getElementById(this.uicontrols.wlError).style.display="none";this.closeWatchAdmin();},closeMenuOnError:function()
{this.enableOnEditMenu();document.getElementById(this.uicontrols.wlError).style.display="none";if(this.adminToggle!='create'&&this.adminToggle!='export'&&this.adminToggle!='edit')
{document.getElementById(this.uicontrols.droplist).style.display="block";}},closeSymLookupMenu:function()
{document.getElementById(this.uicontrols.wlSymLookupPage).style.display="none";},disableAnchor:function(obj,disable,disValue,actValue,type)
{if(disable)
{var href=obj.getAttribute("href");var onclick=obj.getAttribute("onclick");if(href&&href!=""&&href!=null)
{obj.setAttribute('href_bak',href);}
if(onclick!=null)
{obj.setAttribute('onclick_bak',onclick);obj.setAttribute('onclick',"void(0);");}
obj.removeAttribute('href');if(type=='image')
{obj.className=obj.className.replace(/_disable/,'');obj.className=String(obj.className+"_disable");}else{obj.style.color=disValue;}}else{if(obj.attributes['onclick_bak']!=null)
obj.setAttribute('onclick',obj.attributes['onclick_bak'].nodeValue);if(obj.attributes['href_bak']!=null)
obj.setAttribute('href',obj.attributes['href_bak'].nodeValue);if(type=='image')
{obj.className=obj.className.replace(/_disable/,'');}else{obj.style.color=actValue;}}},disableSymlookup:function(disable){if(disable)
{document.getElementById(this.uicontrols.Enterlabel).className='enter_label_disable';document.getElementById(this.uicontrols.lookupField).setAttribute('disabled','true');document.getElementById(this.uicontrols.AddSymButton).style.display='none';document.getElementById(this.uicontrols.AddSymButtonDisable).style.display='block';}else{document.getElementById(this.uicontrols.Enterlabel).className='enter_label';document.getElementById(this.uicontrols.lookupField).removeAttribute('disabled');document.getElementById(this.uicontrols.AddSymButton).style.display='block';document.getElementById(this.uicontrols.AddSymButtonDisable).style.display='none';this.controllers.symlookupSuggester.resetFormField();}},initMenu:function()
{this.disableAnchor(document.getElementById(this.uicontrols.adminBarEdit),true,'','',this.uicontrols.anchorTypeCLR);this.disableAnchor(document.getElementById(this.uicontrols.adminBarCreate),true,'','',this.uicontrols.anchorTypeCLR);this.disableSymlookup(true);this.clearField(this.uicontrols.lookupField);},activeMenu:function(data)
{if(((typeof data.currentWatchlists)!='undefined')&&(data.currentWatchlists.length>0)&&(data.currentWatchlists[0].isImmutable()!=true)&&(data.currentWatchlists[0].getSource()!='portfolio'))
{this.disableAnchor(document.getElementById(this.uicontrols.adminBarEdit),false,'','',this.uicontrols.anchorTypeCLR);var currentSymbolsCount=data.currentWatchlists[0].getSymbols().length;if(currentSymbolsCount==this.maxsymbols){this.disableSymlookup(true);this.controllers.symlookupSuggester.resetFormField();}else{this.disableSymlookup(false);}}else if(((typeof data.currentWatchlists)!='undefined')&&(data.currentWatchlists.length>0)&&(data.currentWatchlists[0].getSource()=='portfolio')){this.disableAnchor(document.getElementById(this.uicontrols.adminBarEdit),false,'','',this.uicontrols.anchorTypeCLR);this.disableSymlookup(true);}
this.disableAnchor(document.getElementById(this.uicontrols.adminBarCreate),false,'','',this.uicontrols.anchorTypeCLR);},disableOnSubmit:function(){this.disableAnchor(document.getElementById(this.uicontrols.wlcancelLNK),true,'','',this.uicontrols.anchorTypeCLR);this.disableAnchor(document.getElementById(this.uicontrols.wlsaveBTN),true,'','',this.uicontrols.anchorTypeCLR);this.disableAnchor(document.getElementById(this.uicontrols.wldelbtn),true,this.uicontrols.anchorEnabledCLR,this.uicontrols.anchorDisabledCLR);this.disableAnchor(document.getElementById(this.uicontrols.adminBarEdit),true,'','',this.uicontrols.anchorTypeCLR);this.disableAnchor(document.getElementById(this.uicontrols.adminBarCreate),true,'','',this.uicontrols.anchorTypeCLR);},disableOnDelete:function(){this.disableAnchor(document.getElementById(this.uicontrols.wlconfirmDelete),true,'','',this.uicontrols.anchorTypeCLR);this.disableAnchor(document.getElementById(this.uicontrols.wlcancel),true,'','',this.uicontrols.anchorTypeCLR);},enableOnEditMenu:function(){this.disableAnchor(document.getElementById(this.uicontrols.wlcancelLNK),false,'','',this.uicontrols.anchorTypeCLR);this.disableAnchor(document.getElementById(this.uicontrols.wlsaveBTN),false,'','',this.uicontrols.anchorTypeCLR);this.disableAnchor(document.getElementById(this.uicontrols.wldelbtn),false,this.uicontrols.anchorEnabledCLR,this.uicontrols.anchorDisabledCLR);this.disableAnchor(document.getElementById(this.uicontrols.adminBarEdit),false,'','',this.uicontrols.anchorTypeCLR);this.disableAnchor(document.getElementById(this.uicontrols.adminBarCreate),false,'','',this.uicontrols.anchorTypeCLR);},enableOnDeleteConfirm:function(){this.disableAnchor(document.getElementById(this.uicontrols.wlconfirmDelete),false,'','',this.uicontrols.anchorTypeCLR);this.disableAnchor(document.getElementById(this.uicontrols.wlcancel),false,'','',this.uicontrols.anchorTypeCLR);},toggleExportLinks:function(type){if(!this.isNull(document.getElementById(this.uicontrols.wlexportlinks)))
{if(type=='watchlist'){var exportHTML='<a href="javascript:cnbc_wlviews.cnbc.exportWatchlistToPortfolio();">Export to Portfolio<\/a>';document.getElementById(this.uicontrols.wlexportlinks).innerHTML=exportHTML;}else if(type=='portfolio'){var exportHTML='<a href="javascript:cnbc_wlviews.cnbc.toggleAdmin(\'export\');">Save as Watchlist<\/a>';document.getElementById(this.uicontrols.wlexportlinks).innerHTML=exportHTML;}else{var exportHTML=' ';document.getElementById(this.uicontrols.wlexportlinks).innerHTML=exportHTML;}}},exportWatchlistToPortfolio:function(){var data=this.controllers.wlController.data;if(!this.isWLNull(data.currentWatchlists)&&(data.currentWatchlists.length>0)){var watchlist=data.currentWatchlists[0];if(((typeof this.controllers.wlController)!='undefined')&&(this.controllers.wlController!=null))
this.controllers.wlController.exportWatchlist(watchlist);}},editWatchlistInPortfolio:function(){var data=this.controllers.wlController.data;if(!this.isWLNull(data.currentWatchlists)&&(data.currentWatchlists.length>0)){var watchlist=data.currentWatchlists[0];if(((typeof this.controllers.wlController)!='undefined')&&(this.controllers.wlController!=null))
this.controllers.wlController.editPortfolioWatchlist(watchlist);}},adminFormSubmit:function(){document.getElementById(this.uicontrols.droplist).style.display="none";var formWLName=document.getElementById(this.uicontrols.adminName).value;if((formWLName!='')&&(formWLName!=null))
{if(this.adminToggle=='create'||this.adminToggle=='export'){this.createWL();}else if(this.adminToggle=='edit'){if(!this.isNull(this.controllers.wlController)){this.updateWL(this.controllers.wlController.data);}}}else{this.displayError('Watchlist Name Field is Blank','','Please give your Watchlist a name.');}},closeWatchAdmin:function()
{var adminWin=document.getElementById(this.uicontrols.admin);if(adminWin.style.display!='none')
{adminWin.style.display='none';this.togglehide(this.uicontrols.adminBar);document.getElementById(this.uicontrols.adminDel).style.display='none';}
var form=document.getElementById(this.uicontrols.adminForm);if(this.adminToggle=='export')
this.disableAnchor(document.getElementById(this.uicontrols.adminBarEdit),true,'','',this.uicontrols.anchorTypeCLR);document.getElementById(this.uicontrols.wlSortTable).style.display='block';document.getElementById(this.uicontrols.wlTable).style.display='block';document.getElementById(this.uicontrols.lookup).style.display='block';if(!this.isNull(document.getElementById(this.uicontrols.wlexportlinks)))
document.getElementById(this.uicontrols.wlexportlinks).style.display='block';document.getElementById(this.uicontrols.droplist).style.display="block";this.adminToggle='';form.reset();this.disableAdminMenuListeners();},toggleAdmin:function(choice)
{var adminHTML='<div id="wl_admin_WLName">ENTER LIST NAME:<\/div><a id="wl_admin_delbtn" href="javascript:'+this.id+'.drawMenuView(\'delete\')">Delete List<\/a>';adminHTML+='<form name="wl_admin_form" id="wl_admin_form"><div id="wl_admin_menu">';adminHTML+='<INPUT type="text" name="wl_admin_Name" id="wl_admin_Name" value=""/>';adminHTML+='<a href="javascript:'+this.id+'.closeWatchAdmin();" id="wl_admin_cancelLNK" class="wl_admin_cancelLNK_Class">Cancel<\/a>';adminHTML+='<a href="javascript:'+this.id+'.adminFormSubmit();" id="wl_admin_saveBTN" class="wl_admin_saveBTN_Class">Save<\/a>';adminHTML+='<\/div><div id="wl_admin_header"> <\/div>';adminHTML+='<div id="wl_admin_rowsDIV">';adminHTML+='<div id="wl_admin_symError" style="display:none;">Symbol Not Found<\/div>';var adminRowLength=30;for(n=1;n<adminRowLength+1;n++)
{adminHTML+='<div class="wl_admin_row">';adminHTML+='<INPUT type="text" name="wl_symbol'+n+'" id="wl_symbol'+n+'" class="wl_admin_rowFLD"';adminHTML+='tabIndex="'+n+'" \/>';adminHTML+='<div id="wl_symbol'+n+'_company" class="wl_admin_companyName"> <\/div>';adminHTML+='<div class="wl_admin_rowX" onClick="'+this.id+'.clearField(';adminHTML+="'wl_symbol"+n+"'";adminHTML+=');" id="wl_symbol'+n+'_removeX"></div>';adminHTML+='<\/div>';adminHTML+='<div id="wl_admin_symbol'+n+'_results" class="wl_admin_lookupR"><\/div>';}
adminHTML+='<\/div><\/form>';if(document.getElementById(this.uicontrols.admin))
{document.getElementById(this.uicontrols.admin).innerHTML=adminHTML;document.getElementById(this.uicontrols.wlcancelLNK).onkeydown=function(evt){};document.getElementById(this.uicontrols.wlsaveBTN).onkeydown=function(evt){};document.getElementById(this.uicontrols.adminName).onkeydown=function(evt){evt=evt||window.event;keycode=evt.keyCode;if(keycode==9){document.getElementById('wl_symbol1').focus();return false;}};document.getElementById(this.uicontrols.admin).onkeydown=function(evt){evt=evt||window.event;evt_target=evt.target||evt.srcElement;evt_target_node=null;keycode=evt.keyCode;if(keycode==13){eval(viewStr+'.adminFormSubmit();');return false;}};}
var wlformArrayLength=document.getElementById(this.uicontrols.adminForm).elements.length-1
var ADMIN_symlookupSuggesterArray=[];var maxsymbols=30;for(x=0;x<maxsymbols;x++)
{var y=x+1;var ADMIN_inputNode=document.getElementById("wl_symbol"+y);var ADMIN_companyNode=document.getElementById("wl_symbol"+y+"_company");var ADMIN_disIconNode=document.getElementById("wl_symbol"+y+"_removeX");var ADMIN_containerNode=document.getElementById("wl_admin_symbol"+y+"_results");var ADMIN_settings=new SymbolLookupSettings("3",",","1","","");var link_event="cnbc_wlviews.cnbc.drawSymLookupPage(\"##param##\");";ADMIN_settings.setLinkEvent(link_event);ADMIN_symlookupSuggesterArray[x]=new CNBCGadgetMenuSymbolLookup(ADMIN_inputNode,ADMIN_containerNode,ADMIN_settings,'',ADMIN_companyNode,ADMIN_disIconNode);var ADMIN_uicontrols={"menu":"wl_admin_symbol"+y+"_results","menutext":"Loading..."};var viewString='ADMIN_cnbcSym'+y;var ADMIN_cnbcSymModel=new SymbolLookupModel({viewString:new CNBCSymbolLookupView(ADMIN_symlookupSuggesterArray[x],ADMIN_uicontrols)});var ADMIN_symLookupController=new BaseSymbolLookupController(ADMIN_cnbcSymModel,new FlashProxyRequestor("flashQuoteProxy","json"),new SymbolLookupParser());ADMIN_symlookupSuggesterArray[x].setController(ADMIN_symLookupController);}
if(choice=='edit'){if(!this.isNull(this.controllers.wlController)){var data=this.controllers.wlController.data;if(!this.isWLNull(data.currentWatchlists)&&(data.currentWatchlists.length>0)&&(data.currentWatchlists[0].isImmutable()!=true)&&(data.currentWatchlists[0].getSource()!='portfolio'))
{this.togglehide(this.uicontrols.admin);this.togglehide(this.uicontrols.adminBar);document.getElementById(this.uicontrols.droplist).style.display="none";document.getElementById(this.uicontrols.adminDel).style.display='block';document.getElementById(this.uicontrols.wlSortTable).style.display='none';document.getElementById(this.uicontrols.wlTable).style.display='none';document.getElementById(this.uicontrols.lookup).style.display='none';if(!this.isNull(document.getElementById(this.uicontrols.wlexportlinks)))
document.getElementById(this.uicontrols.wlexportlinks).style.display='none';document.getElementById(this.uicontrols.adminrowsErrorDIV).style.display='none';this.clearAllFields();document.getElementById(this.uicontrols.adminrowsDIV).scrollTop=0;this.loadEditAdmin(data);document.getElementById(this.uicontrols.adminName).value=data.currentWatchlists[0].getName();this.activateAdminMenuListeners();}else if(!this.isWLNull(data.currentWatchlists)&&(data.currentWatchlists.length>0)&&(data.currentWatchlists[0].getSource()=='portfolio'))
{choice="";this.editWatchlistInPortfolio();}else{document.getElementById(this.uicontrols.droplist).style.display="none";this.displayError('','',this.msgs.editPreDefined);}}}else if(choice=='create'){this.clearAllFields();this.togglehide(this.uicontrols.admin);this.togglehide(this.uicontrols.adminBar);document.getElementById(this.uicontrols.adminrowsDIV).scrollTop=0;document.getElementById(this.uicontrols.adminDel).style.display='none';document.getElementById(this.uicontrols.wlSortTable).style.display='none';document.getElementById(this.uicontrols.wlTable).style.display='none';document.getElementById(this.uicontrols.lookup).style.display='none';if(!this.isNull(document.getElementById(this.uicontrols.wlexportlinks)))
document.getElementById(this.uicontrols.wlexportlinks).style.display='none';document.getElementById(this.uicontrols.adminrowsErrorDIV).style.display='none';document.getElementById(this.uicontrols.droplist).style.display="none";}else if(choice=='export'){if(!this.isNull(this.controllers.wlController)){var data=this.controllers.wlController.data;if(!this.isWLNull(data.currentWatchlists)&&(data.currentWatchlists.length>0))
{this.togglehide(this.uicontrols.admin);this.togglehide(this.uicontrols.adminBar);document.getElementById(this.uicontrols.adminrowsDIV).scrollTop=0;document.getElementById(this.uicontrols.adminDel).style.display='none';document.getElementById(this.uicontrols.wlSortTable).style.display='none';document.getElementById(this.uicontrols.wlTable).style.display='none';document.getElementById(this.uicontrols.lookup).style.display='none';if(!this.isNull(document.getElementById(this.uicontrols.wlexportlinks)))
document.getElementById(this.uicontrols.wlexportlinks).style.display='none';document.getElementById(this.uicontrols.adminrowsErrorDIV).style.display='none';this.clearAllFields();document.getElementById(this.uicontrols.adminrowsDIV).scrollTop=0;document.getElementById(this.uicontrols.droplist).style.display="none";this.loadEditAdmin(data);}else{document.getElementById(this.uicontrols.droplist).style.display="none";this.displayError('','',this.msgs.editPreDefined);}}}
this.adminToggle=choice;},loadEditAdmin:function(data)
{var form=document.getElementById(this.uicontrols.adminForm);if(!this.isWLNull(data.currentWatchlists)&&(data.currentWatchlists.length>0)){var symbolsArray=data.currentWatchlists[0].getSymbols();var i=1;var symTotalCount=(symbolsArray.length>30)?30:symbolsArray.length;for(x=0;x<symTotalCount;x++){if(form.elements[i].name.indexOf('symbol')>-1)
{form.elements[i].value=symbolsArray[x].toUpperCase();if(!this.isNull(this.controllers.quoteController))
{var currentSymbol=this.controllers.quoteController.data.getQuote(symbolsArray[x].toUpperCase());if((currentSymbol!=null)&&(currentSymbol.getCode()!='1'))
{var companyName=currentSymbol.getName();document.getElementById('wl_symbol'+i+'_company').innerHTML=companyName;}}
document.getElementById('wl_symbol'+i+'_removeX').className="wl_admin_rowX_act";i++;}}}},EditAdminUpdateField:function(id,symbol)
{document.getElementById(id).onfocus();document.getElementById(id).value=symbol;document.getElementById(id).onblur();this.closeSymLookupMenu();},clearField:function(id)
{var panel=document.getElementById(id);panel.value='';var companyName=String(id+'_company');if(document.getElementById(companyName)!=undefined){document.getElementById(companyName).innerHTML="";}
var rowXname=String(id+'_removeX');if(document.getElementById(rowXname)!=undefined){document.getElementById(rowXname).className="wl_admin_rowX";}},clearAllFields:function(){var form=document.getElementById(this.uicontrols.adminForm);for(i=1;i<form.elements.length;i++)
{if(form.elements[i].name.indexOf('symbol')>-1){form.elements[i].value='';document.getElementById('wl_symbol'+i+'_company').innerHTML="";document.getElementById('wl_symbol'+i+'_removeX').className="wl_admin_rowX";}}},createWatchlistCookie:function(name,value,hours)
{if(hours)
{var date=new Date();date.setTime(date.getTime()+(hours*60*60*1000));var expires="; expires="+date.toGMTString();}
else{var expires="";}
document.cookie=name+"="+value+expires+";domain=cnbc.com;path=/";},readWatchlistCookie:function(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);}
var unescaped=unescape(document.cookie);var ca2=unescaped.split(';');for(var i=0;i<ca2.length;i++)
{var c=ca2[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;},disableAdminMenuListeners:function()
{var container=document.getElementById(this.uicontrols.wlContainer);cnbc_disableAllEventListeners(this.setPWLFlag,container);CNBC_PWL_ACTIVE_FLAG=false;cnbc_pwl_max_idleTime='';},activateAdminMenuListeners:function()
{var container=document.getElementById(this.uicontrols.wlContainer);cnbc_ActivateAllEventListeners(this.setPWLFlag,container);CNBC_PWL_ACTIVE_FLAG=true;cnbc_pwl_max_idleTime=60;},setPWLFlag:function()
{cnbc_lastIdleTime=new Date().getTime();},init:function()
{var watchlistHTML='';var viewStr=this.id;watchlistHTML+='<div id="wl_title_bar"><span class="fL">CNBC Watchlist -- Version 8.39 JS files --<\/span>';if(!this.userstate){watchlistHTML+='<a href="javascript:cnbc_gotomodURL(\''+this.wlserviceurl+'\',\'?service=url&source=watchlist\');" id="wl_signin">Sign in<\/a>';}
watchlistHTML+='<\/div><div id="wl_Main"><div id="wl_Menu">';watchlistHTML+='<div id="wl_DropDown"><form ACTION="" METHOD="GET">';watchlistHTML+='<select id="wl_DropList" SIZE="1" NAME="wl_DropList" ONCHANGE="'+viewStr+'.getWatchlist([this.options[this.selectedIndex].value]);">';watchlistHTML+='<\/select><\/form><\/div><div id="wl_admin" style="display:none">';watchlistHTML+='<\/div><div id="wl_AdminBar" class="wl_MenuFont">';if(this.userstate){watchlistHTML+='<a id="wl_AdminBar_Edit" href_bak="javascript:'+viewStr+'.toggleAdmin(';watchlistHTML+="'edit'";watchlistHTML+=');" class="wl_AdminBar_Edit_Class_disable">Edit<\/a>';watchlistHTML+='<a id="wl_AdminBar_Create" href_bak="javascript:'+viewStr+'.toggleAdmin(';watchlistHTML+="'create'";watchlistHTML+=');" class="wl_AdminBar_Create_Class_disable">Create<\/a>';}else{watchlistHTML+='<a id="wl_AdminBar_Edit" class="wl_AdminBar_Edit_Class_disable">Edit<\/a>';watchlistHTML+='<a id="wl_AdminBar_Create" href="javascript:cnbc_gotomodURL(\''+this.wlserviceurl+'\',\'?service=url\');"';watchlistHTML+=' class="wl_AdminBar_Create_Class">Create<\/a>';}
watchlistHTML+=' <\/div><\/div><div id="wl_SymLookup">';watchlistHTML+='<form name="wl_symLookUp_form" id="wl_symLookUp_form" method="post" onSubmit="return '+viewStr+'.addSymLookUp();">';watchlistHTML+='<div id="wl_Enter_label" class="enter_label"><\/div>';watchlistHTML+='<INPUT id="wl_SymLookupField" TYPE="text" NAME="wl_SymLookupField" AUTOCOMPLETE="off" \/>';watchlistHTML+='<div id="wl_AddSymButton_disable" class="wl_AddSymButton_disable">Add<\/div>'
watchlistHTML+='<INPUT id="wl_AddSymButton" TYPE="submit" VALUE="" ALT="Add Symbol" \/>';watchlistHTML+='<\/form><\/div><div id="wl_sortTable"><\/div><div id="wl_Table"><\/div>';if(this.userstate){watchlistHTML+='<div id="wl_exportlinks"><\/div>';}
watchlistHTML+='<div id="wl_lookuploader"><\/div>';watchlistHTML+='<div id="wl_lookupresults"><\/div><\/div>';watchlistHTML+='<div id="wl_ErrorTbl" style="display:none;"><\/div>';watchlistHTML+='<div id="wl_symlookup_page_container" style="display:none;"><\/div>';if(document.getElementById(this.uicontrols.wlContainer))
{document.getElementById(this.uicontrols.wlContainer).innerHTML=watchlistHTML;}}});CNBCWLController=Class.create();CNBCWLController.prototype=Object.extend(new BaseWLController(),{initialize:function(data,requestor,parser){this.data=data;this.requestor=requestor
this.parser=parser;this.reqbaseurl="http://qa.pwl.cnbc.com";this.portbaseurl="http://stage.cnbcapps.cnbc.com";},getWatchlists:function(){var URL=this.reqbaseurl+"/rs/watchlists.js";var params="method=get";this.execute(URL,params,{event:WLEvent.Type.GETWLNAMES,method:'GET',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:40000});},getWatchlist:function(watchlistNames){var watchlists=this.fromArrayToString(watchlistNames,",");var URL=this.reqbaseurl+"/rs/watchlists/"+escape(watchlists)+".js";var params="method=get";this.execute(URL,params,{event:WLEvent.Type.GETWL,method:'GET',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:40000});},updateWatchlist:function(watchlist,newWatchlistName){var watchlists=watchlist.getId();var newSymbols=watchlist.getSymbols();var watchlistRenames=newWatchlistName||'';var URL=this.reqbaseurl+"/rs/watchlists/"+escape(watchlists)+".js";var params="method=put";if(watchlistRenames!='')
params+="&rename="+escape(watchlistRenames);if(newSymbols!=undefined&&newSymbols.length>0){for(var i=0;i<newSymbols.length;++i){var s=newSymbols[i].replace(/'/gi,'\'');params+="&s="+s;}}
this.execute(URL,params,{event:WLEvent.Type.UPDATEWL,method:'PUT',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:40000});},deleteWatchlist:function(watchlistNames){var watchlists=this.fromArrayToString(watchlistNames,",");var URL=this.reqbaseurl+"/rs/watchlists/"+escape(watchlists)+".js";var params="method=delete";this.execute(URL,params,{event:WLEvent.Type.DELETEWL,method:'DELETE',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:40000});},createWatchlist:function(watchlist){var watchlists=watchlist.getName();var newSymbols=watchlist.getSymbols();var URL=this.reqbaseurl+"/rs/watchlists/"+escape(watchlists)+".js";var params="method=post";if(newSymbols!=undefined&&newSymbols.length>0){for(var i=0;i<newSymbols.length;++i){var s=newSymbols[i];params+="&s="+s;}}
this.execute(URL,params,{event:WLEvent.Type.CREATEWL,method:'POST',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:40000});},saveSortWatchlist:function(watchlist){var watchlists=watchlist.getId();var newSymbols=watchlist.getSymbols();var URL=this.reqbaseurl+"/rs/watchlists/"+escape(watchlists)+".js";var params="method=put";if(newSymbols){for(var i=0;i<newSymbols.length;i++){var s=newSymbols[i];params+="&s="+s;}}
this.execute(URL,params,{event:WLEvent.Type.SAVESORTWL,method:'PUT',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:40000});},exportWatchlist:function(watchlist){var watchlistid=watchlist.getName();var newSymbols=watchlist.getSymbols();var PortfolioURL=this.portbaseurl+'/portfolio/pages/importWatchlist.asp';PortfolioURL+='?watchlist_id='+escape(watchlistid);if(newSymbols){for(var i=0;i<newSymbols.length;i++){var s=newSymbols[i];if(i==0){PortfolioURL+='&symbols='+s;}else{PortfolioURL+='|'+s;}}}
var URL=this.reqbaseurl+"/rs/portfolio/sign.js";var params="uri="+PortfolioURL;this.execute(URL,params,{event:WLEvent.Type.EXPORTTOPORTFOLIO,method:'POST',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:40000});},editPortfolioWatchlist:function(watchlist){var watchlistid=watchlist.getName();var PortfolioURL=this.portbaseurl+'/portfolio/pages/transactions.asp';PortfolioURL+='?portfolio_id='+escape(watchlistid);var URL=this.reqbaseurl+"/rs/portfolio/sign.js";var params="uri="+PortfolioURL;this.execute(URL,params,{event:WLEvent.Type.EDITINPORTFOLIO,method:'POST',onSuccessEvent:true,onInitializeEvent:true,onErrorEvent:true,onTimeoutEvent:true,onTimeoutLength:40000});}});function setupCNBCWL()
{var wl_user_state=cnbc_watchlist_isRegistered();CNBC_PWL_IDLE_ENABLED=true;if(!document.getElementById("flashQuoteProxy"))
{var flashProxyHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1" height="1" id="flashQuoteProxy" align="middle">';flashProxyHTML+='<param name="allowScriptAccess" value="always">';flashProxyHTML+='<param name="movie" value="http://quote.cnbc.com/quoteproxy.swf">';flashProxyHTML+='<param name="quality" value="high"><param name="bgcolor" value="#ffffff">';flashProxyHTML+='<embed quality="high" bgcolor="#ffffff" width="1" height="1" name="flashQuoteProxy" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://quote.cnbc.com/quoteproxy.swf">';flashProxyHTML+='<\/embed><\/object>';document.getElementById('cnbc_fProxy').innerHTML=flashProxyHTML;}
var flashProxyRequestor=new FlashProxyRequestor("flashQuoteProxy","json");var flashProxyRequestorXML=new FlashProxyRequestor("flashQuoteProxy","xml");var wlQModel=new WLQuoteModel();wlQModel.setPartnerID("4");var quoteController=new BaseWLQuoteController(wlQModel,flashProxyRequestor,new WLQuoteParser());var wlModel=new WLModel();var cnbcController=new CNBCWLController(wlModel,flashProxyRequestor,new WLModelParser());var wl_uicontrols={"wlContainer":"cnbcWLContainer","droplist":"wl_DropList","wlSortTable":"wl_sortTable","wlTable":"wl_Table","wlError":"wl_ErrorTbl","wlTableLoaderIMG":"wlTableLoader","lookup":"wl_SymLookup","lookupForm":"wl_symLookUp_form","Enterlabel":"wl_Enter_label","lookupField":"wl_SymLookupField","lookupLoader":"wl_lookuploader","lookupLoaderIMG":"http://media.cnbc.com/i/CNBC/Common/js/greyPreload.gif","admin":"wl_admin","adminToggle":"wl_adminToggle","adminDel":"wl_admin_delbtn","adminForm":"wl_admin_form","adminName":"wl_admin_Name","adminBar":"wl_AdminBar","adminBarEdit":"wl_AdminBar_Edit","adminBarCreate":"wl_AdminBar_Create","AddSymButton":"wl_AddSymButton","AddSymButtonDisable":"wl_AddSymButton_disable","imgCHup":"wl_imgchg_up","imgCHdwn":"wl_imgchg_dwn","imgVideoAlert":"wl_videoalert_icon","imgNewsAlert":"wl_newsalert_icon",'anchorEnabledCLR':'#424858','anchorDisabledCLR':'#424858','anchorTypeCLR':'image','adminrowsDIV':'wl_admin_rowsDIV','adminrowsErrorDIV':'wl_admin_symError','wlSymLookupPage':'wl_symlookup_page_container','wlSymLookupPageForm':'wl_static_symlookup_form','wlSymLookupPageField':'wl_static_symlookupfield','wlSymLookupPageTable':'wl_static_table','wlSymLookupPageButton':'wl_GoSymButton','wlexportlinks':'wl_exportlinks','wlSymLookupPagination':'wl_static_symlookupPag','wlcancelLNK':'wl_admin_cancelLNK','wlsaveBTN':'wl_admin_saveBTN','wldelbtn':'wl_admin_delbtn','wlconfirmDelete':'wl_admin_confirmDelete','wlcancel':'wl_admin_cancel'};var wl_controllers={"wlController":cnbcController,"quoteController":quoteController,"symlookupSuggester":null,"settings":null,"wl_symlookup_suggester":null};var wl_msgs={'loadDrop':'>> Loading Watchlists','errorLoad':'Error Loading Watchlists:','timeOutLoad':'Timeout Loading Watchlists:','emptyWLCust':' This Watchlist is Empty \n Please Edit the Watchlist and add some Symbols.','emptyWLPre':'This Watchlist is Empty \n Error in Pre-defined Watchlist','errorRetrieve':'Error Retrieving Watchlist:','timeOutRetrieve':'Timeout Retrieving Watchlist:','symInvalid':'These Symbols are Incorrect:\n','errorUpdate':'CNBC-OnUpdateWL: ','timeOutUpdate':'CNBC-OnUpdateWL: ','errorDelete':'CNBC-OnDeleteWL: ','timeOutDelete':'CNBC-OnDeleteWL: ','errorCreate':'CNBC-OnCreateWL: ','timeOutCreate':'CNBC-OnCreateWL: ','errorGetQuote':'CNBC-OnGetQuotes: ','timeOutGetQuote':'CNBC-OnGetQuotes: ','errorGetGuestAlerts':'CNBC-OnGetGuestAlerts: ','timeOutGetGuestAlerts':'CNBC-OnGetGuestQuotes: ','errorSaveSort':'CNBC-OnSaveSort: ','timeOutSaveSort':'CNBC-OnSaveSort: ','editPreDefined':'You cannot Edit the Default Pre-defined Watchlists','addPreDefined':'You cannot add symbols to a Pre-defined Watchlist \n Try creating a Custom Watchlist instead'};var wlservice_url="https://register.cnbc.com/refreshlogin.jsp";var wl_maxsymbols=30;cnbc_wlviews.cnbc=new CNBCGadgetView('cnbc_wlviews.cnbc',wl_controllers,wl_uicontrols,wl_msgs,wl_user_state,wlservice_url,wl_maxsymbols);wlModel.addView("cnbc",cnbc_wlviews.cnbc);wlQModel.addView("cnbc",cnbc_wlviews.cnbc);setTimeout("cnbc_wlviews.cnbc.getWatchlists()",1500);var inputNode=document.getElementById("wl_SymLookupField");var containerNode=document.getElementById("wl_lookupresults");var symfooterDiv="<div id=\"dd_footer\" class=\"fL\"><br/>";symfooterDiv+='<div class=\"dd_footerFont\">Hint: Enter Multiple Symbols Separated by a Comma<\/div>';settings=new SymbolLookupSettings("5",",","5","",symfooterDiv);symlookupSuggester=new CNBCGadgetSymbolLookup(inputNode,containerNode,settings);cnbc_wlviews.cnbcSym=new CNBCSymbolLookupView(symlookupSuggester,{"menu":"wl_lookupresults","menutext":"Loading..."});var symLookupController=new BaseSymbolLookupController(new SymbolLookupModel(cnbc_wlviews),flashProxyRequestor,new SymbolLookupParser());symlookupSuggester.setController(symLookupController);symlookupSuggester.setMaxSymbols(wl_maxsymbols);cnbc_wlviews.cnbc.controllers.symlookupSuggester=symlookupSuggester;cnbc_wlviews.cnbc.controllers.settings=settings;}
var cnbc_wlviews=[];