
var gTFX,gTFon=false;function getTFData(){var w=window,f=true,d=document,frm=d.frmTF;if(gTFon)return false;gTFon=true;if(w.XMLHttpRequest){gTFX=new XMLHttpRequest();}
if(gTFX){gTFX.onreadystatechange=TFWait;gTFX.open("POST","gainandlose.asmx/GetTopsFlops",true);gTFX.setRequestHeader("Content-Type","application/x-www-form-urlencoded");var cc=frm.Country,mi=frm.MarketIndex,pp=frm.PerfParam,tp=frm.TimePeriod;gTFX.send("CountryCode="+cc.options[cc.selectedIndex].value+"&MarketIndex="+mi.options[mi.selectedIndex].value+"&TimePeriod="+tp.options[tp.selectedIndex].value+"&PerfParam="+pp.options[pp.selectedIndex].value);f=false;}
gTFon=false;return f;}
function TFWait(){if(4==gTFX.readyState)
{if(200==gTFX.status)
TFDraw();else
document.frmTF.submit();}}
function TFDraw()
{var n=(typeof(gTFX.responseXml)=="undefined")?gTFX.responseXML:gTFX.responseXml;var d=document,dE=n.documentElement,rgNodes=dE.getElementsByTagName("Instrument");var c,s,r,t=d.getElementById("tblTF"),res=d.getElementById("resTF");h=d.getElementById("headTF"),mi=d.getElementById("MarketIndex");if(t!=null)
{while(t.rows.length>0){t.deleteRow(0);}}
else
{t=d.createElement('table');t.id="tblTF";res.appendChild(t);}
t.style.width="99%";t.style.border="0";t.style.borderCollapse="collapse";t.rules="rows";t.cellSpacing=0;r=t.insertRow(0);r.align="right";var rgHead,pp=d.frmTF.TimePeriod;if(pp.options[pp.selectedIndex].value=="today")
rgHead=rgHead1;else
rgHead=rgHead2;for(var cAtt=0;cAtt<rgAtt.length;cAtt++)
{if(cAtt==0)
{c=r.insertCell(0);c.style.width="225";c.align="left";}
else
{c=r.insertCell((2*cAtt)-1);c.style.width="20";c=r.insertCell(2*cAtt);c.nowrap="true";c.align="right";}
s=d.createTextNode(rgHead[cAtt]);c.appendChild(s);}
var rc=d.getElementById("RowCount"),nRows=rc.options[rc.selectedIndex].value;for(var cNodes=0;cNodes<rgNodes.length&&cNodes<nRows;cNodes++)
{var m=rgNodes[cNodes],ctry=m.getAttribute("Country");r=t.insertRow(cNodes+1);r.align="right";for(var cAtt=0;cAtt<rgAtt.length;cAtt++)
{if(cAtt==0)
{c=r.insertCell(0);c.style.width="225";c.align="left";var tic=m.getAttribute("Ticker");s=d.createElement("a");s.href="/investor/quotes/quotes.aspx"+"?symbol="+ctry+":"+tic;s.innerHTML=m.getAttribute(rgAtt[cAtt]);}
else
{c=r.insertCell((2*cAtt)-1);c.style.width="20";c=r.insertCell(2*cAtt);c.nowrap="true";s=d.createElement("div");s.innerHTML=m.getAttribute(rgAtt[cAtt]);}
c.appendChild(s);}
if(cNodes%2==0)
r.style.background="#F5F5F5";}
var changeTo="<REPLACEHEADER>"+mi.options[mi.selectedIndex].text+"</REPLACEHEADER>";h.innerHTML=h.innerHTML.replace(/<REPLACEHEADER>.*<\/REPLACEHEADER>/g,changeTo);var fNodes=n.getElementsByTagName("File");var m1=fNodes[0],lastprice=m1.getAttribute("LastPrice");var changeLastPriceTo="<REPLACELASTPRICE>"+lastprice+"</REPLACELASTPRICE>";h.innerHTML=h.innerHTML.replace(/<REPLACELASTPRICE>.*<\/REPLACELASTPRICE>/g,changeLastPriceTo);}
function UpdateMI(){var i=0,d=document,frm=d.frmTF;var mi=frm.MarketIndex,cc=frm.Country;var ccVal=cc.options[cc.selectedIndex].value,sel=-1;for(i=0;i<gCC.length;i++){if(ccVal==gCC[i])
{sel=i;}}
if(sel!=-1)
{var arrMIText=gMIText[sel].split("|");var arrMICode=gMICode[sel].split("|");while(mi.length>0)
{mi.remove(0);}
for(x=0;x<arrMIText.length;x++)
{var o=d.createElement('option');o.text=arrMIText[x];o.value=arrMICode[x];try{mi.add(o,null);}
catch(ex){mi.add(o);}}}
else{d.frmTF.submit();}}