/*

  (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"
);
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";
  
  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");
  

  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;
}

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

  var isFor = cpDiv.isFor;

  isFor.style["backgroundColor"] = "#" + this.hexColor;

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

  cpDiv.style["visibility"] = "hidden";
  
  toChangeChatColors(isFor.id);
}

function createOptionsWindow (handlers) {
  var newWin = new AC_Window (winTypes.BUTTONCLOSE | winTypes.HASBUTTONS, "optionsWindow", {"width": "540", "height": "420"});
  //var newWin = new AC_Window (winTypes.BUTTONCLOSE | winTypes.HASBUTTONS, null, {"width": "470", "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));
	
	/*var tabLabel = document.createElement ("input");
      setElementSaP (tabLabel, {"class": "optionsTab"}, {"type": "button"});
	tabLabel.setAttribute ("id", "colorBtn_" + skinOpts[(i * 2) + j]);*/
    ///tabLabel.style["margin"] = "0 3px 3px 3px";
	//tabLabel.style["padding"] = "3px 8px 3px 8px";
	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");

  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 */

  for (var i = 0; i < parseInt (skinOpts.length / 2 ); i++) {
    divCTRow = divCT.insertRow (i + 1);

    for (var j = 0; j < 2; j++) 
	{
      divCTCell = divCTRow.insertCell (j);

      var skinOpt = skinOpts[(i * 2) + j];

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

      oTRow = optTable.insertRow (0);
      oTCellLeft = oTRow.insertCell (0);
      setElementSaP (oTCellLeft, {"textAlign": "right", "paddingLeft": "2px","paddingRight": "3px"}, null);

      oTCellRight = oTRow.insertCell (1);
      setElementSaP (oTCellRight, {"textAlign": "right","width" : "25px" }, null);
	  
	  oTCellRight1 = oTRow.insertCell (2);
      setElementSaP (oTCellRight1, {"textAlign": "right","width" : "23px" }, null);

      var textSpan = addSpanWText (oTCellLeft, null, null, getLanguageString ("dialog", "skin:" + skinOpts[(i * 2) + j], config["currentLanguage"], null));

      textSpan.langType = "dialog";
      textSpan.langStr = "skin:" + skinOpt;

      var colorBtn = document.createElement ("input");
      setElementSaP (colorBtn, {"class": "optColorBtn"}, {"type": "button"});
	  colorBtn.setAttribute ("id", "colorBtn_" + skinOpts[(i * 2) + j]);  
      colorBtn.onclick = function () { showCPWindow (this,true) };

      oTCellRight.appendChild (colorBtn);

      divCTCell.appendChild (optTable);
    }

  }

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

  /*

    tab - index 1

  */

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

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

 
  
  var row_number=0;
  if(config["allowLanguage"]){ 
	  var divCTRow = divCT.insertRow (row_number++);
	  var divCTCell = divCTRow.insertCell (0);
	  var divCTCell2 = divCTRow.insertCell (1);
	  setElementSaP (divCTCell, {"verticalAlign": "top", "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": "top", "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": "top", "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": "top", "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");

  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"]);

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

  
  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 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": "top", "textAlign": "left", "width": "50%"},{"colSpan":"2"});
  //setElementSaP (divCTCell3, {"verticalAlign": "top", "textAlign": "left", "width": "50%"},null);
  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": "top", "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": "top", "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"];
  //setElementSaP (divCTCell2, null, {"rowspan": "4"});
  

  var divCTRow = divCT.insertRow (3);
  var divCTCell = divCTRow.insertCell (0);
 // var divCTCell3 = divCTRow.insertCell (1);
  var divCTCell2 = divCTRow.insertCell (1);
  setElementSaP (divCTCell, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, {"colSpan":"2"});
 // setElementSaP (divCTCell3, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, null);
  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 divCTCell3 = divCTRow.insertCell (1);
  var divCTCell2 = divCTRow.insertCell (1);
  setElementSaP (divCTCell, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, {"colSpan":"2"});
 // setElementSaP (divCTCell3, {"verticalAlign": "top", "textAlign": "left", "width": "50%"}, null);
  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": "top", "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 soundDiv = document.createElement ("div");
  soundDiv.className = "optionsTabContent";
  soundDiv.style["paddingTop"] = "20px";
  displayNONEByNode (soundDiv);

  tabs[3][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);
  var divCTCell3 = divCTRow.insertCell (2);
  var divCTCell4 = divCTRow.insertCell (3);
  setElementSaP (divCTCell, {"width": "35%", "textAlign": "right", "paddingBottom": "12px"}, null);
  setElementSaP (divCTCell2, {"width": "15%", "textAlign": "left", "paddingBottom": "12px"}, null);
  setElementSaP (divCTCell3, {"width": "35%", "textAlign": "right", "paddingBottom": "12px"}, null);
  setElementSaP (divCTCell4, {"width": "15%", "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");

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

    var valueStr = i * 5;

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

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

    volumeSelect.appendChild (opt);
  }

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

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

  divCTCell2.appendChild (volumeSelect);

  var muteAllSpan = addSpanWText (divCTCell3, null, null, getLanguageString ("dialog", "sound:muteall", config["currentLanguage"], null));
  muteAllSpan.langType = "dialog";
  muteAllSpan.langStr = "sound:muteall";

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

  divCTCell3.appendChild (document.createTextNode (" "));
  divCTCell4.appendChild (muteAllCheck);
  
  for (var i = 0; i < parseInt (optionsSound.length / 2); i++) {
    var divCTRow = divCT.insertRow (i + 1);

    for (var j = 0; j < 4; j++) {
      var divCTCell = divCTRow.insertCell (j);
      
	  
		if( j==1 || j==3 )
		{
			setElementSaP (divCTCell, {"textAlign": "left"}, null);
		}
		else
		{
			setElementSaP (divCTCell, {"textAlign": "right"}, null);
		}
	  
	  
	  //var divCTCell2 = divCTRow.insertCell (j+1);
      //setElementSaP (divCTCell2, {"width": "25%", "textAlign": "right"}, null);
	  //------------------------------------------------------------------------------
		
		if( j==0 || j==2 )
		{
      		var k;
			if ( j==0 )
				k = 0;
			
			if ( j==2 )
				k=1;
			var sndOpt = optionsSound[(i * 2) + k];
      		var strLowerCase=sndOpt.toLowerCase ();
      		if (strLowerCase=="receivemessage")
      			strLowerCase="reveivemessage";      	
      		var sndOptSpan = addSpanWText (divCTCell, null, null, getLanguageString ("dialog", "sound:" + strLowerCase, config["currentLanguage"], null));
				divCTCell.appendChild (document.createTextNode (" "));
			
		}
		
		//----------------------------------------------------------------------------
	  	if( j==1 || j==3 )
		{
			var muteCheck = document.createElement ("input");
			muteCheck.setAttribute ("type", "checkbox");
			muteCheck.setAttribute ("name", "mute" + sndOpt);
			muteCheck.setAttribute ("id", "mute" + sndOpt);
			muteCheck["mutes"] = sndOpt;
			divCTCell.appendChild (muteCheck);
      
      /*//alert(config["sound"]["ev"][sndOpt]["muted"]);
      if (config["sound"]["ev"][sndOpt]["muted"] != true) {
        /*if (browserISIE ()) {
          muteCheck.setAttribute ("checked", "checked");
          muteCheck.checked = true;
        }
        else/
        //alert(config["sound"]["ev"][sndOpt]["muted"]);
          //muteCheck.setAttribute ("checked", "true");
          //muteCheck.checked = true;
      }*/
      //muteCheck.setAttribute ("checked", "true");

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

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

      imgSndTest.onclick = function () { testSound (this); };

      muteCheck.onchange = function () { muteUnmute (this); };

      	divCTCell.appendChild (imgSndTest);
	  	//-----------------------------------------------------------------------------
	  }
    }
  }

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

  /*

    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) 2007 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 divCT1 = document.createElement ("table");
  setElementSaP (divCT1, {"width": "100%"}, {"border": "0", "cellSpacing": "1", "cellPadding": "1"});
	
  var divCTRow1 = divCT1.insertRow (0);
  var divCTCell1 = divCTRow1.insertCell (0);
  
  var divCTCell1 = divCTRow1.insertCell (1);	*/	

  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"]; }
 
 
 //newWin.appendChild (cmDiv);
  
  if(!document.getElementById ("contextMenu"))
  {
   	var cmDiv = document.createElement ("div");
  	setElementSaP (cmDiv, {"visibility": "hidden"}, {"id": "contextMenu"});
	var layoutDiv11 = document.getElementById ("layoutDiv");
	layoutDiv11.appendChild (cmDiv);
}
	
  //var menuItems1 = new Array ();
   // menuItems1.push ("privatemessage");
	/*var cmDiv1 = document.createElement ("div");
	
	setElementSaP (cmDiv1, null, {"id": "contextMenu"});
	cmDiv1.style["display"] = "block";
	var layoutDiv11 = document.getElementById ("layoutDiv");
	contentDoc.appendChild (cmDiv1);*/
  
  //setTempColorOptions();
 
  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;
  }
  
  //alert('change: '+change);
  
  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();  
  
  //alert("set opt win");
  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 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.style["backgroundColor"];
				}
				else
					skinOptsValuesTmp["background"]=skinOptsValues["background"];
				//document.getElementById("AC_main").style["backgroundColor"]=skinOptsValuesTmp["background"];	
				//alert(skinOptsValuesTmp["background"]);
				//document.bgColor=skinOptsValuesTmp["background"];
				//alert(document.bgColor);
				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"];	
				//alert('ddd ba' + skinOptsValuesTmp["background"]);
				
			break;
		case "colorBtn_titleText":
				if (x)
					skinOptsValuesTmp["titleText"]=x.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.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.style["backgroundColor"];
				else
					skinOptsValuesTmp["button"]=skinOptsValues["button"];
					
					
				//alert('button background: '+skinOptsValuesTmp["button"]);
				//change color select combo
				//alert("change color");
				//var allElm = document.getElements();
				//if(allElm)
				//	alert(allElm.length);
				//-------------------------
				
				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.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.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=="pW_input" || allSel[i].className=="textInput")  
				 		allSel[i].style["backgroundColor"] = skinOptsValuesTmp["inputBoxBackground"];					
			break;
		case "colorBtn_borderColor":
				if (x)
					skinOptsValuesTmp["borderColor"]=x.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=="pW_input" || allSel[i].className=="textInput")  
						allSel[i].style["borderColor"] = skinOptsValuesTmp["borderColor"];	
				
			break;
		case "colorBtn_dialog":
		//alert('dialog');
		        if (x)
					skinOptsValuesTmp["dialog"]=x.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.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.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.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.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.style["backgroundColor"];
				else
					skinOptsValuesTmp["bodyText"]=skinOptsValues["bodyText"];
				if (browserISIE7())
					break;
				document.getElementById("AC_main").style["color"]=skinOptsValuesTmp["bodyText"];
				//alert(skinOptsValues["bodyText"]);
				/*var allSel= document.getElementsByTagName("body");
				for (var i in allSel)
					if (allSel[i])
						//alert(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.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.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.style["backgroundColor"];
				else
					skinOptsValuesTmp["enterRoomNotify"]=skinOptsValues["enterRoomNotify"];				
			break;		
		case "colorBtn_roomUser":
				
				if (x)
				{
					skinOptsValuesTmp["roomUser"]=x.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"];
							//alert('color'+color);
						
						}
				
				
			break;		
		case "colorBtn_contextMenu":
				if (x)
				{
					skinOptsValuesTmp["contextMenu"]=x.style["backgroundColor"];
				}
				else
				{
					if(skinOptsValues["contextMenu"])
						skinOptsValuesTmp["contextMenu"] = skinOptsValues["contextMenu"];	
				}
				
				//alert('alert' + skinOptsValuesTmp["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 setColorOptions(){	
  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").style["backgroundColor"]=color;
	
	//TempArray["background"] = document.bgColor;
	
	skinOptsValues["background"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["titleText"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["buttonText"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["button"]=color;
	skinOptsValuesTmp["button"]=color;
	//TempArray["button"]=color;
  }  
  if(document.getElementById("colorBtn_buttonBorder")){	
  
  	//alert(getStyle(document.getElementById("optionsTab2"),"border-left-color","borderLeftColor"));
	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").style["backgroundColor"]= color;
	skinOptsValues["buttonBorder"]=color;
	skinOptsValuesTmp["buttonBorder"]=color;

  }  
  
  //alert('alert1');
  
  if(document.getElementById("colorBtn_inputBoxBackground")){	  
	var color=getStyle(document.getElementById("textInputMsgDiv_alpha"),"background-color","backgroundColor");
	
	
	//alert('alert2');
	/*if( document.getElementById("colorBtn_inputBoxBackground").style["backgroundColor"] )
  		TempArray["inputBoxBackground"] = document.getElementById("colorBtn_inputBoxBackground").style["backgroundColor"];
	else
		TempArray["inputBoxBackground"] = color;*/
	
	document.getElementById("colorBtn_inputBoxBackground").style["backgroundColor"]= color;
	skinOptsValues["inputBoxBackground"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["borderColor"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["dialog"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["dialogTitle"]=color;
	skinOptsValuesTmp["dialogTitle"]=color;
	//TempArray["dialogTitle"]=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").style["backgroundColor"]= color;
	skinOptsValues["dialogTitle"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["userListBackground"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]=color;
	skinOptsValues["room"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]=color;
	skinOptsValues["roomText"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]=color;
	skinOptsValues["bodyText"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["publicLogBackground"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["privateLogBackground"]=color;
	skinOptsValuesTmp["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").style["backgroundColor"]= color;
	skinOptsValues["enterRoomNotify"]=color;
	skinOptsValuesTmp["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");
					//alert('color'+color);
					break;
				}
	}
	
	document.getElementById("colorBtn_roomUser").style["backgroundColor"]= color;
	skinOptsValues["roomUser"]=color;
	skinOptsValuesTmp["roomUser"]=color;
	}  
	 
  if(document.getElementById("colorBtn_contextMenu")){	 
  
  	var color;
	
	if(skinOptsValues["contextMenu"]!="")
		color=skinOptsValues["contextMenu"];
	else
	{
		if(document.getElementById("contextMenu"))
		{
			//alert('before');
			color=getStyle(document.getElementById("contextMenu"),"background-color","backgroundColor");
			//alert('after');
		}
		else
		{
			//alert('alert set colr');
			color = "#5469bc";
		}
	}
	document.getElementById("colorBtn_contextMenu").style["backgroundColor"]= color;
	skinOptsValues["contextMenu"]=color;
	skinOptsValuesTmp["contextMenu"]=color;
	 }  
  

  
}
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"] = 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"] = 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"] = 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"] = 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"] = 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"] = 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"] = 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"] = color8;
	
	
	var color9;
	
		color9=getStyle(document.getElementById("optionsWindowwinTitleRow"),"background-color","backgroundColor");
	
		TempArray["dialogTitle"] = color9;	
	
	var color10;
	
		color10=getStyle(document.getElementById("roomList_alpha"),"background-color","backgroundColor");
	
		TempArray["userListBackground"] = 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"] = 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"] = color12;
	
	var color13=getStyle(document.body,"color");

		TempArray["bodyText"] = 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"] = 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"] = 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"] = 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"] = color17;
}
//else
	//alert('alert temp');
  
  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"] = color18;

  
}
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";
//alert(myColor);
	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);
}
