// Custom Javascript

//Tab Function

function Tab() {

    $('.tab_list li').click(function () {
        var active = $(this).attr("alt");
        $('.tab_list li').removeClass('active');
        $(this).addClass('active');
        $('.tab_block').hide();
        $('#tab_' + active).show();
    });

}

//Slider Setting

var setting1 = { mode: 'fade', auto: true, pause: 3000, pager: true }



//Document Ready

$(function () {


    // Layout Setting Start //

    var right_col = $("#right_col").size();
    var left_col = $("#left_col").size();

    var column_class = "";

    if (right_col > 0 && left_col > 0) {
        column_class += "leftright_col";

    }

    else if (right_col == 0 && left_col == 0) {
        column_class += "none_col";

    }

    else if (right_col > 0) {
        column_class += "right_col";

    }

    else if (left_col > 0) {
        column_class += "left_col"

    }



    $('#container').addClass(column_class);

    // Layout Setting End //



    $(".shipment_text .ico").animate({ left: '20' }, 5000);

    // Vote Animate
    $(".survey_box .vote_bg2").each(function () {

        var vote_width = $(this).width();



        if (vote_width < 100) {

            $(this).css({ backgroundColor: '#5DA706' });
        }

        if (vote_width < 46) {

            $(this).css({ backgroundColor: '#DB071D' });
        }

        $(this).width('0');
        $(this).show().animate({ width: vote_width }, 2000);


    });

    Tab();


    $(".basket_link").live('mouseover', function () {

        $("#OrderBox").show();

    });






    $(".Inside a.close").click(function () {

        $("#OrderBox").hide();

    });

    $("#OrderBox").mouseleave(function () {

        $(this).hide();

    });




    //var slider = $(".HomeSlider ul").bxSlider(setting1);

    $(".HomeSlider ul").cycle({ fx: 'fade', timeout: 3000, pager: '#nav', pauseOnPagerHover: 1 });




    $(".MainCategorySlider ul").bxSlider(setting1);


    //    $(".pager-5").bind('click', function () {

    //        //$(".bx-pager").hide();


    //    });


    //        $(".close_button").click(function () {
    //            window.location.reload()

    //            //DefaultScript.ReloadWidget('ContentLeft', '/Catalog/Baskets/MiniBasket', '');


    //        });



    //Pulldown 

    $("li.pulldown").each(function () {

        $(this).hover(function () {

            $(this).find("ul").show();
            $(this).addClass("pulldown_active");

        }, function () {

            $(this).find("ul").hide();
            $(this).removeClass("pulldown_active");
        });


    });





});

function DisplayOptionDivs(href, divStr) {
    ResetAllOptionDivs();
    var divObj = document.getElementById(divStr);
    document.getElementById(href).className = "aktif";
    divObj.style.display = 'block';
}
function ResetAllOptionDivs() {

    document.getElementById('ProDiv1').style.display = "none";
    document.getElementById('ProDiv2').style.display = "none";

    document.getElementById('href1').className = "";
    document.getElementById('href2').className = "";


}


var AddToBasketMiniWidget = (function () {
    var basket = {};

    basket.quantity = 1;
    basket.variationId = 0;
    basket.stockAmount = 0;

    basket.CheckQuantity = function () {
        var tempQuantity = 1;
        if (tempQuantity == "" || parseInt(tempQuantity) <= 0) { DefaultScript.PNotify(SiteTranslate.translate_WARNING, SiteTranslate.translate_ERROR, ''); return false; }
        if (parseInt(tempQuantity) > parseInt(basket.stockAmount)) { DefaultScript.PNotify(SiteTranslate.translate_WARNING, SiteTranslate.translate_QUANTITYMORETHANSTOCK, ''); return false; }
        return true;
    };

    basket.addToBasket = function (variationId, stockAmount) {
        basket.variationId = variationId;
        basket.stockAmount = stockAmount;

        if (!basket.CheckQuantity()) return;

        $.ajax({
            type: 'post',
            data: { 'variationId': basket.variationId, 'quantity': 1 },
            url: '/Catalog/Baskets/AddToBasket',
            success: function (data) {
                $('#divBasketPopUp').html(data);
                DefaultScript.ReloadWidget('basketQuantity', '/Catalog/Baskets/BasketQuantity', '');
                DefaultScript.ReloadWidget('miniBasket', '/Catalog/Baskets/MiniBasket', '');
                $.colorbox({ href: '#divBasketPopUp', inline: 'true' });
            }
        });
    };

    return {
        AddToBasket: basket.addToBasket
    };


} ());


