$(document).ready(function () {
    $("ul.sf-menu").superfish();

    $(".orgBtn img").hover(function () {
        $(this).attr("src", $(this).attr("src").split(".").join("-ovr."));
    }, function () {
        $(this).attr("src", $(this).attr("src").split("-ovr.").join("."));
    });

    $("#mainNav li a img").hover(function () {
        $(this).attr("src", $(this).attr("src").split(".").join("-ovr."));
    }, function () {
        $(this).attr("src", $(this).attr("src").split("-ovr.").join("."));
    });

    var navID;
    $("#mainNav li ul").hover(function () {  //Swap image
        navID = $(this).parent().attr('id');
        $('.' + navID).attr("src", $('.' + navID).attr("src").split(".").join("-ovr."));
    }, function () {
        $('.' + navID).attr("src", $('.' + navID).attr("src").split("-ovr.").join("."));
    });

    var liWidth = 0;
    var liPadding = 0;
    $('#footerNav li').each(function () {
        liWidth = liWidth + parseInt($(this).width());
        liPadding = liPadding + parseInt($(this).css('padding-left')) + parseInt($(this).css('padding-right'));
    });

    var browserDiff;
    if ($.browser.name == 'safari') {
        browserDiff = 52;
    }


    $('#mainNav li ul li').mouseover(function () {
        $(this).css('color', '#C03418');
        Cufon.replace($('#mainNav li ul li'));
        //Cufon.refresh();
        $(this).css('color', '#C03418');
    });
    $('#mainNav li ul li').mouseout(function () {
        $(this).css('color', '#12592f');
        Cufon.replace($('#mainNav li ul li'));
        //Cufon.refresh();
        $(this).css('color', '#12592f');
    });

    $('#mainNav li').hover(function () {
        //console.log($(this).children('a').html());
        //$(this).children().css('color', '#FFF !important');
    }, function () {
        //$(this).children('a').css('color', '#12592F');
    });

    $('.openMap').colorbox({ width: 575, height: 550, iframe: true });
});

function openIFrame(myURL, myWidth, myHeight) {
    $.fn.colorbox({ width: myWidth + "px", height: myHeight + "px", iframe: true, href: myURL });
}

function closeAndThank(msg) {
    //setTimeout(function() { parent.$.fn.colorbox.close(); }, 6000);
    setTimeout(function() { $.fn.colorbox({ width: "250px", height: "190px", open: true, html: msg }); }, 700);
    setTimeout(function() { parent.$.fn.colorbox.close(); }, 6000);
}

function thankAndPDF(msg) {
    setTimeout(function() { parent.$.fn.colorbox.close(); }, 700);
    setTimeout(function() { $.fn.colorbox({ width: "250px", height: "190px", open: true, html: msg }); }, 200);
}
