var stored_icon_cate_id = 1;
var stored_theme_cate_id = 1;

function display_register_room()
{
	var div_room 	= document.getElementById('div_register_room');
	var create_room	= document.getElementById('create_room');
	var flash_demo	= document.getElementById('flash_demo');
	var checkbox_registerroom = document.getElementById('checkbox_registerroom');
	if(div_room.style.display=='none')
	{
		div_room.style.display='block';
		create_room.value = 'yes';
		flash_demo.style.display='block';
		checkbox_registerroom.checked = true;
	}
	else
	{
		div_room.style.display='none';
		create_room.value = 'no';
		flash_demo.style.display='none';
		checkbox_registerroom.checked = false;
	}
}

function RefreshCity()
{			
	var f 			= document.frmregis;		
	var listCountry = f.country;
	var listCity 	= f.location;		
	
	var countryID 	= listCountry.options[listCountry.selectedIndex].value;	
	var arrChildren;
	var arrTemp	;
	var i;
	var x = 1;
	listCity.length = 0 ;				
	var strChildCityList = f.city.value;
	arrChildren = strChildCityList.split("|");
	listCity.options[0] = new Option('[Chọn lựa]', 0);	
	for (i = 0; i < arrChildren.length; i++)
	{
		arrTemp = arrChildren[i].split("~");
		if (countryID == arrTemp[0]) 
		{
			listCity.options[x] = new Option(arrTemp[2], arrTemp[1]);
			x++
		}			
	}
}

function inArray(arr, value)
{
	var i;
	for (i=0; i < arr.length; i++) {
		if (arr[i] === value) {
			return true;
		}
	}

   return false;
}

function set_room_size(intSize)
{
	var eRoomWidth 			= document.getElementById('room_width_value');
	var eRoomHeight 		= document.getElementById('room_height_value');
	var eRoomWidthTextBox 	= document.getElementById('room_width');
	var eRoomHeightTextBox 	= document.getElementById('room_height');
	if(intSize == 1)
	{
		eRoomWidth.value = 330;
		eRoomHeight.value = 270;
		eRoomWidthTextBox.disabled = true;
		eRoomHeightTextBox.disabled = true;
	}
	if(intSize == 2)
	{
		eRoomWidth.value = 400;
		eRoomHeight.value = 300;
		eRoomWidthTextBox.disabled = true;
		eRoomHeightTextBox.disabled = true;
	}
	if(intSize == 3)
	{
		eRoomWidth.value = 500;
		eRoomHeight.value = 400;
		eRoomWidthTextBox.disabled = true;
		eRoomHeightTextBox.disabled = true;
	}
	if(intSize == 4)
	{
		eRoomWidthTextBox.disabled = false;
		eRoomHeightTextBox.disabled = false;
	}
}

function set_width_height(intNumber, intType)
{
	var eRoomWidth 			= document.getElementById('room_width_value');
	var eRoomHeight 		= document.getElementById('room_height_value');
	var eRoomWidthTextBox 	= document.getElementById('room_width');
	var eRoomHeightTextBox 	= document.getElementById('room_height');
	if(isNumeric(intNumber))
	{
		if(intType == 0) // width
		{
			eRoomWidth.value = intNumber;
		}
		if(intType == 1) // height
		{
			eRoomHeight.value = intNumber;
		}
	}
	else
	{
		alert(Register_error.size_e1);
		eRoomWidthTextBox.value = 400;
		eRoomHeightTextBox.value = 300;
		return false;
	}
}

function isNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function set_room_id(room_name)
{
	var forbidArray = new Array('~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '{', '}', '|', ':', ';', '"', '\'', '\\', '<', '>', '?', ',', '.', '/', '[', ']');

	var arrCharFrom = Array(
			   "ạ","á","à","ả","ã","ẵ","Ạ","Á","À","Ả","Ã","Ẵ",
			   "â","ậ","ấ","ầ","ẩ","ẫ","Â","Ậ","Ấ","Ầ","Ẩ","Ẫ",
			   "ă","ặ","ắ","ằ","ẳ","ẫ","Ă","Ắ","Ằ","Ẳ","Ẵ","Ặ",
			   "ê","ẹ","é","è","ẻ","ẽ","Ê","Ẹ","É","È","Ẻ","Ẽ",
			   "ế","ề","ể","ễ","ệ","Ế","Ề","Ể","Ễ","Ệ",
			   "ọ","ộ","ổ","ỗ","ố","ồ","Ọ","Ộ","Ổ","Ỗ","Ố","Ồ","Ô","ô",
			   "ó","ò","ỏ","õ","Ó","Ò","Ỏ","Õ",
			   "ơ","ợ","ớ","ờ","ở","ỡ",
			   "Ơ","Ợ","Ớ","Ờ","Ở","Ỡ",
			   "ụ","ư","ứ","ừ","ử","ữ","ự","Ụ","Ư","Ứ","Ừ","Ử","Ữ","Ự",
			   "ú","ù","ủ","ũ","Ú","Ù","Ủ","Ũ",
			   "ị","í","ì","ỉ","ĩ","Ị","Í","Ì","Ỉ","Ĩ",
			   "ỵ","ý","ỳ","ỷ","ỹ","Ỵ","Ý","Ỳ","Ỷ","Ỹ",
			   "đ","Đ"
			   );
			   // 0
	var arrCharEndNoVn = Array(
			   "a","a","a","a","a","a","A","A","A","A","A","A",
			   "a","a","a","a","a","a","A","A","A","A","A","A",
			   "a","a","a","a","a","a","A","A","A","A","A","A",
			   "e","e","e","e","e","e","E","E","E","E","E","E",
			   "e","e","e","e","e","E","E","E","E","E",
			   "o","o","o","o","o","o","O","O","O","O","O","O","O","o",
			   "o","o","o","o","O","O","O","O",
			   "o","o","o","o","o","o",
			   "O","O","O","O","O","O",
			   "u","u","u","u","u","u","u","U","U","U","U","U","U","U",
			   "u","u","u","u","U","U","U","U",
			   "i","i","i","i","i","I","I","I","I","I",
			   "y","y","y","y","y","Y","Y","Y","Y","Y",
			   "d","D"
			   );

	var formated_str = '';
	var flag = false;
	var out_string = '';

	for(i=0; i<room_name.length; i++)
	{

		for(u=0;u<arrCharFrom.length;u++)
		{
			if(room_name.charAt(i)==arrCharFrom[u])
			{
				out_string+=arrCharEndNoVn[u];
				flag = true;
			}
	
		}
		if(!flag)
		{
			out_string+=room_name.charAt(i);
		}
		flag=false;

		
		if(!inArray(forbidArray,out_string.charAt(i)))
		{
			formated_str+=out_string.charAt(i);
		}
		formated_str = formated_str.replace(' ','_');
		formated_str = formated_str.toLowerCase();
	}

	document.getElementById('room_id').value = formated_str;
	if(formated_str.length>0)
	{
		setup_room('change_room_name', formated_str)
	}
}

function checkNormalName(stringIn)
{
	 retval = false 
	 var i;
     for (i=0;i<=stringIn.length-1;i++) { 
          if ((stringIn.indexOf("<") >= 0)||(stringIn.indexOf(">") >= 0)||(stringIn.indexOf("=") >= 0)||(stringIn.indexOf("#") >= 0)||(stringIn.indexOf("{") >= 0)||(stringIn.indexOf("}") >= 0)||(stringIn.indexOf("[") >= 0)||(stringIn.indexOf("]") >= 0)||(stringIn.indexOf("*") >= 0)||(stringIn.indexOf("^") >= 0)|| (stringIn.indexOf("~") >= 0) || (stringIn.indexOf("$") >= 0) || (stringIn.indexOf('"') >= 0) || (stringIn.indexOf("'") >= 0) || (stringIn.indexOf("!") >= 0) || (stringIn.indexOf("@") >= 0) || (stringIn.indexOf("$") >= 0) || (stringIn.indexOf("%") >= 0) || (stringIn.indexOf("^") >= 0) || (stringIn.indexOf("\\") >= 0) || (stringIn.indexOf("|") >= 0) || (stringIn.indexOf("+") >= 0) || (stringIn.indexOf("<?") >= 0) || (stringIn.indexOf("?>") >= 0)){ 
		      retval = false;
			  break;
      	  }else{
      	  		retval = true;      	  		
         }
     }
	 return retval;
}

function select_icon(icon, icon_id, icon_cate_id)
{
	document.getElementById('use_local_icon').value = 'yes';// set value su dung local icon = yes
	document.getElementById('iconImage').style.background = 'url('+UPLOADS_ZICZAC+'/icon/'+icon+') no-repeat'; // thay doi hinh icon
	document.getElementById('div_icons').style.display 	= 'none'; // hide ba~ng cho.n icon
	document.getElementById('room_icon_value').value = icon_id; // // set value icon
	stored_icon_cate_id = icon_cate_id;
}

function select_other_icon(icon)
{
	document.getElementById('iconImage').style.background= 'url('+UPLOADS_ZICZAC+'/temp/icons/90/'+icon+') no-repeat';
	document.getElementById('use_local_icon').value = 'no';
	document.getElementById('room_icon_image').value = icon;
}

function select_theme(theme_image, theme_id, theme_cate_id)
{
	document.getElementById('use_local_theme').value = 'yes'; // set value su dung local theme = yes
	//document.getElementById('themeImage').src=UPLOADS_ZICZAC+'/themes/thumb/'+theme_image; // thay doi hinh theme
	document.getElementById('themeImage').style.background = 'url('+UPLOADS_ZICZAC+'/themes/thumb/'+theme_image+') no-repeat';
	document.getElementById('div_themes').style.display = 'none'; //hide ba~ng danh sach chon theme
	document.getElementById('room_theme_value').value = theme_id; // set value theme id
	document.getElementById('room_theme_image').value = theme_image; // set value theme image
	setup_room('change_theme',UPLOADS_ZICZAC+'/themes/'+theme_image);
	stored_theme_cate_id = theme_cate_id;
}

function select_other_theme(theme_image)
{
	document.getElementById('use_local_theme').value = 'no';
	document.getElementById('themeImage').style.background='url('+UPLOADS_ZICZAC+'/temp/themes/120/'+theme_image+') no-repeat'; // thay doi hinh theme
	document.getElementById('div_themes').style.display = 'none';
	document.getElementById('room_theme_value').value = 0; // set value theme id
	document.getElementById('room_theme_image').value = theme_image; // set value theme image
	setup_room('change_theme',UPLOADS_ZICZAC+'/temp/themes/sources/'+theme_image);
}

function showListIcons(cate_id,page,first_open)
{
	if(first_open)
	{
		var m = {
			'x' : 410,
			'y' : 500
		};
		document.getElementById('div_icons').style.display 	= 'block';
		document.getElementById('div_icons').style.position = 'absolute';
		document.getElementById('div_icons').style.left 	= m.x + 'px';
		document.getElementById('div_icons').style.top 		= m.y + 'px';
	}
	xajax_loadIcons(cate_id, page);
	stored_icon_cate_id = cate_id;
	
}

function showListThemes(cate_id,page,first_open)
{
	if(first_open)
	{
		var m = {
			'x' : 410,
			'y' : 500
		};
		document.getElementById('div_themes').style.display 	= 'block';
		document.getElementById('div_themes').style.position 	= "absolute";
		document.getElementById('div_themes').style.left 		= m.x + 'px';
		document.getElementById('div_themes').style.top 		= m.y + 'px';
	}
	xajax_loadThemes(cate_id, page);
	stored_theme_cate_id = cate_id;
}

function hideListIcons()
{
	document.getElementById('div_icons').style.display 	= 'none';
}

function hideListThemes()
{
	document.getElementById('div_themes').style.display 	= 'none';
}

function trim(val)
{ 
	return val.replace(/^\s+|\s+$/g,"");
}

//cho phep nhung ky tu tu A->Z, a->z, 0->9,va cac ky tu _-
function CheckUsernameChar(stringIn)
{
	retval = false
     var i;
     for ( i=0; i <= stringIn.length-1; i++) 
	 {
         if ( ( ( stringIn.charCodeAt(i) >= 48)&&(stringIn.charCodeAt(i) <= 57)) || ((stringIn.charCodeAt(i) > 64)&&(stringIn.charCodeAt(i) <= 90)) || ((stringIn.charCodeAt(i) >= 97)&&(stringIn.charCodeAt(i) <= 122)) || (stringIn.charCodeAt(i) == 95) || (stringIn.charCodeAt(i) == 45) )
		 {
           	retval = true;
         }
		 else
		 {
			retval = false;
			break;
         }
     }
     return retval;
}

function Checkchar1(stringIn)
{
	retval = false
     var i;
     for (i=0;i<=stringIn.length-1;i++) 
	 {
         if (((stringIn.charCodeAt(i) >= 8)&&(stringIn.charCodeAt(i) <= 127)) && (stringIn.charCodeAt(i)!=34) && (stringIn.charCodeAt(i)!=39) && (stringIn.charCodeAt(i)!=32))
		 {
           	retval = true;
         }
		 else
		 {
			retval = false;
			break;
         }
     }
     return retval;
}

// kiem tra co dung la dia chi email.
function CheckEmail(stringIn)
{
	var re = /^([A-Za-z0-9\_\-]+\.)*[A-Za-z0-9\_\-]+@[A-Za-z0-9\_\-]+(\.[A-Za-z0-9\_\-]+)+$/;
	if ( stringIn.search(re) == -1 )
	{
		return false;
	}
	else
	{
		return true;
	}
}

function CheckUsernameRegister(strusername)
{
	if ( strusername.length == 0 ) //username rong
	{
		strError+=Register_error.username_e1;
		return 2;
	}
	else
	{
		if ( strusername.indexOf("<")!= '-1' || strusername.indexOf(">") != '-1' ) //co script
		{
			strError+=Register_error.username_e2;
			return 3;
		}
		else
		{		
			if ( strusername.length < 5 || strusername.length > 20 ) //nho hon 6 va lon hon 20
			{
				strError+=Register_error.username_e3;
				return 4;
			}
			else
			{	
				if ( !CheckUsernameChar( strusername ) ) //check unicode
				{
					strError+=Register_error.username_e4;
					return 5;
				}
				else
				{
					return 1;
				}
			}
		}
	}
	return 1;
}


function CheckRoomPasswordRegister(strPassword)
{
	if ( strPassword.indexOf("<")!= '-1' || strPassword.indexOf(">") != '-1' )
	{
		strError+=Register_error.room_password_e1;
		return 2;
	}
	else
	{
		if ( !CheckUsernameChar( strPassword ) ) //check unicode
		{
			strError+=Register_error.room_password_e2;
			return 3;
		}
		else
		{
			return 1;
		}

	}
	return 1;
}

function check_existing_username_button()
{
	var frm 			= document.frmregis;
	var strUsername 	= trim(frm.member_username.value);
	var r 				= CheckUsernameRegister(strUsername);
	if(r==1)
	{
		xajax_checkExistingUserName(strUsername);
	}
	else
	{
		alert(strError);
		strError= "";
	}
}


function CheckPassRegister(strpass)
{
	if ( strpass.length == 0 ) // mat khau rong
	{
		strError+=Register_error.password_e1;
		return 2;
	}
	else
	{
		if ( strpass.indexOf("<") != '-1' || strpass.indexOf(">") != '-1' ) // co chua script
		{
			strError+=Register_error.password_e2;
			return 3;
		}
		else
		{		
			if ( strpass.length < 6 || strpass.length > 30 ) //nho hon 6 va lon hon 30 ky tu
			{
				strError+=Register_error.password_e3;
				return 4;
			}
			else
			{	
				if ( !Checkchar1( strpass ) ) // co unicode
				{
					strError+=Register_error.password_e4;
					return 5;
				}
				else
				{
					return 1;
				}
			}
		}	
	}
	return 1;
}

function CheckPassverifyRegister(strpass, strpassverify)
{
	if ( strpassverify.length == 0 ) // pass verify trong
	{
		strError+=Register_error.password_verify_e1;
		return 2;
	}
	else
	{
		if ( strpassverify != strpass ) // 2 pass khong giong nhau
		{
			strError+=Register_error.password_verify_e2;
			return 3;
		}
		else
		{
			return 1;	
		}
	}
	return 1;
}

function CheckEmailRegister(stremail)
{
	if ( stremail.length == 0 ) // email trong
	{
		strError+=Register_error.email_e2;
		return 2;
	}
	else
	{
		if ( !CheckEmail( stremail ) )
		{
			strError+=Register_error.email_e3;
			return 3;
		}
		else
		{
			return 1;
		}
	}
	return 1;
}

function CheckCityRegister(strcity)
{
	if ( strcity == 0 )
	{
		strError+=Register_error.city_e1;
		return 2;
	}
	else
	{
		return 1;
	}
	return 1;
}

function CheckSecurityRegister(strSecCode)
{
	if ( trim(strSecCode) == '' )
	{
		strError+=Register_error.security_code_e1;
		return 2;
	}
	else
	{
		return 1;
	}
	return 1;
}


function CheckRoomName(strroomname)
{
	if ( strroomname.length == 0 ) //ten room rong
	{
		strError+=Register_error.room_name_e1;
		return 2;
	}
	else
	{
		if ( strroomname.indexOf("<")!= '-1' || strroomname.indexOf(">") != '-1' || strroomname.indexOf("'") != '-1' ) //co script
		{
			strError+=Register_error.room_name_e2;
			return 3;
		}
		else
		{		
			if ( strroomname.length < 6 || strroomname.length > 40 ) //nho hon 6 va lon hon 40
			{
				strError+=Register_error.room_name_e3;
				return 4;
			}
			else
			{
				return 1;
			}
		}
	}
	return 1;
}

function CheckRoomId(strRoomId)
{
	if ( strRoomId.length == 0 ) //room id rong
	{
		strError+=Register_error.room_id_e1;
		return 2;
	}
	else
	{
		if ( !checkNormalName(strRoomId) ) //co script
		{
			strError+=Register_error.room_id_e2;
			return 3;
		}
		else
		{		
			if ( strRoomId.length < 4 || strRoomId.length > 40 ) //nho hon 4 va lon hon 40
			{
				strError+=Register_error.room_id_e3;
				return 4;
			}
			else
			{
				return 1;
			}
		}
	}
	return 1;
}

function CheckRoomTopic(strRoomTopic)
{
	if ( strRoomTopic.length == 0 ) //room id rong
	{
		strError+=Register_error.room_topic_e1;
		return 2;
	}
	else
	{
		if ( strRoomTopic.length < 4 || strRoomTopic.length > 80 ) //nho hon 4 va lon hon 80
		{
			strError+=Register_error.room_topic_e2;
			return 3;
		}
		else
		{
			return 1;
		}
	}
	return 1;
}

function CheckRoomCate(intRoomCate)
{
	if ( intRoomCate == 0 ) // chua chon room cate
	{
		strError+=Register_error.room_cate_id_e1;
		return 2;
	}
	else
	{
		return 1;
	}
	return 1;
}



// regE

function SubmitFormAfterRegisterSuccessful()
{
	var frm 			= document.frmregis;
	frm.submit();
}

function SetTopic()
{
	objJS.sMs(init_room_id+'@'+CONFERENCE+'.'+JSERVER,'','groupchat',init_room_topic);
}

function Disconnect()
{
	objJS.dnn();
}

function c_pick(value)
{
	setup_room('change_background_color', '0x'+value.substring(1,7));
	document.getElementById('theme_color').value = value;
	document.getElementById('backcolor_box').style.backgroundColor = value;
}

function setup_room(strAction, strValue)
{
	var objFlashDemo = thisMovie("newRoom");

	if(strAction == 'change_theme')
	{
		objFlashDemo.changeThemes(strValue);
	}
	if(strAction == 'remove_theme')
	{
		objFlashDemo.removeThemes();
	}
	if(strAction == 'change_topic')
	{
		objFlashDemo.changeTopic(strValue);
	}
	if(strAction == 'change_background_color')
	{
		objFlashDemo.changeBG(strValue);
	}
	if(strAction == 'change_room_name')
	{
		objFlashDemo.changeRoomName(strValue);
	}	
}

function CheckForms()
{
	document.getElementById('btnSubmit').innerHTML = '<img src="'+STATIC_ZICZAC+'/images/graphics/ajaxLoad.gif" border="0" />';

	var frm 			= document.frmregis;
	var strusername 	= trim(frm.member_username.value);
	var strpass 		= trim(frm.member_password.value);
	var strpassverify 	= trim(frm.member_password2.value);
	var stremail		= trim(frm.member_email.value);
	var strcity			= trim(frm.location.value);
	var strseccode		= trim(frm.security_code.value);
		strCreateRoom	= document.getElementById('create_room').value;
	
	var strcheck1 = strcheck2 = 0;
	
	var a = b = c = d = e = f = 0;
	
	//---- Username-------------
	a = CheckUsernameRegister(strusername);
	//---- Username-------------
	
	//---- Pass-------------
	b = CheckPassRegister(strpass);
	//---- Pass-------------

	//---- Passverify-------------
	c = CheckPassverifyRegister(strpass, strpassverify);
	//---- Passverify-------------
	
	//---- Email-------------
	d = CheckEmailRegister(stremail);
	//---- Email-------------
	
	//---- City-------------
	e = CheckCityRegister(strcity);
	//---- City-------------
	
	//---- Security Code-------------
	f = CheckSecurityRegister(strseccode);
	//---- Security Code-------------

	if ( a == 1 && b == 1 && c == 1 && d == 1 && e == 1 && f == 1) 
	{
		strcheck1 = 1;
	}
	else
	{
		strcheck1 = 0;
	}

	if(strCreateRoom=='yes') // kiem tra thong tin room
	{
		var g = h = m = n = 0;
		//kiem tra them room info
		var strRoomName 	= trim(frm.room_name.value);
		var strRoomId 		= trim(frm.room_id.value);
		var strRoomPassword	= trim(frm.room_password.value);

		var strRoomTopic 	= trim(frm.room_topic.value);
		var strRoomDescription	= trim(frm.room_description.value);
		
		var intRoomCate		= frm.room_cate_id.value;

		g = CheckRoomName(strRoomName);
		h = CheckRoomId(strRoomId);
		i = CheckRoomCate(intRoomCate);
		k = CheckRoomTopic(strRoomTopic);
		
		if(strRoomPassword!='') // neu co nhap mat khau room
		{
			var l = CheckRoomPasswordRegister(strRoomPassword);
			if(g == 1 && h == 1 && i == 1 && k == 1 && l == 1)
			{
				strcheck2 = 1;
			}
			else
			{
				strcheck2 = 0;
			}
		}
		else
		{
			if(g == 1 && h == 1 && i == 1)
			{
				strcheck2 = 1;
			}
			else
			{
				strcheck2 = 0;
			}
		}

		if(strcheck1 == 1 && strcheck2 == 1) // neu thong tin user va thong tin room hop le
		{
			//xajax_checkUsernameAndEmailAndRoom(strusername,stremail,strpass,strRoomId,strRoomName,strRoomTopic,strRoomDescription,strRoomPassword)
			xajax_checkRegisterInfo(strusername,stremail,strpass,strpassverify,strcity,strseccode,strCreateRoom,strRoomId,strRoomName,intRoomCate,strRoomTopic,strRoomDescription,strRoomPassword)
		}
		else
		{
			reCreateButton();
			alert(strError);
			strError = '';
			return false;
		}
	}
	else
	{
		if( strcheck1 == 1) // neu thong tin user hop le
		{
			//xajax_checkUsernameAndEmail(strusername,stremail,strpass);
			xajax_checkRegisterInfo(strusername,stremail,strpass,strpassverify,strcity,strseccode,strCreateRoom,'','','','','','')
		}
		else
		{
			reCreateButton();
			alert(strError);
			strError = '';
			return false;
		}
	}
}

function alertRegisterError(strErrorMsg)
{
	reCreateButton();
	alert(strErrorMsg);
	return false;
	
}

function reCreateButton()
{
	document.getElementById('btnSubmit').innerHTML = '<span class="span_top"></span><span class="span_center" onclick="CheckForms();" style="cursor:hand;cursor:pointer">'+Register_error.btn_recreate+'</span><span class="span_bottom"></span>';
}

function setupInitVar(strUsername, strEmail, strPassword, strHost, strPort, strPasswordEc, strJid, strRoomId, strRoomName, strRoomTopic, strRoomDescription, strRoomPassword)
{
	init_username 			= strUsername;
	init_password 			= strPassword;
	init_email	 			= strEmail;
	init_host 				= strHost; 
	init_port				= strPort;
	init_displayname		= strUsername;
	init_password_ec		= strPasswordEc;
	init_jid	 			= strJid;
	
	if(strRoomName, strRoomName, strRoomTopic)
	{
		init_room_id 			= strRoomId; 
		init_room_name			= strRoomName;
		init_room_topic			= strRoomTopic;
		init_room_description	= strRoomDescription;
		init_room_password		= strRoomPassword;
	}
	objJS.iCtn(init_host,init_port);
}

// regE

function resetIcon(strIcon)
{
	document.getElementById('iconImage').style.background= 'url('+UPLOADS_ZICZAC+'/icon/icon_ziczac.png) no-repeat';
	document.getElementById('use_local_icon').value = 'yes';
	document.getElementById('room_icon_image').value = '';
	document.getElementById('room_icon_value').value = '191';
}

function resetTheme(strTheme)
{
	document.getElementById('themeImage').style.background= 'url('+UPLOADS_ZICZAC+'/themes/thumb/theme_default.jpg) no-repeat';
	document.getElementById('use_local_theme').value = 'yes';
	document.getElementById('room_theme_image').value = '';
	document.getElementById('room_theme_value').value = 0;
	setup_room('change_theme','');
}