﻿$(function() {

    var countdown = {
        init: function() {
            countdown.remaining = countdown.max - $(countdown.obj).val().length;
            if (countdown.remaining > countdown.max) {
                $(countdown.obj).val($(countdown.obj).val().substring(0, countdown.max));
            }
            $(countdown.obj).siblings(".remaining").html(countdown.remaining + " characters remaining.");
        },
        max: null,
        remaining: null,
        obj: null
    };
    $(".countdown").each(function() {
        $(this).focus(function() {
            var c = $(this).attr("class");
            countdown.max = parseInt(c.match(/limit_[0-9]{1,}_/)[0].match(/[0-9]{1,}/)[0]);
            countdown.obj = this;
            iCount = setInterval(countdown.init, 1000);
        }).blur(function() {
            countdown.init();
            clearInterval(iCount);
        });
    });

});

//$(function() {


//$(".recipe_rating_popup").click(function(e) {

//$(".recipe_rating_popup").hover( function(){

//        $(this).css('background-color', '#F00');

//   
//));

// $(".recipe_rating_popup").mouseenter(function(e) {
//        $(this).addClass("recipe_rating_popup_rollover").fadeIn("slow");
//    }).mouseleave(function(e) {
//        $(this).removeClass("recipe_rating_popup_rollover");
//    });



//});

// $(".recipe_rating_popup").mouseenter(function(e) {
//        $(this).addClass("recipe_rating_popup_rollover").fadeIn("slow");
//    }).mouseleave(function(e) {
//        $(this).removeClass("recipe_rating_popup_rollover");
//    });



//});


//    maxWidth = 180;
//    minWidth = 80;	

//$(".recipe_rating_popup").hover(
//      function(){
//        $(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:400 });
//	$(this).animate({width: maxWidth+"px"}, { queue:false, duration:400});
//	lastBlock = this;
//      }
//    );



//jQuery.fn.fadeToggle = function(speed, easing, callback) {
//    return this.animate({ opacity: 'toggle' }, speed, easing, callback);

//};) 


//$(document).ready(function(){
//   
//    maxWidth = 210;
//    minWidth = 75;	

//    $(".recipe_rating_popup").hover(
//      function(){
//        $(".recipe_rating_popup").animate({width: minWidth+"px"}, { queue:false, duration:400 });
//	$(this).animate({width: maxWidth+"px"}, { queue:false, duration:400});
//	
//      }
//    );
//});


$(document).ready(function() {

    maxWidth = 180;
    minWidth = 80;

    //    $(".recipe_rating_popup").hover(
    //      function(){
    //        $(".recipe_rating_popup").animate({width: minWidth+"px"}, { queue:false, duration:400 });
    //	$(this).animate({width: maxWidth+"px"}, { queue:false, duration:400});
    //	
    //      }
    //    );



    //    $(".recipe_rating_popup").mouseenter(function(e) {
    //        $(this).addClass("recipe_rating_popup_rollover").fadeIn("slow");
    //        $(this).animate({width: maxWidth+"px"}, { queue:false, duration:400 });
    //        
    //    }).mouseleave(function(e) {
    //        $(this).animate({width: minWidth+"px"}, { queue:false, duration:400});
    //        $(this).removeClass("recipe_rating_popup_rollover");
    //    });
    //    

    $(".recipe_rating_popup").mouseenter(function(e) {
        if ($.browser.msie) {

        } else {
            $(this).addClass("recipe_rating_popup_rollover");
            $(this).stop().animate({ width: maxWidth + "px" }, { queue: false, duration: 400 });
        }


    }).mouseleave(function(e) {
        if ($.browser.msie) {

        } else {

            $(this).stop().animate({ width: minWidth + "px" }, { queue: false, duration: 100 });
            $(this).removeClass("recipe_rating_popup_rollover");
        }
    });




    $(".recipe_button").click(function(e) {
        if ($.browser.msie) {

            $(".recipe_rating_popup").fadeToggle(500);

        } else {


        }
    });
    //    });

    jQuery.fn.fadeToggle = function(speed, easing, callback) {
        return this.animate({ opacity: 'toggle' }, speed, easing, callback);

    }; 

});