

		var Panel = new Object();
		
		Panel.Current = null;
		
		Panel.Settings = {
			Id : 'dynamic_profile_container',
			MoveBy : 620,
			FlagBasePath : '/assets/images/th_icons/flags_codes/',
			MoodBasePath : '/assets/images/moods/',
			JSON : null,
			AddButtonClass : 'icon option_hotlist',
			AddButtonTxt : 'Add to Hotlist',
			RemoveButtonClass : 'icon option_not_hotlist',
			RemoveButtonTxt : 'Remove from Hotlist',
			NotesContentId : 'profile_item_notes',
			NotesButtonId : 'profile_panel_save',
			NotesConfirmId : 'profile_panel_saved',
			SubscribeButtonClass : 'icon option_subscribe',
			SubscribeButtonTxt : 'Subscribe to shouts',
			UnSubscribeButtonClass : 'icon option_unsubscribe',
			UnSubscribeButtonTxt : 'Unsubscribe from shouts',
			Tabs : {
				ImageId : 'show_image_tab',
				AudioId : 'show_audio_tab',
				VideoId : 'show_video_tab',
				ImageContainerId : 'tab_photo',
				AudioContainerId : 'tab_audio',
				VideoContainerId : 'tab_video',
				AudioPlayerContainerId : 'tab_audio_player',
				VideoPlayerContainerId : 'tab_video_player',
				ActiveClass : 'Active',
				AvailableClass : 'Available',
				UnavailableClass : 'Unavailable',
				SourceBasePath : '/ajax/streamDescription.php?id=',
				AudioExtension : '&ext=.mp3',
				VideoExtension : '&ext=.flv'
				
			}
		}
		
		
		//////////////////////////////////////////////////////////////////////
		////////////////////////                       ///////////////////////
		////////////////////////    HIDE/SHOW/LOAD     ///////////////////////
		////////////////////////                       ///////////////////////
		////////////////////////                       ///////////////////////
		//////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////
		
		
		Panel.Show = function(RefMemId) {
			if(FlirtXchange.Common.Busyness.IsBusy('Panel')) return;
			FlirtXchange.Common.Busyness.Set('Panel', true);
			Panel.LoadData(MainGrid.GetData(RefMemId));
			
			Panel.Current = RefMemId;
						
			new Effect.Move(FlirtXchange.ViewController.Panel.Settings.Id, {x: 0, y: FlirtXchange.ViewController.Panel.Settings.MoveBy, duration: 0.4});
		}
		
		Panel.Hide = function() {
			if(!FlirtXchange.Common.Busyness.IsBusy('Panel')) return;
			FlirtXchange.Common.Busyness.Set('Panel', false);
						
			new Effect.Move(FlirtXchange.ViewController.Panel.Settings.Id, {x: 0, y: -FlirtXchange.ViewController.Panel.Settings.MoveBy, duration: 0.4});
		}

		Panel.LoadData = function(JSON) {

			Panel.HideShowFields(JSON.Member.ShowExtendedInfo);
			Panel.ReplaceSimple(JSON);
			Panel.SetOnline(JSON.Member.OnlineStatus.State);
			Panel.LoadPicture(JSON.Member.Photos);
			Panel.SetDC(JSON.FMN.DCStatus.State);
			Panel.SetLocation(JSON.Member.Location);
			Panel.SetMood(JSON.Member.Mood);
			Panel.SetRating(JSON.FMN.Response);
			Panel.SetNotes(JSON.Member.Notes);
			Panel.ToggleHotlistButton (JSON.HotPointer);
			Panel.ToggleSubscriptionButton (JSON.Data.SMSSubscriptions.Shouts);
			Panel.ToggleToolTips(JSON);
			Panel.Tabs.Initialize(JSON.FMN.Descriptions);
		}
		
		Panel.ToggleSubscriptionButton = function(JSON) {
			if(JSON.IsSubscribed)
			{
				$('member_option_subcribe_shout').className = Panel.Settings.UnSubscribeButtonClass;
				$('subscribe_button').innerHTML = Panel.Settings.UnSubscribeButtonTxt;
			}
			else
			{
				$('member_option_subcribe_shout').className = Panel.Settings.SubscribeButtonClass;
				$('subscribe_button').innerHTML = Panel.Settings.SubscribeButtonTxt;
			}
		}
		
		Panel.ToggleHotlistButton = function(HotPointer) {
			if(HotPointer == '1')
			{
				$('member_option_move_user').className = Panel.Settings.RemoveButtonClass;
				$('add_to_hotlist_button').innerHTML = Panel.Settings.RemoveButtonTxt;
			}
			else
			{
				$('member_option_move_user').className = Panel.Settings.AddButtonClass;
				$('add_to_hotlist_button').innerHTML = Panel.Settings.AddButtonTxt;
			}
		}
		
		Panel.HideShowFields = function(Show) {
			$('FMN_info_holder').style.display = (Show) ? 'block' : 'none';
			$('FMN_status_holder').style.display = (Show) ? 'block' : 'none';
			if(Show) {
				$('main_panel_holder').className = 'member_profile';
				$('shout_guest_copy').style.display = 'none';
				$('member_options_holder').style.display = 'block';
				$('profile_guest_about').style.display = 'none';
				$('tab_profile_menu').style.display = 'block';
				$('shout_member_copy').style.display = 'block';
				$('profile_member_about').style.display = 'block';
			} else {
				$('main_panel_holder').className = 'member_profile member_profile_guest';
				$('shout_member_copy').style.display = 'none';
				$('member_options_holder').style.display = 'none';
				$('profile_member_about').style.display = 'none';
				$('tab_profile_menu').style.display = 'none';
				$('shout_guest_copy').style.display = 'block';
				$('profile_guest_about').style.display = 'block';
			}
			
		}
		
		Panel.ToggleToolTips = function(Data) {
			if (Data.IsOperator == '1') {
				$('flirt_number_tooltip_07').style.display = 'none';
				$('flirt_number_tooltip_09').style.display = 'block';
				$('callback_tooltip_07').style.display = 'none';
				$('callback_tooltip_09').style.display = 'block';
				
				$('sms_chat_tooltip_content').innerHTML = $('sms_chat_tooltip_op').innerHTML.replace('[%PIN%]', Data.Data.LiveCode.toUpperCase());
			}
			else {
				$('flirt_number_tooltip_09').style.display = 'none';
				$('flirt_number_tooltip_07').style.display = 'block';
				$('callback_tooltip_09').style.display = 'none';
				$('callback_tooltip_07').style.display = 'block';
				
				$('sms_chat_tooltip_content').innerHTML = $('sms_chat_tooltip_customer').innerHTML.replace('[%PROFILE%]', Data.Member.Profilename.toUpperCase());
			}
		}
		
		
		
		Panel.LoadPicture = function(JSON, check) {
			if(!check) {
				$('photo_dynamic_preloader').style.display = 'block';	
				$('profile_item_image').src = JSON[0];
			}
			if($('profile_item_image').complete) {
				$('photo_dynamic_preloader').style.display = 'none';	
			} else {
				setTimeout(function() { Panel.LoadPicture(JSON, 1) }, 100);
			}
			
		}
		
		Panel.ReplaceSimple = function(JSON) {
			Panel.ReplaceInner('profile_item_name', JSON.Member.Profilename);
			Panel.ReplaceInner('profile_item_number', JSON.FMN.Number);
			Panel.ReplaceInner('profile_item_shout_message', JSON.Member.Shout.Message);
			Panel.ReplaceInner('profile_item_shout_date', JSON.Member.Shout.Updated);
			Panel.ReplaceInner('profile_item_age', JSON.Member.Age);
			Panel.ReplaceInner('profile_item_into', JSON.Member.Preference);
		}
		
		Panel.SetOnline = function(IsOnline) {
			if(IsOnline) {
				$('profile_item_log_icon').className = 'icon user_online';
				$('profile_item_log_status').className = 'on';
				$('profile_item_log_status').innerHTML = 'I am online';
			} else {
				$('profile_item_log_icon').className = 'icon user_offline';
				$('profile_item_log_status').className = 'off';
				$('profile_item_log_status').innerHTML = 'I am offline';
			}
		}
		
		Panel.SetDC = function(IsTaking) {
			if(IsTaking) {
				$('profile_item_status_icon').className = 'icon phone_on';
				$('profile_item_status_text').className = $('profile_item_number').className = 'on';
				$('profile_item_status_text').innerHTML = 'Flirt Number Status : Call me now!';
			} else {
				$('profile_item_status_icon').className = 'icon phone_off';
				$('profile_item_status_text').className = $('profile_item_number').className = 'off';
				$('profile_item_status_text').innerHTML = 'Flirt Number Status : Leave me Voicemail';
			}
		}
		
		Panel.SetLocation = function(Location) {
			$('profile_item_location_flag').src = Panel.Settings.FlagBasePath+Location.CountryCode+'.gif';
			$('profile_item_location').innerHTML = (Location.RegionName != '') ? Location.RegionName+', '+Location.CountryName : Location.CountryName;
		}
		
		Panel.SetMood = function(Mood) {
			$('profile_item_mood_img').src = Panel.Settings.MoodBasePath+Mood+'.png';
			$('profile_item_mood').innerHTML = Mood;
		}
		
		Panel.SetRating = function(Rating) {
			var result = (Rating * 5) / 100;
			
			for(var i = 1; i < 6; i++) {
				$('rat_'+i).className = 'minus';
			}

			if(result >= 0) $('rat_1').className = 'plus';
			if(result >= 1) $('rat_2').className = 'plus';
			if(result >= 2) $('rat_3').className = 'plus';
			if(result >= 3) $('rat_4').className = 'plus';
			if(result >= 4) $('rat_5').className = 'plus';
		}
		
		Panel.SetNotes = function(Notes) {
			$('profile_item_notes').innerHTML = Notes;
			$('profile_item_notes').value = Notes;
		}
		
		Panel.ReplaceInner = function(id, content) {
			$(id).innerHTML = content;
		}
		
		//////////////////////////////////////////////////////////////////////
		////////////////////////                       ///////////////////////
		////////////////////////    HIDE/SHOW/LOAD     ///////////////////////
		////////////////////////        END            ///////////////////////
		////////////////////////                       ///////////////////////
		//////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////
		////////////////////////                       ///////////////////////
		////////////////////////    MEMBER OPTIONS     ///////////////////////
		////////////////////////                       ///////////////////////
		////////////////////////                       ///////////////////////
		//////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////
		
		
		Panel.MemberOptions = {
			Settings : {
				Info : {
					ParentId : 'profile_item_option_work',
					ContainerId : 'profile_item_option_process'
				}
			}
		}
		
		Panel.MemberOptions.Success = function() {
			Panel.MemberOptions.ShowInfo('Thanks. Your request has been accepted.');
		}
		
		Panel.MemberOptions.NotLogged = function() {
			Panel.MemberOptions.ShowInfo('In order to use the Members Options you must have registered for an account and be logged in. Please Sign Up or Login and try again.');
		}
		
		Panel.MemberOptions.Error = function() {
			Panel.MemberOptions.ShowInfo('Sorry there has been a system error.');
		}
		
		Panel.MemberOptions.ShowInfo = function(Message) {
			$(Panel.MemberOptions.Settings.Info.ParentId).style.display = 'block';
			$(Panel.MemberOptions.Settings.Info.ContainerId).innerHTML = Message;
		}
		
		Panel.MemberOptions.ToggleLoader = function(State) {
			if(State) {
				Panel.MemberOptions.ShowInfo('Please wait. We are processing your request.');
			} else {
				return;
			}
		}
		
		Panel.MemberOptions.ProcessCallbackConnect = function(JSON) {
			switch(JSON.returnCode) {
				case 0:
					Panel.MemberOptions.Success();
					break;
				case -2:
					Panel.MemberOptions.NotLogged();
					break;
				default:
					Panel.MemberOptions.Error();
			}
		}
		
		Panel.MemberOptions.ProcessShoutSubscription = function(responseObject, Current) {
			var returnCode = (responseObject == null || typeof(responseObject.returnCode) == 'undefined') ? -10 : responseObject.returnCode;
			switch(returnCode) {
				case 1:
					var Data = MainGrid.GetData(Current);
					Data.Data.SMSSubscriptions.Shouts.IsSubscribed = !Data.Data.SMSSubscriptions.Shouts.IsSubscribed;
					
					if(Data.Data.SMSSubscriptions.Shouts.IsSubscribed)
						MainGrid.AddToHotlist(Panel.Current);
						
					MainGrid.SaveData(
						Current, Data
					);
					
					Panel.LoadData(Data);
					
					Panel.MemberOptions.Success();
					break;
				case -2:
					Panel.MemberOptions.NotLogged();
					break;
				default:
					Panel.MemberOptions.Error();
			}
		}
		
		Panel.MemberOptions.ProcessSMSChatSend = function(JSON, isOperator) {
			switch(JSON.returnCode) {
				case 5:
					Panel.MemberOptions.ShowInfo($((isOperator == '1') ? 'sms_chat_info_op' : 'sms_chat_info_cust').innerHTML);
					break;
				case -5:
					Panel.MemberOptions.ShowInfo($('sms_no_wallet_points').innerHTML);
					break;
				case 101:
				case 1:
					Panel.MemberOptions.Success();
					break;
				case 103:
				case 104:
				case 107:
					Panel.MemberOptions.ShowInfo($('sms_invalid_mobile_number').innerHTML);
					break;
				default:
					Panel.MemberOptions.Error();
			}
		}
		
		//////////////////////////////////////////////////////////////////////
		////////////////////////                       ///////////////////////
		////////////////////////    MEMBER OPTIONS     ///////////////////////
		////////////////////////        END            ///////////////////////
		////////////////////////                       ///////////////////////
		//////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////
		////////////////////////                       ///////////////////////
		////////////////////////    TABS OPTIONS       ///////////////////////
		////////////////////////                       ///////////////////////
		////////////////////////                       ///////////////////////
		//////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////
		
		Panel.Tabs = new Object();
		
		Panel.Tabs.Activate = function(key) {
			Panel.Tabs.SwitchTabClass('Image', 0);
			Panel.Tabs.SwitchTabClass('Audio', 0);
			Panel.Tabs.SwitchTabClass('Video', 0);
			Panel.Tabs.SwitchTabClass(key, 1);
			Panel.Tabs.SwitchContainer('Audio', 0);
			Panel.Tabs.SwitchContainer('Video', 0);
			Panel.Tabs.SwitchContainer(key, 1);
			Panel.Tabs.LoadMovie(key);
		}
		
		Panel.Tabs.SwitchTabClass = function(key, state) {
			var obj = $(Panel.Settings.Tabs[key+'Id']);
			if(obj.className.toString() == key+Panel.Settings.Tabs.UnavailableClass) return;
			
			obj.className = (state) ? key+Panel.Settings.Tabs.ActiveClass
									: key+Panel.Settings.Tabs.AvailableClass;
		}
		
		Panel.Tabs.SwitchContainer = function(key, state) {
			var obj = $(Panel.Settings.Tabs[key+'ContainerId']);
			obj.style.display = (state) ? 'block'
										: 'none';
		}
		
		Panel.Tabs.Initialize = function(JSON) {
			with (Panel.Settings.Tabs) {
				$(ImageId).className = 'Image'+AvailableClass;
				$(ImageId).onclick = function(){
					Panel.Tabs.Activate('Image');
				}
				if(JSON.HasAudio == 1) {
					$(AudioId).className = 'Audio'+AvailableClass;
					$(AudioId).onclick = function() {
						Panel.Tabs.Activate('Audio');
					}
				} else {
					$(AudioId).className = 'Audio'+UnavailableClass;
					$(AudioId).onclick = function() {
						return false;
					}
				}
				if(JSON.HasVideo == 1) {
					$(VideoId).className = 'Video'+AvailableClass;
					$(VideoId).onclick = function() {
						Panel.Tabs.Activate('Video');
					}
				} else {
					$(VideoId).className = 'Video'+UnavailableClass;
					$(VideoId).onclick = function() {
						return false;
					}
				}
			}
			Panel.Tabs.Activate('Image');
		}
		
		Panel.Tabs.LoadMovie = function(key) {
			if(key == 'Image') return;
			
			var MovieId = MainGrid.GetData(Panel.Current).FMN.Descriptions[key]
			
			var Movie = Panel.Settings.Tabs.SourceBasePath+MovieId+Panel.Settings.Tabs[key+'Extension'];
			FlirtXchange.ViewController.MediaPlayer.Initialize($(Panel.Settings.Tabs[key+'PlayerContainerId']), Movie, 250, 250);
		}
		
		FlirtXchange.ViewController.Panel = Panel;