// JavaScript Document
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
num = Math.floor(num/100).toString();
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-')  + num );
}

function ShowWeatherBox(vId){
	var sLink = '';
	sLink = '/getVnexpressWeather.asp?city=';
	switch (parseInt(vId)){	    	
		case 1: sLink = sLink.concat('Sonla.xml');break;
		case 2: sLink = sLink.concat('Viettri.xml');break;
		case 3: sLink = sLink.concat('Haiphong.xml');break;
		case 4: sLink = sLink.concat('Hanoi.xml');break;
		case 5: sLink = sLink.concat('Vinh.xml');break;
		case 6: sLink = sLink.concat('Danang.xml');break;
		case 7: sLink = sLink.concat('Nhatrang.xml');break;
		case 8: sLink = sLink.concat('Pleicu.xml');break;		
		case 9: sLink = sLink.concat('HCM.xml');break;	
		default: sLink = sLink.concat('Hanoi.xml');break;
	}
	//sLink = '/getVnexpressWeather.asp?city=Hanoi.xml'
	AjaxRequest.get(
		{
			'url':sLink
			,'onSuccess':function(req){
				var vAdImg, vAdImg1, vAdImg2, vAdImg3, vAdImg4, vAdImg5, vWeather;
				vAdImg = req.responseXML.getElementsByTagName('AdImg').item(0).firstChild.nodeValue;
				vAdImg1 = req.responseXML.getElementsByTagName('AdImg1').item(0).firstChild.nodeValue;
				if(req.responseXML.getElementsByTagName('AdImg2').item(0).firstChild != null)
					vAdImg2 = req.responseXML.getElementsByTagName('AdImg2').item(0).firstChild.nodeValue;
				if(req.responseXML.getElementsByTagName('AdImg3').item(0).firstChild != null)
					vAdImg3 = req.responseXML.getElementsByTagName('AdImg3').item(0).firstChild.nodeValue;
				if(req.responseXML.getElementsByTagName('AdImg4').item(0).firstChild != null)
					vAdImg4 = req.responseXML.getElementsByTagName('AdImg4').item(0).firstChild.nodeValue;
				if(req.responseXML.getElementsByTagName('AdImg5').item(0).firstChild != null)
					vAdImg5 = req.responseXML.getElementsByTagName('AdImg5').item(0).firstChild.nodeValue;
				vWeather = req.responseXML.getElementsByTagName('Weather').item(0).firstChild.nodeValue;
				GetWeatherBox(vAdImg, vAdImg1, vAdImg2, vAdImg3, vAdImg4, vAdImg5, vWeather);				
				}
			,'onError':function(req){}
		}
	)
}

function GetWeatherBox(vImg, vImg1, vImg2, vImg3, vImg4, vImg5, vWeather){
	var sHTML = '';
	sHTML = sHTML.concat('<img src="/Images/Weather/').concat(vImg).concat('" class="img-weather" alt="" />&nbsp;');
	sHTML = sHTML.concat('<img src="/Images/Weather/').concat(vImg1).concat('" class="img-weather" alt="" />');
	if(vImg2!=null) sHTML = sHTML.concat('<img src="/Images/Weather/').concat(vImg2).concat('" class="img-weather" alt="" />');
	if(vImg3!=null) sHTML = sHTML.concat('<img src="/Images/Weather/').concat(vImg3).concat('" class="img-weather" alt="" />');
	if(vImg4!=null) sHTML = sHTML.concat('<img src="/Images/Weather/').concat(vImg4).concat('" class="img-weather" alt="" />');
	if(vImg5!=null) sHTML = sHTML.concat('<img src="/Images/Weather/').concat(vImg5).concat('" class="img-weather" alt="" />');
	sHTML = sHTML.concat('<img src="/Images/Weather/c.gif" class="img-weather" alt="" />');
	
	document.getElementById('img-Do').innerHTML = sHTML;
	document.getElementById('txt-Weather').innerHTML = vWeather;
}

function ShowGoldPrice(){
	var sHTML = '';
	sHTML = sHTML.concat('<table width="100%" border="0px" cellpadding="2px" cellspacing="1px" class="tbl-weather">');
	sHTML = sHTML.concat('	<tr>');
	sHTML = sHTML.concat('		<td class="td-weather-title">Mua</td>');
	sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldBuy).concat('</td>');
	sHTML = sHTML.concat('	</tr>');
	sHTML = sHTML.concat('	<tr>');
	sHTML = sHTML.concat('		<td class="td-weather-title">B&#225;n</td>');
	sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSell).concat('</td>');
	sHTML = sHTML.concat('	</tr>');
	sHTML = sHTML.concat('</table>');
	document.getElementById('eGold').innerHTML = sHTML;
}

function ShowForexRate(){
	var sHTML = '';
	sHTML = sHTML.concat('<table width="110px" border="0px" cellpadding="2px" cellspacing="1px" class="tbl-weather">');
	for(var i=0;i<vForexs.length;i++){
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td class="td-weather-title">').concat(vForexs[i]).concat('</td>');
		sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vCosts[i]).concat('</td>');
		sHTML = sHTML.concat('	</tr>');
	}
	sHTML = sHTML.concat('</table>');
	document.getElementById('eForex').innerHTML = sHTML;
}

 function OnTab(a)
    {
        var strPaneId, strFirst, strCenter, strLast;
        for(i=1;i<=4;i++)
        {
            strPaneId = "CTP" + i;
            strFirst = "TabFirst" + i;
            strLast = "TabLast" + i;
            strCenter = "TabCenter" + i;
            document.getElementById(strPaneId).style.display = "none";
			
			if(i==a)
            {
                    document.getElementById(strFirst).className = "TH_tabLeftFirstOn";
                    document.getElementById(strCenter).className = "TH_tabCenterOn";
                    document.getElementById(strLast).className = "TH_tabRightLastOn";
            }
            else
            {
                if(i==1)
                {
                    document.getElementById(strFirst).className = "TH_tabLeftFirstOff";
                    document.getElementById(strCenter).className = "TH_tabOff";
                    if(i==(a-1))
                    {document.getElementById(strLast).className = "TH_tabOff";}else{document.getElementById(strLast).className = "TH_tabSeperateOff";}}else{document.getElementById(strFirst).className = "TH_tabOff";document.getElementById(strCenter).className = "TH_tabOff";if(i==(a-1)){document.getElementById(strLast).className = "TH_tabOff";}else{document.getElementById(strLast).className = "TH_tabSeperateOff";}}}}strPaneId = "CTP" + a;document.getElementById(strPaneId).style.display = "";}
