
		//advAjax default settings.
		advAJAX.setDefaultParameters({
			AjaxKey : '__hrtfd__',
   			onError : function(obj) {
    	        switch(obj.status) {
    	        	case 403:
    	        		alert('NotLoggedIn');
    	        		break;
    	        	default:
    	        		alert('generic error');
    	        }
    		}
		});
		
		FlirtXchange.ActionDispatcher = new Object();
		
		FlirtXchange.ActionDispatcher.Registry = new Object();
		FlirtXchange.ActionDispatcher.Registry.CurrentSection = null;

		FlirtXchange.ActionDispatcher.doListCall = function(section, URLext) {
			if(FlirtXchange.Common.Busyness.IsBusy('SectionLoad')) return;
			FlirtXchange.Common.Busyness.Set('SectionLoad', true); 
			FlirtXchange.ActionDispatcher.Registry.CurrentSection = section || 'null';
			if(!URLext) URLext = '';
			advAJAX.post({
				url: '/instant_flirt_connections/index.php'+URLext,
    			sec: section,
				seop : 'asdad',
				hot : FlirtXchange.ViewController.HotList.GetHotListed(),
    			onLoading : function() {
	    			FlirtXchange.ViewController.List.ToggleLoader(1);
    			},
    			onSuccess : function(obj) {
    				setTimeout( function() {
						FlirtXchange.ViewController.List.LoadGrid(obj.responseJSON);
						FlirtXchange.ViewController.List.ToggleLoader(0);
						FlirtXchange.Common.Busyness.Set('SectionLoad', false);
    				}, 500);
    			}
			});
		}
			
		FlirtXchange.ActionDispatcher.doSetCall = function(set) { 
			if(FlirtXchange.Common.Busyness.IsBusy('SectionLoad')) return;
			FlirtXchange.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 : FlirtXchange.ViewController.HotList.GetHotListed(),
	    		set: FlirtXchange.ViewController.List.Settings.Pagination.Details.CurrentSet + set,
	    		previous: FlirtXchange.ViewController.List.Settings.Pagination.Details.CurrentSet,
    			sec: FlirtXchange.ActionDispatcher.Registry.CurrentSection,
    			onLoading : function() {
	    			FlirtXchange.ViewController.List.ToggleLoader(1);
    			},
    			onSuccess : function(obj) {
    				setTimeout( function() {
    					FlirtXchange.ViewController.List.LoadGrid(obj.responseJSON);
    					FlirtXchange.ViewController.List.ToggleLoader(0);
						FlirtXchange.Common.Busyness.Set('SectionLoad', false);
    				}, 500);
    			}
			});
		}
		
		FlirtXchange.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.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]);
			
			FlirtXchange.ActionDispatcher.doListCall('Search', URL);
			
		}
		
		FlirtXchange.ActionDispatcher.changeGenderPreference = function(gender) {
			if(FlirtXchange.Common.Busyness.IsBusy('SectionLoad')) return;
			FlirtXchange.ViewController.List.SortGenderTabs(gender);
			var URL = '?gpref='+encodeURIComponent(gender);
			FlirtXchange.ActionDispatcher.doListCall(FlirtXchange.ActionDispatcher.Registry.CurrentSection, URL);
		}
		
		FlirtXchange.ActionDispatcher.saveHotList = function() {
			if(FlirtXchange.Common.Busyness.IsBusy('HotList.Save') || !FlirtXchange.ViewController.HotList.Settings.Changed) return;
			FlirtXchange.Common.Busyness.Set('HotList.Save', true);
			FlirtXchange.ViewController.HotList.Settings.Changed = false;
			advAJAX.post({
				url: '/ajax/saveHotlist.php',
				hotlist: FlirtXchange.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') {
						FlirtXchange.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>';
						FlirtXchange.Common.Busyness.Set('HotList.Save', false);
					}, 1200);
				}
			});
		}
		
		FlirtXchange.ActionDispatcher.requestNotesSave = function(MemberId) {
			if (FlirtXchange.Common.Busyness.IsBusy('SaveNote')) return;
			FlirtXchange.Common.Busyness.Set('SaveNote', true);
			advAJAX.post({
				url: '/ajax/saveNotes.php',
				content: $F(FlirtXchange.ViewController.Panel.Settings.NotesContentId),
				target_id :  MemberId,
				onSuccess: function(obj){
					$(FlirtXchange.ViewController.Panel.Settings.NotesButtonId).hide();
					$(FlirtXchange.ViewController.Panel.Settings.NotesConfirmId).show();
					
					var JSON = FlirtXchange.ViewController.Panel.Settings.JSON.evalJSON();
										
					JSON.Member.Notes = $F(FlirtXchange.ViewController.Panel.Settings.NotesContentId);
					FlirtXchange.ViewController.HotList.UpdateJSONStrings(
						JSON.HotList.Id, JSON
					);
					
					FlirtXchange.Common.Busyness.Set('SaveNote', false);
				}
			});
		}
		
		FlirtXchange.ActionDispatcher.requestCallbackConnect = function(JSONString) {
			var JSON = eval(	'(' + JSONString + ')'	);
			if (!FlirtXchange.Common.Busyness.IsBusy('CallbackConnect')) {
				FlirtXchange.Common.Busyness.Set('CallbackConnect', true, 20000);
				advAJAX.post({
					userCheck : true,
					url: '/ajax/getCallback.php',
					cli: null,
					country: JSON.Country,
					is_op : JSON.IsOperator,
					live_C : JSON.LiveCode,
					cli_type: 1, //is_mobile, 1 for mobile 0 for landlines
					service_name: JSON.Service,
					conference: JSON.Number,
					returnType : 'JSON',
					onLoading: function(){
						FlirtXchange.ViewController.Panel.MemberOptions.ToggleLoader(1);
					},
					onSuccess: function(obj){
						FlirtXchange.ViewController.Panel.MemberOptions.ProcessCallbackConnect(obj.responseJSON);
					}
				});
			} else {
				FlirtXchange.ViewController.Panel.MemberOptions.ShowInfo('Sorry - You must wait at least 20 seconds before placing another callback request.');
			}			
		}
		
		FlirtXchange.ActionDispatcher.requestShoutSubscription = function(JSON, onSuccessCallback) {
			//FlirtXchange.ViewController.Panel.MemberOptions.ShowInfo('This great new feature is currently being developed. Please check back in the next few days.');
			if (!FlirtXchange.Common.Busyness.IsBusy('ShoutSubscription')) {
				FlirtXchange.Common.Busyness.Set('ShoutSubscription', true, 20000);
				
				if(JSON.HotPointer == '0') {
					FlirtXchange.ViewController.HotList.MoveUser()
				}
				advAJAX.post({
					url: '/ajax/smsSubscriptions.php',
					returnType : 'JSON',
					event : 'Shout',
					is_op : JSON.Data.SMSSubscriptions.Shouts.TargetIsOperator,
					target_mem_id : JSON.Data.SMSSubscriptions.Shouts.TargetId,
					direction : !JSON.Data.SMSSubscriptions.Shouts.IsSubscribed,
					onLoading: function(){
						FlirtXchange.ViewController.Panel.MemberOptions.ToggleLoader(1);
					},
					onSuccess : function(obj) {
						if(typeof(onSuccessCallback) != 'undefined') {
							onSuccessCallback(obj.responseJSON, JSON);
							FlirtXchange.Common.Busyness.Set('ShoutSubscription', false);
						} else {
							FlirtXchange.ViewController.Panel.MemberOptions.ProcessShoutSubscription(obj.responseJSON, JSON);
						}
					}
				});
			} else {
				FlirtXchange.ViewController.Panel.MemberOptions.ShowInfo('Sorry - You must wait at least 20 seconds before placing another subscription request.');
			}
		}
		
		FlirtXchange.ActionDispatcher.requestIVRDescription = function(DescriptionId) {
			FlirtXchange.ViewController.Panel.MemberOptions.ShowInfo('This great new feature is currently being developed. Please check back in the next few days.');
			return;
			if(DescriptionId == null || DescriptionId == '') {
				FlirtXchange.ViewController.Panel.MemberOptions.ShowInfo('Unfortunately this user has yet to record a profile. Please check back later.');
				return;
			}
			if (!FlirtXchange.Common.Busyness.IsBusy('DescriptionOrder')) {
				FlirtXchange.Common.Busyness.Set('DescriptionOrder', true, 15000);
				advAJAX.get({
					url: '/ajax/orderDescription.php',
					d_id : DescriptionId,
					onLoading: function(){
						FlirtXchange.ViewController.Panel.MemberOptions.ToggleLoader(1);
					},
					onSuccess: function(obj){
						FlirtXchange.ViewController.Panel.MemberOptions.ProcessDescriptionOrder(obj.responseJSON);
					}
				});
			} else {
				FlirtXchange.ViewController.Panel.MemberOptions.ShowInfo('Sorry - You must wait at least 15 seconds before placing another request.');
			}			
		}
		
		FlirtXchange.ActionDispatcher.doHotListedCall = function(section) {
			FlirtXchange.ActionDispatcher.Registry.CurrentSection = section || 'null';
			advAJAX.post({
				url: '/mypage/hotlisted_me',
    			sec: 'get_users',
				hot : FlirtXchange.ViewController.HotList.GetHotListed(),
    			onLoading : function() {
	    			FlirtXchange.ViewController.List.ToggleLoader(1);
    			},
    			onSuccess : function(obj) {
    				setTimeout( function() {
    					FlirtXchange.ViewController.List.LoadGrid(obj.responseJSON);
    					FlirtXchange.ViewController.List.ToggleLoader(0);
    				}, 500);
    			}
			});
		}
		
		FlirtXchange.ActionDispatcher.requestRedeemCallback = function(minutes) {
			if (!FlirtXchange.Common.Busyness.IsBusy('RedeemCallback')) {
				FlirtXchange.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: 'XPAN',
					minutes : (typeof(minutes) == 'undefined') ? null : minutes, 
					returnType : 'JSON',
					onLoading: function(){
						FlirtXchange.ViewController.CallbackControllers.Redeem.Start();
					},
					onSuccess: function(obj){
						FlirtXchange.ViewController.CallbackControllers.Redeem.Process(obj.responseJSON);
					}
				});
			} else {
				FlirtXchange.ViewController.CallbackControllers.Redeem.ShowInfo('Sorry - You must wait at least 45 seconds before placing another callback request.');
			}			
		}
