$(document).ready(function () {
    // register modal dialog
    $('.modal').click(function (e) {
        e.preventDefault();
        var $link = $(this);
        var $dialog = $('<iframe></iframe>')
                    .attr('src', $link.attr('href'))
                    .attr('frameBorder', 0)
                    .dialog({
                        autoOpen: true,
                        title: $link.attr('title'),
                        height: 650,
                        width: 500,
                        autoResize: true,
                        modal: true
                    }).width(697);
    });

    $("a.openSlider").click(function (e) {
        e.preventDefault();
        $("div.sliderContainer div.slider:visible").each(function (index, element) { $(this).hide(300); $(this).parents("div.sliderContainer:first").removeClass("selected") })
        $(this).parents("div.sliderContainer:first").find("div.slider:first").show(300);
        $(this).parents("div.sliderContainer:first").addClass("selected");
    });

    $("a.closeSlider").click(function (e) {
        e.preventDefault();
        $(this).parents("div.sliderContainer:first").find("div.slider:first").hide(300);
        $(this).parents(".selected:first").removeClass("selected");
    });

    $(".moreLinkContainer").click(function (e) {
        e.preventDefault();
        var link = $(this).find("a.more:first");
        if (link.length == 0)
            link = $(this).find("a:first");

        if (link.attr("target"))
            window.open(link[0].href);
        else
            location.href = link[0].href;
    });
});
