
		//advAjax default settings.
		advAJAX.setDefaultParameters({
			AjaxKey : '__hrtfd__',
   			onError : function(obj) {
    	        switch(obj.status) {
    	        	case 403:
    	        		alert('NotLoggedIn');
    	        		break;
    	        	default:
    	        		//alert('generic error');
    	        }
    		}
		});
		
		AFL_JS.ActionDispatcher = new Object();
		
		AFL_JS.ActionDispatcher.Registry = new Object();
		AFL_JS.ActionDispatcher.Registry.CurrentSection = null;

		AFL_JS.ActionDispatcher.doListCall = function(section, URLext) {
			if(AFL_JS.Common.Busyness.IsBusy('SectionLoad')) return;
			AFL_JS.Common.Busyness.Set('SectionLoad', true); 
			AFL_JS.ActionDispatcher.Registry.CurrentSection = section || 'null';
			if(!URLext) URLext = '';
			advAJAX.post({
				url: '/gay_connections/index.php'+URLext,
    			sec: section,
				seop : 'asdad',
				hot : AFL_JS.ViewController.HotList.GetHotListed(),
    			onLoading : function() {
	    			AFL_JS.ViewController.List.ToggleLoader(1);
    			},
    			onSuccess : function(obj) {
    				setTimeout( function() {
						AFL_JS.ViewController.List.LoadGrid(obj.responseJSON);
						AFL_JS.ViewController.List.ToggleLoader(0);
						AFL_JS.Common.Busyness.Set('SectionLoad', false);
    				}, 500);
    			}
			});
		}
			
		AFL_JS.ActionDispatcher.doSetCall = function(set) { 
			if(AFL_JS.Common.Busyness.IsBusy('SectionLoad')) return;
			AFL_JS.Common.Busyness.Set('SectionLoad', true); 
			//This function is exact copy of doListCall above, it has been created that way to ensure that further 
			//changes to the sets loading can be implemented easly. 
			var set = set || null;
			if(set == null) return;
			advAJAX.post({
	    		url: '/instant_flirt_connections',
				hot : AFL_JS.ViewController.HotList.GetHotListed(),
	    		set: AFL_JS.ViewController.List.Settings.Pagination.Details.CurrentSet + set,
	    		previous: AFL_JS.ViewController.List.Settings.Pagination.Details.CurrentSet,
    			sec: AFL_JS.ActionDispatcher.Registry.CurrentSection,
    			onLoading : function() {
	    			AFL_JS.ViewController.List.ToggleLoader(1);
    			},
    			onSuccess : function(obj) {
    				setTimeout( function() {
    					AFL_JS.ViewController.List.LoadGrid(obj.responseJSON);
    					AFL_JS.ViewController.List.ToggleLoader(0);
						AFL_JS.Common.Busyness.Set('SectionLoad', false);
    				}, 500);
    			}
			});
		}
		
		AFL_JS.ActionDispatcher.doListSearchCall = function() {
			var params = new Object();
			params.Top = $('top_rated_input').checked;
			params.New = $('new_input').checked;
			params.AgeFrom = $F('age_input_from');
			params.AgeTo = $F('age_input_to');
			params.Country = $F('country_input');
			params.Region = $F('region_input');
			params.Interest = $F('interest_input');
			params.Taking = $('taking_calls_input').checked;
			params.WithVideo = $('with_video_input').checked;
			params.WithAudio = $('with_audio_input').checked;
			params.WithImage = $('with_image_input').checked;
			params.DirectInput = ($('direct_input').value.length > 0) ? $('direct_input').value : false;
			
			var URL = '?dummy=0';
			
			for(var a in params) URL += '&'+a+'='+encodeURIComponent(params[a]);
			
			AFL_JS.ActionDispatcher.doListCall('Search', URL);
			
		}
		
		AFL_JS.ActionDispatcher.changeGenderPreference = function(gender) {
			if(AFL_JS.Common.Busyness.IsBusy('SectionLoad')) return;
			AFL_JS.ViewController.List.SortGenderTabs(gender);
			var URL = '?gpref='+encodeURIComponent(gender);
			AFL_JS.ActionDispatcher.doListCall(AFL_JS.ActionDispatcher.Registry.CurrentSection, URL);
		}
		
		AFL_JS.ActionDispatcher.saveHotList = function() {
			if(AFL_JS.Common.Busyness.IsBusy('HotList.Save') || !AFL_JS.ViewController.HotList.Settings.Changed) return;
			AFL_JS.Common.Busyness.Set('HotList.Save', true);
			AFL_JS.ViewController.HotList.Settings.Changed = false;
			advAJAX.post({
				url: '/ajax/saveHotlist.php',
				hotlist: AFL_JS.ViewController.HotList.GetHotListed(),
				onLoading: function() {
					$('tab_hot_list_save').innerHTML = 'Please wait while we are saving your hotlist.';
				},
				onSuccess: function(obj){
					if(obj.responseText == '-1') {
						AFL_JS.ViewController.HotList.ShowNotLogged();
					} else {
						$('tab_hot_list_save').innerHTML = 'Your hotlist has been successfully saved.';
					}
					setTimeout(function(){
						$('tab_hot_list_save').innerHTML = '<div>Remember to save your hotlist before leaving this page</div>';
						AFL_JS.Common.Busyness.Set('HotList.Save', false);
					}, 1200);
				}
			});
		}
			
		AFL_JS.ActionDispatcher.doHotListedCall = function(section) {
			AFL_JS.ActionDispatcher.Registry.CurrentSection = section || 'null';
			advAJAX.post({
				url: '/mypage/hotlisted_me',
    			sec: 'get_users',
				hot : AFL_JS.ViewController.HotList.GetHotListed(),
    			onLoading : function() {
	    			AFL_JS.ViewController.List.ToggleLoader(1);
    			},
    			onSuccess : function(obj) {
    				setTimeout( function() {
    					AFL_JS.ViewController.List.LoadGrid(obj.responseJSON);
    					AFL_JS.ViewController.List.ToggleLoader(0);
    				}, 500);
    			}
			});
		}
		
		AFL_JS.ActionDispatcher.requestRedeemCallback = function(minutes) {
			if (!AFL_JS.Common.Busyness.IsBusy('RedeemCallback')) {
				AFL_JS.Common.Busyness.Set('RedeemCallback', true, 45000);
				advAJAX.post({
					userCheck : true,
					url: '/ajax/getCallback.php',
					cli: null,
					country: JSON.Country,
					cli_type: 1, //is_mobile, 1 for mobile 0 for landlines
					service_name: 'MFORCE',
					minutes : (typeof(minutes) == 'undefined') ? null : minutes, 
					returnType : 'JSON',
					onLoading: function(){
						AFL_JS.ViewController.CallbackControllers.Redeem.Start();
					},
					onSuccess: function(obj){
						AFL_JS.ViewController.CallbackControllers.Redeem.Process(obj.responseJSON);
					}
				});
			} else {
				AFL_JS.ViewController.CallbackControllers.Redeem.ShowInfo('Sorry - You must wait at least 45 seconds before placing another callback request.');
			}			
		}
