// JavaScript Document
function gmobj(o){

	if(document.getElementById){ m=document.getElementById(o); }

	else if(document.all){ m=document.all[o]; }

	else if(document.layers){ m=document[o]; }

	return m;

}
function ShowWeatherBox(vId){
	var vAdImg, vAdImg1, vAdImg2, vAdImg3, vAdImg4, vAdImg5, vWeather,vCity;
	var sLink = '';
	sLink = nvcms_url + '/data/weather/';
	switch (parseInt(vId)){	    	
		case 1: sLink = sLink.concat('Sonla.xml');vCity = "Sơn La";break;
		case 2: sLink = sLink.concat('Viettri.xml');vCity = "Việt Trì";break;
		case 3: sLink = sLink.concat('Haiphong.xml');vCity = "Hải Phòng";break;
		case 4: sLink = sLink.concat('Hanoi.xml');vCity = "Hà Nội";break;
		case 5: sLink = sLink.concat('Vinh.xml');vCity = "Vinh";break;
		case 6: sLink = sLink.concat('Danang.xml');vCity = "Đà Nẵng";break;
		case 7: sLink = sLink.concat('Nhatrang.xml');vCity = "Nha Trang";break;
		case 8: sLink = sLink.concat('Pleicu.xml');vCity = "Pleicu";break;		
		case 9: sLink = sLink.concat('HCM.xml');vCity = "TP HCM";break;	
		default: sLink = sLink.concat('Hanoi.xml');vCity = "Hà Nội";break;
	}
	
	AjaxRequest.get({
		'url':sLink,
		'onSuccess':function(req){
			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;
			//vCity=req.responseXML.getElementsByTagName('City').item(0).firstChild.nodeValue;
			GetWeatherBox(vAdImg, vAdImg1, vAdImg2, vAdImg3, vAdImg4, vAdImg5, vWeather,vCity);				
		},
		'onError':function(req){}
	})
}

function GetWeatherBox(vImg, vImg1, vImg2, vImg3, vImg4, vImg5, vWeather,vCity){
	var sHTML = '';
	sHTML = sHTML.concat('<img src="http://vnexpress.net/Images/Weather/').concat(vImg).concat('" class="img-weather1" alt="" />');
	sHTML = sHTML.concat('<img src="http://vnexpress.net/Images/Weather/').concat(vImg1).concat('" class="img-weather" alt="" />');
	if(vImg2!=null) sHTML = sHTML.concat('<img src="http://vnexpress.net/Images/Weather/').concat(vImg2).concat('" class="img-weather" alt="" />');
	if(vImg3!=null) sHTML = sHTML.concat('<img src="http://vnexpress.net/Images/Weather/').concat(vImg3).concat('" class="img-weather" alt="" />');
	if(vImg4!=null) sHTML = sHTML.concat('<img src="http://vnexpress.net/Images/Weather/').concat(vImg4).concat('" class="img-weather" alt="" />');
	if(vImg5!=null) sHTML = sHTML.concat('<img src="http://vnexpress.net/Images/Weather/').concat(vImg5).concat('" class="img-weather" alt="" />');
	sHTML = sHTML.concat('<img src="http://vnexpress.net/Images/Weather/c.gif" class="img-weather" alt="" />');
	
	gmobj('img-Do').innerHTML = sHTML;
	gmobj('txt-Weather').innerHTML = vWeather;
	gmobj('txt-City').innerHTML=vCity
}

function ShowGoldPrice(){
	var sHTML = '';
	sHTML = sHTML.concat('<div style="text-align:right;color:#8A0000;font:bold 10px arial;">ÐVT: tr.&#273;/l&#432;&#7907;ng</div>');
	if(vGoldSbjBuy=='{0}' || vGoldSbjSell=='{1}' || vGoldSjcBuy =='{2}' || vGoldSjcSell=='{3}'){
		sHTML = sHTML.concat('<table border="0px" cellpadding="2px" cellspacing="1px" class="tbl-goldprice">');
		sHTML = sHTML.concat('	<tr>');	
		sHTML = sHTML.concat('		<td class="td-weather-title" style="text-align:center;font-size:10px;width:35%;font-weight:bold">D&#7919; li&#7879;u &#273;ang &#273;&#432;&#7907;c c&#7853;p nh&#7853;t</td>');	
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('</table>');
	}
	else{	
		sHTML = sHTML.concat('<table border="0px" cellpadding="2px" cellspacing="1px" class="tbl-goldprice">');
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td class="td-weather-title" style="font-size:10px;width:30%;">Lo&#7841;i</td>');
		sHTML = sHTML.concat('		<td class="td-weather-title" style="text-align:center;font-size:10px;width:35%;">Mua</td>');

		sHTML = sHTML.concat('		<td class="td-weather-title" style="text-align:center;font-size:10px;width:35%;">B&#225;n</td>');
		sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('	<tr>');
		sHTML = sHTML.concat('		<td class="td-weather-title">SBJ</td>');
		sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSbjBuy).concat('</td>');
		sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSbjSell).concat('</td>');
		sHTML = sHTML.concat('	</tr>');
		// sHTML = sHTML.concat('	<tr>');
		// sHTML = sHTML.concat('		<td class="td-weather-title">SJC</td>');
		// sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSjcBuy).concat('</td>');
		// sHTML = sHTML.concat('		<td class="td-weather-data txtr">').concat(vGoldSjcSell).concat('</td>');
		// sHTML = sHTML.concat('	</tr>');
		sHTML = sHTML.concat('</table>');	
	}
	gmobj('eGold').innerHTML = sHTML;
}
