﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />

function fl(layId) {
    $.ajax(
    {
        url: "/PopLayer.ashx?LayerID=" + layId,
        type: "POST",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function(data, textStatus) {
            $(".indexpoptop2").html("").append("<img src=\"" + data[0].poperLayerImage + "\" width=\"88\" height=\"96\" />");

            var c = $(".indexpoptop3>ul").html("");
            for (var i = 0; i < data[1].length; i++) {
                var li = $("<li/>");
                var a = $("<a/>").attr("href", data[1][i].link);
                a.text(data[1][i].title);
                a.appendTo(li);
                li.appendTo(c);
            }
        }
    });

    var $img = $(".indexpoptop1:first>a>img");
    $img.each(function() {
        var r = $(this);
        r.attr("src", r.attr("outsrc"));
    });

    var s = $img.eq(layId - 1);
    s.attr("src", s.attr("oversrc"));
}

$(document).ready(function() {

    var down = true;
    $(".indexpoptop>img").bind("click", function(event) {
        if (down) {
            $(".indexpopbox").fadeOut("slow", function() {
                $(".indexpopbox1").css("visibility", "visible").fadeIn("slow");
            });
            down = false;
        }
        else {
            $(".indexpopbox1").fadeOut("slow", function() {
                $(".indexpopbox").show();
            });
            down = true;
        }
    });

    fl('1');
});


