//  @import com.hedgehoglab.application.BaseApplication;
//	@import com.hedgehoglab.solomon.service.DealsService;
//	@import com.hedgehoglab.solomon.service.UsersService;
//	@import com.hedgehoglab.solomon.service.NotesService;
//	@import com.hedgehoglab.solomon.service.TasksService;
//	@import com.hedgehoglab.solomon.service.ContactsService;
//	@import com.hedgehoglab.solomon.service.LicenceService;
	
//	@import com.hedgehoglab.solomon.view.DealsListView;
//	@import com.hedgehoglab.solomon.view.DealsEditView;
//	@import com.hedgehoglab.solomon.view.DealsSearchView;
//	@import com.hedgehoglab.solomon.view.DealsActionsView;
	
//	@import com.hedgehoglab.solomon.controller.DealsController;
	
function DealsIndexApplication(scope) {
	
	//	Test!
	//	Need a linked list that:
	//	1) Can be accessed by a key
	//	2) The item returned, returns the object AND the index
	//	3) when items are removed they are reinedxed?
	
	//	onw sort indexes
	// var t=[5,4,2,9];
	// var lookup={
	// 	5:0,
	// 	4:1,
	// 	2:2,
	// 	9:3
	// };
	// 
	// console.log(t,lookup);
	// 
	// var u=t.sort(function(a,b){
	// 	if(a>b){
	// 		console.log(a,b);
	// 		//	switch
	// 		t_a=lookup[a];
	// 		t_b=lookup[b];
	// 
	// 		lookup[a]=t_b;
	// 		lookup[b]=t_a;
	// 		
	// 		console.log(t_a,t_b);
	// 	}
	// 	
	// 	return (a>b)?true:false;
	// });
	// 
	// console.log(u);
	// console.log(lookup);
	// 
	// return false;
	// UsersService.call
    BaseApplication.call(this, scope);

    this.main = function(resource) {
	var _licence_service = new LicenceService({interval:10});
		var _deals_service = new DealsService();
		var _contacts_service = new ContactsService();
		var _notes_service = new NotesService();
		var _users_service = new UsersService();
		var _tasks_service = new TasksService();
		
		//	Views
		var _deals_list_view = new DealsListView({
	            element:$('.deals-pane')
	        });
		// 
		var _deals_edit_view = new DealsEditView({
	            element:$('.deals-editing-pane')
	        });
		var _deals_actions_view = new DealsActionsView({
			element:$('#new-contact-action')
		});
		// 	
		//var _search_contacts_view = new SearchContactsView({element:$('.FindPanel')});
		var _deals_search_view = new DealsSearchView({element:$('.FindPanel')});
		
		var _deals_controller = new DealsController({
			deals_service : _deals_service,
			users_service : _users_service,
			notes_service : _notes_service,
			tasks_service : _tasks_service,
			licence_service : _licence_service,
			
			contacts_service:_contacts_service,
			
			message_service:resource.message_service,
			
			deals_search_view : _deals_search_view,
			deals_list_view : _deals_list_view,
			deals_edit_view : _deals_edit_view,
			deals_actions_view : _deals_actions_view
		});
	};
};

new DealsIndexApplication({});