// JScript 文件
var DestineStyle = "color:Green;";
var CheckingStyle = "color:Red;";
var EmptyStyle = "color:Blue;";

function PageInit()
{
    var imgMap = GetElementById("ImgMap");
    for (var i = 0; i < ShowPositionList.length; i++)
    {
        var sp = ShowPositionList[i];
        var num = i;
        var style = "";
       if (sp.OrderId < 102 && sp.OrderId > 0)
        {
            style = CheckingStyle;
        }
        else if (sp.OrderId == 0)
        {
            style = EmptyStyle;
        }
		else
        {
            style = DestineStyle;
        }
        GetElementById("ShowPositionPanel").insertAdjacentHTML("beforeEnd","<div class=\"ShowPosition\" style=\"" + style + "\" id=\"SP" + num + "\" Num=\"" + num + "\" onclick=\"DestineShowPosition(this);\" onmouseover=\"mouseover(this);\" onmouseout=\"mouseout();\">" + sp.Name + "</div>");
        var divSp = GetElementById("SP" + num);
        divSp.style.left = GetBrowserPositionX(imgMap) + parseInt(sp.PointX);
        divSp.style.top = GetBrowserPositionY(imgMap) + parseInt(sp.PointY); 
        divSp.style.height = sp.Height;
        divSp.style.width = sp.Width;
    }
}

function ResizeWindow()
{
    var imgMap = GetElementById("ImgMap");
    for (var i = 0; i < ShowPositionList.length; i++)
    {
        var sp = ShowPositionList[i];
        var num = i;
        var style = "";
        if (sp.OrderId < 102 && sp.OrderId > 0)
        {
            style = CheckingStyle;
        }
        else if (sp.OrderId == 0)
        {
            style = EmptyStyle;
        }
		else
        {
            style = DestineStyle;
        }
        var divSp = GetElementById("SP" + num);
        divSp.style.left = GetBrowserPositionX(imgMap) + parseInt(sp.PointX);
        divSp.style.top = GetBrowserPositionY(imgMap) + parseInt(sp.PointY); 
        divSp.style.height = sp.Height;
        divSp.style.width = sp.Width;
    }
}

function DestineShowPosition(obj)
{
    var num = parseInt(obj.Num);
    var sp = ShowPositionList[num];
    if (sp.OrderId == 0)
    {
        document.URL = "DestineInfo.aspx?spid=" + sp.Id;
    }
}

function mouseover(obj)
{
    var num = parseInt(obj.Num);
    var sp = ShowPositionList[num];
    var info = "";
    info += "状态：";
    if (sp.OrderId < 102 && sp.OrderId > 0)
    {
        info += "<span style=\"" + CheckingStyle + "\">已被预定</span><br />";
        info += "公司名称：<span style=\"font-weight:bold;" + CheckingStyle + "\">" + sp.Company + "</span><br />";
    }
    else if (sp.OrderId == 0)
    {
        info += "<span style=\"" + EmptyStyle + "\">空位,单击进入预定页面</span><br />";
    }
	else
    {
        info += "<span style=\"" + DestineStyle + "\">审核中...</span><br />";
    }

    if (parseFloat(sp.Price) > 0)
    {
        info += "价格：<span style=\"color:red;\">" + sp.Price + "</span>";
    }
    var divInfo = GetElementById("DivInfo");
    divInfo.style.display = "block";
    divInfo.style.left = GetBrowserPositionX(obj);
    divInfo.style.top = GetBrowserPositionY(obj) + 20;
    divInfo.innerHTML = info;
}

function mouseout()
{
    GetElementById("DivInfo").style.display = "none";
}
window.onresize = function()
{
    ResizeWindow();
}
