if (typeof(SFX) == "undefined") {
    var SFX = {}; //load the SFX var if we don't already have one.
}

 SFX.softwaremap = function () {
     return {
         'mostDownloadedDays': function() {
             jQuery("#most_downloaded_ever").removeClass('sel');
             jQuery("#most_downloaded_days").addClass('sel');

             var get_data = {"func": "days"};
             jQuery.ajax({url: '/softwaremap/most_downloaded.php', data: get_data, type: 'GET',
                 success: SFX.softwaremap.most_downloaded_success, failure: SFX.softwaremap.most_downloaded_failure, cache: false});
             return false;
         },
         'mostDownloadedEver': function() {
             jQuery("#most_downloaded_days").removeClass('sel');
             jQuery("#most_downloaded_ever").addClass('sel');

             var get_data = {"func": "ever"};
             jQuery.ajax({url: '/softwaremap/most_downloaded.php', data: get_data, type: 'GET',
                 success: SFX.softwaremap.most_downloaded_success, failure: SFX.softwaremap.most_downloaded_failure, cache: false});
             return false;
         },
         'mostActiveDays': function(trove_cat_id) {
	     jQuery("#most_active_ever").removeClass('sel');
             jQuery("#most_active_days").addClass('sel');

	     var get_data;
	     if(trove_cat_id == null) {
	        get_data = {"func": "days"};
	     } else {
		    get_data = {"func": "days", "form_cat": trove_cat_id};
	     }
             jQuery.ajax({url: '/softwaremap/most_active.php', data: get_data, type: 'GET',
                 success: SFX.softwaremap.most_active_success, failure: SFX.softwaremap.most_active_failure, cache: false});
             return false;
         },
         'mostActiveEver': function(trove_cat_id) {
             jQuery("#most_active_days").removeClass('sel');
             jQuery("#most_active_ever").addClass('sel');

             var get_data;
             if(trove_cat_id == null) {
                get_data = {"func": "ever"};
             } else {
                get_data = {"func": "ever", "form_cat": trove_cat_id};
             }

	     jQuery.ajax({url: '/softwaremap/most_active.php', data: get_data, type: 'GET',
                 success: SFX.softwaremap.most_active_success, failure: SFX.softwaremap.most_active_failure, cache: false});
             return false;
         },
         'most_downloaded_success': function(data, textStatus) {
             jQuery("#most_downloaded").html(jQuery(data));
         },
         'most_downloaded_failure': function(request, textStatus, errorThrown) {
             jQuery("#most_downloaded").html(jQuery(errorThrown));
         },

         'most_active_success': function(data, textStatus) {
             jQuery("#most_active").html(jQuery(data));
         },
         'most_active_failure': function(request, textStatus, errorThrown) {
             jQuery("#most_active").html(jQuery(errorThrown));
         }

     };

 }();
