function HeatUpdater(id,page)
{
    this.id=id;
    this.page=page;
    this.obj=document.getElementById(id);
    this.attempts=0;
    this.calledOnce=false;
    this.timer=null;
    this.properties={url:HI_URL,enabled:LIVE_NEWS_ENABLED,interval:HI_INTERVAL};
    this.load=function(data){if(jsdebug)debug(data);
    var obj=document.getElementById(id);if(obj){if((data.response)&&typeof data.response.data.getHeatResponse.tickers!="undefined"){var tickers=data.response.data.getHeatResponse.tickers;for(var i=0;i<tickers.length;i++){var updatedHeat=tickers[i].heat;if((JS_SYMBOL.toUpperCase()+"."+JS_COUNTRY.toUpperCase())==tickers[i].ticker.toUpperCase()){updateHeat(updatedHeat);}
updateHeatVar(updatedHeat,tickers[i].ticker);}}
obj=null;}
this.scriptTag.removeScriptTag();this.scriptTag=null;this.timer=window.setTimeout("bootstrap.getActiveModule('"+this.id+"').update()",this.properties.interval);data=null;};this.kill=function(){if(this.timer!=null){if(jsdebug)debug("cancelling HeatUpdater timer");window.clearTimeout(this.timer);}};this.error=function(msg){if(jsdebug)debug("ERROR : "+msg);};this.update=function(){var widget=getElementByClassName("RiverWidget",null,"div");if(typeof widget!="undefined"){if(this.calledOnce){return;}}
this.calledOnce=true;var heats=getElementsByClassName("heatVar",null,"span");var extra_tickers="";for(var i=0;i<heats.length;i++){var heat=heats[i];var ticker="";for(var y=0;y<heat.attributes.length;y++){if(heat.attributes[y].name.toLowerCase()=='ticker'){ticker="&ticker="+heat.attributes[y].value.toUpperCase()+".USA";}}
extra_tickers=extra_tickers+ticker;}
heats=null;widget=null;var optionalArgs="?ticker="+JS_SYMBOL.toUpperCase()+"."+JS_COUNTRY.toUpperCase()+extra_tickers+"&f=json&appId=MF";if(jsdebug)debug("URL is... "+this.properties.url+optionalArgs+"&c=bootstrap.getActiveModule('"+this.id+"').load");this.scriptTag=new JSONRequest(this.properties.url+optionalArgs+"&c=bootstrap.getActiveModule('"+this.id+"').load");};this.init=function(){if(this.properties.enabled){this.update();}};}

function updateHeat(updatedHeat)
{
    //debugger;
    //var heats=getElementsByClassName("heat",null,"span");for(var i=0;i<heats.length;i++){heat=heats[i];if(updatedHeat>=HI_HOT){if(heat!="(H)"){heat.innerHTML=heats;}}else{if(heat=="(H)"){heat.innerHTML="";}}}
    var heats=getElementsByClassName("headlineDate",null,"span");for(var i=0;i<heats.length;i++){heat=heats[i];if(updatedHeat>=HI_HOT){if(heat!="(H)"){heat.innerHTML="(H)";}}else{if(heat=="(H)"){heat.innerHTML="";}}}
    
if(updatedHeat>=HI_HOT){var heat_cold_els=AIM.util.getElementsByClassName(document.getElementsByTagName("body")[0],"*","heat_cold");for(var i=0;i<heat_cold_els.length;i++){el_class=heat_cold_els[i].className;el_class=el_class.replace(/(^|\s)heat_cold(\s|$)/," heat_hot ");heat_cold_els[i].className=el_class;}
var heat_images=AIM.util.getElementsByClassName(document.getElementsByTagName("body")[0],"img","relegence_heat_icon");for(var i=0;i<heat_images.length;i++){heat_images[i].src=heat_images[i].src.replace(/\-normal\./,"-hot.");heat_images[i].title=heat_images[i].title.replace(/^([^\s]+)\s.*$/,"$1 is experiencing high news volume");heat_images[i].alt=heat_images[i].title;}
heat_hot_els=null;heat_images=null;}else{var heat_hot_els=AIM.util.getElementsByClassName(document.getElementsByTagName("body")[0],"*","heat_hot");for(var i=0;i<heat_hot_els.length;i++){el_class=heat_hot_els[i].className;el_class=el_class.replace(/(^|\s)heat_hot(\s|$)/," heat_cold ");heat_hot_els[i].className=el_class;}
var heat_images=AIM.util.getElementsByClassName(document.getElementsByTagName("body")[0],"img","relegence_heat_icon");for(var i=0;i<heat_images.length;i++){heat_images[i].src=heat_images[i].src.replace(/\-hot\./,"-normal.");heat_images[i].title=heat_images[i].title.replace(/^([^\s]+)\s.*$/,"$1 is experiencing normal news volume");heat_images[i].alt=heat_images[i].title;}
heat_hot_els=null;heat_images=null;}
heats=null;}
function updateHeatVar(updatedHeat,tkr){var heats=getElementsByClassName("heatVar",null,"span");for(var i=0;i<heats.length;i++){heat=heats[i];var ticker="";for(var y=0;y<heat.attributes.length;y++){if(heat.attributes[y].name.toLowerCase()=='ticker'){ticker=heat.attributes[y].value.toUpperCase()+".USA";}}
if(tkr==ticker){if(updatedHeat>=HI_HOT){if(heat!="(H)"){heat.innerHTML="(H)";}}else{if(heat=="(H)"){heat.innerHTML="<img src=\"${cannae.getPageProperty('imgDir')}icons/icon-textarticle.gif\" />";}}}}
heats=null;}
