var BaseURL = 'http://localhost:8888/sharesy/index.php/';

var CoreService = {
	
	DoAjax: function(rType, rURL, successCallBack){
		$.ajax({
			type: rType,
			url: rURL,
			success: function(res){ eval(successCallBack(res)); },
			error: function(res){ alert(XMLHttpRequest.responseText); }
		});
	},
	
	ShowForm: function(id, data){
		$("#" + id).html(data);
		if($().is(':hidden'))
		{
			$("#" + id).css("height", "400");
			$("#" + id).slideToggle();	
		}
	}
}

var BaseService = {
	AddForm: function(controller){
		CoreService.DoAjax("GET", BaseURL + controller + "/add/", function(res){ CoreService.ShowForm('account_form', res); } );
	},
	
	EditForm: function(controller,id){
		CoreService.DoAjax("GET", BaseURL + controller + "/edit/"+ id, function(res){ CoreService.ShowForm('account_form', res); });
	},
	
    Delete: function(controller, id){
		CoreService.DoAjax("POST", BaseURL + controller + "/delete/"+ id, function(res){ alert(res); });
    }
};
