﻿// Slider functions
var sliderTimer = setInterval(MoveSlider, 5000);
var tabToActivateOnLoad = "";
var maxTabs = 5;
$(function () {
    
});

function MoveSlider() {
    var currPosition = parseInt($("#sliderImages").css("left"));
    var containerWidth = $("#sliderImages").css("width");
    if (currPosition + (-675) == -(parseInt(containerWidth))) {
        $("#sliderImages").animate({ "left": "0" }, 1000, "easeinout");
    }
    else {
        $("#sliderImages").animate({ "left" : "-=675" }, 500, "easeinout");
    }
}

$(function () {
    $("#prevImage").click(function () {
        var sliderRemoveTimer = clearInterval(sliderTimer);
        sliderTimer = setInterval(MoveSlider, 3000);
        var currPosition = parseInt($("#sliderImages").css("left"));
        var containerWidth = $("#sliderImages").css("width");
        if (currPosition == 0) {

        }
        else {
            $("#sliderImages").animate({ "left": "+=675" }, 500, "easeinout");
        }
    });
    $("#nextImage").click(function () {
        var sliderRemoveTimer = clearInterval(sliderTimer);
        sliderTimer = setInterval(MoveSlider, 3000);

        var currPosition = parseInt($("#sliderImages").css("left"));
        var containerWidth = $("#sliderImages").css("width");
        if (currPosition + (-675) == -(parseInt(containerWidth))) {

        }
        else {
            $("#sliderImages").animate({ "left": "-=675" }, 500, "easeinout");
        }
    });
});


// Envelope functions
$(function () {
    $(".envelopeInfo").hover(function () {
        //var senderParent = $(this).parent();
        $(this).stop().animate({ "bottom": "0" }, 300, "easeinout");
    }, function () {
        //var senderParent = $(this).parent();
        $(this).stop().animate({ "bottom": "-250" }, 300, "easeinout");
    });
});

// Tabbed Interface functions
$(function () {
    $(".tabbedDiv").css({ "display": "none" });
    tabToActivateOnLoad = "tab" + selectRandomTab();
    activateTab(tabToActivateOnLoad);
});

function selectRandomTab() {
    var randomTab = Math.floor(Math.random() * (maxTabs));
    return randomTab + 1;
}

function activateTab(tabName) {
    $(".tabbedDiv").css({ "display": "none" });
    $("#" + tabName).css({ "display": "block" });
    $(".tabLink").removeClass("activeTab");
    $("#tabLink" + tabName).addClass("activeTab");
}

// MAILING FUNCTIONS
$(function () {
    var mailDiv = $(".mailing");
    $(mailDiv).css({ "top": "-115px" });

    $("#closeMailing").click(function () {
        $(mailDiv).stop().animate({ "top": "-115" }, 500, "easeout");
    });

    $(".mailing").toggle(function () {
        $(mailDiv).stop().animate({ "top": "0" }, 500, "easeout");
		document.getElementById("txtName").focus();
    }, function () {

    });
});

// DROPDOWN MENU FUNCTIONS
$(function () {
    $(".dropdownBox").css({ "display": "none" });

    $(".menuItemDropdown").hover(function () {
        var ddId = $(this).attr("dropdown");
        $("#" + ddId).animate({ "height": "toggle" }, 300, "easeinout");
    }, function () {
        //var ddId = $(this).attr("dropdown");
        //$("#" + ddId).animate({ "height": "hide" }, 300, "easeinout");
    });

    $(".dropdownBox").hover(function () {

    }, function () {
        $(this).animate({ "height": "hide" }, 300, "easeinout");
    });
});;
