// This creates a slideout notifying the user that Live Chat is available.
// This appears after the first setTimeout occurance (2000 (2 seconds)).

$("body").append('<script>var clicked=true;' +
'$(".one, #twotitlebar, #twobody").on("click", function(){' +
    'if(clicked)'+
    '{' +
        'clicked=false;' +
        '$(".two").css({"right": 0});' +
        '$(".one").css({"right": 400});' +
    '}' +
    'else' +
    '{' +
        'clicked=true;' +
        '$(".two").css({"right": "-400px"});' +
        '$(".one").css({"right": "0px"});' +
    '}' +
'});<\/script>');


if(localStorage.getItem("dontshow") === "yes") {
    $('#dontshow').prop('checked', true);
} else {
    $('#dontshow').prop('checked', false);
    setTimeout(showComingChat, 2000);
    setTimeout(hideComingChat, 18000);
}

$('#dontshow').on('click', function() {   
    if(localStorage.getItem("dontshow") === "yes") {
        localStorage.setItem("dontshow", "no");
        // alert("don't show");
        hideComingChat();
    }
    else {
        localStorage.setItem("dontshow", "yes");
        // alert("show");
    }
});




function localStorageAvailable() {
    if (typeof(Storage) !== "undefined") {
        return true;
    }
    else {
        return false;
    }
}

function showComingChat() {
    $(".one").trigger('click');
}
function hideComingChat() {
    $("#twobody").trigger('click');
}

$('#dontshow').on('click', function() {
    $.cookie("dontShow", "YES"); 
});
