﻿//----------------------------------------

$(document).ready(function () {
    $('body').supersleight();
    $('ul.sf-menu').superfish();
    load_minicart();
    load_selector();
    //----------------------------------------


    $(".mouseOver").hover(function () {
        $(this).attr("src", $(this).attr("src").split(".").join("_ovr."));
    }, function () {
        $(this).attr("src", $(this).attr("src").split("_ovr.").join("."));
    });

    //----------------------------------------

    $("#slide1").slider({
        range: true,
        value: 60,
        min: 20,
        max: 100,
        step: 20,
        values: [20, 100],
        slide: function (event, ui) {
            var v1 = ui.values[0]
            var v2 = ui.values[1]

            $("#slide1val1").val(v1 / 10 / 2);
            $("#slide1val2").val(v2 / 10 / 2);

            $(this).stop();
            $(this).css('background-image', getColor(v1));
        }
    });


    $("#slide2").slider({
        range: true,
        value: 60,
        min: 20,
        max: 100,
        step: 20,
        values: [20, 100],
        slide: function (event, ui) {
            var v1 = ui.values[0]
            var v2 = ui.values[1]

            $("#slide2val1").val(v1 / 10 / 2);
            $("#slide2val2").val(v2 / 10 / 2);

            $(this).stop();
            $(this).css('background-image', getColor(v1));
        }

    });
    //----------------------------------------

    $('.inlineRadios input[type=radio]').prettyCheckboxes({ 'display': 'inline' });

});




//Cart Function -----------------------------------------

function load_minicart() {

    $.get("cartCount.aspx?refresh=" + Math.floor(Math.random() * 10000), function (data) {

        $(".myBagCountMain").html(data);
        $(".myBagCount").html(data);
        
    });

}
//Slider Function----------------------------------------

function getColor(opacityVal) {
    switch (opacityVal) {
        case 20:
            return "";
            break;
        case 40:
            return "";
            break;
        case 60:
            return "";
            break;
        case 80:
            return "";
            break;
        case 100: ;
            return "";
            break;
    }
}



function load_selector() {

    if ($("#openSlider").val() == 'yep') {
        // home page is open by default
        $("#coffeeSelectorContainer").animate({ top: '0' }, 1000);
        $("#selectorDrop").animate({ height: '227' }, 1000);
        $("#openButton").hide();
        $("#closeButton").show();

    } else {
        $("#openButton").show();
        $("#closeButton").hide();

    }

    $("#closeButton").click(function () {

        $("#coffeeSelectorContainer").stop().animate({ top: '-200' }, 1000);
        $("#selectorDrop").animate({ height: '27' }, 1000);
        $("#openButton").show();
        $("#closeButton").hide();
        cookieThing('close');
    })

    $("#openButton").click(function () {

        $("#coffeeSelectorContainer").stop().animate({ top: '0' }, 1000);
        $("#selectorDrop").animate({ height: '227' }, 1000);
        $("#openButton").hide();
        $("#closeButton").show();
        cookieThing('open');
    })

}


function cookieThing(state) {

    $.get("rememberCookie.aspx?state=" + state, function () { 
        
        //just sets a cookie
    
    })
        

}

//function verlicon(data) {
//    if (window.console && window.console.firebug) {
//        //Firebug is enabled
//        console.log(data);
//    } else if (window.console) {
//        console.log(data);
//    }
//}


