(function($){
	$.fn.refreshEntExamSubjects = function(options) {
		var defaultContentField = $(this).find("tbody");
		var defaultContent = $(defaultContentField).html();
		$.ajax({
		    type: 'POST',
		    url: "contents/plugins/admission/ajax.php",
		    data: {action: "get_ent_subjects"},
		    success: function(data) {
		    	data = JSON.parse(data);
		    	if(data.error == 1) {

		    	} else if(data.error == 0) {
		    		$(defaultContentField).html("");
		    		i = 1;
		    		for(var key in data.subjects) {
		    			var tr = $("<tr></tr>");
				    	$(tr).addElement({"element": "td", "content": i})
				    	.addElement({"element": "td", "content": data.subjects[key].subject_name})
				    	.addElement({"element": "td", "content": data.subjects[key].classes_involved})
				    	.addElement({"element": "td", "content": '<a href="javascript:void(0);" class="remove_post_item" data-callback="refreshEntExamSubjects" data-callbackid="#entrance-exam-subjects-list" data-id="'+data.subjects[key].id+'">Remove</a>'});
			    		$(defaultContentField).append(tr);
			    		i++;
		    		}
		    	}
		    },
		    error: function(xhr, status, error) {

		    }
		});
	}
})(jQuery);

jQuery(document).ready(function($){
	$.extend({
	    getEntExamSubjects : function(options) {
	       return $.ajax({
                type: 'POST',
                url: 'contents/plugins/admission/ajax.php',
                data: {action: 'get_class_subjects', class_id: options.class_id},
	        });
	    }
	})
});