﻿
/*
var initWeatherValue='t-p-ho-chi-minh';function zfWeContent(idx)
{
	var strCont='<p class="strong temp"><img style="float:left;margin:2px;padding:2px;width:26px;" src="/news/images/weather/'+weather[idx][3]+'" alt="os" align="absmiddle" />';
strCont+=weather[idx][2]+'<br /><span>'+weather[idx][4]+'</span></p>';
strCont+='<p>Äá»™ áº©m: <span>'+weather[idx][5]+'</span></p>';
strCont+='<p><span>'+weather[idx][6]+'</span></p>';
$('zfWeContent').innerHTML=strCont;};
function zfChange(this_)
{zfWeContent(this_.selectedIndex);};
function zfShowWeather()
{
	var strcboWeather='<select class="sltbox01" onchange="zfChange(this);">';
	var itemindex=0;for(var i=0;i<weather.length;i++)
{
	var id=weather[i][0];
	if(initWeatherValue==id)
itemindex=i;
strcboWeather+='<option value="'+id+'"'+(initWeatherValue==id?' selected ':'')+'>'+weather[i][1]+'</option>';
}
$('cboWeather').innerHTML=strcboWeather+'</select>';
zfWeContent(itemindex);
};

*/



	

/*function zfShowWeather(){
		var strcboWeather='<select onchange="zfChange(this);">';
		var itemindex=0;
		for(var i=0;i<weather.length;i++){var id=weather[i][0];
		if(initWeatherValue==id)
itemindex=i;var name=weather[i][1];strcboWeather+='<option value="'+id+'"'+(initWeatherValue==id?' selected ':'')+'>'+name+'</option>';}
document.getElementById('cboWeather').innerHTML=strcboWeather+'</select>';zfWeContent(itemindex);};

zfShowWeather();
*/
function showWeather(IMGs,Explain) {
var arrIMGs = IMGs.split("|")
var s="",ipah = "http://vnexpress.net/Images/Weather/"
s=s+"<img src='"+ipah+arrIMGs[0]+"'> "
	for (i=1;i<arrIMGs.length;i++) {
		s=s+"<img align='middle' src='"+ipah+arrIMGs[i]+"'>"
	}
	s=s+"<img src='"+ipah+"c.gif'>"
	s=s+"<p>"+Explain+"</p>"
	document.getElementById("weather").innerHTML=s
}

function zfWeContent(idx)	
{
	var strc='<p class="degree" align=left><img src="http://www.zing.vn/news/images/weather/'+weather[idx][3]+'" alt=""  align="middle" />';
	strc+='<span><strong>'+weather[idx][2]+'<br></strong>'+weather[idx][4]+'</span><br>';
	   strc+='Độ ẩm: <span>'+weather[idx][5]+'<br></span>';
    strc+=''+weather[idx][6];
	/*strc+='<span><strong>'+weather[idx][2]+'</strong></span></p>';
	strc+=weather[idx][4]+'<p>Độ ẩm:<span>'+weather[idx][5]+'</span></p>';
				strc+=weather[idx][6]+'<p style="clear:both;"></p><br class="clear" />';
 */
	document.getElementById('zfWeContent').innerHTML=strc;
}
function zfChange(this_)
{ 
		zfWeContent(this_.selectedIndex);
};

function zfShowWeather()
{ 
		var strcboWeather='<br /><select onchange="zfChange(this);">';
		var itemindex=0;
		//var initWeatherValue='danang';
		//var initWeatherValue='t-p-ho-chi-minh';
		var initWeatherValue='t-p-ha-noi';
		for(var i=0;i<weather.length;i++)
		{ 
			var id=weather[i][0];
			if (initWeatherValue==id)
				itemindex=i;
				strcboWeather+='<option value="'+id+'"'+(initWeatherValue==id?' selected ':'')+'>'+weather[i][1]+'</option>';
		}
	document.getElementById('cboWeather').innerHTML=strcboWeather+'</select>';
	zfWeContent(itemindex);
};
function ShowWeatherBox(vId){
	var sLink = '';
	sLink = 'http://vnexpress.net/ListFile/Weather/';
	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;
	}
	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="http://vnexpress.net/images/Weather/').concat(vImg).concat('" class="img-weather" alt="" />&nbsp;');
	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;
}
