function setHeader(num, square, h_square)
    {
        if(square==0)
        {
            $("#info_block h5 a").html(" Участок №"+num).attr("href", "javascript: return false;");
        }
        else
        {
            if(h_square!=148 && h_square!=0)
                $("#info_block h5 a").html(" Участок №"+num+" <span>("+square+" соток)</span>").attr("href", "dom-"+h_square+"-kv.htm");
            else
                $("#info_block h5 a").html(" Участок №"+num+" <span>("+square+" соток)</span>").attr("href", "javascript: return false;");
        }
    }
    function setImg(img)
    {
        $("#info_block img").attr("src", "houses/"+img);
    }
    function setHouse(name, status)
    {
        $("#house .name").text(name);
        $("#house .status").text(status);
    }
    function setSquare(square)
    {
        $("#square span").text(square);
    }
    function setDescription(desc)
    {
        desc=desc.replace("[br]", "<br>");
        desc=desc.replace("[br]", "<br>");

        $("#desc").html(desc);
    }
    function createInfoBlock()
    {
        $('<div id="info_block"><div class="bottom"><div class="center"><div class="inner"><h5><a href=""></a></h5><img id="img" src="houses/house.jpg" width="283" height="139" alt="" /><p id="house"><b><span class="name"></span></b>&nbsp;&mdash; <span class="status"></span></p><p id="square"><b>Площадь дома:</b> <span></span> м<sup>2</sup></p><p id="description"><b>Описание:</b> <span id="desc"></span></p></div><a id="close" a href="#">Закрыть</a></div></div></div>').appendTo("#swf");
        $("#close").click(function(){$("#info_block").remove(); $("#transparent").css("left", "-5000px"); return false;});
    }
    function showInfo(x, y, area_num, id, area_square, img, name, status, house_square, description)
    {
        $("#transparent").css("left", "0");
        createInfoBlock();

        if(id=="undefined")
        {
            setHeader(area_num, 0);
            $("#img").css("display", "none");
            $("#house").css("display", "none");
            $("#square").css("display", "none");
            setDescription("вторая очередь застройки");
        }
        else
        {
            switch(status)
            {
                case "1": { status="Участок без дома"; break; }
                case "2": { status="продано"; break; }
                case "3": { status="в резерве"; break; }
                case "4": { status="свободно"; break; }
            }

            setHeader(area_num, area_square, house_square);
            setImg(img);
            setHouse(name, status);
            setSquare(house_square);


            if(description=="undefined")
                $("#description").css("display", "none");
            else
                setDescription(description);

            if(img==0)
                $("#img").css("display", "none");
            else
                $("#img").css("display", "block");

            $("#house").css("display", "block");
            $("#square").css("display", "block");
        }

        var height=$("#info_block").height();
        x*=1;
        y*=1;

        if(x+331<=690)
            $("#info_block").css("left", (x-10)+"px");
        else
            $("#info_block").css("left", (x-321)+"px");

        if(y+height<=520)
            $("#info_block").css("top", (y-10)+"px");
        else
            $("#info_block").css("top", (y-height-10)+"px");
    }
    function init()
    {
        $("#transparent").click(function(){$("#info_block").remove(); $("#transparent").css("left", "-5000px");});
    }
    $(document).ready(init);

