/*
  (c) 2006 TUFaT.com. All Rights Reserved
*/

/* sound options enumeration for sound options tab in options window */
optionsSound = new Array (
  "LeaveRoom",
  "InitialLogin",
  "EnterRoom",
  "Logout",
  "OtherUserEnters",
  "UserMenuMouseOver",
  "ReceiveMessage",
  "RoomOpenClose",
  "SubmitMessage",
  "ComboListOpenClose",
  "PrivateMessageReceived",
  "PopupWindowOpen",
  "InvitationReceived",
  "PopupWindowCloseMin",
  "UserBannedBooted",
  "PressButton"
);

colorArray = new Array ();
styleArray = new Array ();

stepVolume = 5;
soundArray = new Array ();

TempArray = new Array();
TempArraySound = new Array();
TempArrayEffect = new Array();
TempArrayInc = new Array();
TempArrayAvatar = new Array();
function createCPicker () {

  var cpDiv = document.createElement ("div");

cpDiv.style["background"] = "#314194";
cpDiv.style["borderColor"] = "white";
cpDiv.style["borderWidth"] = "1px";
cpDiv.style["borderStyle"] = "solid";
cpDiv.style["textAlign"] = "left";
  if (cpDiv == null)
    return;

  setElementSaP (cpDiv, null, {"id": "colorPicker"});

  var colors = new Array ();

  for (var i = 0; i < 6; i++)
    for (var j = 0; j < 6; j++)
      for (var k = 0; k < 6; k++) {
        var b = i * 51;
        var r = j * 51;
        var g = k * 51;

        var idx = (i * 18) + (j * 6) + k;
        //colors[idx] = "rgb(" + r + ", " + g + ", " + b + ")";
        colors[idx] = dec2hex (r) + dec2hex (g) + dec2hex (b);
      }

  for (var i = 0; i < 6; i ++)
    for (var j = 3; j < 6; j ++)
      for (var k = 0; k < 6; k ++) {
        var b = i * 51;
        var r = j * 51;
        var g = k * 51;

        var idx = 108 + (i * 18) + ((j - 3) * 6) + k;
        //colors[idx] = "rgb(" + r + ", " + g + ", " + b + ")";
        colors[idx] = dec2hex (r) + dec2hex (g) + dec2hex (b);
      }

  var newTABLE = document.createElement ("table");
  newTABLE.setAttribute ("border", "1");
  newTABLE.setAttribute ("cellpadding", "0");
  newTABLE.setAttribute ("cellspacing", "1");

  for (var i = 0; i < 12; i++) {
    var row = newTABLE.insertRow (i);
    for (var j = 0; j < 18; j++) {
      var newCell = row.insertCell (j);

      newCell.style["backgroundColor"] = "#" + colors[(i * 18) + j];
      newCell.hexColor = colors[(i * 18) + j];
      newCell.cpDiv = cpDiv;
      newCell.onclick = cpColorClickHandler;
	  newCell.onmouseover = cpColorOverHandler;
    }
  }

	var color = addDiv (cpDiv, null, {"id": "color"});

  	color.style["height"] = "30px";
	color.style["width"] = "200px";
	color.style["textAlign"] = "left";


	var newTABLE1 = document.createElement ("table");
  	newTABLE1.setAttribute ("border", "0");
	newTABLE1.setAttribute ("width", "100px");
	newTABLE1.setAttribute ("id", "TableColor");
	newTABLE1.setAttribute ("height", "20px");
	newTABLE1.setAttribute ("whiteSpace", "nowrap");
	newTABLE1.style["backgroundColor"] = "#314194";
	newTABLE1.style["borderWidth"] = "0px";
	var row1 = newTABLE1.insertRow (0);

	var newCell1 = row1.insertCell (0);
	newCell1.style["borderWidth"] = "0px";
	//newCell1.setAttribute ("wi, "TableColor1");
	var newCell2 = row1.insertCell (1);
	newCell2.style["borderWidth"] = "0px";
	//newCell1.setAttribute ("id", "TableColor2");

	var colorView = addDiv (color, null, {"id": "colorView"});

	colorView.style["background"] = "white";
	colorView.style["border"] = "1px";

	colorView.style["borderColor"] = "white";
	colorView.style["borderStyle"] = "solid";
	colorView.style["width"] = "30px";
	colorView.style["height"] = "20px";
	colorView.style["float"] = "left";

	var colorColor = document.createElement ("input");
    setElementSaP (colorColor, {"class": "input", "top": "0px","width":"70px","height":"20px"}, {"id": "colorcod", "type": "input"});
    colorColor.setAttribute ("value", "#FFFFFF");
	//rL_addRoom.onmouseover = function () { this.style["backgroundColor"] = skinOptsValuesTmp["buttonover"]; }
    //rL_addRoom.onmouseout  = function () { this.style["backgroundColor"] = skinOptsValuesTmp["button"]; }


	var br = document.createElement ("br");
	br.setAttribute ("clear", "all");
    setElementSaP (br);

	newCell1.appendChild (colorView);
	newCell2.appendChild (colorColor);
	color.appendChild (newTABLE1);



	var colorPick = addDiv (cpDiv, null, {"id": "colorPick"});
	colorPick.appendChild (newTABLE);
	cpDiv.style["visibility"] = "hidden";

	cpDiv.themesColorOption = false;

  return cpDiv;
}
function cpColorOverHandler()
{
	var view = document.getElementById ("colorView");
	view.style["backgroundColor"] =  "#" + this.hexColor;
	var cpDiv = document.getElementById ("colorPicker");


	var code = document.getElementById ("colorcod");
	code.value = "#" + this.hexColor;
	//code.style["backgroundColor"] =  "#" + this.hexColor;
}
function showCPWindow (node, doNotCloseButtonWindows)
{
  var cpDiv = document.getElementById ("colorPicker");
  cpDiv.themesColorOption = false;

  if( skinOptsValuesTmp["dialog"] )
  {
  	cpDiv.style["backgroundColor"] = skinOptsValuesTmp["dialog"];
	document.getElementById ("TableColor").style["backgroundColor"] = skinOptsValuesTmp["dialog"];
}
else
{
	cpDiv.style["backgroundColor"] = "#314194";
	document.getElementById ("TableColor").style["backgroundColor"] = "#314194";;
}

var roomList = document.getElementById ("roomList");
  if (cpDiv == null)
    return;

  var divLayout = document.getElementById ("layoutDiv");
  if (divLayout == null)
    return;




  cpDiv.style["borderColor"] = getStyle(document.getElementById("helpBtn"),"border-top-color","borderColor");
  var cNPosition = getTLfromNode (node, divLayout);

	var viewC = document.getElementById ("colorBtn").style["backgroundColor"];
	var view = document.getElementById ("colorView");
	view.style["backgroundColor"] =  viewC.toUpperCase();
	view.style["borderColor"] = getStyle(document.getElementById("helpBtn"),"border-top-color","borderColor");
	var code = document.getElementById ("colorcod");
	code.style["borderColor"] = getStyle(document.getElementById("helpBtn"),"border-top-color","borderColor");
	var colorHex = new RGBColor(viewC);
	if(viewC.substring(0,1)!="#")
	{
		code.value = colorHex.toHex();
	}
	else
	{
		code.value = viewC.toUpperCase();
	}



  /* this condition fixes workaround for IE 6 */
  if (cpDiv.style["display"] != "block")
    cpDiv.style["display"] = "block";

  if (cpDiv.style["visibility"] == "hidden")
  {
	if (doNotCloseButtonWindows!=true)
		closeAllButtonWindows();
    cpDiv.style["left"] = (cNPosition[0]) + "px";
    cpDiv.style["top"] = (cNPosition[1] - cpDiv.clientHeight - 4) + "px";

    cpDiv.style["visibility"] = "visible";
  }
  else
    cpDiv.style["visibility"] = "hidden";

  cpDiv.isFor = node;
}
var colorDiv = null;
function showCPOptionWindow (node)
{

  var cpDiv = document.getElementById ("colorPicker");
  cpDiv.themesColorOption = true;

  if( skinOptsValuesTmp["dialog"] )
  {
  	cpDiv.style["backgroundColor"] = skinOptsValuesTmp["dialog"];
	document.getElementById ("TableColor").style["backgroundColor"] = skinOptsValuesTmp["dialog"];
  }
  else
  {
  	cpDiv.style["backgroundColor"] = "#314194";
	document.getElementById ("TableColor").style["backgroundColor"] = "#314194";;
  }

  cpDiv.style["borderColor"] = getStyle(document.getElementById("helpBtn"),"border-top-color","borderColor");
  colorDiv = cpDiv;
  var viewC = document.getElementById ("colorBtn").style["backgroundColor"];

  if (cpDiv.style["display"] != "block")
    cpDiv.style["display"] = "block";

  if (cpDiv.style["visibility"] == "hidden")
  {
	 idTimer = setTimeout ("colorVisible ()", 100);
  }

	cpDiv.isFor = node;

	return cpDiv;
}

var idTimer;

function colorVisible ()
{
	if (colorDiv != null)
	{
		cpDiv = colorDiv ;
		if (cpDiv.style["visibility"] == "hidden")
		{
			var optionWnd = document.getElementById ("optionsWindow");

			if (optionWnd != null)
			{

				if ( getBrowser()  == 2)//Firefox
				{
					cpDiv.style["left"] = optionWnd['offsetLeft'] + 275 + "px";
					cpDiv.style["top"]  = optionWnd['offsetTop' ] + 108 + "px";
				}

				if ( getBrowser()  == 4)//IE6
				{
				 	cpDiv.style["left"] = optionWnd['offsetLeft'] + 255 + "px";
					cpDiv.style["top"]  = optionWnd['offsetTop' ] + 124 + "px";
				}

				if ( browserISIE7() )//IE7
				{//257-111
					cpDiv.style["left"] = optionWnd['offsetLeft'] + 237 + "px";
					cpDiv.style["top"]  = optionWnd['offsetTop' ] + 111 + "px";
				}

				cpDiv.style["visibility"] = "visible";
				colorDiv = null;
				clearTimeout (idTimer);
			}
			else
			{
				 idTimer = setTimeout ("colorVisible ()", 100);

			}
		}
	}
}



function cpColorClickHandler ()
{
  var cpDiv = this.cpDiv;
  var isFor = cpDiv.isFor;

  if (isFor == null)
  {
  	return;
  }
  if (isFor.changeHandler != null)
  isFor.changeHandler (this.hexColor);



  if (cpDiv.themesColorOption)
  {
  	isFor.value = "#" + this.hexColor;
	cpDiv.style["visibility"] = "visible";

  }
  else
  {
	isFor.style["backgroundColor"] = "#" + this.hexColor;
	cpDiv.style["visibility"] = "hidden";
  }

  toChangeChatColors(isFor.id);
}


function createOptionsWindow (handlers) {

  var newWin = new AC_Window (winTypes.BUTTONCLOSE | winTypes.HASBUTTONS, "optionsWindow", { "width": "500", "height": "380"});

  if (! newWin)
    return null;

  newWin.userData["winType"] = "optionsWindow";

  var contentDoc = document.createDocumentFragment ();

  var contentTable = document.createElement ("table");
  setElementSaP (contentTable, {"width": "100%"}, {"border": "0", "cellSpacing": "0", "cellPadding": "4", "font-size": "8px"});
  var row = contentTable.insertRow (0);
  var cell = row.insertCell (0);

  var tabs = new Array ();

	var contentTable1 = document.createElement ("table");
setElementSaP (contentTable1, {"width": "auto"}, {"border": "0", "cellSpacing": "0", "cellPadding": "4", "font-size": "8px"});
  var row1 = contentTable1.insertRow (0);

  for (var i = 0; i < optionsTabs.length; i++) {
  var cell1 = row1.insertCell (i);
    var tabLabel = addSpanWText (cell1, {"class": "optionsTab"}, null, getLanguageString ("dialog", optionsTabs[i], config["defaultLanguage"], null));

	tabLabel.langType = "dialog";
	tabLabel.setAttribute('id','optionsTab'+i);
    tabLabel.langStr = optionsTabs[i];

	tabLabel.style["border"] = '1px solid '+getStyle(document.getElementById("helpBtn"),"border-left-color","borderLeftColor");
	tabLabel.style["borderBottom"] = "none";
    tabLabel.tabId = i;
    tabs[i] = new Array ();
    tabs[i][0] = tabLabel;

	if (i == 0)
	{
		tabLabel.className += " active";
	}
    tabLabel.onclick = function () { activateOWTab (tabs, this); }
  }
  cell.appendChild(contentTable1);
  newWin.userData["tabs"] = tabs;

  var row = contentTable.insertRow (1);
  var cell = row.insertCell (0);

  /*

    tab - index 0

  */

  var themesDiv = document.createElement ("div");
  themesDiv.className = "optionsTabContent";
  displayBLOCKByNode (themesDiv);

  tabs[0][1] = themesDiv;

  var divCT = document.createElement ("table");
  setElementSaP (divCT, {"width": "100%"}, {"border": "0", "cellSpacing": "1", "cellPadding": "1"});

  var divCTRow = divCT.insertRow (0);
  var divCTCell = divCTRow.insertCell (0);
  setElementSaP (divCTCell, {"verticalAlign": "top"}, {"colSpan": "2"});

  var themeSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "skin:selectBigSkin", config["currentLanguage"], null));
  themeSpan.langType = "dialog";
  themeSpan.langStr = "skin:selectBigSkin";

  divCTCell.appendChild (document.createTextNode (" "));

  var themeSelect = document.createElement ("select");
  themeSelect.setAttribute ("id", "list_themes");

  for (var i = 0; i < config["themes"].length; i++) {
    var tS_option = document.createElement ("option");


	if (config["themes"][i] == config["theme"])
      tS_option.setAttribute ("selected", "selected");

    tS_option.appendChild (document.createTextNode (config["themes"][i]["title"]));

    tS_option.value = i;

    themeSelect.appendChild (tS_option);
  }


  themeSelect.onchange = changeTheme;

  divCTCell.appendChild (themeSelect);

  var nullDiv = document.createElement ("div");
  nullDiv.style["height"] = "10px";
  divCTCell.appendChild (nullDiv);

  // the others options from theme

  var themeSelectOption = document.createElement("select");

 themeSelectOption.setAttribute ("size", "12");


  for (var i = 0; i < parseInt (skinOpts.length / 2 ); i++)
  {
	for (var j = 0; j < 2; j++)
	{
  		var skinOpt = skinOpts[(i * 2) + j];

	  	var skinOption = document.createElement ("option");

       	skinOption.appendChild (document.createTextNode (getLanguageString ("dialog", "skin:" + skinOpt, config["currentLanguage"], null)));

		skinOption.setAttribute ("id", "colorBtn_" + skinOpt );

    	themeSelectOption.appendChild (skinOption);
	}
  }
  themeSelectOption['selectedIndex'] = 0;

  var coloOpt = showCPOptionWindow();

  themeSelectOption.onclick = function ()
  {
  	var skinOptionName = this['childNodes'][this['selectedIndex']]['id'].substr(9);

  	var view = document.getElementById ("colorView");
	var code = document.getElementById ("colorcod");
	checkColor (skinOptsValuesTmp[skinOptionName]);
	if (skinOptsValuesTmp[skinOptionName].toUpperCase() == 'WHITE')
	{
		skinOptsValuesTmp[skinOptionName] = '#FFFFFF';
	}
	if (skinOptsValuesTmp[skinOptionName].toUpperCase().indexOf ('RGB') != -1 )
	{
		var color  = skinOptsValuesTmp[skinOptionName].toUpperCase();
		color  = color.replace("RGB", "");
		color  = color.replace("(", "");
		color  = color.replace(")", "");
		color  = color.replace(" ", "");

		if(color != '')
		{
			var x='0123456789ABCDEF';
			var colorArray = color.split(',');
			var hexColor = '#';
			for ( var ind = 0; ind < colorArray.length; ++ind )
			{
				var  hex = colorArray[ind];

				if (hex == null ||  parseInt(hex) == 0 || isNaN(parseInt(hex)))
				{
					hex = "00";
				}
				else
				{
					hex = parseInt(hex);
					hex = Math.max(0,hex);
					hex = Math.min(hex,255);
					hex = Math.round(hex);

					hex = "0123456789ABCDEF".charAt( (hex - hex%16) / 16 ) + "0123456789ABCDEF".charAt( hex%16 );
				}
				hexColor += hex;
			}
			skinOptsValuesTmp[skinOptionName] = hexColor
		}
	}

	if (skinOptsValuesTmp[skinOptionName].toUpperCase() == '')
	{
		view.style["backgroundColor"] = '#FFFFFF';
		code.value = '#FFFFFF';
	}
	else
	{
		view.style["backgroundColor"] =  skinOptsValuesTmp[skinOptionName].toUpperCase();
		code.value = skinOptsValuesTmp[skinOptionName].toUpperCase();
	}

	coloOpt = showCPOptionWindow (this['childNodes'][this['selectedIndex']]) ;
  }
  divCTCell.appendChild ( themeSelectOption );

  var divCTCell2 = divCTRow.insertCell (1);

  var resetThemeBtn = document.createElement ("input");

  resetThemeBtn.setAttribute ("type", "button");
  resetThemeBtn.className = "button";
  resetThemeBtn.value = getLanguageString ("dialog", "themes:reset", config["currentLanguage"], null);
  resetThemeBtn.langType = "dialog";
  resetThemeBtn.langStr = "themes:reset";
  resetThemeBtn.onmouseover = function () { this.style["backgroundColor"] = skinOptsValuesTmp["buttonover"]; }
  resetThemeBtn.onmouseout  = function () { this.style["backgroundColor"] = skinOptsValuesTmp["button"]; }

  resetThemeBtn.onclick = function ()
  {
  	var color = styleArray[themeSelect['selectedIndex']][themeSelectOption['childNodes'][themeSelectOption['selectedIndex']]['id']];

	var view = document.getElementById ("colorView");
	view.style["backgroundColor"] = color.toUpperCase();

	var code = document.getElementById ("colorcod");
	code.value = color.toUpperCase();

	themeSelectOption['childNodes'][themeSelectOption['selectedIndex']]['value'] = color.toUpperCase();
	toChangeChatColors( themeSelectOption['childNodes'][themeSelectOption['selectedIndex']]['id'] );
  }

  var nullDiv = document.createElement ("div");

  if (getBrowser() == 2 )//Firefox
  {
  	nullDiv.style["height"] = "203px";
	nullDiv.style["width"] = "85px";
  }
  if ( getBrowser() == 4  )//IE6
  {
  	nullDiv.style["height"] = "203px";
  }
  if ( browserISIE7() )
  {
  	nullDiv.style["height"] = "203px";
	resetThemeBtn.style['left'] = "-57px"

  }

  divCTCell2.appendChild (nullDiv);

  divCTCell2.appendChild ( resetThemeBtn );

  themeSelectOption.style["width"] = "203px";

  if (getBrowser() == 2 )//Firefox
  {
  	themeSelectOption.style["height"] = "195px";
	themeSelectOption.style["width"] = "209px";

  }

  themesDiv.appendChild ( divCT );
  cell.appendChild (themesDiv);

  /*

    tab - index 1

  */

  var soundDiv = document.createElement ("div");
  soundDiv.className = "optionsTabContent";
  soundDiv.style["paddingTop"] = "0px";
  displayNONEByNode (soundDiv);

  tabs[1][1] = soundDiv;

  var divCT = document.createElement ("table");
  setElementSaP (divCT, {"width": "96%"}, {"border": "0", "cellSpacing": "1", "cellPadding": "1"});

  var divCTRow = divCT.insertRow (0);
  var divCTCell = divCTRow.insertCell (0);
  var divCTCell2 = divCTRow.insertCell (1);

  setElementSaP (divCTCell,  {"width": "50%", "textAlign": "left", "paddingBottom": "12px", "verticalAlign": "middle"}, null);
  setElementSaP (divCTCell2, {"width": "50%", "textAlign": "left", "paddingBottom": "12px"}, null);

  var volumeSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "sound:volume", config["currentLanguage"], null));
  volumeSpan.langType = "dialog";
  volumeSpan.langStr = "sound:volume";

  divCTCell.appendChild (document.createTextNode (" "));

  var volumeSelect = document.createElement ("select");
  volumeSelect.setAttribute ( "id", "volumeall" );

  for (var i = 0; i < 21; i++)
  {
    var opt = document.createElement ("option");

    var valueStr = i * stepVolume;

    opt.setAttribute ("value", valueStr.toString ());

    opt.appendChild (document.createTextNode (valueStr.toString () + "%"));

    volumeSelect.appendChild (opt);
  }

  if ( soundArray['volume'] == undefined )
  {
  	soundArray['volume'] = config['sound']['volume'];
  }

  for ( var ind in config ['sound']['ev'] )
  {
	if ( soundArray[ind] == undefined )
	{
		soundArray[ind] = config['sound']['ev'][ind]['muted'];
	}
  }

  if (config["sound"]["volume"] != null)
    setSelectOptionByValue (volumeSelect, config["sound"]["volume"]);

  volumeSelect.onchange = function () { changeVolume (this); };

  divCTCell.appendChild (volumeSelect);

  var imgSndTest = document.createElement ("img");
  imgSndTest.setAttribute ("border", "0");
  imgSndTest.src = "imgs/speaker.gif";
  imgSndTest.style["cursor"] = "pointer";

  imgSndTest.onclick = function ()
  {
  	var volumeOption = document.getElementById ("volumeSelectOption");

	if (volumeOption == null)
		return;

	var volumeOptionName = volumeOption['childNodes'][volumeOption['selectedIndex']]['id'].substr(10);

  	testSound (volumeOptionName, true);
  };

  divCTCell.appendChild (imgSndTest);

  muteAllCheck = document.createElement ("input");
  muteAllCheck.setAttribute ("type", "checkbox");
  muteAllCheck.setAttribute ("name", "muteAll");
  muteAllCheck.setAttribute ("id", "muteAll");
  muteAllCheck["mutes"] = "all";
  muteAllCheck.onchange = function () { muteUnmute (this); };

  divCTCell.appendChild (document.createTextNode (" "));

  divCTCell.appendChild (muteAllCheck);
  divCTCell.appendChild (document.createTextNode (" "));
  var muteAllSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "sound:muteall", config["currentLanguage"], null));
  muteAllSpan.langType = "dialog";
  muteAllSpan.langStr = "sound:muteall";

  var divCTRow = divCT.insertRow (1);
  setElementSaP (divCTRow, {"verticalAlign": "top"}, {"colSpan": "3"});
  var divCTCell  = divCTRow.insertCell (0);

 setElementSaP (divCTCell3, {"width":"40%", "textAlign": "left", "paddingTop": "0px","verticalAlign": "top"}, null);

  var volumeSelectOption = document.createElement("select");
  volumeSelectOption.setAttribute ("id", "volumeSelectOption");
  volumeSelectOption.setAttribute ("size", "12");

  divCTCell.appendChild (volumeSelectOption);

  for (var i = 0; i < optionsSound.length; ++i)
  {
  	var sndOpt = optionsSound[i];

	var volumeOption = document.createElement ("option");

	var strLowerCase=sndOpt.toLowerCase ();
	if (strLowerCase=="receivemessage")
		strLowerCase="reveivemessage";

	volumeOption.appendChild (document.createTextNode (getLanguageString ("dialog", "sound:" + strLowerCase, config["currentLanguage"], null)));

	volumeOption.setAttribute ("id", "volumeBtn_" + sndOpt );

	volumeSelectOption.appendChild (volumeOption);
  }
  volumeSelectOption['selectedIndex'] = 0;

  var divCTCell  = divCTRow.insertCell (1);

  var newDivCT = document.createElement ("table");

  divCTCell.appendChild(newDivCT);
  setElementSaP (newDivCT, {"width": "96%"}, {"border": "0", "cellSpacing": "1", "cellPadding": "1"});
  var newdivCTRow = newDivCT.insertRow (0);

  var divCTCell3  = newdivCTRow.insertCell (0);
  var divCTCell5 = newdivCTRow.insertCell (1);
  var divCTCell4 = newdivCTRow.insertCell (2);

  setElementSaP (divCTCell3, {"textAlign": "right", "paddingBottom": "12px","verticalAlign": "middle"}, null);
  setElementSaP (divCTCell4, {"textAlign": "left" , "paddingBottom": "12px","verticalAlign": "top"}, null);

  var muteCheck = addSpanWText (divCTCell3, null, null, getLanguageString ("dialog", "sound:mute", config["currentLanguage"], null));

  muteCheck.langType = "dialog";
  muteCheck.langStr = "sound:mute";

  muteCheck = document.createElement ("input");
  muteCheck.setAttribute ("type", "checkbox");
  muteCheck.setAttribute ("name", "mute");
  muteCheck.setAttribute ("id", "mute");
  divCTCell3.appendChild (document.createTextNode ("   "));

  divCTCell4.appendChild (muteCheck);
  var newdivCTRow = newDivCT.insertRow (1);

  var divCTCell3  = newdivCTRow.insertCell (0);
  var divCTCell5 = newdivCTRow.insertCell (1);
  var divCTCell4 = newdivCTRow.insertCell (2);
  setElementSaP (divCTCell3, {"textAlign": "right", "paddingBottom": "12px","verticalAlign": "middle"}, null);
  setElementSaP (divCTCell4, {"textAlign": "left" , "paddingBottom": "12px","verticalAlign": "top"}, null);

  muteCheck.onclick = function ()
  {
  	var volumeSelectOption = document.getElementById('volumeSelectOption');
	var index =  volumeSelectOption['selectedIndex'];
	var volumeName = volumeSelectOption[index]['id'].substr(10);

	config['sound']['ev'][volumeName]['muted'] = this['checked'];
  }

  var volumeSelectSpan = addSpanWText (divCTCell3, null, null, getLanguageString ("dialog", "sound:volume", config["currentLanguage"], null));
  volumeSelectSpan.langType = "dialog";
  volumeSelectSpan.langStr = "sound:volume";
divCTCell3.appendChild (document.createTextNode ("   "));

  var volumeSelectOpt = document.createElement ("select");
  volumeSelectOpt.setAttribute ( "id", "currentvolume");

  for (var i = 0; i < 21; i++)
  {
    var opt = document.createElement ("option");

    var valueStr = i * stepVolume;

    opt.setAttribute ("value", valueStr.toString ());

    opt.appendChild (document.createTextNode (valueStr.toString () + "%"));

    volumeSelectOpt.appendChild (opt);
  }
  var cur_volume;
  if (config["sound"]["volume"] != null)
  {
  	var cur_volume = (Math.round(config['sound']['volume']/10)*stepVolume - stepVolume);

	if ( cur_volume < 0 )
	{
		cur_volume = 0;
	}

	setSelectOptionByValue (volumeSelectOpt, cur_volume);

	for (var i = 0; i < optionsSound.length; ++i)
	{
		var sndOpt = optionsSound[i];

		if ( config['sound']['ev'][sndOpt] != undefined )
		{
			if ( config['sound']['ev'][sndOpt]['volume'] ==  undefined)
			{
				config['sound']['ev'][sndOpt]['volume'] = cur_volume;
			}
		}
	}
  }

  volumeSelectOpt.onchange = function ()
  {
  	var volumeOption = document.getElementById ("volumeSelectOption");
	if (volumeOption == null)
		return;

	var volumeOptionName = volumeOption['childNodes'][volumeOption['selectedIndex']]['id'].substr(10);

	config['sound']['ev'][volumeOptionName]['volume'] = this.value;

  }

  volumeSelectOption.onclick = function ()
  {
	var index =  this['selectedIndex'];
	var volumeName = this[index]['id'].substr(10);

	var volumeOpt = document.getElementById ('currentvolume');
	var muteOpt   = document.getElementById ('mute');
	if (muteOpt == null)
		return;

	muteOpt['checked'] = config['sound']['ev'][volumeName]['muted'];

	if (config['sound']['ev'][volumeName]['volume'] == undefined)
	{
		volumeOpt['value'] = Math.round(config['sound']['volume']/10)*stepVolume - stepVolume;
		if(volumeOpt['value'] < 0)
		{
			volumeOpt['value'] = 0;
		}
	}
	else
	{
		volumeOpt['value'] = config['sound']['ev'][volumeName]['volume'];
	}
	var main = document.getElementById ('main');

	if  (main == null)
		return ;
	if (config['sound']['ev'][volumeName]['main'] != undefined)
	{
		main['checked'] = config['sound']['ev'][volumeName]['main'];
	}
	else
	{
		config['sound']['ev'][volumeName]['main'] = false;
		main['checked'] = false;
	}
  }

  divCTCell4.appendChild (volumeSelectOpt);

  var imgSndTestOne = document.createElement ("img");
  imgSndTestOne.setAttribute ("border", "0");
  imgSndTestOne.src = "imgs/speaker.gif";
  imgSndTestOne.style["cursor"] = "pointer";

  imgSndTestOne.onclick = function ()
  {
  	var volumeOption = document.getElementById ("volumeSelectOption");

	if (volumeOption == null)
		return;

	var volumeOptionName = volumeOption['childNodes'][volumeOption['selectedIndex']]['id'].substr(10);

  	testSound (volumeOptionName);
  };

 divCTCell4.appendChild (imgSndTestOne);

 var newdivCTRow = newDivCT.insertRow (2);

  var divCTCell3  = newdivCTRow.insertCell (0);
  var divCTCell5 = newdivCTRow.insertCell (1);
  var divCTCell4 = newdivCTRow.insertCell (2);

  setElementSaP (divCTCell3, {"textAlign": "right", "paddingBottom": "12px","verticalAlign": "top"}, null);
  setElementSaP (divCTCell4, {"textAlign": "left" , "paddingBottom": "12px","verticalAlign": "top"}, null);

  var useMainChack = document.createElement ("input");
  useMainChack.setAttribute ("type", "checkbox");
  useMainChack.setAttribute ("name", "main");
  useMainChack.setAttribute ("id", "main");

  useMainChack.onclick = function ()
  {
	var volumeSelectOption = document.getElementById('volumeSelectOption');
	var index =  volumeSelectOption['selectedIndex'];
	var volumeName = volumeSelectOption[index]['id'].substr(10);

	config['sound']['ev'][volumeName]['main'] = this['checked'];
  }

  divCTCell3.appendChild (useMainChack);

  var useMainChack = addSpanWText (divCTCell4, null, null, getLanguageString ("dialog", "sound:mainsettings", config["currentLanguage"], null));
  useMainChack.langType = "dialog";
  useMainChack.langStr = "sound:mainsettings";

  divCTCell3.appendChild (document.createTextNode ("   "));
  divCTCell4.appendChild (useMainChack);

  var resetSoundBtn = document.createElement ("input");

  resetSoundBtn.setAttribute ("type", "button");
  resetSoundBtn.className = "button";
  setElementSaP (resetSoundBtn, {"horizontalAlign": "center"}, null);
  resetSoundBtn.value = getLanguageString ("dialog", "sound:reset", config["currentLanguage"], null);
  resetSoundBtn.langType = "dialog";
  resetSoundBtn.langStr = "sound:reset";
  resetSoundBtn.onmouseover = function () { this.style["backgroundColor"] = skinOptsValuesTmp["buttonover"]; }
  resetSoundBtn.onmouseout  = function () { this.style["backgroundColor"] = skinOptsValuesTmp["button"]; }

 resetSoundBtn.onclick = function ()
 {
   	var volumeOption = document.getElementById ("volumeSelectOption");
	if (volumeOption == null)
		return;
	var volumeOptionName = volumeOption['childNodes'][volumeOption['selectedIndex']]['id'].substr(10);

	var curr_volume = document.getElementById('currentvolume');
	if (curr_volume == null)
		return;
	curr_volume['value'] = soundArray['volume'];
	config['sound']['ev'][volumeOptionName]['volume'] = soundArray['volume'];
	var curr_mute = document.getElementById('mute');
	if (curr_mute == null )
	{
		return;
	}
	curr_mute['checked'] =  soundArray[volumeOptionName];
	config['sound']['ev'][volumeOptionName]['muted'] = soundArray[volumeOptionName];

	var  main = document.getElementById('main');
	if (main == null)
		return;
	main['checked'] = false;
	config['sound']['ev'][volumeOptionName]['main'] = false;

 }

 if (getBrowser() == 2 )//Firefox
 {
 	volumeSelectOption.style["height"] = "197px";
	volumeSelectOption.style["width" ] = "209px";
 }
 if ( getBrowser() == 4  )//IE
 {
 	volumeSelectOption.setAttribute ("size", "12");
	volumeSelectOption.style["width" ] = "203px";
 }

  var newdivCTRow = newDivCT.insertRow (3);

  var divCTCell3  = newdivCTRow.insertCell (0);
  var divCTCell5 = newdivCTRow.insertCell (1);
  var divCTCell4 = newdivCTRow.insertCell (2);

 setElementSaP (divCTCell4, { "verticalAlign": "top"}, null);

 divCTCell4.appendChild (resetSoundBtn);
 soundDiv.appendChild ( divCT );
 cell.appendChild (soundDiv);

  /*

    tab - index 2

  */

  var effDiv = document.createElement ("div");
  effDiv.className = "optionsTabContent";
  effDiv.style["padding"] = "20px";
  displayNONEByNode (effDiv);

  tabs[2][1] = effDiv;

  var divCT = document.createElement ("table");
  setElementSaP (divCT, {"width": "90%"}, {"border": "0", "cellSpacing": "0", "cellPadding": "4"});

  var divCTRow = divCT.insertRow (0);

  var divCTCell = divCTRow.insertCell (0);
  var divCTCell2 = divCTRow.insertCell (1);
  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "left", "width": "50%"},{"colSpan":"2"});
  setElementSaP (divCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, null);

  var avatarSpan = addSpanWText (divCTCell, {"class": "optionsTitle1"},null, getLanguageString ("dialog", "effects:avatars", config["currentLanguage"], null));
  avatarSpan.langType = "dialog";
  avatarSpan.langStr = "effects:avatars";

  var photoSpan = addSpanWText (divCTCell2, {"class": "optionsTitle1"}, null, getLanguageString ("dialog", "effects:photo", config["currentLanguage"], null));
  photoSpan.langType = "dialog";
  photoSpan.langStr = "effects:photo";

  var divCTRow = divCT.insertRow (1);
  var divCTCell = divCTRow.insertCell (0);
  var divCTCell3 = divCTRow.insertCell (1);
  var divCTCell2 = divCTRow.insertCell (2);

  var AdivCTRow = divCT.insertRow (2);
   var AdivCTCell = AdivCTRow.insertCell (0);
  var AdivCTCell3 = AdivCTRow.insertCell (1);
  var AdivCTCell2 = AdivCTRow.insertCell (2);

  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "left", "width": "25%"}, null);
  setElementSaP (divCTCell3, {"verticalAlign": "top", "textAlign": "left", "width": "25%"}, null);
  setElementSaP (divCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, {"rowSpan": "5"});

  setElementSaP (AdivCTCell, {"verticalAlign": "middle", "textAlign": "left", "width": "25%"}, null);
  setElementSaP (AdivCTCell3, {"verticalAlign": "top", "textAlign": "left", "width": "25%"}, null);
  setElementSaP (AdivCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, {"rowSpan": "5"});

  var checkMCAvatar = document.createElement ("input");
  checkMCAvatar.setAttribute ("type", "checkbox");
  checkMCAvatar.setAttribute ("name", "checkMCAvatar");
  checkMCAvatar.setAttribute ("id", "checkMCAvatar");

  divCTCell.appendChild (checkMCAvatar);

  divCTCell.appendChild (document.createTextNode (" "));

  var mcAvatarSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "effects:mainchat", config["currentLanguage"], null));
  mcAvatarSpan.langType = "dialog";
  mcAvatarSpan.langStr = "effects:mainchat";

  divCTCell.appendChild (document.createTextNode (" "));

  var mcAvatarSelect = document.createElement ("select");

  smiArray = config["smiArray"];

  for (var i = 0; i < smiArray.length; i++) {
    var opt = document.createElement ("option");
    opt.setAttribute ("value", smiArray[i]);
	if (smiArray[i] == config["effects"]["avatarsmainchat-avatar"])
		opt.setAttribute ("selected", "true");
    opt.appendChild (document.createTextNode (smiArray[i]));

    mcAvatarSelect.appendChild (opt);
  }

  divCTCell3.appendChild (mcAvatarSelect);
  mcAvatarSelect.setAttribute ("id", "mcAvatarSelect");

  divCTCell.appendChild (document.createElement ("br"));

  var checkRLAvatar = document.createElement ("input");
  checkRLAvatar.setAttribute ("type", "checkbox");
  checkRLAvatar.setAttribute ("name", "checkRLAvatar");
  checkRLAvatar.setAttribute ("id", "checkRLAvatar");
  checkRLAvatar.onclick = previewPersonalRoomAvatar;

  AdivCTCell.appendChild (checkRLAvatar);
  AdivCTCell.appendChild (document.createTextNode (" "));

  var rlAvatarSpan = addSpanWText (AdivCTCell, null, null, getLanguageString ("dialog", "effects:roomlist", config["currentLanguage"], null));
  rlAvatarSpan.langType = "dialog";
  rlAvatarSpan.langStr = "effects:roomlist";

  AdivCTCell.appendChild (document.createTextNode (" "));

  var rlAvatarSelect = document.createElement ("select");

  smiArray = config["smiArray"];

  for (var i = 0; i < smiArray.length; i++) {
    var opt = document.createElement ("option");
    opt.setAttribute ("value", smiArray[i]);
	if (smiArray[i] == config["effects"]["avatarsroomlist-avatar"])
		opt.setAttribute ("selected", "true");
    opt.appendChild (document.createTextNode (smiArray[i]));

    rlAvatarSelect.appendChild (opt);
  }

  AdivCTCell3.appendChild (rlAvatarSelect);
  rlAvatarSelect.setAttribute ("id", "rlAvatarSelect");
  rlAvatarSelect.onchange = previewPersonalRoomAvatar;

  var photoCustomBtn = document.createElement ("input");
  photoCustomBtn.setAttribute ("type", "button");
  photoCustomBtn.className = "button";
  photoCustomBtn.value = getLanguageString ("dialog", "effects:custom", config["currentLanguage"], null);
  photoCustomBtn.langType = "dialog";
  photoCustomBtn.langStr = "effects:custom";
  photoCustomBtn.onmouseover = function () { this.style["backgroundColor"] = skinOptsValuesTmp["buttonover"];  }
  photoCustomBtn.onmouseout  = function () { this.style["backgroundColor"] = skinOptsValuesTmp["button"];      }
  photoCustomBtn.style["top"]="0px";
  if ((handlers != null) && (handlers["customPhoto"] != null))
    photoCustomBtn.onclick = handlers["customPhoto"];

  divCTCell2.appendChild (photoCustomBtn);

  var noPhotoCustom = new ImgButton ("close");

  divCTCell2.appendChild (document.createTextNode ("  "));
  divCTCell2.appendChild (noPhotoCustom.node);

  noPhotoCustom.clickHandler = function () {
	  		 TempArrayAvatar["mypicture-temp"] = config["effects"]["mypicture-temp"];
			 config["effects"]["mypicture-temp"] = "imgs/blank.gif";
			 TempArrayAvatar["myPicture"] = document.getElementById("myPicture").innerHTML;
			 document.getElementById("myPicture").innerHTML = "";
	  	}

  divCTCell2.appendChild (document.createElement ("br"));
  divCTCell2.appendChild (document.createElement ("br"));

  var picDiv = document.createElement ("div");
  setElementSaP (picDiv, null, {"id": "myPicture"});

  divCTCell2.appendChild(picDiv);
  if (config["effects"]["mypicture"])
  	picDiv.innerHTML="<img src=\"." + config["effects"]["mypicture"] + "\" width=\"120px\">";
  config["effects"]["mypicture-temp"] = config["effects"]["mypicture"];

  var divCTRow = divCT.insertRow (3);
  var divCTCell = divCTRow.insertCell (0);
  var divCTCell2 = divCTRow.insertCell (1);

  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "left", "width": "50%"}, {"colSpan":"2"});
  setElementSaP (divCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, null);

  var backgroundSpan = addSpanWText (divCTCell, {"class": "optionsTitle1"}, null, getLanguageString ("dialog", "effects:background", config["currentLanguage"], null));
  backgroundSpan.langType = "dialog";
  backgroundSpan.langStr = "effects:background";

  divCTCell.appendChild (backgroundSpan);

  var divCTRow = divCT.insertRow (4);
  var divCTCell = divCTRow.insertCell (0);
  var divCTCell2 = divCTRow.insertCell (1);

  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "left", "width": "50%"}, {"colSpan":"2"});
  setElementSaP (divCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, null);

  var shBackCheck = document.createElement ("input");
  shBackCheck.setAttribute ("type", "checkbox");
  shBackCheck.setAttribute ("name", "showBackgroundCh");
  shBackCheck.setAttribute ("id", "showBackgroundCh");

  divCTCell.appendChild (shBackCheck);
  divCTCell.appendChild (document.createTextNode (" "));

  shBackCheck.onclick = ifShowBackground;

  var shBackSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "effects:showBackgroundImages", config["currentLanguage"], null));
  shBackSpan.langType = "dialog";
  shBackSpan.langStr = "effects:showBackgroundImages";

  divCTCell.appendChild (document.createElement ("br"));
  divCTCell.appendChild (document.createElement ("br"));

  var backCustomBtn = document.createElement ("input");

  backCustomBtn.setAttribute ("type", "button");
  backCustomBtn.className = "button";
  backCustomBtn.value = getLanguageString ("dialog", "effects:custom", config["currentLanguage"], null);
  backCustomBtn.langType = "dialog";
  backCustomBtn.langStr = "effects:custom";
  backCustomBtn.style["top"]="0px";
  backCustomBtn.onmouseover = function () { this.style["backgroundColor"] = skinOptsValuesTmp["buttonover"]; }
  backCustomBtn.onmouseout  = function () { this.style["backgroundColor"] = skinOptsValuesTmp["button"]; }

  if ((handlers != null) && (handlers["customBackground"] != null))
    backCustomBtn.onclick = handlers["customBackground"];

  divCTCell.appendChild (backCustomBtn);

  var noBackCustom = new ImgButton ("close");
  divCTCell.appendChild (document.createTextNode ("  "));
  divCTCell.appendChild (noBackCustom.node);

  config["effects"]["background-image-temp"] =  config["effects"]["background-image"];
  config["effects"]["background-image-lockthemes-temp"] = config["effects"]["background-image-lockthemes"];

  noBackCustom.clickHandler = function () {
	  		TempArrayAvatar["themeImgTemp"] = config["effects"]["background-image-temp"];
			TempArrayAvatar["themeImgTempLock"] = config["effects"]["background-image-lockthemes-temp"];
			config["effects"]["background-image-temp"] = "themes/" + config["theme"]["name"] + "/" + config["theme"]["background-default"];
	  		config["effects"]["background-image-lockthemes-temp"]=0;
	  		ifShowBackground();
	  	}

  var divCTRow = divCT.insertRow (5);
  var divCTCell = divCTRow.insertCell (0);
  var divCTCell2 = divCTRow.insertCell (1);
  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "left", "width": "50%"}, {"colSpan":"2"});
  setElementSaP (divCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, null);

  var focusCheck = document.createElement ("input");
  focusCheck.setAttribute ("type", "checkbox");
  focusCheck.setAttribute ("name", "focusCheck");
  focusCheck.setAttribute ("id", "focusCheck");


  divCTCell.appendChild (focusCheck);

  divCTCell.appendChild (document.createTextNode (" "));

  var focusSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "effects:splashWindow", config["currentLanguage"], null));
  focusSpan.langType = "dialog";
  focusSpan.langStr = "effects:splashWindow";

  divCTCell.appendChild (focusSpan);

  effDiv.appendChild (divCT);
  cell.appendChild (effDiv);

  /*

    tab - index 3

  */
  var textDiv = document.createElement ("div");
  textDiv.className = "optionsTabContent";
  textDiv.style["paddingTop"] = "20px";
  displayNONEByNode (textDiv);

  tabs[3][1] = textDiv;
 var divCT = document.createElement ("table");
  setElementSaP (divCT, {"width": "100%"}, {"border": "0", "cellSpacing": "0", "cellPadding": "4"});

  var row_number=0;

  var divCTRow = divCT.insertRow (row_number++);
  var divCTCell = divCTRow.insertCell (0);
  var divCTCell2 = divCTRow.insertCell (1);

  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "right", "width": "38%"}, null);
  setElementSaP (divCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "62%"}, null);

  var itcSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "text:itemChange", config["currentLanguage"], null));
  itcSpan.langType = "dialog";
  itcSpan.langStr = "text:itemChange";

  var itcSelect = document.createElement ("select");
  itcSelect.setAttribute ("id", "itcSelect");

  if (config["itc"]["mainChat"] != null) {
    var opt = document.createElement ("option");
    opt.setAttribute ("value", "mainChat");

    var valText = document.createTextNode (getLanguageString ("dialog", "text:mainChat", config["currentLanguage"], null));
    opt.langType = "dialog";
    opt.langStr = "text:mainChat";

    opt.appendChild (valText);

    itcSelect.appendChild (opt);
  }

  if (config["itc"]["interface"] != null) {
    var opt = document.createElement ("option");
    opt.setAttribute ("value", "interface");

    var valText = document.createTextNode (getLanguageString ("dialog", "text:interfaceElements", config["currentLanguage"], null));

    opt.langType = "dialog";
    opt.langStr = "text:interfaceElements";

    opt.appendChild (valText);

    itcSelect.appendChild (opt);
  }

  if (config["itc"]["title"] != null) {
    var opt = document.createElement ("option");
    opt.setAttribute ("value", "title");

    var valText = document.createTextNode (getLanguageString ("dialog", "text:title", config["currentLanguage"], null));
    opt.langType = "dialog";
    opt.langStr = "text:title";

    opt.appendChild (valText);

    itcSelect.appendChild (opt);
  }

  itcSelect.onchange = adjustTextSelects;

  divCTCell2.appendChild (itcSelect);

  var divCTRow = divCT.insertRow (row_number++);
  var divCTCell = divCTRow.insertCell (0);
  var divCTCell2 = divCTRow.insertCell (1);

  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "right", "width": "32%"}, null);
  setElementSaP (divCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "68%"}, null);

  var fSizeSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "text:fontSize", config["currentLanguage"], null));
  fSizeSpan.langType = "dialog";
  fSizeSpan.langStr = "text:fontSize";

  divCTCell.appendChild (document.createTextNode (" "));

  var fsSelect = document.createElement ("select");
  fsSelect.setAttribute ("id", "fsSelect");

  for (i = 0; i < config["itc"]["sizes"].length; i++) {
    var opt = document.createElement ("option");
    opt.setAttribute ("value", config["itc"]["sizes"][i]);

    opt.appendChild (document.createTextNode (config["itc"]["sizes"][i]));

    fsSelect.appendChild (opt);
  }

  fsSelect.onchange = changeTextSize;

  divCTCell2.appendChild (fsSelect);


  var divCTRow = divCT.insertRow (row_number++);
  var divCTCell = divCTRow.insertCell (0);
  var divCTCell2 = divCTRow.insertCell (1);

  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "right", "width": "32%"}, null);
  setElementSaP (divCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "68%"}, null);

  var fFamilySpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "text:fontFamily", config["currentLanguage"], null));
  fFamilySpan.langType = "dialog";
  fFamilySpan.langStr = "text:fontFamily";

  divCTCell.appendChild (document.createTextNode (" "));

  ffSelect = document.createElement ("select");
  ffSelect.setAttribute ("id", "ffSelect");

  var  fonts = new Array ( "Arial", "Times", "Courier", "Verdana", "Georgia");
  for (i = 0; i < fonts.length; i++)
  {
    var opt = document.createElement ("option");
    opt.setAttribute ("value", fonts[i]);

    opt.appendChild (document.createTextNode (fonts[i]));

    ffSelect.appendChild (opt);
  }
  /*for (i = 0; i < config["itc"]["families"].length; i++) {
    var opt = document.createElement ("option");
    opt.setAttribute ("value", config["itc"]["families"][i]);

    opt.appendChild (document.createTextNode (config["itc"]["families"][i]));

    ffSelect.appendChild (opt);
  }*/

  ffSelect.onchange = changeTextFamily;

  divCTCell2.appendChild (ffSelect);

  if (config["itc"]["mainChat"] != null)
  	setSelectOptionByValue (fsSelect, config["itc"]["mainChat"]["fontSize"]);
  else if (config["itc"]["interface"] != null)
  	setSelectOptionByValue (fsSelect, config["itc"]["interface"]["fontSize"]);
  else if (config["itc"]["title"] != null)
  	setSelectOptionByValue (fsSelect, config["itc"]["title"]["fontSize"]);

  if (config["itc"]["mainChat"] != null)
  	setSelectOptionByValue (ffSelect, config["itc"]["mainChat"]["fontFamily"]);
  else if (config["itc"]["interface"] != null)
  	setSelectOptionByValue (ffSelect, config["itc"]["interface"]["fontFamily"]);
  else if (config["itc"]["title"] != null)
  	setSelectOptionByValue (ffSelect, config["itc"]["title"]["fontFamily"]);

   if(config["allowLanguage"]){
	  var divCTRow = divCT.insertRow (row_number++);
	  var divCTCell = divCTRow.insertCell (0);
	  var divCTCell2 = divCTRow.insertCell (1);
	  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "right", "width": "38%"}, null);
	  setElementSaP (divCTCell2, {"verticalAlign": "top", "textAlign": "left", "width": "62%"}, null);

	  var langSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "text:language", config["currentLanguage"], null));
	  langSpan.langType = "dialog";
	  langSpan.langStr = "text:language";

	  var langSelect = document.createElement ("select");

	  for (key in loginLangs) {
	    var langOpt = document.createElement ("option");
	    langOpt.setAttribute ("value", key);

	    if (key == config["defaultLanguage"])
	      langOpt.setAttribute ("selected", "selected");

	    langOpt.appendChild (document.createTextNode (loginLangs[key]["name"]));

	    langSelect.appendChild (langOpt);
	  }

	  setSelectOptionByValue (langSelect, config["currentLanguage"]);

	  if ((handlers != null) && (handlers["changeLang"] != null))
	    langSelect.onchange = handlers["changeLang"];

	  divCTCell2.appendChild (langSelect);
  }

  var divCTRow = divCT.insertRow (row_number++);
  var divCTCell = divCTRow.insertCell (0);
  var divCTCell2 = divCTRow.insertCell (1);

  setElementSaP (divCTCell, {"verticalAlign": "middle", "textAlign": "right", "width": "32%"}, null);
  setElementSaP (divCTCell2, {"verticalAlign": "middle", "textAlign": "left", "width": "68%"}, null);

  var checkMyTextColor = document.createElement ("input");
  checkMyTextColor.setAttribute ("type", "checkbox");
  checkMyTextColor.setAttribute ("name", "checkMyTextColor");
  checkMyTextColor.setAttribute ("id", "checkMyTextColor");
  checkMyTextColor.onclick  = function () { config["itc"]["mytextcolor"] = document.getElementById("checkMyTextColor").checked; applyMyTextColor(); }

  divCTCell.appendChild (checkMyTextColor);

  divCTCell.appendChild (document.createTextNode (" "));

  var txtMyTextColor = addSpanWText (divCTCell2, null, null, getLanguageString ("dialog", "text:mytextcolor", config["currentLanguage"], null));
  txtMyTextColor.langType = "dialog";
  txtMyTextColor.langStr = "text:mytextcolor"

  textDiv.appendChild (divCT);
  cell.appendChild (textDiv);

  /*

    tab - index 4

  */

  var aboutDiv = document.createElement ("div");
  aboutDiv.className = "optionsTabContent";
  displayNONEByNode (aboutDiv);

  tabs[4][1] = aboutDiv;

  var divCT = document.createElement ("table");
  setElementSaP (divCT, {"width": "100%"}, {"border": "0", "cellSpacing": "1", "cellPadding": "1"});

  var divCTRow = divCT.insertRow (0);
  var divCTCell = divCTRow.insertCell (0);
  setElementSaP (divCTCell, {"width": "100%", "textAlign": "left", "paddingTop": "10px", "paddingLeft": "20px"}, null);

  divCTCell.appendChild (document.createTextNode (" "));

  var ACVersDiv = addDiv (divCTCell, null, null)
  ACVersDiv.innerHTML = "<font class=\"optionsAbout1\">AJAX Chat</font>&nbsp;&nbsp;&nbsp;v" + config["ajaxVersion"] + "<br/><br/>";

  var copyDiv = addDiv (divCTCell, null, null);
  copyDiv.innerHTML = "(c) 2008 TUFaT.com, All Rights Reserved";

  divCTCell.appendChild (document.createElement ("br"));

  var DGSpan = addSpanWText (divCTCell, null, null, "Darren Gates");
  divCTCell.appendChild (document.createElement ("br"));
  var CCSpan = addSpanWText (divCTCell, null, null, "Adrian Cical");
  divCTCell.appendChild (document.createElement ("br"));
  var CCSpan = addSpanWText (divCTCell, null, null, "Claudiu Cismaru");
  divCTCell.appendChild (document.createElement ("br"));
  var CCSpan = addSpanWText (divCTCell, null, null, "RuAnSoft team");

  aboutDiv.appendChild (divCT);
  cell.appendChild (aboutDiv);

  /*

    end of tab content

  */

  contentDoc.appendChild (contentTable);
  newWin.addContent (contentDoc);

  var okButton = newWin.addButton ("dialog", "common:okBtn", null, actionTypes.OK);
  okButton.style["width"] = "55px";
  okButton.style["marginRight"] = "15px";
  okButton.onmouseover = function () { this.style["backgroundColor"] = skinOptsValuesTmp["buttonover"]; }
  okButton.onmouseout  = function () { this.style["backgroundColor"] = skinOptsValuesTmp["button"]; }

  var cancelButton=newWin.addButton ("dialog", "common:cancelBtn", null, actionTypes.CANCELOPT);
  cancelButton.style["marginRight"] = "15px";
  cancelButton.onmouseover = function () { this.style["backgroundColor"] = skinOptsValuesTmp["buttonover"];   }
  cancelButton.onmouseout  = function () { this.style["backgroundColor"] = skinOptsValuesTmp["button"]; }

  if(!document.getElementById ("contextMenu"))
  {
   	var cmDiv = document.createElement ("div");
  	setElementSaP (cmDiv, {"visibility": "hidden"}, {"id": "contextMenu"});
	var layoutDiv11 = document.getElementById ("layoutDiv");
	layoutDiv11.appendChild (cmDiv);
  }

  return newWin;
}

function adjustTextSelects () {
  var currentOption = this.value;

  if (config["itc"][currentOption] != null) {
    var fsSelect = document.getElementById ("fsSelect");
    var ffSelect = document.getElementById ("ffSelect");

    setSelectOptionByValue (fsSelect, config["itc"][currentOption]["fontSize"]);
    setSelectOptionByValue (ffSelect, config["itc"][currentOption]["fontFamily"]);
  }
}

function changeTextSize () {
  var currentOption = this.value;

  var itcSelect = document.getElementById ("itcSelect");

  config["itc"][itcSelect.value]["fontSize"] = currentOption;
  optFontChange[itcSelect.value].style["fontSize"] = currentOption + "px";

  if (itcSelect.value=="interface")
     setInterfaceFont();

  if (itcSelect.value=="mainChat")
  	optFontChange["inputMessage"].style["fontSize"] = currentOption + "px";

}

function changeTextFamily () {
  var currentOption = this.value;

  var itcSelect = document.getElementById ("itcSelect");

  config["itc"][itcSelect.value]["fontFamily"] = currentOption;
  optFontChange[itcSelect.value].style["fontFamily"] = currentOption;

  if (itcSelect.value=="interface"){
	 setInterfaceFont();
	 /*
     var allSel= document.getElementsByTagName("select");
     for (var i in allSel)
  	 	if (allSel[i] &&  allSel[i].value)
  	 		allSel[i].style["fontFamily"] = currentOption;
	 var allSel= document.getElementsByTagName("input");
  	 for (var i in allSel)
  	 	if (allSel[i] &&  allSel[i].value)
  	 		allSel[i].style["fontFamily"] = currentOption;
  	 var allSel= document.getElementsByTagName("div");
  	 for (var i in allSel)
  	 	if (allSel[i] &&  allSel[i].value)
  	 		allSel[i].style["fontFamily"] = currentOption;
  	 var allSel= document.getElementsByTagName("td");
  	 for (var i in allSel)
  	 	if (allSel[i] &&  allSel[i].value)
  	 		allSel[i].style["fontFamily"] = currentOption;  	*/
  }

  if (itcSelect.value=="mainChat")
  	optFontChange["inputMessage"].style["fontFamily"] = currentOption;
}

function createRoomPassWindow (userData) {
  var newWin = new AC_Window (winTypes.BUTTONCLOSE | winTypes.HASBUTTONS, null, {"width": "300", "height": "140"});

  if (! newWin)
    return null;

  newWin.userData["forRoom"] = userData["room"];
  newWin.userData["winType"] = "askRoomPass";

  var contentDoc = document.createDocumentFragment ();

  var contentTable = document.createElement ("table");
  setElementSaP (contentTable, {"width": "100%"}, {"border": "0", "cellSpacing": "0", "cellPadding": "4"});

  var row = contentTable.insertRow (0);
  var cell = row.insertCell (0);

  var rlSpan = addSpanWText (cell, null, null, "");
  rlSpan.innerHTML = getLanguageString ("lang", "roomlock", config["currentLanguage"], null);

  var row = contentTable.insertRow (1);
  var cell = row.insertCell (0);
  cell.setAttribute("vAlign","top");

  var passInput = addInput (cell, {"class": "textInput", "marginTop": "0px", "width": "98%"}, null);
  passInput.onkeyup = submitOnEnter;
  newWin.node.userForm.elems["roomPass"] = passInput;

  contentDoc.appendChild (contentTable);
  newWin.addContent (contentDoc);

  newWin.addButton ("dialog", "common:okBtn", null, actionTypes.OK);

  return newWin;
}

function closeAllButtonWindows(){
	if(document.getElementById("optionsWindow"))
		document.getElementById("optionsWindow").object.closeWindow();

	var smilesNode = document.getElementById ("smilesList");
  	if (smilesNode != null)
  		smilesNode.style["visibility"] = "hidden";

	var cpDiv = document.getElementById ("colorPicker");
	if (cpDiv != null)
		cpDiv.style["visibility"] = "hidden";
}

function setInterfaceFont(){

  if(config["itc"]["interface"] == null)
  	return;
  /*var allSel= document.getElementsByTagName("table");
  for (var i in allSel)
 	if (allSel[i] && allSel[i].style)
 		allSel[i].style["fontSize"] = config["itc"]["interface"]["fontSize"] + "px";
 	*/
  var allSel= document.getElementsByTagName("textarea");
  for (var i in allSel)
	if (allSel[i])
	if (allSel[i].className=="textInput"){
 		allSel[i].style["fontSize"] = config["itc"]["interface"]["fontSize"] + "px";
 		allSel[i].style["fontFamily"] = config["itc"]["interface"]["fontFamily"];
	}

  var allSel= document.getElementsByTagName("select");
  for (var i in allSel)
 	if (allSel[i] && allSel[i].value){
 		allSel[i].style["fontSize"] = config["itc"]["interface"]["fontSize"] + "px";
 		allSel[i].style["fontFamily"] = config["itc"]["interface"]["fontFamily"];
	}
  var allSel= document.getElementsByTagName("input");
  for (var i in allSel)
 	if (allSel[i] && allSel[i].value){
 		allSel[i].style["fontSize"] = config["itc"]["interface"]["fontSize"] + "px";
 		allSel[i].style["fontFamily"] = config["itc"]["interface"]["fontFamily"];
	}
  var allSel= document.getElementsByTagName("table");
  for (var i in allSel)
 	if (allSel[i] && allSel[i].style){
 		allSel[i].style["fontSize"] = config["itc"]["interface"]["fontSize"] + "px";
 		allSel[i].style["fontFamily"] = config["itc"]["interface"]["fontFamily"];
	}
}

function setOptionsWindow(){

  config["theme_old"]=config["theme"]["name"];
  for (var i in skinOpts)
  	skinOptsValues[skinOpts[i]]=skinOptsValuesTmp[skinOpts[i]];

  //theme color

  var color_t = new RGBColor(skinOptsValues["bodyText"]).toHex().replace("#","");

  //changeColor(color_t);

  var newval, change;
  if(document.getElementById("checkMCAvatar"))
	if(document.getElementById("checkMCAvatar").checked==true)
    	config["effects"]["avatarsmainchat"]=1;
    else
		config["effects"]["avatarsmainchat"]=0;

  if(document.getElementById("mcAvatarSelect"))
  	config["effects"]["avatarsmainchat-avatar"] = document.getElementById("mcAvatarSelect").value;

  // Main chat avatar
  change=0;
  newval=0;
  if(document.getElementById("checkMCAvatar"))
	if(document.getElementById("checkMCAvatar").checked==true)
    	newval=1;
    else
		newval=0;
  if (newval!=config["effects"]["avatarsmainchat-avatar"]){
  	config["effects"]["avatarsmainchat"]=newval;
  	change=1;
  }
  newval="";

  if(document.getElementById("mcAvatarSelect"))
  	newval = document.getElementById("mcAvatarSelect").value;
  if (newval!=config["effects"]["avatarsmainchat-avatar"]){
	  config["effects"]["avatarsmainchat-avatar"]=newval;
	  change=1;
  }

  if (change==1){

	  var valavatar=config["effects"]["avatarsmainchat-avatar"];
	  if (config["effects"]["avatarsmainchat"]==0)
	  	valavatar="";

	  var data = formatSetMainChatAvatar (null, valavatar);
	  clearTimeout (timeOutId);
	  enqueueMessage (data, sendQueue);
	  timeOutId = setTimeout ("chatLoop ()", 1);
  }
  // --

  // Room list avatar
  change=0;
  newval=0;
  if(document.getElementById("checkRLAvatar"))
	if(document.getElementById("checkRLAvatar").checked==true)
    	newval=1;
    else
		newval=0;


  if (newval!=config["effects"]["avatarsroomlist-avatar"]){
  	config["effects"]["avatarsroomlist"]=newval;
  	change=1;
  }
  newval="";
  if(document.getElementById("rlAvatarSelect"))
  	newval = document.getElementById("rlAvatarSelect").value;
  if (newval!=config["effects"]["avatarsroomlist-avatar"]){
	  config["effects"]["avatarsroomlist-avatar"]=newval;
	  change=1;
  }


  if (change==1){
	  var valavatar=config["effects"]["avatarsroomlist-avatar"];
	  if (config["effects"]["avatarsroomlist"]==0)
	  	valavatar="";

	  var data = formatSetRoomAvatar (null, valavatar);
	  clearTimeout (timeOutId);
	  enqueueMessage (data, sendQueue);
	  timeOutId = setTimeout ("chatLoop ()", 1);
  }
  // --

  if(document.getElementById("showBackgroundCh"))
	if(document.getElementById("showBackgroundCh").checked==true)
    	config["effects"]["showbackground"]=1;
    else
		config["effects"]["showbackground"]=0;

  config["effects"]["background-image"] = config["effects"]["background-image-temp"];
  config["effects"]["background-image-lockthemes"] = config["effects"]["background-image-lockthemes-temp"];

  if(document.getElementById("focusCheck"))
	if(document.getElementById("focusCheck").checked==true)
    	config["splashWindow"]=1;
    else
		config["splashWindow"]=0;

  if(config["effects"]["mypicture-temp"] == "imgs/blank.gif" || config["effects"]["mypicture-temp"] == ""){
	config["effects"]["mypicture-temp"] = "";
  	config["effects"]["mypicture"] = "";
  }else
    config["effects"]["mypicture"]=config["effects"]["mypicture-temp"] + "?" + Math.random();

  var data = formatSetPicture (null, config["effects"]["mypicture"]);
  clearTimeout (timeOutId);
  enqueueMessage (data, sendQueue);

  timeOutId = setTimeout ("chatLoop ()", 1);
}

function previewPersonalRoomAvatar(){
  if(document.getElementById("checkRLAvatar"))
	if(document.getElementById("checkRLAvatar").checked==true)
	{
		avatarsroomlist=1;
	}
    else
	{
		avatarsroomlist=0;
	}
  if(document.getElementById("rlAvatarSelect"))
  	avatarsroomlist_avatar = document.getElementById("rlAvatarSelect").value;

  var valavatar=avatarsroomlist_avatar;
  if (avatarsroomlist==0)
  	valavatar="";

  var data = formatSetRoomAvatar (user["uid"], valavatar);
  clearTimeout (timeOutId);
  enqueueMessage (data, sendQueue);
  timeOutId = setTimeout ("chatLoop ()", 1);
}

function resetAvatar(){
	if(document.getElementById("rlAvatarSelect")){
		  var valavatar=config["effects"]["avatarsroomlist-avatar"];
		  if (config["effects"]["avatarsroomlist"]==0)
		  	valavatar="";
		  var data = formatSetRoomAvatar (user["uid"], valavatar);
		  clearTimeout (timeOutId);
		  enqueueMessage (data, sendQueue);
		  timeOutId = setTimeout ("chatLoop ()", 1);
	}
}

function ifRollbackTheme(){
	if (config["theme_old"]!=config["theme"]["name"])
		for (var i = 0; i < config["themes"].length; i++)
    		if (config["themes"][i]["name"] == config["theme_old"])
    			changeTheme (i);
}

function resetThemesColors ()
{

}

function resetThemeColors(){
	for (var i in skinOpts)
	{
		skinOptsValuesTmp[skinOpts[i]]="";
		skinOptsValues[skinOpts[i]]="";
		toChangeChatColors("colorBtn_" + skinOpts[i],true);
	}
}

function applyColorChanges()
{

	for (var i in skinOpts)
		toChangeChatColors("colorBtn_" + skinOpts[i]);





	document.body.style["display"] = "none";
	document.body.style["display"] = "block";
}

function toChangeChatColors(elemId, removeall){

	var x;
	if (elemId.indexOf("colorBtn_")!=0)
		return;
	if (removeall!=true)
		x=document.getElementById(elemId);

	switch(elemId){
		case "colorBtn_background":

					//if (browserISIE7())
					//break;
				if (x)
				{
					skinOptsValuesTmp["background"] = x.value;//style["backgroundColor"];
				}
				else
					skinOptsValuesTmp["background"]=skinOptsValues["background"];
				//document.getElementById("AC_main").style["backgroundColor"]=skinOptsValuesTmp["background"];
					//document.bgColor=skinOptsValuesTmp["background"];

				document.body.style["backgroundColor"]=skinOptsValuesTmp["background"];

				//document.getElementById("AC_main").style["display"]="none";
				//document.getElementById("AC_main").style["display"]="block";
				//document.getElementById("AC_main").style["backgroundColor"]=skinOptsValuesTmp["background"];

			break;
		case "colorBtn_titleText":
				if (x)
					skinOptsValuesTmp["titleText"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["titleText"]=skinOptsValues["titleText"];
				if(document.getElementById("AC_mainTitleRow"))
					document.getElementById("AC_mainTitleRow").style["color"]=skinOptsValuesTmp["titleText"];
			break;
		case "colorBtn_buttonText":
				if (x)
					skinOptsValuesTmp["buttonText"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["buttonText"]=skinOptsValues["buttonText"];
				var allSel= document.getElementsByTagName("input");
				for (var i in allSel)
					if (allSel[i])
					if (allSel[i].type=="button")
				 		allSel[i].style["color"] = skinOptsValuesTmp["buttonText"];

				var allSel11= document.getElementsByTagName("select");
				for (var i in allSel11)
				{
					if(allSel11[i]!=null && allSel11[i]!=undefined)
					{
						if( allSel11[i].type!=undefined )
						{
							allSel11[i].style["color"] = skinOptsValuesTmp["buttonText"];
						}
					}
				}
			break;
		case "colorBtn_button":

				if (x)
					skinOptsValuesTmp["button"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["button"]=skinOptsValues["button"];

				//change color select combo
				//var allElm = document.getElements();
				//if(allElm)
				//-------------------------

				var allSel11= document.getElementsByTagName("select");
				for (var i in allSel11)
				{
					if( allSel11[i]!=null )
					{
						if( allSel11[i].type!=undefined )
						{
							allSel11[i].style["backgroundColor"] = skinOptsValuesTmp["button"];
						}
					}
				}
				var allSel= document.getElementsByTagName("input");
				for (var i in allSel)
					if (allSel[i])
					{

						if (allSel[i].type=="button" && allSel[i].className!="optColorBtn" && allSel[i].id!="colorBtn")//
				 			allSel[i].style["backgroundColor"] = skinOptsValuesTmp["button"];
					}





				var skip=0;
				if (skinOptsValuesTmp["button"])
			 		color = new RGBColor(skinOptsValuesTmp["button"]);
				else if (document.getElementById("helpBtn"))
					color = new RGBColor(getStyle(document.getElementById("helpBtn"),"background-color","backgroundColor"));
				else if (document.getElementById("loginBtn"))
					color = new RGBColor(getStyle(document.getElementById("loginBtn"),"background-color","backgroundColor"));
				else
					skip=1;
				if (skip!=1)
				if (color.ok) {
				    color.r=parseInt(color.r*3/4);
				    color.g=parseInt(color.g*3/4);
				    color.b=parseInt(color.b*3/4);
				    skinOptsValuesTmp["buttonover"] = color.toHex();

				}

				var allSel22 = document.getElementsByTagName("span");
				for (var i in allSel22)
					if (allSel22[i])
					{
						if (allSel22[i].className=="optionsTab")
				 			allSel22[i].style["backgroundColor"] = skinOptsValuesTmp["button"];

						if (allSel22[i].className=="optionsTab active")
				 			allSel22[i].style["backgroundColor"] = skinOptsValuesTmp["buttonover"];
					}

			break;
		case "colorBtn_buttonBorder":


		        if (x)
					skinOptsValuesTmp["buttonBorder"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["buttonBorder"]=skinOptsValues["buttonBorder"];
				var allSel= document.getElementsByTagName("input");
				for (var i in allSel)
				{
					if (allSel[i])
					{
						if (allSel[i].type=="button")
						{
				 			//if(allSel[i].className=="optionsTab")

							allSel[i].style["borderColor"] = skinOptsValuesTmp["buttonBorder"];
						}
					}
				}

				/*var allSel11= document.getElementsByTagName("select");
				for (var i in allSel11)
				{
					if( allSel11[i].style["borderColor"]!=null && allSel11[i].style["borderColor"]!=undefined )
					{
						allSel11[i].style["borderColor"] = skinOptsValuesTmp["buttonBorder"];
					}
				}	*/


				var allSel22 = document.getElementsByTagName("span");
				for (var i in allSel22)
					if (allSel22[i])
					{
						if (allSel22[i].className=="optionsTab")
				 			allSel22[i].style["borderColor"] = skinOptsValuesTmp["buttonBorder"];

						if (allSel22[i].className=="optionsTab active")
				 			allSel22[i].style["borderColor"] = skinOptsValuesTmp["buttonBorder"];
					}
			break;
		case "colorBtn_inputBoxBackground":
				if (x)
					skinOptsValuesTmp["inputBoxBackground"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["inputBoxBackground"]=skinOptsValues["inputBoxBackground"];
				if (document.getElementById("textInputMsgDiv_alpha"))
					document.getElementById("textInputMsgDiv_alpha").style["backgroundColor"] = skinOptsValuesTmp["inputBoxBackground"];
				var allSel= document.getElementsByTagName("textarea");
				for (var i in allSel)
					if (allSel[i])
					if (allSel[i].className=="textInput")
				 		allSel[i].style["backgroundColor"] = skinOptsValuesTmp["inputBoxBackground"];
				var allSel= document.getElementsByTagName("input");
				for (var i in allSel)
					if (allSel[i])
					if (allSel[i].className=="pmW_input" || allSel[i].className=="pW_input" || allSel[i].className=="textInput")
				 		allSel[i].style["backgroundColor"] = skinOptsValuesTmp["inputBoxBackground"];
			break;
		case "colorBtn_borderColor":
				if (x)
					skinOptsValuesTmp["borderColor"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["borderColor"]=skinOptsValues["borderColor"];
				var allSel= document.getElementsByTagName("div");
				for (var i in allSel)
					if (allSel[i]){
						if (allSel[i].className != null)
							if (allSel[i].className=="pW_messages" || allSel[i].className=="window")
				 				allSel[i].style["borderColor"] = skinOptsValuesTmp["borderColor"];
					 	if (allSel[i].id != null)
					 		if (allSel[i].id=="roomList")
					 			allSel[i].style["borderColor"] = skinOptsValuesTmp["borderColor"];
					 		if (allSel[i].id=="chatMessages")
					 			allSel[i].style["borderColor"] = skinOptsValuesTmp["borderColor"];
			 		}

				var allSel= document.getElementsByTagName("textarea");
				for (var i in allSel)
					if (allSel[i])
					if (allSel[i].className=="textInput" || allSel[i].className=="textInputMsg")
				 		allSel[i].style["borderColor"] = skinOptsValuesTmp["borderColor"];
				var allSel= document.getElementsByTagName("input");
				for (var i in allSel)
					if (allSel[i])
					if (allSel[i].className=="pmW_input" || allSel[i].className=="pW_input" || allSel[i].className=="textInput")
						allSel[i].style["borderColor"] = skinOptsValuesTmp["borderColor"];

			break;
		case "colorBtn_dialog":
			        if (x)
					skinOptsValuesTmp["dialog"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["dialog"]=skinOptsValues["dialog"];
				var allSel= document.getElementsByTagName("div");
				for (var i in allSel)
					if (allSel[i])
						if (allSel[i].className=="window")
				 			allSel[i].style["backgroundColor"] = skinOptsValuesTmp["dialog"];


				document.getElementById("TableColor").style["backgroundColor"]=skinOptsValuesTmp["dialog"];
				//document.getElementById("TableColor").setAttribute('BORDERCOLOR',skinOptsValuesTmp["dialog"]);
				//document.getElementById("TableColor").setAttribute('BORDERCOLOR',skinOptsValuesTmp["dialog"]);
				//document.getElementById("TableColor1").style["borderWidth"]=;
				document.getElementById("colorPicker").style["backgroundColor"]=skinOptsValuesTmp["dialog"];
			break;
		case "colorBtn_dialogTitle":
		        if (x)
					skinOptsValuesTmp["dialogTitle"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["dialogTitle"]=skinOptsValues["dialogTitle"];


				if(document.getElementById("AC_mainTitleRow"))
					document.getElementById("AC_mainTitleRow").style["backgroundColor"]=skinOptsValuesTmp["dialogTitle"];


				var allSel= document.getElementsByTagName("div");
				for (var i in allSel)
					if (allSel[i])
						if (allSel[i].className=="windowTitleRow")
				 			allSel[i].style["backgroundColor"] = skinOptsValuesTmp["dialogTitle"];
			break;
		case "colorBtn_userListBackground":
				if (x)
					skinOptsValuesTmp["userListBackground"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["userListBackground"]=skinOptsValues["userListBackground"];
				if(document.getElementById("roomList_alpha"))
					document.getElementById("roomList_alpha").style["backgroundColor"]=skinOptsValuesTmp["userListBackground"];
			break;
		case "colorBtn_room":
		        if (x)
					skinOptsValuesTmp["room"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["room"]=skinOptsValues["room"];
				var allSel= document.getElementsByTagName("div");
				for (var i in allSel)
					if (allSel[i])
						if (allSel[i].className=="roomTitle" || allSel[i].className=="roomTitle disabled")
				 			allSel[i].style["backgroundColor"] = skinOptsValuesTmp["room"];
			break;
		case "colorBtn_roomText":
		        if (x)
					skinOptsValuesTmp["roomText"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["roomText"]=skinOptsValues["roomText"];
				var allSel= document.getElementsByTagName("div");
				for (var i in allSel)
					if (allSel[i])
						if (allSel[i].className=="roomTitle")
				 			allSel[i].style["color"] = skinOptsValuesTmp["roomText"];
				 		else if (allSel[i].className=="roomTitle disabled"){
					 		if (skinOptsValuesTmp["roomText"]){
						 		var color = new RGBColor(skinOptsValuesTmp["roomText"]);
								if (color.ok) {
									if ((color.r+color.g+color.b)/3>150)
										rap=2./3;
									else if ((color.r+color.g+color.b)/3>50)
										rap=3./2;
									else if ((color.r+color.g+color.b)/3>20)
										rap=4./2;
									else{
										rap=6./2;
										color.r+=10; color.g+=10; color.b+=10;
									}
									color.r = Math.min(parseInt(color.r*rap),255);
								    color.g = Math.min(parseInt(color.g*rap),255);
								    color.b = Math.min(parseInt(color.b*rap),255);
								    allSel[i].style["color"] = color.toHex();
								}
							}else
								allSel[i].style["color"] = skinOptsValuesTmp["roomText"];
				 		}
			break;
		case "colorBtn_bodyText":
				if (browserISIE7())
					break;
				if (x)
					skinOptsValuesTmp["bodyText"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["bodyText"]=skinOptsValues["bodyText"];
				if (browserISIE7())
					break;
				document.getElementById("AC_main").style["color"]=skinOptsValuesTmp["bodyText"];
				/*var allSel= document.getElementsByTagName("body");
				for (var i in allSel)
					if (allSel[i])
						allSel[i].style["color"]=skinOptsValuesTmp["bodyText"];*/
				document.body.style["color"]=skinOptsValuesTmp["bodyText"];
				//document.bgColor=skinOptsValuesTmp["bodyText"];
				var allSel= document.getElementsByTagName("div");
				for (var i in allSel)
					if (allSel[i])
					if (allSel[i].className != null)
					if (allSel[i].className=="window")
				 		allSel[i].style["color"] = skinOptsValuesTmp["bodyText"];
			break;
		case "colorBtn_publicLogBackground":
				if (x)
					skinOptsValuesTmp["publicLogBackground"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["publicLogBackground"]=skinOptsValues["publicLogBackground"];
				if(document.getElementById("chatMessages_alpha"))
					document.getElementById("chatMessages_alpha").style["backgroundColor"]=skinOptsValuesTmp["publicLogBackground"];
			break;
		case "colorBtn_privateLogBackground":
				if (x)
					skinOptsValuesTmp["privateLogBackground"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["privateLogBackground"]=skinOptsValues["privateLogBackground"];
				var allSel= document.getElementsByTagName("div");
				for (var i in allSel)
					if (allSel[i])
						if (allSel[i].className=="pW_messages")
				 			allSel[i].style["backgroundColor"] = skinOptsValuesTmp["privateLogBackground"];
			break;
		case "colorBtn_enterRoomNotify":
				if (x)
					skinOptsValuesTmp["enterRoomNotify"]=x.value;//style["backgroundColor"];
				else
					skinOptsValuesTmp["enterRoomNotify"]=skinOptsValues["enterRoomNotify"];
			break;
		case "colorBtn_roomUser":

				if (x)
				{
					skinOptsValuesTmp["roomUser"]=x.value;//style["backgroundColor"];
				}
				else
				{
					skinOptsValuesTmp["roomUser"]=skinOptsValues["roomUser"];
				}

				var allSel= document.getElementsByTagName("div");
				for (var i in allSel)
					if (allSel[i])
						if (allSel[i].className == "roomUser")
						{
							allSel[i].style["backgroundColor"] = skinOptsValuesTmp["roomUser"];
						}


			break;
		case "colorBtn_contextMenu":
				if (x)
				{
					skinOptsValuesTmp["contextMenu"]=x.value;//style["backgroundColor"];
				}
				else
				{
					if(skinOptsValues["contextMenu"])
						skinOptsValuesTmp["contextMenu"] = skinOptsValues["contextMenu"];
				}

				if(document.getElementById("contextMenu"))
					document.getElementById("contextMenu").style["backgroundColor"] = skinOptsValuesTmp["contextMenu"];


			break;
	}

	document.body.style["display"] = "none";
	document.body.style["display"] = "block";

}
function getStyle(x,styleProp,stylePropF){
	if (!(stylePropF))
		stylePropF=styleProp;

	if (x.currentStyle)
		var y = x.currentStyle[stylePropF];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

function setValueColorArray(currentStyle, colorName, color)
{
	if ( styleArray[currentStyle['selectedIndex']] == undefined )
	{
		colorArray[colorName] = color;
	}
}

function setColorOptions()
{
	var currentStyle = document.getElementById ( "list_themes" );


  if(document.getElementById("colorBtn_background")){


  if(getBrowser ()==3)
  	var color = getStyle(document.body,"background-color","backgroundColor");
else
	var color = document.bgColor;


	document.getElementById("colorBtn_background").value = color;//style["backgroundColor"]=color;

	//TempArray["background"] = document.bgColor;

	skinOptsValues["background"]=color;
	skinOptsValuesTmp["background"]=color;

	setValueColorArray(currentStyle,'colorBtn_background', color);
	//TempArray["background"]=document.bgColor;
  }
  if(document.getElementById("colorBtn_titleText"))
  {
 	var color=getStyle(document.getElementById("AC_mainTitleRow"),"color");

	/*if( document.getElementById("colorBtn_titleText").style["backgroundColor"] )
  		TempArray["titleText"] = document.getElementById("colorBtn_titleText").style["backgroundColor"];
	else
		TempArray["titleText"] = color;*/

	document.getElementById("colorBtn_titleText").value = color;//style["backgroundColor"]= color;
	skinOptsValues["titleText"]=color;
	skinOptsValuesTmp["titleText"]=color;

	setValueColorArray(currentStyle,'colorBtn_titleText', color);
	//TempArray["titleText"]=color;
  }
  if(document.getElementById("colorBtn_buttonText")){
  var color=getStyle(document.getElementById("helpBtn"),"color","color");

	/*if( document.getElementById("colorBtn_buttonText").style["backgroundColor"] )
  		TempArray["buttonText"] = document.getElementById("colorBtn_buttonText").style["backgroundColor"];
	else
		TempArray["buttonText"] = color;*/

	document.getElementById("colorBtn_buttonText").value = color;//style["backgroundColor"]= color;
	skinOptsValues["buttonText"]=color;
	skinOptsValuesTmp["buttonText"]=color;
	setValueColorArray(currentStyle,'colorBtn_buttonText', color);
	//TempArray["buttonText"]=color;
  }
  if(document.getElementById("colorBtn_button")){
	var color=getStyle(document.getElementById("helpBtn"),"background-color","backgroundColor");

	/*if( document.getElementById("colorBtn_button").style["backgroundColor"] )
  		TempArray["button"] = document.getElementById("colorBtn_button").style["backgroundColor"];
	else
		TempArray["button"] = color;*/

	document.getElementById("colorBtn_button").value = color;//style["backgroundColor"]= color;
	skinOptsValues["button"]=color;
	skinOptsValuesTmp["button"]=color;
	setValueColorArray(currentStyle,'colorBtn_button', color);
	//TempArray["button"]=color;
  }
  if(document.getElementById("colorBtn_buttonBorder")){

  	var color = getStyle(document.getElementById("optionsTab2"),"border-left-color","borderLeftColor");

	/*if( document.getElementById("colorBtn_buttonBorder").style["backgroundColor"] )
  		TempArray["buttonBorder"] = document.getElementById("colorBtn_buttonBorder").style["backgroundColor"];
	else
		TempArray["buttonBorder"] = color;	*/


	document.getElementById("colorBtn_buttonBorder").value = color;//style["backgroundColor"]= color;
	skinOptsValues["buttonBorder"]=color;
	skinOptsValuesTmp["buttonBorder"]=color;
	setValueColorArray(currentStyle,'colorBtn_buttonBorder', color);

  }

  if(document.getElementById("colorBtn_inputBoxBackground")){
	var color=getStyle(document.getElementById("textInputMsgDiv_alpha"),"background-color","backgroundColor");

	/*if( document.getElementById("colorBtn_inputBoxBackground").style["backgroundColor"] )
  		TempArray["inputBoxBackground"] = document.getElementById("colorBtn_inputBoxBackground").style["backgroundColor"];
	else
		TempArray["inputBoxBackground"] = color;*/

	document.getElementById("colorBtn_inputBoxBackground").value = color;//style["backgroundColor"]= color;
	skinOptsValues["inputBoxBackground"]=color;
	skinOptsValuesTmp["inputBoxBackground"]=color;
	setValueColorArray(currentStyle,'colorBtn_inputBoxBackground', color);
	//TempArray["inputBoxBackground"]=color;
  }
  if(document.getElementById("colorBtn_borderColor")){
	var color=getStyle(document.getElementById("roomList"),"border-top-color","borderColor");

	/*if( document.getElementById("colorBtn_borderColor").style["backgroundColor"] )
  		TempArray["borderColor"] = document.getElementById("colorBtn_borderColor").style["backgroundColor"];
	else
		TempArray["borderColor"] = color;*/

	document.getElementById("colorBtn_borderColor").value = color;//style["backgroundColor"]= color;
	skinOptsValues["borderColor"]=color;
	skinOptsValuesTmp["borderColor"]=color;
	setValueColorArray(currentStyle,'colorBtn_borderColor', color);
	//TempArray["borderColor"]=color;
  }
  if(document.getElementById("colorBtn_dialog")){
	var color;
	if(skinOptsValues["dialog"])
		color=skinOptsValues["dialog"];
	else
		color=getStyle(document.getElementById("optionsWindow"),"background-color","backgroundColor");


	/*if( document.getElementById("colorBtn_dialog").style["backgroundColor"] )
  		TempArray["dialog"] = document.getElementById("colorBtn_dialog").style["backgroundColor"];
	else
		TempArray["dialog"] = color;*/

	document.getElementById("colorBtn_dialog").value = color;//style["backgroundColor"]= color;
	skinOptsValues["dialog"]=color;
	skinOptsValuesTmp["dialog"]=color;
	setValueColorArray(currentStyle,'colorBtn_dialog', color);
	//TempArray["dialog"]=color;
  }
  if(document.getElementById("colorBtn_dialogTitle")){
	var color;
	if(skinOptsValues["dialogTitle"])
		color=skinOptsValues["dialogTitle"];
	else
		color=getStyle(document.getElementById("optionsWindowwinTitleRow"),"background-color","backgroundColor");

	/*if( document.getElementById("colorBtn_dialogTitle").style["backgroundColor"] )
  		TempArray["dialogTitle"] = document.getElementById("colorBtn_dialogTitle").style["backgroundColor"];
	else
		TempArray["dialogTitle"] = color;	*/

	document.getElementById("colorBtn_dialogTitle").value = color;//style["backgroundColor"]= color;
	skinOptsValues["dialogTitle"]=color;
	skinOptsValuesTmp["dialogTitle"]=color;
	setValueColorArray(currentStyle,'colorBtn_dialogTitle', color);
	//TempArray["dialogTitle"]=color;
  }
  if(document.getElementById("colorBtn_userListBackground")){
	var color;
	if(skinOptsValues["userListBackground"])
		color=skinOptsValues["userListBackground"];
	else
		color=getStyle(document.getElementById("roomList_alpha"),"background-color","backgroundColor");

	/*if( document.getElementById("colorBtn_userListBackground").style["backgroundColor"] )
  		TempArray["userListBackground"] = document.getElementById("colorBtn_userListBackground").style["backgroundColor"];
	else
		TempArray["userListBackground"] = color;	*/


	document.getElementById("colorBtn_userListBackground").value = color;//style["backgroundColor"]= color;
	skinOptsValues["userListBackground"]=color;
	skinOptsValuesTmp["userListBackground"]=color;
	setValueColorArray(currentStyle, 'colorBtn_userListBackground', color);
	//TempArray["userListBackground"]=color;
  }
  if(document.getElementById("colorBtn_room")){
	var color;
	if(skinOptsValues["room"])
		color=skinOptsValues["room"];
	else{
		var allSel= document.getElementsByTagName("div");
		for (var i in allSel)
			if (allSel[i])
			if (allSel[i].className=="roomTitle")
				color=getStyle(allSel[i],"background-color","backgroundColor");
	}

	/*if( document.getElementById("colorBtn_room").style["backgroundColor"] )
  		TempArray["room"] = document.getElementById("colorBtn_room").style["backgroundColor"];
	else
		TempArray["room"] = color;*/

	document.getElementById("colorBtn_room").value = color;//style["backgroundColor"]=color;
	skinOptsValues["room"]=color;
	skinOptsValuesTmp["room"]=color;
	setValueColorArray(currentStyle,'colorBtn_room', color);
	//TempArray["room"]=color;
  }
  if(document.getElementById("colorBtn_roomText")){
	var color;
	if(skinOptsValues["roomText"])
		color=skinOptsValues["roomText"];
	else{
		var allSel= document.getElementsByTagName("div");
		for (var i in allSel)
			if (allSel[i])
			if (allSel[i].className=="roomTitle")
				color=getStyle(allSel[i],"color");
	}

	/*if( document.getElementById("colorBtn_roomText").style["backgroundColor"] )
  		TempArray["roomText"] = document.getElementById("colorBtn_roomText").style["backgroundColor"];
	else
		TempArray["roomText"] = color;*/

	document.getElementById("colorBtn_roomText").value = color;//style["backgroundColor"]=color;
	skinOptsValues["roomText"]=color;
	skinOptsValuesTmp["roomText"]=color;
	setValueColorArray(currentStyle, 'colorBtn_roomText', color);
	//TempArray["roomText"]=color;
  }
  if(document.getElementById("colorBtn_bodyText")){
	var color=getStyle(document.body,"color");

	/*if( document.getElementById("colorBtn_bodyText").style["backgroundColor"] )
  		TempArray["bodyText"] = document.getElementById("colorBtn_bodyText").style["backgroundColor"];
	else
		TempArray["bodyText"] = color;*/

	document.getElementById("colorBtn_bodyText").value = color;//style["backgroundColor"]=color;
	skinOptsValues["bodyText"]=color;
	skinOptsValuesTmp["bodyText"]=color;
	setValueColorArray(currentStyle, 'colorBtn_bodyText', color);
	//TempArray["bodyText"]=color;
  }
  if(document.getElementById("colorBtn_publicLogBackground")){
	var color=getStyle(document.getElementById("chatMessages_alpha"),"background-color","backgroundColor");
	/*
	if( document.getElementById("colorBtn_publicLogBackground").style["backgroundColor"] )
  		TempArray["publicLogBackground"] = document.getElementById("colorBtn_publicLogBackground").style["backgroundColor"];
	else
		TempArray["publicLogBackground"] = color;*/

	document.getElementById("colorBtn_publicLogBackground").value = color;//style["backgroundColor"]= color;
	skinOptsValues["publicLogBackground"]=color;
	skinOptsValuesTmp["publicLogBackground"]=color;
	setValueColorArray(currentStyle, 'colorBtn_publicLogBackground', color);
	//TempArray["publicLogBackground"]=color;
  }
  if(document.getElementById("colorBtn_privateLogBackground")){
	var color;
	if(skinOptsValues["privateLogBackground"])
		color=skinOptsValues["privateLogBackground"];
	else{
		if(!(document.getElementById("divtest"))){
			addDiv (document.getElementById ("layoutDiv"), {"class": "pW_messages", "display": "none"}, {"id": "divtest"});
	  	}
		color=getStyle(document.getElementById("divtest"),"background-color","backgroundColor");
	}

	/*if( document.getElementById("colorBtn_privateLogBackground").style["backgroundColor"] )
  		TempArray["privateLogBackground"] = document.getElementById("colorBtn_privateLogBackground").style["backgroundColor"];
	else
		TempArray["privateLogBackground"] = color;*/

	document.getElementById("colorBtn_privateLogBackground").value = color;//style["backgroundColor"]= color;
	skinOptsValues["privateLogBackground"]=color;
	skinOptsValuesTmp["privateLogBackground"]=color;
	setValueColorArray(currentStyle, 'colorBtn_privateLogBackground', color);
	//TempArray["privateLogBackground"]=color;
  }
  if(document.getElementById("colorBtn_enterRoomNotify")){
	var color;
	if(skinOptsValues["enterRoomNotify"]!="")
		color=skinOptsValues["enterRoomNotify"];
	else
		color=getStyle(document.getElementById("chatMessages"),"color");

	/*if( document.getElementById("colorBtn_enterRoomNotify").style["backgroundColor"] )
  		TempArray["enterRoomNotify"] = document.getElementById("colorBtn_enterRoomNotify").style["backgroundColor"];
	else
		TempArray["enterRoomNotify"] = color;*/

	document.getElementById("colorBtn_enterRoomNotify").value = color;//style["backgroundColor"]= color;
	skinOptsValues["enterRoomNotify"]=color;
	skinOptsValuesTmp["enterRoomNotify"]=color;
	setValueColorArray(currentStyle, 'colorBtn_enterRoomNotify', color);
	//TempArray["enterRoomNotify"]=color;
  }




   if(document.getElementById("colorBtn_roomUser")){
	var color;
	if(skinOptsValues["roomUser"]!="")
		color=skinOptsValues["roomUser"];
	else
	{
		var allSel= document.getElementsByTagName("div");
		for (var i in allSel)
			if (allSel[i])
				if (allSel[i].className == "roomUser")
				{
					color=getStyle(allSel[i],"background-color","backgroundColor");
					break;
				}
	}

	document.getElementById("colorBtn_roomUser").value = color;//style["backgroundColor"]= color;
	skinOptsValues["roomUser"]=color;
	skinOptsValuesTmp["roomUser"]=color;
	setValueColorArray(currentStyle,'colorBtn_roomUser', color);
	}

  if(document.getElementById("colorBtn_contextMenu")){

  	var color;

	if(skinOptsValues["contextMenu"]!="")
		color=skinOptsValues["contextMenu"];
	else
	{
		if(document.getElementById("contextMenu"))
		{
			color=getStyle(document.getElementById("contextMenu"),"background-color","backgroundColor");
		}
		else
		{
			color = "#5469bc";
		}
	}
	document.getElementById("colorBtn_contextMenu").value = color;//style["backgroundColor"]= color;
	skinOptsValues["contextMenu"]=color;
	skinOptsValuesTmp["contextMenu"]=color;
	setValueColorArray(currentStyle,'colorBtn_contextMenu', color);
	 }

  if ( styleArray[currentStyle['selectedIndex']] == undefined &&  colorArray != undefined)
  {
  	 styleArray[currentStyle['selectedIndex']] = colorArray;
	 colorArray = new Array;
  }


}
function setTempColorOptions(){
  TempArray["background"] = document.bgColor;


	var color1=getStyle(document.getElementById("AC_mainTitleRow"),"color");

	/*if( document.getElementById("colorBtn_titleText").style["backgroundColor"] )
  		TempArray["titleText"] = document.getElementById("colorBtn_titleText").style["backgroundColor"];
	else*/
		TempArray["titleText"] = checkColor( color1 );


  //if(document.getElementById("colorBtn_buttonText")){
	var color2=getStyle(document.getElementById("helpBtn"),"color");

	//if( document.getElementById("colorBtn_buttonText").style["backgroundColor"] )
  		//TempArray["buttonText"] = document.getElementById("colorBtn_buttonText").style["backgroundColor"];
	//else
		TempArray["buttonText"] = checkColor(  color2 );

	//document.getElementById("colorBtn_buttonText").style["backgroundColor"]= color;
	//skinOptsValues["buttonText"]=color;
	//skinOptsValuesTmp["buttonText"]=color;
	//TempArray["buttonText"]=color;
  //}
  //if(document.getElementById("colorBtn_button")){
	var color3=getStyle(document.getElementById("helpBtn"),"background-color","backgroundColor");

	//if( document.getElementById("colorBtn_button").style["backgroundColor"] )
  		//TempArray["button"] = document.getElementById("colorBtn_button").style["backgroundColor"];
	//else
		TempArray["button"] =  checkColor( color3 );

	//document.getElementById("colorBtn_button").style["backgroundColor"]= color;
	//skinOptsValues["button"]=color;
	//skinOptsValuesTmp["button"]=color;
	//TempArray["button"]=color;
  //}
  //if(document.getElementById("colorBtn_buttonBorder")){

  	var color4 = getStyle(document.getElementById("helpBtn"),"border-left-color","borderColor");

	//if( document.getElementById("colorBtn_buttonBorder").style["backgroundColor"] )
  		//TempArray["buttonBorder"] = document.getElementById("colorBtn_buttonBorder").style["backgroundColor"];
	//else
		TempArray["buttonBorder"] = checkColor( color4 );


	//document.getElementById("colorBtn_buttonBorder").style["backgroundColor"]= color;
	//skinOptsValues["buttonBorder"]=color;
	//skinOptsValuesTmp["buttonBorder"]=color;

 // }
 // if(document.getElementById("colorBtn_inputBoxBackground")){
	var color5=getStyle(document.getElementById("textInputMsgDiv_alpha"),"background-color","backgroundColor");

	//if( document.getElementById("colorBtn_inputBoxBackground").style["backgroundColor"] )
  		//TempArray["inputBoxBackground"] = document.getElementById("colorBtn_inputBoxBackground").style["backgroundColor"];
	//else
		TempArray["inputBoxBackground"] = checkColor( color5 );

	//document.getElementById("colorBtn_inputBoxBackground").style["backgroundColor"]= color;
	//skinOptsValues["inputBoxBackground"]=color;
	//skinOptsValuesTmp["inputBoxBackground"]=color;
	//TempArray["inputBoxBackground"]=color;
  //}
  //if(document.getElementById("colorBtn_borderColor")){
	var color6=getStyle(document.getElementById("roomList"),"border-top-color","borderColor");

	//if( document.getElementById("colorBtn_borderColor").style["backgroundColor"] )
  		//TempArray["borderColor"] = document.getElementById("colorBtn_borderColor").style["backgroundColor"];
	//else
		TempArray["borderColor"] = checkColor( color6 );

	//document.getElementById("colorBtn_borderColor").style["backgroundColor"]= color;
	//skinOptsValues["borderColor"]=color;
	//skinOptsValuesTmp["borderColor"]=color;
	//TempArray["borderColor"]=color;
  //}
  //if(document.getElementById("colorBtn_dialog")){
	var color7;
	//if(skinOptsValues["dialog"])
		//color=skinOptsValues["dialog"];
	//else
		color7=getStyle(document.getElementById("optionsWindow"),"background-color","backgroundColor");


	//if( document.getElementById("colorBtn_dialog").style["backgroundColor"] )
  		//TempArray["dialog"] = document.getElementById("colorBtn_dialog").style["backgroundColor"];
	//else
		TempArray["dialog"] = checkColor( color7 );

	//document.getElementById("colorBtn_dialog").style["backgroundColor"]= color;
	//skinOptsValues["dialog"]=color;
	//skinOptsValuesTmp["dialog"]=color;
	//TempArray["dialog"]=color;
  //}
 // if(document.getElementById("colorBtn_dialogTitle")){
	var color8;
	//if(skinOptsValues["dialogTitle"])
		//color=skinOptsValues["dialogTitle"];
	//else
		color8=getStyle(document.getElementById("optionsWindowwinTitleRow"),"background-color","backgroundColor");

	//if( document.getElementById("colorBtn_dialogTitle").style["backgroundColor"] )
  		//TempArray["dialogTitle"] = document.getElementById("colorBtn_dialogTitle").style["backgroundColor"];
	//else
		TempArray["dialogTitle"] = checkColor( color8 );


	var color9;

		color9=getStyle(document.getElementById("optionsWindowwinTitleRow"),"background-color","backgroundColor");

		TempArray["dialogTitle"] =  checkColor( color9 );

	var color10;

		color10=getStyle(document.getElementById("roomList_alpha"),"background-color","backgroundColor");

		TempArray["userListBackground"] = checkColor( color10 ) ;

	var color11;

		var allSel= document.getElementsByTagName("div");
		for (var i in allSel)
			if (allSel[i])
			if (allSel[i].className=="roomTitle")
				color11=getStyle(allSel[i],"background-color","backgroundColor");

		TempArray["room"] = checkColor( color11 );

	var color12;

		var allSel= document.getElementsByTagName("div");
		for (var i in allSel)
			if (allSel[i])
			if (allSel[i].className=="roomTitle")
				color12=getStyle(allSel[i],"color");

		TempArray["roomText"] = checkColor( color12 );

	var color13=getStyle(document.body,"color");

		TempArray["bodyText"] = checkColor( color13 );

	var color14=getStyle(document.getElementById("chatMessages_alpha"),"background-color","backgroundColor");

	//if( document.getElementById("colorBtn_publicLogBackground").style["backgroundColor"] )
  	//	TempArray["publicLogBackground"] = document.getElementById("colorBtn_publicLogBackground").style["backgroundColor"];
	//else

		TempArray["publicLogBackground"] = checkColor( color14 );

	//document.getElementById("colorBtn_publicLogBackground").style["backgroundColor"]= color;
	//skinOptsValues["publicLogBackground"]=color;
	//skinOptsValuesTmp["publicLogBackground"]=color;
	//TempArray["publicLogBackground"]=color;
  //}
  //if(document.getElementById("colorBtn_privateLogBackground")){
	var color15;
	//if(skinOptsValues["privateLogBackground"])
	//	color=skinOptsValues["privateLogBackground"];
	//else{
		if(!(document.getElementById("divtest"))){
			addDiv (document.getElementById ("layoutDiv"), {"class": "pW_messages", "display": "none"}, {"id": "divtest"});
	  	}
		color15=getStyle(document.getElementById("divtest"),"background-color","backgroundColor");
	//}

	//if( document.getElementById("colorBtn_privateLogBackground").style["backgroundColor"] )
  		//TempArray["privateLogBackground"] = document.getElementById("colorBtn_privateLogBackground").style["backgroundColor"];
	//else
		TempArray["privateLogBackground"] = checkColor( color15 );

	//document.getElementById("colorBtn_privateLogBackground").style["backgroundColor"]= color;
	//skinOptsValues["privateLogBackground"]=color;
	//skinOptsValuesTmp["privateLogBackground"]=color;
	///TempArray["privateLogBackground"]=color;
  //}
 // if(document.getElementById("colorBtn_enterRoomNotify")){
	var color16;
	//if(skinOptsValues["enterRoomNotify"]!="")
	//	color=skinOptsValues["enterRoomNotify"];
	//else
		color16=getStyle(document.getElementById("chatMessages"),"color");

	//if( document.getElementById("colorBtn_enterRoomNotify").style["backgroundColor"] )
  	//	TempArray["enterRoomNotify"] = document.getElementById("colorBtn_enterRoomNotify").style["backgroundColor"];
	//else
		TempArray["enterRoomNotify"] = checkColor( color16 );

	//document.getElementById("colorBtn_enterRoomNotify").style["backgroundColor"]= color;
	//skinOptsValues["enterRoomNotify"]=color;
	//skinOptsValuesTmp["enterRoomNotify"]=color;
	//TempArray["enterRoomNotify"]=color;
  //}
  var color17;
  if(document.getElementById("contextMenu"))
  {
  	color17 = getStyle(document.getElementById("contextMenu"),"background-color","backgroundColor");
  	TempArray["contextMenu"] = checkColor( color17 );
}
//else


  var color18;
  var allSel= document.getElementsByTagName("div");
		for (var i in allSel)
			if (allSel[i])
			if (allSel[i].className=="roomUser")
				color18=getStyle(allSel[i],"background-color","backgroundColor");


  TempArray["roomUser"] = checkColor(color18);


}

function checkColor(color)
{
	color = color.toUpperCase();

	switch (color)
	{
		case 'TRANSPARENT'  : color = '#DCDCDC'; break;
		case 'RED'     		: color = '#FF0000'; break;
		case 'BLACK'   		: color = '#000000'; break;
		case 'GREEN'   		: color = '#008000'; break;
		case 'SILVER'  		: color = '#C0C0C0'; break;
		case 'LIME'    		: color = '#00FF00'; break;
		case 'GRAY'    		: color = '#808080'; break;
		case 'OLIVE'   		: color = '#808000'; break;
		case 'WHITE'   		: color = '#FFFFFF'; break;
		case 'YELLOW'  		: color = '#FFFF00'; break;
		case 'MAROON'  		: color = '#800000'; break;
		case 'NAVY'    		: color = '#000080'; break;
		case 'BLUE'    		: color = '#0000FF'; break;
		case 'PURPLE'  		: color = '#800080'; break;
		case 'TEAL'    		: color = '#008080'; break;
		case 'FUCHSIA' 		: color = '#FF00FF'; break;
		case 'AQUA'    		: color = '#00FFFF'; break;
	}

	return color;
}

function saveTempOptions(){

//avatar settings----------------------------------------------------------------------------------



	TempArray["theme_old"]=config["theme"]["name"];

	if(document.getElementById("checkMCAvatar"))
	{
  		TempArrayEffect["avatarsmainchat"] = config["effects"]["avatarsmainchat"];
	}
	if(document.getElementById("checkRLAvatar"))
	{
		TempArrayEffect["avatarsroomlist"] = config["effects"]["avatarsroomlist"];
	}
 	TempArrayEffect["avatarsmainchat_allow_override"]	=  config["effects"]["avatarsmainchat_allow_override"];
	TempArrayEffect["avatarsroomlist_allow_override"]	=  config["effects"]["avatarsroomlist_allow_override"];
	if(document.getElementById("showBackgroundCh"))
	{
		TempArrayEffect["showbackground"]	= config["effects"]["showbackground"];
	}
	TempArrayEffect["splashWindow"] =config["splashWindow"];
   	TempArrayEffect["mytextcolor"] = config["itc"]["mytextcolor"];

	TempArrayAvatar["avatarsmainchat-avatar"] = config["effects"]["avatarsmainchat-avatar"];
	TempArrayAvatar["avatarsroomlist-avatar"] = config["effects"]["avatarsroomlist-avatar"];
//end avatar settings------------------------------------------------------------------------------


//sound setting------------------------------------------------------------------------------------
  for (var i = 0; i < parseInt (optionsSound.length); i++)
  {
  	if (config["sound"]["ev"][optionsSound[i]]["muted"] == false)
	  if(document.getElementById("mute" + optionsSound[i]))
	 	TempArraySound[optionsSound[i]] = false;

	if (config["sound"]["ev"][optionsSound[i]]["muted"] == true)
	  if(document.getElementById("mute" +optionsSound[i]))
	 	TempArraySound[optionsSound[i]] = true;
  }
	 TempArraySound["All"] = config["sound"]["muteAll"];
	TempArraySound["volume"] = config["sound"]["volume"];
//end sound setting---------------------------------------------------------------------------------


//text settings--------------------------------------------------------------------------------------
	var itcSelect = document.getElementById ("itcSelect");
  	TempArrayInc["fontSize"] = config["itc"][itcSelect.value]["fontSize"];
	TempArrayInc["mainchat"] = itcSelect.value;
	TempArrayInc["fontFamily"] = config["itc"][itcSelect.value]["fontFamily"];
//end text settings----------------------------------------------------------------------------------

	TempArrayInc["currentLanguage"] = config["currentLanguage"];

}
function configureOptionsWindow()
{

  saveTempOptions();
  config["theme_old"] = config["theme"]["name"];

  setColorOptions();


  if(document.getElementById("checkMCAvatar"))
  	if (config["effects"]["avatarsmainchat"]==1)
	  document.getElementById("checkMCAvatar").checked=true;

  if(document.getElementById("checkRLAvatar"))
  	if (config["effects"]["avatarsroomlist"]==1)
	  document.getElementById("checkRLAvatar").checked=true;

  if (!config["effects"]["avatarsmainchat_allow_override"])
  if(document.getElementById("checkMCAvatar")){
  	document.getElementById("mcAvatarSelect").disabled = true;
  	document.getElementById("checkMCAvatar").disabled = true;
  }

  if (!config["effects"]["avatarsroomlist_allow_override"])
  if(document.getElementById("checkRLAvatar")){
  	document.getElementById("rlAvatarSelect").disabled = true;
  	document.getElementById("checkRLAvatar").disabled = true;
  }

  if(document.getElementById("showBackgroundCh"))
  	if (config["effects"]["showbackground"]==1)
	  document.getElementById("showBackgroundCh").checked=true;

  if(document.getElementById("focusCheck"))
  	if (config["splashWindow"]==1)
	  document.getElementById("focusCheck").checked=true;

  if (config["sound"]["muteAll"] == "1")
    if(document.getElementById("muteAll"))
      document.getElementById("muteAll").checked=true;

  if (config["itc"]["mytextcolor"] == true)
  	if(document.getElementById("checkMyTextColor"))
      document.getElementById("checkMyTextColor").checked=true;

  for (var i = 0; i < parseInt (optionsSound.length); i++)
	if (config["sound"]["ev"][optionsSound[i]]["muted"] == false)
	  if(document.getElementById("mute" + optionsSound[i]))
		document.getElementById("mute" + optionsSound[i]).checked=true;


}

function isFocusWindowOnNewMessages(){
	var valReturn;
	valReturn=(config["splashWindow"]==1) ? true : false;

	if(document.getElementById("focusCheck"))
		valReturn=document.getElementById("focusCheck").checked;

	return valReturn;
}

function ifShowBackground(){
	var showBg = false, bgImg;
	if(document.getElementById("showBackgroundCh")){
		if(document.getElementById("showBackgroundCh").checked==true)
			showBg=true;
	}else if (config["effects"]["showbackground"]==1)
		showBg=true;



	if(document.getElementById("showBackgroundCh"))
		bgImg = config["effects"]["background-image-temp"];
	else
		bgImg = config["effects"]["background-image"];

	if(showBg==true){
		 if(document.getElementById("backgroundimage"))
  			document.getElementById("backgroundimage").src=bgImg;
	}
    else{
		 if(document.getElementById("backgroundimage"))
  			document.getElementById("backgroundimage").src="imgs/blank.gif";
	}
}

function applyMyTextColor(){
	if(document.getElementById("colorBtn"))
		var myColor = document.getElementById("colorBtn").style["backgroundColor"];
	else
		var myColor = "#ffffff";
	if (config["itc"]["mytextcolor"]){
		var allSel= document.getElementsByTagName("span");
		for (var i in allSel)
			if (allSel[i])
			if (allSel[i].className=="textcolorval")
			{
				allSel[i].style["color"] = myColor;//"#" + user["color"];
			}
	 }else{
		 var allSel= document.getElementsByTagName("span");
		for (var i in allSel)
			if (allSel[i])
			if (allSel[i].className=="textcolorval")
		 		allSel[i].style["color"] = "";
	 }

}

function isSpecialLanguage(inLanguage) {
	if (inLanguage == undefined)
		inLanguage = config["currentLanguage"];
	for (var i in config["special_language"])
		if (config["special_language"][i]==inLanguage)
			return true;
	return false;
}

function getAvatar() {
	var ret_val = null;
	switch(parseInt(user["role"]))
	{
		case config["role"]["ROLE_USER"]:
		case config["role"]["ROLE_CUSTOMER"]:
			if(user["gender"] == config["gender"]["GENDER_MALE"])
				ret_val = config.avatars.user.male;
			else if(user["gender"] == config["gender"]["GENDER_FEMALE"])
				ret_val = config.avatars.user.female;
			//else ret_val = config.avatars.user.male;
			break;
		case config["role"]["ROLE_ADMIN"]:
			if(user["gender"] == config["gender"]["GENDER_MALE"])
				ret_val = config.avatars.admin.male;
			else if(user["gender"] == config["gender"]["GENDER_FEMALE"])
				ret_val = config.avatars.admin.female;
			else ret_val = config.avatars.admin.male;
			break;
		case config["role"]["ROLE_MODERATOR"]:
			if(user["gender"] == config["gender"]["GENDER_MALE"])
				ret_val = config.avatars.moderator.male;
			else if(user["gender"] == config["gender"]["GENDER_FEMALE"])
				ret_val = config.avatars.moderator.female;
			else
				ret_val = config.avatars.moderator.male;
			break;
		default:
			break;
	}
	return(ret_val);
}

