﻿// JScript 文件

//地图范围
var MapLeft =220469.66886048816;
var MapRight=903758.4110906627;
var MapButtom=2732500.17907416828;
var MapTop=3328964.5395802935;
var MapBeginLeft= 0;
var MapBeginTop = 0;
var MapWith = 0;
var MapLong=0;

function SetValue()
{
    var hunanmap = document.getElementById("HunanMap");
    MapBeginLeft= 200+hunanmap.offsetLeft;
    MapBeginTop= hunanmap.offsetTop;
    MapWith = hunanmap.offsetWidth;
    MapLong = hunanmap.offsetHeight;
    MapWith = 467;
    MapLong = 417;
}

function AddTable(posx,posy,stationtext,station,colorvale)
{
    
}
function SendTest()
{
    infoWindow("wait");
    send_request("POST","DoMain.ashx?Flag=YL","_mothod=1",Test_CallBack,"");
}
function Test_CallBack(response)
{
    infoWindow("close");
    try
    {        
        //var axlResponse = new ActiveXObject("msxml2.domdocument");
        //var Is = axlResponse.loadXML(response.value);
        var   axlResponse   =   new   InitXDom(response.value); 
        //var   is   =   axlResponse.parseFromString(response.value, "text/xml ");
       
        var list = null;
        var serverInfo = null;
        if (axlResponse.getElementsByTagName("RESPONSE").length >= 1)
        {
               list = axlResponse.getElementsByTagName("StationInfo");
        }
        //
        var htm = "";
        var DivTable = document.getElementById("DivTable");
        var DivTitle = document.getElementById("DivTitle");
        var Titlehtm = "";
        if(list.length>0)
        { 
            var aaa = list[0].attributes.getNamedItem("DateTime").nodeValue;
            var startTimeDatejs = new Date(aaa.replace(/-/g,"\/"));
            startTimeDatejs.setDate(startTimeDatejs.getDate() - 1);
            Titlehtm = "湖南省"+startTimeDatejs.getYear()+"-"+(startTimeDatejs.getMonth()+1)+"-"+startTimeDatejs.getDate()+" "+"08:00到"+list[0].attributes.getNamedItem("DateTime").nodeValue.replace("0:00:00","")+"08:00雨量实况累计图(单位：mm)";
            DivTitle.innerHTML = Titlehtm;
        }
        DivTable.style.fontSize = 12;
        for(i =0 ;i<list.length;i++)
        {
            var x = (parseFloat(list[i].attributes.getNamedItem("X").nodeValue)-MapLeft)*MapWith/(MapRight-MapLeft);
            var y = (parseFloat(list[i].attributes.getNamedItem("Y").nodeValue)-MapTop)*MapLong/(MapButtom-MapTop);
            if(parseFloat(list[i].attributes.getNamedItem("value").nodeValue)<50)
            htm += "<div style=\"POSITION: absolute;Left:"+x+"px;Top:"+y+"px\"><Table><tr><td><img src='image/station.jpg'alt=\""+list[i].attributes.getNamedItem("City").nodeValue+" "+list[i].attributes.getNamedItem("value").nodeValue+"mm\"></td><td style=\" color:blue\">"+list[i].attributes.getNamedItem("value").nodeValue+"</td></tr><tr><td colspan=\"2\">"+list[i].attributes.getNamedItem("City").nodeValue+"</td></tr></Table></div>";
            else
            htm += "<div style=\"POSITION: absolute;Left:"+x+"px;Top:"+y+"px\"><Table><tr><img src='image/station.jpg'alt=\""+list[i].attributes.getNamedItem("City").nodeValue+" "+list[i].attributes.getNamedItem("value").nodeValue+"mm\"></td><td style=\" color:red\">"+list[i].attributes.getNamedItem("value").nodeValue+"</td></tr><tr><td colspan=\"2\">"+list[i].attributes.getNamedItem("City").nodeValue+"</td></tr></Table></div>";
        }
        DivTable.innerHTML = htm;
        
        
        return list;
    }
    catch(e)
    {
        return null;
    }
}

