// Dialogs Class
var Dialogs =
{
    mainDialogShow: function(dialog)
	{
      	if(this.currentMainDialog) Element.setStyle(this.currentMainDialog + 'Dialog', {'display': 'none'});
      	Element.setStyle(dialog + 'Dialog', {'display': 'block'});
	},

    conferenceBox: function(room_name)
	{
      	var conferenceBoxWin;
       	if($('conferenceBox'))
		{
         	Windows.getWindow('conferenceBox').toFront();
         	return;
      	}  
	  
		var strOptions = '';
		for(var roster in Buddylist.listObjects)
		{
			if(Buddylist.listObjects[roster].jid==init_jid)
			{
				nick_name  = chatnhe_get_username(roster);		 
				strOptions += '<option value="' + roster + '">' + nick_name + '</option>';	
			}
		}

		conferenceBoxWin = new Window({id: 'conferenceBox', className: "dialog", width: 400, height: 300, resizable: false,
								 title: Languages.get('conferenceBox'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
								 minWidth: 400, minHeight: 300, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
		  
		conferenceBoxWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
		  
		conferenceBoxWin.getContent().innerHTML = '<div class="dialog_info lang-conferenceBoxText langinsert-clear" style="padding:3px;"><span class="mbText">' + Languages.get('conferenceBoxText') + '</span></div> \
											 <div id="conferenceBox_box" style="padding-left:0px;width:100%;"> \
		<table border="0" cellpadding="0" cellspacing="0" align="center"> \
				<tr> \
					<td rowspan="2" align="center"> \
						<div style="padding:4px"><select name="list1"  multiple="multiple" style="width:135px; height:220px;" > \
	' + strOptions + '</select></div> \
					</td> \
					<td align="center">' + ButtonCtl.create(Languages.get('select'), 'moveNick();return false;') +'</td> \
					<td rowspan="2"> \
						<div style="padding:4px"><select name="list2" style="width:135px; height:220px;" multiple="multiple"></select></div> \
					</td> \
				</tr> \
				<tr> \
					<td>' + ButtonCtl.create(Languages.get('unselect'), 'removeNick();return false;') +'</td> \
				</tr> \
	   <tr><td colspan="3" valign="top"><span class="mbText">'+Languages.get('conferenceBoxInviteText')+'</span> <input type="text" id="txtReason" maxlength="50" size="30" value="Cùng tám nhe!" /></td></tr> \
	   </table> \
											 </div> \
											 <div id="conferenceBox_buttons">' +
											 ButtonCtl.create(Languages.get('invite'), 'inviteConference(\''+ room_name +'\');') +
											 ButtonCtl.create(Languages.get('cancel'), 'Windows.close(\'conferenceBox\');') +
											 '</div>';
	
		$('conferenceBox_buttons').setStyle({position: 'absolute', top:'310px', left:'125px'});

      	conferenceBoxWin.setDestroyOnClose();
      	conferenceBoxWin.showCenter();
	},

    alertDecideJoinRoom: function(room_name, from, message)
	{
		var alertDecideJoinRoomWin;
       	if($('alertDecideJoinRoom'))
		{
         	Windows.getWindow('alertDecideJoinRoom').toFront();
         	return;
      	}
	  	nick_name = chatnhe_get_username(from);
	  
		alertDecideJoinRoomWin = new Window({id: 'alertDecideJoinRoom', className: "dialog", width: 250, height: 100, resizable: false,
								 title: Languages.get('notice'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
								 minWidth: 250, minHeight: 100, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
		  
		alertDecideJoinRoomWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
		  
		alertDecideJoinRoomWin.getContent().innerHTML = '<div class="dialog_info lang-alertDecideJoinRoomText langinsert-clear" style="padding:3px;"><span class="mbText">'+ nick_name +' ' + Languages.get('alertDecideJoinRoomText') + '. ' + Languages.get('message') + '</span></div> \
											 <div style="padding-left:10px;width:100%;" class="mbText"><i>'+ message +'</i></div> \
											 <div id="alertDecideJoinRoom_buttons">' +
											 ButtonCtl.create(Languages.get('joinRoom'), 'room_decide(\'' + room_name + '\',\'' + from + '\',\'' + user + '\',\'accept\');') +
											 ButtonCtl.create(Languages.get('decline'), 'room_decide(\'' + room_name + '\',\'' + from + '\',\'' + user + '\',\'deny\');') +
											 '</div>';
	
		$('alertDecideJoinRoom_buttons').setStyle({position: 'absolute', top:'80px', left:'50px'});

      	alertDecideJoinRoomWin.setDestroyOnClose();
      	alertDecideJoinRoomWin.showCenter();
	},

    alert_subscribtion_request: function(from)
	{
    	var alertSubscribtionRequestWin;
	//alert(from);
	from = from.replace(' ','@');
       	if($('alertSubscribtionRequest_'+from))
		{
         	Windows.getWindow('alertSubscribtionRequest_'+from).toFront();
         	return;
      	}
	  	nick_name = chatnhe_get_username(from);
	  
		alertSubscribtionRequestWin = new Window({id: 'alertSubscribtionRequest_'+from, className: "dialog", width: 250, height: 100, resizable: false,
								 title: Languages.get('notice'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
								 minWidth: 250, minHeight: 100, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
		  
		alertSubscribtionRequestWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
		  
		alertSubscribtionRequestWin.getContent().innerHTML = '<div class="dialog_info mbText" style="padding:3px;"><b>'+ nick_name +'</b> '+ Languages.get('alertSubscribtionRequestText') + '</div> \
											 <div id="alertSubscribtionRequest_buttons_'+from+'">' +
											 ButtonCtl.create(Languages.get('accept'), 'Dialogs.newBuddy(\'' + from + '\', \'accept_and_add\');') +
											 ButtonCtl.create(Languages.get('decline'), 'denySubscribtion(\'' + from + '\');') +
											 '</div>';
	
		$('alertSubscribtionRequest_buttons_'+from).setStyle({position: 'absolute', top:'80px', left:'50px'});

      	alertSubscribtionRequestWin.setDestroyOnClose();
      	alertSubscribtionRequestWin.showCenter();
   	},

	alert_add_auth: function(from, groupname)
	{
		var alertAddAuthWin;
       	if($('alertAddAuth_'+from))
	   	{
         	Windows.getWindow('alertAddAuth_'+from).toFront();
         	return;
      	}
	  	nick_name = chatnhe_get_username(from);
	  
		alertAddAuthWin = new Window({id: 'alertAddAuth_'+from, className: "dialog", width: 250, height: 150, resizable: false,
								 title: Languages.get('notice'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
								 minWidth: 250, minHeight: 150, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
		  
		alertAddAuthWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
		  
		alertAddAuthWin.getContent().innerHTML = '<div class="dialog_info lang-alertAddAuthText langinsert-clear" style="padding:3px;"><b>'+ nick_name +'</b> '+ Languages.get('alertAddAuthText') + '</div> \
											 <div id="alertAddAuth_buttons_'+from+'">' +
											 ButtonCtl.create(Languages.get('accept'), 'accept_add_auth(\'' + from + '\',\'' + groupname + '\');') +
											 ButtonCtl.create(Languages.get('decline'), 'denySubscribtion(\'' + from + '\');') +
											 '</div>';
	
		$('alertAddAuth_buttons_'+from).setStyle({position: 'absolute', top:'100px', left:'30px'});

      	alertAddAuthWin.setDestroyOnClose();
      	alertAddAuthWin.showCenter();
   	},

    alertBasic: function(win_id, message, strErrorIcon)
	{
      	var alertBasicWin;
       	if($('alertBasic_'+win_id))
		{
         	Windows.getWindow('alertBasic_'+win_id).toFront();
         	return;
      	}  
      	alertBasicWin = new Window({id: 'alertBasic_'+win_id, className: "dialog", width: 240, height: 120, resizable: false,
                             title: Languages.get('notice'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                             minWidth: 240, minHeight: 120, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	alertBasicWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
      	alertBasicWin.getContent().innerHTML = '<div class="dialog_info langinsert-clear" style="padding:3px;"></div> \
                                         <span id="alertBasic_error_msg" class="errorMsg">'+ message +'</span> \
                                         <div id="alertBasic_icons"><img src="'+STATIC_ZICZAC+'/images/error/'+strErrorIcon+'" border="0"></div> \                                         <div id="alertBasic_buttons">' +
                                         ButtonCtl.create(Languages.get('ok'), 'Windows.close(\'alertBasic_'+win_id+'\');') +
                                         '</div>';
      	$('alertBasic_buttons').setStyle({position: 'absolute', top:'120px', left:'80px'});
      	$('alertBasic_icons').setStyle({position: 'absolute', top:'75px', left:'95px'});
    	alertBasicWin.setDestroyOnClose();
    	alertBasicWin.showCenter();
	},
   
	accountsDialog: function()
	{
    	var accountsDialogWin;
       	if($('accountsDialog'))
		{
        	Windows.getWindow('accountsDialog').toFront();
        	return;
      	}  
    
    accountsDialogWin = new Window({id: 'accountsDialog', className: "preferences", width: 500, height: 300, resizable: false,
                             title: Languages.get('yourconnection'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                             minWidth: 500, minHeight: 300, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
    accountsDialogWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
    accountsDialogWin.getContent().innerHTML = '<span class="mbText">&nbsp;&nbsp;'+Languages.get('transportIntro')+'</span><br><br><div id="div_accounts"></div> \
                                         <div id="accountsDialog_buttons">' +
                                         ButtonCtl.create(Languages.get('addnewtransport'), 'Dialogs.addTransportDialog(\'\',\'\');') +
                                         '</div>';

    $('accountsDialog_buttons').setStyle({position: 'absolute', top:'300px', left:'400px'});

		xajax_loadRegisteredGateway();
      	accountsDialogWin.setDestroyOnClose();
      	accountsDialogWin.showCenter();
	},

	addTransportDialog: function(strTransport,strUsername)
	{
		var addTransportDialogWin;

		if($('addTransportDialog')) {
			Windows.getWindow('addTransportDialog').toFront();
			return;
		}
		addTransportDialogWin = new Window({id: 'addTransportDialog', className: "dialog", width: 300, height: 200, resizable: false, title: Languages.get('addnewtransport'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false, minWidth: 300, minHeight: 200, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
		addTransportDialogWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
		addTransportDialogWin.getContent().innerHTML = '<div class="accounts" style="padding:3px;"> \
<table width="100%" border="0" class="mbText"> \
  <tr><td colspan="2">'+Languages.get('transportChooseYourService')+'<br><br></td></tr> \
  <tr><td width="40%">'+Languages.get('service')+'</td><td><img id="transport_icon" src="'+STATIC_ZICZAC+'/themes/transport/yahoo.gif" border="0" /><select style="width:145px" class="mbText" onchange="change_transport_icons(this.value);" id="selected_transport"><option id="gtw_yahoo" value="yahoo">Yahoo Messenger!</option><option id="gtw_msn" value="msn">MSN Messenger</option><option id="gtw_aim" value="aim">AIM</option><option id="gtw_gtalk" value="gtalk">Google Talk</option></select></td></tr> \
  <tr><td>Username</td><td><img width="17" src="'+STATIC_ZICZAC+'/themes/images/blank.gif" border="0" /><input class="cn_default" type="text" id="transport_username" value="'+strUsername+'" maxlength="32" style="height:15px; font-size:11; width:145px"></td></tr> \
  <tr><td>Password</td><td><img width="17" src="'+STATIC_ZICZAC+'/themes/images/blank.gif" border="0" /><input class="cn_default" type="password" id="transport_password" maxlength="32" style="height:15px; font-size:11; width:145px"></td></tr> \
  <tr><td align="right" colspan="2"><input type="checkbox" name="cnosu" checked="checked"> <font color="#430000">'+Languages.get('auto_connect')+'</font><input type="checkbox" name="soai" checked="checked"> <font color="#430000">Invisible</font></td></tr> \
</table></div> \
	<div id="addTransportDialog_buttons">' +ButtonCtl.create(Languages.get('addnewconnection'), 'addNewConnection();') +'</div>';
	
		$('addTransportDialog_buttons').setStyle({position: 'absolute',
													top:      '200px',
													left:     '195px'});
		
		addTransportDialogWin.setDestroyOnClose();
		addTransportDialogWin.showCenter();
		if(strTransport!='')
		{
			$('gtw_'+strTransport).selected = 'selected';
			change_transport_icons(strTransport);
			$('selected_transport').disabled = 'disabled';
		}
	},

	newRoom: function()
	{
      	var newRoomWin;
      	if($('newRoom')) {
         	Windows.getWindow('newRoom').toFront();
         	return;
      	}
      
      	newRoomWin = new Window({id: 'newRoom', className: "preferences", width: 650, height: 550, resizable: false,
                               title: Languages.get('newRoom'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                               minWidth: 650, minHeight: 550, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	newRoomWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
      	newRoomWin.getContent().innerHTML = '<img src="images/blank.gif" width="2" height="4" border="0"><div id="box_search" style="padding-left:10px"><span style="float:left" class="mbText">'+Languages.get('searh_room')+' </span> <select name="room_cate_code" id="room_cate_code" style="float:left; height:20px; font-size:11px"><option value="0" selected="selected">'+Languages.get('room_cate_all')+'</option><option value="1">'+Languages.get('room_cate_amnhac')+'</option><option value="11">'+Languages.get('room_cate_linhtinh')+'</option><option value="10">'+Languages.get('room_cate_tinhyeu')+'</option><option value="9">'+Languages.get('room_cate_raovat')+'</option><option value="8">'+Languages.get('room_cate_forum')+'</option><option value="7">'+Languages.get('room_cate_blog')+'</option><option value="6">'+Languages.get('room_cate_scandal')+'</option><option value="5">'+Languages.get('room_cate_thoisu')+'</option><option value="4">'+Languages.get('room_cate_xeco')+'</option><option value="3">'+Languages.get('room_cate_dulich')+'</option><option value="2">'+Languages.get('room_cate_dienanh')+'</option><option value="12">'+Languages.get('room_cate_thoitrang')+'</option></select><input style="float:left" type="text" name="keyword" id="keyword" onkeypress="search_handler(event,\'ajax\');" /> '+ ButtonCtl.create(Languages.get('search'), 'SearchRoom(\'ajax\');')+'</div><div class="content_main_right"><div id="ds_room"></div></div>';

		xajax_loadListRoom(0, '', 1);

      	newRoomWin.setDestroyOnClose();
      	newRoomWin.showCenter();
   	},

	miniGames: function()
	{
      	var miniGamesWin;
      	if($('miniGames')) {
         	Windows.getWindow('miniGames').toFront();
         	return;
      	}
      
      	miniGamesWin = new Window({id: 'miniGames', className: "preferences", width: 650, height: 400, resizable: false,
                               title: 'Mini Games', draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                               minWidth: 650, minHeight: 400, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	miniGamesWin.setConstraint(false, {left: 0, right: 0, top: 0, bottom: 0});
      
      	miniGamesWin.getContent().innerHTML = '<img src="images/blank.gif" width="2" height="4" border="0"><div><table border="0" width="100%"><tr><td align="left"><div id="ds_games"></div></td></tr></table></div>';

		xajax_loadListGames(1);

		miniGamesWin.setDestroyOnClose();
		miniGamesWin.showCenter();
	},

	GameDialog: function(game_id, game_title, game_source)
	{
		var GameDialogWin;
        if($('game_'+game_id))
		{
			Windows.getWindow('game_'+game_id).toFront();
         	return;
		}

		GameDialogWin = new Window({id: 'game_'+game_id, className: "preferences", width: 610, height: 450, resizable: true, title: game_title, draggable: true, closable: true, maximizable: true, minimizable: true, detachable: false, minWidth: 610, minHeight: 450, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
		  
		GameDialogWin.setConstraint(false, {left: 0, right: 0, top: 0, bottom: 0});
		  
		GameDialogWin.getContent().innerHTML = '<div style="z-index:1; width:100%; height:100%""><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="'+game_title+'" align="" width="100%" height="100%"><param name="wmode" value="transparent" /><param name="movie" value="'+game_source+'"><param name="quality" value="high"><param name="bgcolor" value="000000"><param name="menu" value="false"><embed src="'+game_source+'" quality="high" bgcolor="000000" name="'+game_title+'" menu="false" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" style="z-index:1" align="" width="100%" height="100%"></object></div>';
		GameDialogWin.setDestroyOnClose();
		GameDialogWin.showCenter();
		Windows.close('miniGames');
	},

	ChatRoomDialog: function(room_name)
	{
		var ChatRoomDialogWin;
        if($(room_name+'_chat'))
		{
			Windows.getWindow(room_name+'_chat').toFront();
         	return;
		}
		if(init_type=='ziczac')
		{
			nick_name = chatnhe_get_username(user);
		}
		else
		{
			nick_name = init_displayname;
		}

		ChatRoomDialogWin = new Window({id: room_name+'_chat', className: "preferences", width: 650, height: 450, resizable: true, title: room_name, draggable: true, closable: true, maximizable: true, minimizable: true, detachable: false, minWidth: 650, minHeight: 450, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
		  
		ChatRoomDialogWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
		  
		ChatRoomDialogWin.getContent().innerHTML = '<div style="z-index:1; width:100%; height:100%"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="ZicZac" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+STATIC_ZICZAC+'/ziczac.swf"/><param name="FlashVars" value="UID='+room_name+'&WEBSITE='+UPLOADS_ZICZAC+'&USERID='+nick_name+'" /><param name="quality" value="high" /><param name="bgcolor" value="#F2F4F3" /><embed src="'+STATIC_ZICZAC+'/ziczac.swf" flashVars="UID='+room_name+'&WEBSITE='+UPLOADS_ZICZAC+'&USERID='+nick_name+'" quality="high" width="100%" height="100%" name="preloader" align="middle" allowScriptAccess="sameDomain" style="z-index:1" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>';
	//ChatWindow.windows[room_name].setRoom(room_name);
      	ChatRoomDialogWin.setDestroyOnClose();
      	ChatRoomDialogWin.showCenter();
	  	Windows.close('newRoom');
	},
   
	newBuddy: function(from, type)
	{
        var newBuddyWin;
		var strDisplayName ='';
		var disabled = '';
		
		var checked_local = '';
		var checked_yahoo = '';
		var checked_msn = '';
		var checked_aim = '';
		var checked_gtalk = '';
	
		var disabled_local = '';
		var disabled_yahoo = '';
		var disabled_msn = '';
		var disabled_aim = '';
		var disabled_gtalk = '';
		
		if(from!='')
		{
			Windows.close('alertSubscribtionRequest_'+from);
			type ='accept_and_add';
			disabled = ' disabled="disabled" ';
	
			var strDisplayName = chatnhe_get_username(from);
			//var transport = from.slice((strDisplayName.length)+1,(from.length - (JSERVER.length+1)));
			
		var arrTransportInfo = from.split('@');
		if(typeof(arrTransportInfo[2]) != 'undefined')
		{
			var arrTransportInfo2 = arrTransportInfo[2].split('.'+JSERVER)
		}
		else
		{
			var arrTransportInfo2 = arrTransportInfo[1].split('.'+JSERVER)
		}
		var transport = arrTransportInfo2[0];
			selected_transport = transport;


			if(transport=='' || transport==JSERVER)
			{
				checked_local = 'checked="checked"';
				disabled_yahoo = ' disabled="disabled" ';
				disabled_msn = ' disabled="disabled" ';
				disabled_aim = ' disabled="disabled" ';
				disabled_gtalk = ' disabled="disabled" ';
				selected_transport = JSERVER;
			}
			if(transport=='yahoo')
			{
				checked_yahoo = 'checked="checked"';
				disabled_local = ' disabled="disabled" ';
				disabled_msn = ' disabled="disabled" ';
				disabled_aim = ' disabled="disabled" ';
				disabled_gtalk = ' disabled="disabled" ';
			}
			if(transport=='msn')
			{
				checked_msn = 'checked="checked"';
				disabled_local = ' disabled="disabled" ';
				disabled_yahoo = ' disabled="disabled" ';
				disabled_aim = ' disabled="disabled" ';
				disabled_gtalk = ' disabled="disabled" ';
			}
			if(transport=='aim')
			{
				checked_aim = 'checked="checked"';
				disabled_local = ' disabled="disabled" ';
				disabled_msn = ' disabled="disabled" ';
				disabled_yahoo = ' disabled="disabled" ';
				disabled_gtalk = ' disabled="disabled" ';
			}
			if(transport=='gtalk')
			{
				checked_gtalk = 'checked="checked"';
				disabled_local = ' disabled="disabled" ';
				disabled_msn = ' disabled="disabled" ';
				disabled_yahoo = ' disabled="disabled" ';
				disabled_aim = ' disabled="disabled" ';
			}
			
		}	  
	  
		if($('newBuddy_'+from)) {
			Windows.getWindow('newBuddy_'+from).toFront();
			return;
		}
      
      	newBuddyWin = new Window({id: 'newBuddy_'+from, className: "dialog", width: 310, height: 170, resizable: false,
                                title: Languages.get('newBuddy'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                                minWidth: 310, minHeight: 170, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});

      	newBuddyWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});

      	newBuddyWin.getContent().innerHTML = '<div class="dialog_info" style="padding:3px;"><span class="mbText">' + Languages.get('newBuddyPlease') + '</span></div> \
                                            <div id="newbuddy_box" style="padding-left:22px;width:100%;" class="mbText"> \
                                            <div style="display:block;float:left;margin-right:24px;padding-top:4px;">' + Languages.get('username') + ':</div><div>&nbsp;&nbsp;&nbsp;<input value="'+strDisplayName+'" type="text" style="width:110px;" id="newBuddyUsername" name="newBuddyUsername" '+disabled+'  onkeypress="handleInput(event, function() { Buddylist.addNewBuddy($(\'newBuddyUsername\').value, $(\'newBuddyGroup\').value, \''+type+'\', \'newBuddy_'+from+'\'); })" /></div> \
                                            <div style="display:block;float:left;margin-right:5px;padding-top:4px;">' + Languages.get('addtogroup') + ':</div><div><input type="text" style="width:110px;" id="newBuddyGroup" name="newBuddyGroup" value="Friends" onfocus="this.select();" onkeypress="handleInput(event, function() { Buddylist.addNewBuddy($(\'newBuddyUsername\').value, $(\'newBuddyGroup\').value, \''+type+'\', \'newBuddy_'+from+'\'); })" /></div> \
                                            </div> \
											 <div class="mbText" id="transports" style="padding-left:52px;width:100%;"><label><input onclick="setTransportValue(\''+JSERVER+'\');" type="radio" name="transport_gateway" value="'+JSERVER+'" '+ checked_local +' '+ disabled_local +' /> <img src="'+STATIC_ZICZAC+'/themes/transport/ziczac.gif" /> <span style="margin-right:19px;">ZicZac!</span></label> <label><input onclick="setTransportValue(\'yahoo\');" style="padding-left:50px;" type="radio" name="transport_gateway" value="yahoo" '+ checked_yahoo +' '+ disabled_yahoo +' /> <img src="'+STATIC_ZICZAC+'/themes/transport/yahoo.gif" /> Yahoo!</label><br><label><input onclick="setTransportValue(\'msn\');" type="radio" name="transport_gateway" value="msn" '+ checked_msn +' '+ disabled_msn +' /> <img src="'+STATIC_ZICZAC+'/themes/transport/msn.gif" /> <span style="margin-right:16px;">MSN</span></label> <label><input onclick="setTransportValue(\'aim\');" type="radio" name="transport_gateway" value="aim" '+ checked_aim +' '+ disabled_aim +' /> <img src="'+STATIC_ZICZAC+'/themes/transport/aim.gif" /><span style="margin-right:16px;">AIM</span></label><label><input onclick="setTransportValue(\'gtalk\');" type="radio" name="transport_gateway" value="gtalk" '+ checked_gtalk +' '+ disabled_gtalk +' /> <img src="'+STATIC_ZICZAC+'/themes/transport/gtalk.gif" /> GTALK</label></div> \
                                            <div id="newbuddy_buttons_'+from+'">' +
                                            ButtonCtl.create(Languages.get('add'), 'Buddylist.addNewBuddy($(\'newBuddyUsername\').value, $(\'newBuddyGroup\').value, \''+type+'\', \'newBuddy_'+from+'\');') +
                                            ButtonCtl.create(Languages.get('cancel'), 'Windows.close(\'newBuddy_'+from+'\');') +
                                            '</div>';

		$('newbuddy_buttons_'+from).setStyle({position: 'absolute', top:'165px', left:'80px'});

		newBuddyWin.setDestroyOnClose();
		newBuddyWin.showCenter();

      //setTimeout("$('newBuddyUsername').focus();", 125);
	},

	removeBuddy: function(user_name)
	{
      var delBuddyWin;
	  if(user_name && user_name.length > 0)
	  {
		curSelected = user_name;
	  }
      if(curSelected == '' || curSelected.length == 0)
         return;
      
      if($('delBuddy')) {
         Windows.getWindow('delBuddy').toFront();
         return;
      }
      
      delBuddyWin = new Window({id: 'delBuddy', className: "dialog", width: 240, height: 70, resizable: false,
                               title: Languages.get('removeBuddy'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                               minWidth: 240, minHeight:70, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      delBuddyWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
      delBuddyWin.getContent().innerHTML = '<div class="dialog_info" style="padding:3px;"><span class="mbText">' + Languages.get('removeBuddyAreYouSure').replace('%1', chatnhe_get_username(curSelected)) + '</span></div> \
                                            <div id="delbuddy_buttons">' +
                                            ButtonCtl.create(Languages.get('ok'), 'Buddylist.deleteBuddy(curSelected);Windows.close(\'delBuddy\');') +
                                            ButtonCtl.create(Languages.get('cancel'), 'Windows.close(\'delBuddy\');') +
                                            '</div>';
                                            
      $('delbuddy_buttons').setStyle({position: 'absolute',
                                      top:      '60px',
                                      left:     '45px'});
                                      
      delBuddyWin.setDestroyOnClose();
      delBuddyWin.showCenter();
   },
   
    embedRoom: function(strRoomName)
	{
      	var embedRoomWin;
       	if($('embedRoom'))
		{
         	Windows.getWindow('embedRoom').toFront();
         	return;
      	}  
      	embedRoomWin = new Window({id: 'embedRoom', className: "preferences", width: 340, height: 160, resizable: false,
                             title: Languages.get('embedRoomTitle'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                             minWidth: 340, minHeight: 160, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	embedRoomWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
      	embedRoomWin.getContent().innerHTML = '<span class="mbText" id="embedRoomContent"></span>';
		xajax_loadEmbedRoomInfo();
    	embedRoomWin.setDestroyOnClose();
    	embedRoomWin.showCenter();
	},
	
    embedRoomPage: function(strRoomName)
	{
      	var embedRoomWin;
       	if($('embedRoomPage'))
		{
         	Windows.getWindow('embedRoomPage').toFront();
         	return;
      	}  
      	embedRoomPageWin = new Window({id: 'embedRoomPage', className: "preferences", width: 450, height: 340, resizable: false,
                             title: Languages.get('embedRoomTitle'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                             minWidth: 450, minHeight: 340, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	embedRoomPageWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
      	embedRoomPageWin.getContent().innerHTML = '<span class="mbText" id="embedRoomPageContent"></span>';
		xajax_loadEmbedRoomCode();
    	embedRoomPageWin.setDestroyOnClose();
    	embedRoomPageWin.showCenter();
	},
	
    createEmbedRoom: function(strType)
	{
      	var createEmbedRoomWin;
       	if($('createEmbedRoom'))
		{
         	Windows.getWindow('createEmbedRoom').toFront();
         	return;
      	}  
      	createEmbedRoomWin = new Window({id: 'createEmbedRoom', className: "preferences", width: 720, height: 520, resizable: false,
                             title: Languages.get('createEmbedRoomTitle'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                             minWidth: 720, minHeight: 520, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	createEmbedRoomWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});

      	createEmbedRoomWin.getContent().innerHTML = '<div id="divColorMap"></div><div id="createEmbedRoom_html" style="padding-left:10px; padding-top:10px"></div>';

		xajax_loadColorMap();
		xajax_loadRoomInfo(strType);

    	createEmbedRoomWin.setDestroyOnClose();
    	createEmbedRoomWin.showCenter();
	},

    listIconsDialog: function(intIconsCateId,intPage)
	{
      	var listIconsDialog_Win;
       	if($('listIconsDialogObj'))
		{
         	Windows.getWindow('listIconsDialogObj').toFront();
         	return;
      	}  
      	listIconsDialog_Win = new Window({id: 'listIconsDialogObj', className: "preferences", width: 510, height: 300, resizable: false,
                             title: Languages.get('listIcons'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                             minWidth: 510, minHeight: 300, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	listIconsDialog_Win.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
      	listIconsDialog_Win.getContent().innerHTML = '<div class="cssListIcon" id="div_listicons"></div>';
    	listIconsDialog_Win.setDestroyOnClose();
    	listIconsDialog_Win.showCenter();
		
		xajax_loadIcons(intIconsCateId, intPage);
	},

    listThemesDialog: function(intThemesCateId,intPage)
	{
      	var listThemesDialog_Win;
       	if($('listThemesDialogObj'))
		{
         	Windows.getWindow('listThemesDialogObj').toFront();
         	return;
      	}  
      	listThemesDialog_Win = new Window({id: 'listThemesDialogObj', className: "preferences", width: 560, height: 290, resizable: false,
                             title: Languages.get('listThemes'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                             minWidth: 560, minHeight: 290, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	listThemesDialog_Win.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
      	listThemesDialog_Win.getContent().innerHTML = '<div class="cssListTheme" id="div_listthemes" style="width:550px;"></div>';
    	listThemesDialog_Win.setDestroyOnClose();
    	listThemesDialog_Win.showCenter();
		xajax_loadThemes(intThemesCateId, intPage);
	},

    showProfileDialog: function(strUsername, strDisplayName)
	{
		//var transport = strUsername.slice((strDisplayName.length)+1,(strUsername.length - (JSERVER.length+1)));
		
		var arrTransportInfo = strUsername.split('@');
		if(typeof(arrTransportInfo[2]) != 'undefined')
		{
			var arrTransportInfo2 = arrTransportInfo[2].split('.'+JSERVER)
		}
		else
		{
			var arrTransportInfo2 = arrTransportInfo[1].split('.'+JSERVER)
		}
		var transport = arrTransportInfo2[0];
		
		
		if(transport=='' || transport==JSERVER)
		{
			transport = 'ziczac';	
		}

		xajax_loadProfile(strDisplayName, transport);
		
      	var showProfileWin;
       	if($('showProfile_'+strUsername))
		{
         	Windows.getWindow('showProfile_'+strUsername).toFront();
         	return;
      	}  
      	showProfileWin = new Window({id: 'showProfile_'+strUsername, className: "dialog", width: 340, height: 130, resizable: false,
                             title: Languages.get('profileTitle'), draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                             minWidth: 340, minHeight: 130, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	showProfileWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
      	showProfileWin.getContent().innerHTML = '<span class="mbText"><div style="width:330px;"> \<div style="float:left;width:120px;height:120px;"><div id="div_avatar" style="padding:5px"><img src="'+STATIC_ZICZAC+'/images/graphics/ajaxLoad.gif" border="0" /></div></div><div style="float:left; width:190px; height:auto;"><b>Group: '+Buddylist.listObjects[strUsername].group+'</b><br><b>Nickname: '+strDisplayName+'</b><br><b>Transport: '+transport+'</b></div></div></span>';
    	showProfileWin.setDestroyOnClose();
    	showProfileWin.showCenter();
	},

    accountSettingDialog: function(strRoomName)
	{
      	var embedRoomWin;
       	if($('accountSettingDialog'))
		{
         	Windows.getWindow('accountSettingDialog').toFront();
         	return;
      	}  
      	accountSettingDialogWin = new Window({id: 'accountSettingDialog', className: "preferences", width: 300, height: 240, resizable: false,
                             title: 'Cấu hình tài khoản', draggable: true, closable: true, maximizable: false, minimizable: false, detachable: false,
                             minWidth: 300, minHeight: 240, showEffectOptions: {duration: 0}, hideEffectOptions: {duration: 0}});
      
      	accountSettingDialogWin.setConstraint(true, {left: 0, right: 0, top: 0, bottom: 0});
      
      	accountSettingDialogWin.getContent().innerHTML = '<span class="mbText" id="accountSettingDialogContent"></span>';
		xajax_loadAccountSetting();
    	accountSettingDialogWin.setDestroyOnClose();
    	accountSettingDialogWin.showCenter();
	}
};