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({'background-image' : 'url(images/bgminiatura_hover.png)'});
		}, function () {
		    var cssObj = {
			    'background-image' : 'url(images/bgminiatura.png)'
		    }
		    $(this).css(cssObj);
		});
        
        $("#slider .miniatura").show();
	},
    
    categories_setup : function(args) {
        //meoss.cat_list_uri = args.list_uri;
        meoss.curr_idcategory = args.curr_idcategory;
        
        // Bind click events to categories with children
        $("#menupro .items a.haschildcats").click(function() {
            $(this).siblings("ul").toggle(300);
            return false;
        });
        
        // Show all parents of current category
        $("#menupro span.category_id:contains(" + meoss.curr_idcategory + ")").parents("ul").show();
    }
    
/*
    _handle_category_click : function(ah) {
        // Show loader
        $(ah).siblings("span.ajax_loader").show();

        // Build the URI
        var luri = meoss.cat_list_uri.replace(
            "pgkey", $(ah).siblings("span.category_id").text()
        );
        
        // Insert the UL, removing it if already present so it'll
        // be refreshed
        $(ah).siblings("ul").remove();
        $(ah).parent().append("<ul></ul>");
        $(ah).siblings("ul").load(luri, function() {
            // Hide loader
            $(ah).siblings("span.ajax_loader").hide();
        });
        
        // Bind events to children
        $(ah).siblings("ul").find("a.haschildcats").click(function() {
            meoss._handle_category_click(this);
            return false;
        });
    }
*/
};
