// JavaScript Document

$(document).ready(function () {
    $('#subscribe_email').fieldtag();

    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
        $("html").css("-webkit-text-size-adjust", "none");
        $("#manage_address .inner").css("height", "505px");
    }

    $('.smoothscroll').bind('click', function () {
        var href = $(this).attr('href');
        var scrollY = $(href).offset().top;

        $('html, body').animate({ scrollTop: scrollY }, 1500);

        return false;
    });

    $('.colorboxClose').bind('click', function () {
        $.colorbox.close();
        return false;
    });

    $('#main_nav .lev_1 li a').bind('mouseover', function () {
        i = $(this).attr('id').substring(4, $(this).attr('id').length);
        if (i > 0) {
            show_nav(i);
            $('#nav_' + i).hover(function () { show_nav(i) }, function () { hide_nav(i) });
            $('#sub_nav_' + i).hover(function () { show_nav(i) }, function () { hide_nav(i) });
        }
    });
});

show_nav = function (obj) {
    pos = $("#nav_" + obj).position().left;
    $("#nav_" + obj).addClass("hover");
    $("#sub_nav_" + obj).css('display', 'block');
    $("#sub_nav_" + obj).css('left', pos + "px");
}

hide_nav = function (obj) {
    $("#nav_" + obj).removeClass("hover");
    $("#sub_nav_" + obj).css('display', 'none');
}

function select(pos) {
    if (document.getElementById("news_nav_" + pos).className == "expanded") {
        document.getElementById("news_nav_" + pos).className = ""
    } else {
        document.getElementById("news_nav_" + pos).className = "expanded"
    }
}

function show_basket(obj){
	var height =$("#"+obj).height()
	document.getElementById('mini_basket_iframe').style.height=(height-10)+"px";
	document.getElementById('mini_basket_iframe').style.display="block";
	document.getElementById(obj).style.display="block";
}

function hide_basket(obj){
	document.getElementById('mini_basket_iframe').style.display="none";
	document.getElementById(obj).style.display="none";
}

function confirmDeletion(){
    var answer = confirm("Do you wish to Delete this product? All details will be deleted and you will no longer have access to this product.")
    if (answer) {
        return true;
    } else {
        return false;
    }
}
