﻿/* Initialize Accordion */
$(document).ready(function () {
    Accordion.init();
});

// Init Tooltips
$(document).ready(function () {

    /* how long before the tooltip times out and then fades out */
    Tooltips.hide_speed = 250; // 1 second

    /* how fast fading in/out goes */
    Tooltips.fade_speed = 'fast';

    /* additional alignment to position tip bubble at right spot */
    Tooltips.additional = 10; // pixels

    /* Enable a CLOSE button */
    Tooltips.close_button = true;
    Tooltips.close_button_html = 'Close';

    /* initialize Tooltips! */
    Tooltips.init();
});

//Init Tooltip for Tell-a-Friend
$(document).ready(function () {
    /* how long before the tooltip times out and then fades out */
    TooltipsTellFriend.hide_speed = 700; // 1 second

    /* how fast fading in/out goes */
    TooltipsTellFriend.fade_speed = 'slow';

    /* additional alignment to position tip bubble at right spot */
    TooltipsTellFriend.additional = 10; // pixels

    /* Enable a CLOSE button */
    TooltipsTellFriend.close_button = false;
    TooltipsTellFriend.close_button_html = 'Close';

    /* initialize TooltipsTellFriend! */
    TooltipsTellFriend.init();
});

//Init HashChange
$(document).ready(function () {
    Hashchange.init();
});

//Init Shadowbox
$(document).ready(function () {
    Shadowbox.init({
        overlayOpacity: 0.8,
		handleOversize: 'none'
    });
});

//JQuery plugin to mimic HTML5 placeholder functionality created by Patrick
(function (a) { a.fn.nInputDefault = function (e) { var d = { focusClass: "focus" }, b = a.extend(d, e), c = (function () { var f = document.createElement("input"); return "placeholder" in f })(); return this.each(function () { var g = a(this), f; if (g.attr("type") == "text" || g.is("textarea")) { f = g.attr("placeholder"); if (!c && !g.val().length) { g.val(f) } g.unbind("focus.nInputDefault").bind("focus.nInputDefault", function () { if (!c) { if ((g.val() == f || g.val() == "")) { g.val("") } } g.addClass(b.focusClass) }).unbind("blur.nInputDefault").bind("blur.nInputDefault", function () { if (!c) { if (g.val() == f || g.val() == "") { g.val(f) } } g.removeClass(b.focusClass) }) } }) } })(jQuery);

var bimba = bimba || { };

bimba = {
    vars: { },

    init: function() {
        bimba.eraseInput.init();
        bimba.tellafriend.init();
    },

    eraseInput: {        
        init: function() {

            $('#search input[type="text"], #footer-search input[type="text"]').focus(function() {

                if ($(this).val() === $(this).attr('title')) {
                    $(this).val("");
                }

            }).blur(function() {
                if ($(this).val() === "") {
                    $(this).val($(this).attr('title'));
                }
            });

            $("form").submit(function() {
                if ($('#search > input[type="text"]').val() == $('#search > input[type="text"]').attr('title')) {
                    $('#search >input[type="text"]').val("");

                }
            });
        }
    },

    tellafriend: {
        init: function() {

            $('#tell-a-friend-link').click(function(e) {
                $('#share-container').modal();
            });
        }
    }
};

$(document).ready(function() {
    
    bimba.init(); 
});

//Mega Menu Tabbing
$(document).ready(function() {
    var SelfLocation = window.location.href.split('?');
    switch (SelfLocation[1]) {
    case "justify_right":
        jQuery(".megamenu").megamenu({ 'justify': 'right' });
        break;
    case "justify_left":
    default:
        jQuery(".megamenu").megamenu();
    }
});

//Industry Landing Page
$(document).ready(function() {
    $("div.industry-category").mouseover(function() {
        $(this).addClass("industry-category-hover");
    });
    $("div.industry-category").mouseout(function() {
        $(this).removeClass("industry-category-hover");
    });
});

//Industry Page
$(document).ready(function() {
    var tabContainers = $('div.tabs > div');
    tabContainers.hide().filter(':first').show();

    $('div.tabs ul.tabNavigation a').click(function() {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();
});

//Press Release Listing Page
$(document).ready(function() {

    var tabContainers = $('div.tabs > div');
    tabContainers.hide().filter(':first').show();

    $('div.tabs ul.press-releases-tabNavigation a').click(function() {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabs ul.press-releases-tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();

});

//Product Landing Page
$(document).ready(function() {
    $("div.product-category").mouseover(function() {
        $(this).addClass("product-category-hover");
    });
    $("div.product-category").mouseout(function() {
        $(this).removeClass("product-category-hover");
    });
});


$(document).ready(function() {
    $("div.products-mini").mouseover(function() {
        $(this).addClass("products-mini-hover");
    });
    $("div.products-mini").mouseout(function() {
        $(this).removeClass("products-mini-hover");
    });
});

//Product Page
$(document).ready(function() {
    var tabContainers = $('div.tabs > div');
    tabContainers.hide().filter(':first').show();

    $('div.tabs ul.tabNavigation a').click(function() {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();
});

$(document).ready(function() {
    $("li.product").mouseover(function() {
        $(this).addClass("product-hover");
    });
    $("li.product").mouseout(function() {
        $(this).removeClass("product-hover");
    });
});

function setCookie(c_name, value, exdays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
    document.cookie = c_name + "=" + c_value;
}

function getCookie(c_name) {
    var i, x, y, ARRcookies = document.cookie.split(";");
    for (i = 0; i < ARRcookies.length; i++) {
        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
        x = x.replace(/^\s+|\s+$/g, "");
        if (x == c_name) {
            return unescape(y);
        }
    }
}


