/**
 * Created by Edin Rustempasic
 * Date: 06/11/11
 */

$(window).load(function() {
    $('#slider').nivoSlider(
        {
            effect:'fade',
            animSpeed:900,
            pauseTime:10000,
            startSlide:0,
            pauseOnHover:true
	    }
    );
});

$(document).ready(function() {

    $(".datepicker").datetimepicker({
        dateFormat: 'yy-mm-dd',
        minDate: 0,
        hourMin: 12,
	hourMax: 22,
        timeFormat: 'hh:mm',
        stepMinute: 10,
	separator: ' @ '
    });

    $("a[rel^='prettyPhoto']").prettyPhoto();

    $('#dish_menu').onePageNav();
    
    var menu = $('#dishes_block');
    var did = $(menu).attr('id');
    
    if ( did !== undefined ) {
        var top = menu.offset().top;

        $(window).scroll(function() {
            //didScroll = true;
            y = $(this).scrollTop();
            //menu.removeAttr('style');
            if (y > top) {
                //menu.css('position', 'fixed').css('top', 20);
		menu.removeClass('menuAbsolute');
		menu.addClass('menuFixed');
            } else {
                //menu.removeAttr('style');
                //menu.css('position', 'absolute');
		menu.removeClass('menuFixed');
		menu.addClass('menuAbsolute');

            }
        });
    }

    $('a.cartItem').live('click', function(){
        
        $.blockUI({ 
            theme:     true, 
            title:    'Restaurant Lasanie', 
            message:  '<p>Loading ...</p>', 
            timeout:   2000 
        });
        
        var _href = $(this).attr('href');
        $.ajax({
            type:	'POST',
            url:	_href,
            //data:	"ajax=1",
            dataType:	'html',
            timeout:	3000,
            cache:      false,
            success: function(d,s){
                //$('#loading').fadeOut('slow',function(){
                    //$(this).remove();
                    //$('#cart').slideUp('slow',function(){
                        //$(this).html(d).slideDown('slow');
                    //});
                //});
                
                $('#cart').html(d);
            },
            error: function(o,s,e){
                window.location = _href;
            },
            complete: function() { 
                // unblock when remote call returns 
                $.unblockUI(); 
            } 
        });
        return false;
    });
    
});

