jQuery.postJSON = function(url, data, callback) {
	jQuery.post(url, data, callback, "json");
};

var RandomizeStudentProject = {
	
	init : function() {
		RandomizeStudentProject.createRandomizeLink();
	},
	
	createRandomizeLink : function() {
		if (jQuery('.randomize-container').length > 0) {
			jQuery('.randomize-container').html('<a class="randomize-project" href="#" onclick="return false;">anderes Projekt zeigen</a>');
			
			jQuery('.randomize-project').click(function() {
				RandomizeStudentProject.getRandomProject();
			});
		}
		
	},
	
	getRandomProject : function() {
		jQuery.postJSON("index.php?eID=uwh_student_projects&action=get_rnd", '',
			function(json) {
				RandomizeStudentProject.handleResponse(json);
			}
		);
	},
	
	handleResponse : function(json) {
		jQuery('.uwh-student-project').html(json.html);
	}
	
};

jQuery(document).ready(function(){
	RandomizeStudentProject.init();
});
