var meoss = {
    curr_idcategory : null,
    
    ajHTML: function(args) {
        mdig.aj(args, 'html');
    },

    ajJSON: function(args) {
        mdig.aj(args, 'json');
    },

    // Makes an Ajax HTML request with sensible defaults    
    aj: function(args, dataType) {
        // On some parameters we test against undefined as the caller might
        // pass null values on purpose
        $.ajax({
            type:       args.type || 'POST',
            dataType:   dataType,
            url:        args.url,
            data:       (args.data !== undefined ? args.data : null),
            timeout:    30000,
            success:    args.success,
            beforeSend: args.beforeSend,
            error:      (args.error !== undefined ? args.error : mdig._ajError)
        });
    },

    // Service functions
    _ajError : function() {
        alert("Error in Ajax call.\n\nThis might be due to a network error. Please reload the page and try again.");
    },

	
	slider_setup : function() {
		$("#slider").easySlider({
			auto: true,
            continuous: true 
		});
		
		
		$(".miniatura").hover(function () {
		  $(this).css('backgroundImage', 'url(images/bgminiatura_hover.png)');
		}, function () {
		    $(this).css('background-image', 'url(images/bgminiatura.png)');
		});
	},
    
    categories_setup : function(args) {
        meoss.curr_idcategory = args.curr_idcategory;
        meoss.curr_idmaker = args.curr_idmaker;
        
        // Bind click events to categories with children
        $("#menupro .items a.haschildren").click(function() {
            $(this).siblings("ul").toggle(300);
            return false;
        });
        
        // Show all parents of current category...
        var $curcat = $("#menupro span.category_id:contains(" + meoss.curr_idcategory + ")");
        $curcat.parents("ul").show();
        // ...and of current maker as well (only in current category!)
        $curcat.parent().find("span.maker_id:contains(" + meoss.curr_idmaker + ")").parents("ul").show();
    }
};
