﻿/* Global Functionality */

$(document).ready(function () {
    //set height of pop-ups for IE6
    if ($.browser.msie === true && Math.floor($.browser.version <= 6)) {
        setPopUpSize();
        $(window).resize(setPopUpSize);
    }

    $('.MiniBasketClosed .showhide').toggle(
        function () {
            $('.MiniBasketExpanded').slideDown(400);
            $(this).css('background-position', '0 0').attr('title', 'Hide Basket Summary');
        },
        function () {
            $('.MiniBasketExpanded').slideUp(400);
            $(this).css('background-position', '0 -14px').attr('title', 'Show Basket Summary');
        }
    );

    $('.smoothscroll').bind('click', function () {
        var href = $(this).attr('href');
        var scrollY = $(href).offset().top;

        $('html, body').animate({ scrollTop: scrollY }, 1200);

        return false;
    });

    //make sure superfish main navigation is ipad/iphone touchscreen compatible when selecting submenus
    var isiPad = navigator.userAgent.match(/iPad/i) != null
    var isiphone = navigator.userAgent.match(/iPhone/i) != null
    if (isiPad || isiphone) {
        $(this).sftouchscreen();
    }
});

/* Global Functions */
function setPopUpSize() {
    $('#overlayMask').css({
        height: $('body').outerHeight() + 'px',
        width: $('body').outerWidth() + 'px'
    });
}

function textFocus(inputElement, val) {
    var ele = document.getElementById(inputElement);
    if (ele.value == val) {
        ele.value = '';
    }
}

function textBlur(inputElement, val) {
    var ele = document.getElementById(inputElement);
    if (ele.value == '') {
        ele.value = val;
    }
}
