﻿var IE6 = false/*@cc_on || @_jscript_version < 5.7@*/;
var c = "";
var theQueue = "";
var theCurrent = "";
var thePast = "";
var theRating = "";
var curNavSection = "";


//Limit Chars
function limitChars(textid, limit, infodiv) {

    var text = $('.' + textid).val();

    var textlength = text.length;

    if (textlength > limit) {

        $('.' + infodiv).html(limit + '/' + limit);

        $('.' + textid).val(text.substr(0, limit));

        return false;

    }

    else {

        $('.' + infodiv).html(textlength + '/' + limit);

        return true;

    }

}


$(document).ready(function () {
    loadEffects();

    if (IE6 == true) {
        $(".homeRating").hover(
      function () {
          $(this).addClass('hover');
      },
      function () {
          $(this).removeClass('hover');
      }
    );

    }

    $(".homeRating").hover(
          function () {
              $("#RO" + $(this).attr('id')).fadeTo("medium", 1).fadeTo("medium", 1);
          },
          function () {
              $("#RO" + $(this).attr('id')).stop(true).fadeTo("fast", 0);
          }
        );



    //Form values
    function setFormDefaults() {
        $(".defaultText").focus(function (srcc) {
            if ($(this).val() == $(this)[0].title) {
                $(this).removeClass("defaultTextActive");
                $(this).val("");
            }
        });

        $(".defaultText").blur(function () {
            if ($(this).val() == "") {
                $(this).addClass("defaultTextActive");
                $(this).val($(this)[0].title);
            }
        });

        $(".defaultText").blur();
    }
    setFormDefaults();


    //Adding Ingredient form fields
    $("#addIng").click(function () {
        addFormFields();
        setFormDefaults();
    })








    //Char Count
    $(function () {
        $('.inputRecipeDesc').keyup(function () { limitChars('inputRecipeDesc', 300, 'txtRecipeDescR'); })
    });











    //End jQuery
});



$(function () {
    $('.custom_button, .hover_menu').mouseenter(function () {
        $('.hover_menu').fadeIn('fast');
        $('.custom_button').addClass('active');
        $(this).data('in', true);
        $('.hover_menu').data('hidden', false);
    }).mouseleave(function () {
        $(this).data('in', false);
        setTimeout(hideMenu, delay);
    });

    var delay = 400;
    function hideMenu() {
        if (!$('.custom_button').data('in') && !$('.hover_menu').data('in') && !$('.hover_menu').data('hidden')) {
            $('.hover_menu').fadeOut('fast');
            $('.custom_button').removeClass('active');
            $('.hover_menu').data('hidden', true);
        }
    }


});


function loadEffects() {
    $(".ui-fade-rollover").each(function () {
        if ($(this).attr("effect_loaded") == "true") return;
        $(this).attr("effect_loaded", "true");

        if ($(this).attr("alt") != null && curNavSection != "" && $(this).attr("alt").indexOf(curNavSection) != -1) {
            $(this).attr("src", $(this).attr("src").replace("_off", "_on"));
            isOn = true;
        }
        else {
            $(this).bind("mouseenter", function (e) {
                $(this).attr("src", $(this).attr("src").replace("_off", "_over"));
            });
            $(this).bind("mouseleave", function (e) {
                $(this).attr("src", $(this).attr("src").replace("_over", "_off"));
            });
        }

    });
}
