$(document).ready(function () {

    //select all the a tag with name equal to modal  
    $('a[name=modal]').click(function (e) {
        //Cancel the link behavior  
        e.preventDefault();
        //Get the A tag  
        var id = '#dialog';  //$(this).attr('href');

        //Get the screen height and width  
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set height and width to mask to fill up the whole screen
        //$("#mask").removeAttr("style");
        $('#mask').css({ 'width': maskWidth, 'height': maskHeight });



        //transition effect

        $('#mask').fadeTo(1000, 0.8, function () {
            //$('#mask').fadeTo("fast",0.8);    
            //Get the window height and width  
            var winH = $(window).height();
            var winW = $(window).width();

            $(id).parent().detach().prependTo('body');

            //Set the popup window to center  
            $(id).css('top', winH / 2 - (385 / 2));
            $(id).css('left', winW / 2 - $(id).width() / 2);

            $("#dialog.windowClosed").prepend("<div id='closeButton'><a href='#' id='closeLink'>Close X</a></div>")
            //transition effect
            $(id).show();
            //$("#boxes object param[name=movie]").attr("value", $("#boxes object param[name=movie]:value").val() + "&amp;autoplay=1&amp;enablejsapi=1");
            $(id).animate({
                height: "385px"
            }, 1000, function () {

                ;
                $(this).removeClass("windowClosed");
                $(this).addClass("windowOpen");
            });

        });
    });

    //if close button is clicked
    $("#mask").click(function (e) {
        //Cancel the link behavior
        e.preventDefault();

        $("#dialog").animate({
            height: "0px"
        }, 1000, function () {
            $("#dialog").hide();

            $("#closeButton").remove();
            var x = $("#dialog").html();
            $("#dialog").html(x);
            $("#dialog").removeClass("windowOpen");
            $("#dialog").addClass("windowClosed");

            $("#mask").fadeOut(1000);
        });
    });

    $('a[id=closeLink]').live('click', function (e) {
        e.preventDefault();

        $("#dialog").animate({
            height: "0px"
        }, 1000, function () {
            $("#dialog").hide();

            $("#closeButton").remove();
            var x = $("#dialog").html();
            $("#dialog").html(x);
            $("#dialog").removeClass("windowOpen");
            $("#dialog").addClass("windowClosed");

            $("#mask").fadeOut(1000);
        });
    });

    $(".NewsPane li:even").addClass("even");

});  
