﻿
$(document).ready(function () {

    settings = {
        tl: { radius: 5 },
        tr: { radius: 5 },
        bl: { radius: 5 },
        br: { radius: 5 },
        autoPad: true,
        validTags: ["div"]
    }

    $('.Rounded').corner(settings);


    //When page loads...
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function () {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });

    //JQ ZOOM STUFF 
        $(".jqzoom").jqzoom();

    //Hide Menu


    $(".btnSearch").click(function () {

        if ($('#depth').val() == "" || $('#widthatfront').val() == "" || $('#widthatback').val() == "") {
            alert("Please populate all fields");
            return false
        }
        return true ;
    });

    $(".product-images a").click(function () {

        $('.image-holder .product-image img').attr('src', $(this).attr('href'));

        $('.zoom').attr('href', $(this).attr('href').replace('/small/', '/large/'));

        $('.jqzoom').attr('href', $(this).attr('href').replace('/small/', '/zoom/'));

        $('.jqzoom').jqzoom();
        return false;
    });

    $(".zoom").colorbox();
    $(".lightbox").colorbox({iframe:true, innerWidth:425, innerHeight:344});


    $(".OptionRadio").click(function () {

        $(".single-price").html($(this).parent().parent().find(".sku-price").html());
    });



    //Search
    $("#seach-btn").click(function () {
        if ($('#search-name').val() != "") {

            $("#Loading").show();
            var SearchStr = $('#search-name').val();
            var Search = "/Search/" + encodeURIComponent(SearchStr);

            top.location.href = Search;
            return false;
        } else {
            alert("Please Enter Search Term");
        }
    });

    $("#search-name").keypress(function (event) {
        if (event.keyCode == 13) {
            if ($('#search-name').val() != "") {
                $("#Loading").show();

                var SearchStr = $('#search-name').val();
                var Search = "/Search/" + encodeURIComponent(SearchStr);

                top.location.href = Search;
                return false;
            } else {
                alert("Please Enter Search Term");
            }
        }

    });

    //category sort
    $('.Sort').change(function () {
        $("#Loading").show();
        var SortMode = $(this).val();
        var pathname = window.location.pathname;

        location.href = pathname + "?sort=" + SortMode;
    });

    //category sort
    $('.Manufacturer').change(function () {
        $("#Loading").show();
        var FilterMode = $(this).val();
        var pathname = window.location.pathname;

        location.href = pathname + "?filter=" + FilterMode;
    });
    

    //Basket Page

    //Basket Page
    $('.DeletePerm').click(function () {
        return confirm("Are you sure you wish to delete this?");
    });

    //Cufon
    Cufon.replace('#cat-area .main-group', { fontFamily: 'SBT' });
    Cufon.replace('#cat-area li a', { fontFamily: 'SBT' });
    Cufon.replace('#center-right-column h1', { fontFamily: 'SBT' });
    Cufon.replace('.product-main .product-code', { fontFamily: 'SBT' });
    Cufon.replace('.related-name', { fontFamily: 'SBT' });


});
