﻿function isIE() {
    return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}



var ShownVideoId;
ShownVideoId = 0;

function SlideVideoHowTo() {

    SlideVideoTVSpotCloseQuick();

    $("#divHowToInner").hide();
    $("#divHowToInnerCover").show();
    $("#divHowToVideo").slideRightShow();

    setTimeout('$("#divHowToInner").show(); $("#divHowToInnerCover").hide(); ', 760);

    ShownVideoId = 1;

}
function SlideVideoHowToClose() {

    $("#divHowToInner").hide();
    $("#divHowToInnerCover").show();

    setTimeout('$("#divHowToVideo").slideRightHide();', 300);

    ShownVideoId = 0;
}
function SlideVideoHowToCloseQuick() {

    $("#divHowToInner").hide();
    $("#divHowToInnerCover").show();
    $("#divHowToVideo").slideRightHideFast();

    ShownVideoId = 0;
}




function SlideVideoTVSpot() {

    SlideVideoHowToCloseQuick();

    $("#divTVSpotInner").hide();
    $("#divTVSpotInnerCover").show();
    $("#divTVSpot").slideRightShow();

    setTimeout('$("#divTVSpotInner").show(); $("#divTVSpotInnerCover").hide(); ', 760);
    
    ShownVideoId = 2;
}
function SlideVideoTVSpotClose() {

    $("#divTVSpotInner").hide(); 
    $("#divTVSpotInnerCover").show();

    setTimeout('$("#divTVSpot").slideRightHide();', 300);
    
    ShownVideoId = 0;
}
function SlideVideoTVSpotCloseQuick() {

    $("#divTVSpotInner").hide();
    $("#divTVSpotInnerCover").show();

    $("#divTVSpot").slideRightHideFast();

    ShownVideoId = 0;
}





function InitializeProductImage()
{
    var kid = $($('#productimages').children()[0]);
    kid.show();
}
function ShowImage(ImageId) {

    var $kids = $('#productimages').children();
    $kids.hide();

    var divId = '#productimage' + ImageId;
    var div = $(divId);
    div.show();
}

function hideAllTabs() {
    hidediv('tab1');
    hidediv('tab2');
    hidediv('tab3');
    hidediv('tab4');
}
function showTab1() {
    hideAllTabs();
    showdiv('tab1');
}
function showTab2() {
    hideAllTabs();
    showdiv('tab2');
}
function showTab3() {
    hideAllTabs();
    showdiv('tab3');
}
function showTab4() {
    hideAllTabs();
    showdiv('tab4');
}





function showdiv(id) {
    $('#' + id).show();
}
function hidediv(id) {
    $('#' + id).hide();
}











var ShownRecipeId = '';
var AnimationLock = 0;
var isPrint = 0;

function TurnOnButton(RecipeId) {
    var divId = '#divRecipeButton' + RecipeId;
    var div = $(divId);
    div.removeClass('recipebutton');
    div.addClass('recipebutton_on'); 
}
function TurnOffButton(RecipeId) {
    var divId = '#divRecipeButton' + RecipeId;
    if (ShownRecipeId != RecipeId) {
        var div = $(divId);
        div.removeClass('recipebutton_on');
        div.addClass('recipebutton'); 
    }
}
function TurnOffLastButton() {
    var divId = '#divRecipeButton' + ShownRecipeId;
    var div = $(divId);
    div.removeClass('recipebutton_on');
    div.addClass('recipebutton'); 
}
function SlideOpen(RecipeId) {

    if (AnimationLock == 0) {
    
        LockAnimation();

        var UnlockDelayMS = 1000;
        var ShowDivTimeDelayMS = 50;
        var OpenRecipeDetailsTimeDelayMS = 100;
        var OpenRecipeImageTimeDelayMS = 800;


        TurnOffLastButton();
        TurnOnButton(RecipeId);


        var col2 = $('#recipescol2');
        if (col2.css("display") != "none") {
            if (ShownRecipeId != RecipeId) {
                SlideClose(0);
                ShowDivTimeDelayMS = 800;
                OpenRecipeDetailsTimeDelayMS = 950;
                OpenRecipeImageTimeDelayMS = 1550;
                UnlockDelayMS = 2000;
            }
        }


        if (ShownRecipeId != RecipeId) {

            setTimeout('SlideRecipe()', OpenRecipeDetailsTimeDelayMS);
            setTimeout('SlideRecipeImage()', OpenRecipeImageTimeDelayMS);
           
            var funcShowDiv2 = "showdiv('divRecipeDetails" + RecipeId + "')";
            setTimeout(funcShowDiv2, ShowDivTimeDelayMS);

            var funcShowDiv3 = "showdiv('divRecipeImage" + RecipeId + "')";
            setTimeout(funcShowDiv3, ShowDivTimeDelayMS);

        }

        ShownRecipeId = RecipeId;

        SetFormHiddenRecipeIdValue();

        setTimeout('UnlockAnimation()', UnlockDelayMS);

       
    }
}
function SlideClose(turnOffFlag) {
   
    if (turnOffFlag != 0) {
        LockAnimation();
    }

    HideRecipePrint();
    HideRecipeEmail();
   
    var funcHideDiv = "hidediv('divRecipeDetails" + ShownRecipeId + "')";
    setTimeout(funcHideDiv, 1000);

    var funcHideDiv = "hidediv('divRecipeImage" + ShownRecipeId + "')";
    setTimeout(funcHideDiv, 1000);

    setTimeout('SlideCloseRecipeImage()', 300);
    setTimeout('SlideCloseRecipe()', 700);
   
    if (turnOffFlag != 0) {
        TurnOffLastButton();
        ShownRecipeId = '';

        SetFormHiddenRecipeIdValue();

        setTimeout('UnlockAnimation()', 1500);
    }
    
}
function UnlockAnimation() {
    AnimationLock = 0;
}
function LockAnimation() {
    AnimationLock = 1;
}
function SetFormHiddenRecipeIdValue() {
    var hidRid = '#' + getHiddenRecipeIdClientId();
    $(hidRid).val(ShownRecipeId);
}
function SlideRecipe() {
    $('#recipescol2').slideLeftShow();
}
function SlideRecipeImage() {
    $('#recipescol3').slideLeftShow();
}
function SlideCloseRecipe() {
    $('#recipescol2').slideLeftHide();
}

function SlideCloseRecipeImage() {
    $('#recipescol3').slideLeftHide();
}










function ShowRecipePrint() {

    showdiv('divRecipePrint' + ShownRecipeId);

    if (isIE()) {
  
        showdiv('recipeprint');
    }
    else {
        $("#recipeprint").fadeIn(500);
    }
}
function ShowRecipeEmail() {
    if (isIE()) {
        showdiv('recipeemail');
    }
    else {
        $("#recipeemail").fadeIn(500);
    }
}
function HideRecipePrint() {
    hidediv('divRecipePrint' + ShownRecipeId);

    if (isIE()) {
        hidediv('recipeprint');
    }
    else {
        $("#recipeprint").fadeOut(225);
    }

}
function HideRecipeEmail() {
    if (isIE()) {
        hidediv('recipeemail');
    }
    else {
        $("#recipeemail").fadeOut(225);
    }
}

function ShowEmailSent() {
    if (isIE()) {
        setTimeout(" showdiv('recipeemailsent')", 500);
        setTimeout(" hidediv('recipeemailsent')", 3500);
    }
    else {
        setTimeout("$(\"#recipeemailsent\").fadeIn(750)", 500);
        setTimeout("$(\"#recipeemailsent\").fadeOut(750)", 3500);
    }
}
function ShowEmailNotSent() {
    if (isIE()) {
        setTimeout(" showdiv('recipeemailnotsent')", 500);
        setTimeout(" hidediv('recipeemailnotsent')", 3500);
    }
    else {
        setTimeout("$(\"#recipeemailnotsent\").fadeIn(750)", 500);
        setTimeout("$(\"#recipeemailnotsent\").fadeOut(750)", 3500);
    }
}
function popprintwindow(WebsiteURL) {

    var path = WebsiteURL + '/recipeprint.aspx?rid=' + ShownRecipeId;

    var options = 'width=700, height=500, resizable=yes, scrollbars=auto, toolbar=no, location=no, directories=no, status=no,  menubar=no ';
    
    var newwin = window.open(path, 'CafeFrappeRecipePrint', options);

}



















function hideAllSupportTabs() {
    hidediv('supporttab1');
    hidediv('supporttab2');
    hidediv('supporttab3');
    hidediv('supporttab4');
    hidediv('supporttab5');
    hidediv('supportright-pic1');
    hidediv('supportright-pic2');
    hidediv('supportright-pic3');
    hidediv('supportright-pic4');
    hidediv('supportright-pic5');
}

function showSupportTab1() {
    hideAllSupportTabs();
    showdiv('supporttab1');
    showdiv('supportright-pic1');
    showdiv('supportright-bottom');
}
function showSupportTab2() {
    hideAllSupportTabs();
    showdiv('supporttab2');
    showdiv('supportright-pic2');
    hidediv('supportright-bottom');

}
function showSupportTab3() {
    hideAllSupportTabs();
    showdiv('supporttab3');
    showdiv('supportright-pic3');
    hidediv('supportright-bottom');
}
function showSupportTab4() {
    hideAllSupportTabs();
    showdiv('supporttab4');
    showdiv('supportright-pic4');
    hidediv('supportright-bottom');
}
function showSupportTab5() {
    hideAllSupportTabs();
    showdiv('supporttab5');
    showdiv('supportright-pic5');
    hidediv('supportright-bottom');
    OpenProdReg();
}
function OpenProdReg() {

    var path = 'http://www.prodregister.com/mrcoffee/default.shtml';

    var options = 'width=725, height=600, resizable=yes, scrollbars=yes, toolbar=no, location=no, directories=no, status=no,  menubar=no ';

    var newwin = window.open(path, 'CafeFrappeProdReg', options);
}