﻿ function checkXmlHttp()
 {
     var xmlHttp;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
            {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    return xmlHttp;
 }


 function ShowWherther(thamso) {
     document.getElementById("images_thoitiet").innerHTML = "";
     document.getElementById("thongtintt_thoitiet").innerHTML = "<img src='ThoiTiet/loading6.gif' width='100px' />";
    var xmlHttp =checkXmlHttp();  
    var linktp;
  //  thamso = document.form1.selectthanhpho.value;
    if (thamso == 1) 
     {
       linktp = "http://vnexpress.net/ListFile/Weather/Danang.xml"
     }
    else if (thamso == 2) 
     { linktp = "http://vnexpress.net/ListFile/Weather/Haiphong.xml" }
    else if (thamso == 3) 
     { linktp = "http://vnexpress.net/ListFile/Weather/Nhatrang.xml" }  
    else if (thamso == 4) 
     { linktp = "http://vnexpress.net/ListFile/Weather/Pleicu.xml" }
    else if (thamso == 5) 
     { linktp = "http://vnexpress.net/ListFile/Weather/Sonla.xml" }
    else if (thamso == 6) 
     { linktp = "http://vnexpress.net/ListFile/Weather/Hanoi.xml" }
    else if (thamso == 7) 
     { linktp = "http://vnexpress.net/ListFile/Weather/HCM.xml" }
    else if (thamso == 8) 
     { linktp = "http://vnexpress.net/ListFile/Weather/Vinh.xml" }
    else if (thamso == 9) 
     { linktp = "http://vnexpress.net/ListFile/Weather/Viettri.xml" }      
    //xmlDoc.async=false;
     // xmlDoc.load(linktp);

     //alert(linktp);
             
            var url="ThoiTiet/getTT.aspx?urls="+linktp+"&dd="+Math.random();
            url = encodeURI(url);
           
           // alert(url);
        xmlHttp.open("GET",url,true);
        xmlHttp.onreadystatechange = function () {

            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                //var slc=document.getElementById("gia").innerHTML;
                var xmlDoc = xmlHttp.responseXML;

                document.getElementById("thongtintt_thoitiet").innerHTML = //"</span><img src='http://vnexpress.net/Images/Weather/c.gif'><br>"+
                xmlDoc.getElementsByTagName("Weather")[0].childNodes[0].nodeValue;

                document.getElementById("images_thoitiet").innerHTML = "<img align='left' src='http://vnexpress.net/Images/Weather/" +
                xmlDoc.getElementsByTagName("AdImg")[0].childNodes[0].nodeValue + "'>"+
                "<img align='left' style='margin-top:3px;' src='http://vnexpress.net/Images/Weather/" +
                xmlDoc.getElementsByTagName("AdImg1")[0].childNodes[0].nodeValue + "'>"+
                "<img align='left' style='margin-top:3px;' src='http://vnexpress.net/Images/Weather/" +
                xmlDoc.getElementsByTagName("AdImg2")[0].childNodes[0].nodeValue + "'>"+
                " <img align='left' style='margin-top:3px;' src='http://vnexpress.net/Images/Weather/c.gif'><div style='clear:both;'></div>";

                


            }
        } 
        
       xmlHttp.send(null);

 }
 
