﻿var curNavSection = "";
var curSubNavSection = "";

$(document).ready(function () {


    addCorners();


    //Form field defaults
    $(".defaultText").focus(function (srcc) {
        if ($(this).val() == $(this)[0].title) {
            $(this).removeClass("defaultTextActive");
            $(this).val("");
        }
    });

    //Policy Popin
    $("a#policy").fancybox({
        'autoDimensions' : false,
        'width': 900,
        'height' : 554
    });

    $(".defaultText").blur(function () {
        if ($(this).val() == "") {
            $(this).addClass("defaultTextActive");
            $(this).val($(this)[0].title);
        }
    });

    $(".defaultText").blur();

    //Fade Rollover Code
    $(".ui-fade-rollover").each(function () {
        if ($(this).attr("effect_loaded") == "true") return;

        $(this).attr("effect_loaded", "true");

        if ($(this).attr("alt") != null && curNavSection != "" && $(this).attr("alt").indexOf(curNavSection) != -1)
            $(this).attr("src", $(this).attr("src").replace("_off", "_over"));

        if ($(this).attr("alt") != null && curSubNavSection != "" && $(this).attr("alt").indexOf(curSubNavSection) != -1)
            $(this).attr("src", $(this).attr("src").replace("_off", "_over"));

        var wrapper = "<div style='display: block; height: auto; width: auto; background-repeat: no-repeat; background-image: url(" + $(this).attr("src").replace("_off", "_over") + ")'></div>";
        //alert(wrapper);
        if ($(this).parent().get(0).tagName == "A")
            $(this).parent().wrap(wrapper);
        else
            $(this).wrap(wrapper);

        $(this).bind("mouseenter", function (e) {
            $(this).stop().animate({ opacity: 0 }, 300);
        });
        $(this).bind("mouseleave", function (e) {
            $(this).stop().animate({ opacity: 1 }, 300);
        });
    });


    $("#theTweet").getTwitter({
        userName: "MarlinBreakfast",
        numTweets: 1,
        loaderText: "Loading tweets...",
        slideIn: true,
        slideDuration: 750,
        showHeading: false,
        headingText: "Latest Tweets",
        showProfileLink: true,
        showTimestamp: false
    });


});

function addCorners()
{
    var bgColor = "cc:#d2d3d5";
    var pxSize = "16px";

    $(".addCorner").each(function(i)
    {
        var corners = "round";
        
        if ($(this).hasClass("tl")) corners += " tl";
        if ($(this).hasClass("bl")) corners += " bl";
        if ($(this).hasClass("tr")) corners += " tr";
        if ($(this).hasClass("br")) corners += " br";
        
        $(this).corner(bgColor + " " + corners + " " + pxSize);
    });
}
