﻿$(document).ready(function() {    
    //activate drop down menu 
    $("ul.top-nav").superfish({
        autoArrows: false,
        onBeforeShow: function() {
            //$(this).find("a:last").corner("keep bottom");
            //$(this).find("a:last").addClass("black-corner");
            //remove all the hover classes for the sub nav so we don't show under the sub nav
            $("ul.sub-nav").removeClass("sub-nav-hover");
        },
        onHide: function() {
            //$(this).find("a:last").uncorner();
        }
    });
    $("ul.sub-nav").superfish({
        autoArrows: false,
        delay: 300,
        speed: 'fast',
        onBeforeShow: function() {
            //set sub menu to be the width of parent button
            var w = parseInt($(this).parent().find("img").width()) - 11;
            w = w + "px";
            $(this).css({ "width": w });

            //set parent's z-index so that we can place the drop down menu under it
            //$(this).parent().find("img").css({ "position": "relative", "z-index": "999" });
            $(this).parent().find("img").addClass("sub-nav-hover");
            //set the menu's z-index to be less than the parents
            $(this).addClass("sub-nav-hover-menu");

            //add curve to bottom of menu
            //$(this).find("a:last").corner("bottom keep");
        },
        onHide: function() {
            //$(this).find("a:last").uncorner();
            //set parent's z-index so that we can place the drop down menu under it
            //$(this).parent().find("img").css({ "position": "" });            
            $(this).parent().find("img").removeClass("sub-nav-hover");
            //reset menu
            $(this).removeClass("sub-nav-hover-menu");
        }
    });

    //add rounded corners to images
    AddBorder();
});

//add border to images
function AddBorder() {
    //e8e8e8
    //$(".photo-border").wrap("<div class=\"photo-border-wrapper\"></div>");
    //$(".photo-border-wrapper").corner("cc:#ffffff");
    $(".photo-border").each(function() {
        var offset = $(this).offset();
        var x = offset.left - 3;
        var y = offset.top + 15;
        var w = $(this).width() + 6;
        var h = $(this).height() + 8;
        $(this).after($("<img src='/images/corner.png' alt='corner'></img>").addClass("photo-border-wrapper").css({ "left": x, "top": y, "width": w, "height": h }));
        //alert("image y: " + offset.top + "\ncorner y: " + y + "\n\nimage x: " + offset.left + "\ncorner x: " + x);
    });    
        
    if ($(".fire-house").length > 0) {
        $(".fire-house").corner("cc:#ffffff");
        $(".fire-house > .inner").corner();
    }
    if ($(".winners-prizes").length > 0) {
        $(".winners-prizes").corner("cc:#ffffff");
        $(".winners-prizes > .inner").corner();
    }
    if ($(".slide-show-box").length > 0) {
        $(".slide-show-box").corner("cc:#ffffff");
        $(".slide-show-box > .inner").corner();
    }
    if ($(".red-box").length > 0) {
        $(".red-box").corner("cc:#ffffff");
        $(".red-box > .inner").corner();
    }
}
function CloseSlideShow() {
    modalWindow.close();
}
