From f168f1baaf9ed74988c12f35c88a531943d29f58 Mon Sep 17 00:00:00 2001
From: Evgeny Gryaznov <inspirer@users.sourceforge.net>
Date: Wed, 10 Oct 2007 15:15:47 +0000
Subject: [PATCH] fix eol, add agentId into chatmessage and chatthread, minor
 changes in html, several utility functions

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@27 c66351dc-e62f-0410-b875-e3a5c0b9693f
---
 src/webim/button.php                   |  60 +-
 src/webim/client.php                   | 134 ++--
 src/webim/install/index.php            |  38 +-
 src/webim/install/install.php          | 186 +++---
 src/webim/install/view_index.php       | 121 ++--
 src/webim/install/view_install.php     | 121 ++--
 src/webim/libs/chat.php                | 873 +++++++++++++------------
 src/webim/libs/common.php              | 626 +++++++++---------
 src/webim/libs/config.php              | 178 ++---
 src/webim/libs/converter.php           |  94 +--
 src/webim/libs/operator.php            | 298 ++++-----
 src/webim/libs/pagination.php          | 196 +++---
 src/webim/mail.php                     |  98 +--
 src/webim/operator/agent.php           | 110 ++--
 src/webim/operator/getcode.php         | 128 ++--
 src/webim/operator/history.php         | 108 +--
 src/webim/operator/index.php           |  76 +--
 src/webim/operator/login.php           |  82 +--
 src/webim/operator/logout.php          |  46 +-
 src/webim/operator/operator.php        | 168 ++---
 src/webim/operator/operators.php       |  50 +-
 src/webim/operator/threadprocessor.php |  62 +-
 src/webim/operator/update.php          | 194 +++---
 src/webim/operator/users.php           |  50 +-
 src/webim/thread.php                   | 172 ++---
 src/webim/view/agent.php               | 273 ++++----
 src/webim/view/agents.php              | 237 ++++---
 src/webim/view/chat_ajaxed.php         | 504 +++++++-------
 src/webim/view/chat_error.php          | 212 +++---
 src/webim/view/chat_mailsent.php       | 212 +++---
 src/webim/view/chat_mailthread.php     | 260 ++++----
 src/webim/view/chat_oldbrowser.php     | 194 +++---
 src/webim/view/chat_simple.php         | 478 +++++++-------
 src/webim/view/gen_button.php          | 261 ++++----
 src/webim/view/login.php               | 267 ++++----
 src/webim/view/menu.php                | 169 +++--
 src/webim/view/pending_users.php       | 332 +++++-----
 src/webim/view/properties_en           | 304 ++++-----
 src/webim/view/properties_ru           | 304 ++++-----
 src/webim/view/thread_log.php          | 164 +++--
 src/webim/view/thread_search.php       | 228 ++++---
 41 files changed, 4299 insertions(+), 4369 deletions(-)

diff --git a/src/webim/button.php b/src/webim/button.php
index 95328d9f..ed885f7a 100644
--- a/src/webim/button.php
+++ b/src/webim/button.php
@@ -1,31 +1,31 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('libs/common.php');
-require('libs/operator.php');
-
-$image = verifyparam("image","/^\w+$/", "webim");
-$lang = verifyparam("lang", "/^\w\w$/", "");
-if( !$lang || !in_array($lang,$available_locales) )
-	$lang = $current_locale;
-
-$image_postfix = has_online_operators() ? "on" : "off";
-$name = "images/webim/${image}_${lang}_${image_postfix}.gif";
-
-$fp = fopen($name, 'rb') or die("no image");
-header("Content-Type: image/gif");
-header("Content-Length: ".filesize($name));
-fpassthru($fp);
-exit;
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('libs/common.php');
+require('libs/operator.php');
+
+$image = verifyparam("image","/^\w+$/", "webim");
+$lang = verifyparam("lang", "/^\w\w$/", "");
+if( !$lang || !in_array($lang,$available_locales) )
+	$lang = $current_locale;
+
+$image_postfix = has_online_operators() ? "on" : "off";
+$name = "images/webim/${image}_${lang}_${image_postfix}.gif";
+
+$fp = fopen($name, 'rb') or die("no image");
+header("Content-Type: image/gif");
+header("Content-Length: ".filesize($name));
+fpassthru($fp);
+exit;
 ?>
\ No newline at end of file
diff --git a/src/webim/client.php b/src/webim/client.php
index 61166005..933b8542 100644
--- a/src/webim/client.php
+++ b/src/webim/client.php
@@ -1,68 +1,68 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('libs/common.php');
-require('libs/chat.php');
-
-if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
-
-	$thread = NULL;
-	if( isset($_SESSION['threadid']) ) {
-		$thread = reopen_thread($_SESSION['threadid']);
-	}
-
-	if( !$thread ) {
-		$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "";
-		$remote = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $_SERVER['REMOTE_ADDR'];
-		$visitor = $remote_visitor();
-		$thread = create_thread($visitor['name'], $remote, $referer,$current_locale);
-		$_SESSION['threadid'] = $thread['threadid'];
-		if( $referer ) {
-			post_message($thread['threadid'],$kind_for_agent,getstring2('chat.came.from',array($referer)));
-		}
-		post_message($thread['threadid'],$kind_info,getstring('chat.wait'));
-	}
-	$threadid = $thread['threadid'];
-	$token = $thread['ltoken'];
-	$level = get_remote_level($_SERVER['HTTP_USER_AGENT']);
-	header("Location: ".dirname($_SERVER['PHP_SELF'])."/client.php?thread=$threadid&token=$token&level=$level");
-	exit;
-}
-
-$token = verifyparam( "token", "/^\d{1,8}$/");
-$threadid = verifyparam( "thread", "/^\d{1,8}$/");
-$level = verifyparam( "level", "/^(ajaxed|simple|old)$/");
-
-$thread = thread_by_id($threadid);
-if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
-	die("wrong thread");
-}
-
-//$level = "simple";
-
-setup_chatview_for_user($thread, $level);
-start_html_output();
-
-$pparam = verifyparam( "act", "/^(mailthread)$/", "default");
-if( $pparam == "mailthread" ) {
-	require('view/chat_mailthread.php');
-} else if( $level == "ajaxed" ) {
-	require('view/chat_ajaxed.php');
-} else if( $level == "simple" ) {
-	require('view/chat_simple.php');
-} else if( $level == "old" ) {
-	require('view/chat_oldbrowser.php');
-}
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('libs/common.php');
+require('libs/chat.php');
+
+if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
+
+	$thread = NULL;
+	if( isset($_SESSION['threadid']) ) {
+		$thread = reopen_thread($_SESSION['threadid']);
+	}
+
+	if( !$thread ) {
+		$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "";
+		$remote = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $_SERVER['REMOTE_ADDR'];
+		$visitor = $remote_visitor();
+		$thread = create_thread($visitor['name'], $remote, $referer,$current_locale);
+		$_SESSION['threadid'] = $thread['threadid'];
+		if( $referer ) {
+			post_message($thread['threadid'],$kind_for_agent,getstring2('chat.came.from',array($referer)));
+		}
+		post_message($thread['threadid'],$kind_info,getstring('chat.wait'));
+	}
+	$threadid = $thread['threadid'];
+	$token = $thread['ltoken'];
+	$level = get_remote_level($_SERVER['HTTP_USER_AGENT']);
+	header("Location: ".dirname($_SERVER['PHP_SELF'])."/client.php?thread=$threadid&token=$token&level=$level");
+	exit;
+}
+
+$token = verifyparam( "token", "/^\d{1,8}$/");
+$threadid = verifyparam( "thread", "/^\d{1,8}$/");
+$level = verifyparam( "level", "/^(ajaxed|simple|old)$/");
+
+$thread = thread_by_id($threadid);
+if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
+	die("wrong thread");
+}
+
+//$level = "simple";
+
+setup_chatview_for_user($thread, $level);
+start_html_output();
+
+$pparam = verifyparam( "act", "/^(mailthread)$/", "default");
+if( $pparam == "mailthread" ) {
+	require('view/chat_mailthread.php');
+} else if( $level == "ajaxed" ) {
+	require('view/chat_ajaxed.php');
+} else if( $level == "simple" ) {
+	require('view/chat_simple.php');
+} else if( $level == "old" ) {
+	require('view/chat_oldbrowser.php');
+}
+
 ?>
\ No newline at end of file
diff --git a/src/webim/install/index.php b/src/webim/install/index.php
index 0e4f02df..4a2cd1e5 100644
--- a/src/webim/install/index.php
+++ b/src/webim/install/index.php
@@ -1,19 +1,19 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-
-start_html_output();
-require('view_index.php');
-?>
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+
+start_html_output();
+require('view_index.php');
+?>
diff --git a/src/webim/install/install.php b/src/webim/install/install.php
index b47e3929..cbdf2b68 100644
--- a/src/webim/install/install.php
+++ b/src/webim/install/install.php
@@ -1,90 +1,98 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-
-function drop_tables() {
-	$link = connect();
-	perform_query("DROP TABLE IF EXISTS chatthread",$link);
-	perform_query("DROP TABLE IF EXISTS chatmessage",$link);
-	perform_query("DROP TABLE IF EXISTS chatrevision",$link);
-	perform_query("DROP TABLE IF EXISTS chatoperator",$link);
-	mysql_close($link);
-}
-
-function create_tables() {
-	global $dbencoding;
-	$link = connect();
-
-	$query = 
-		"CREATE TABLE chatthread (\n".
-		"	threadid int NOT NULL auto_increment PRIMARY KEY ,\n".
-		"	userName varchar(64) NOT NULL,\n".
-		"	agentName varchar(64),\n".
-		"	dtmcreated datetime DEFAULT 0,\n".
-		"	dtmmodified datetime DEFAULT 0,\n".
-		"	lrevision int NOT NULL DEFAULT 0,\n".
-		"	istate int NOT NULL DEFAULT 0,\n".
-		"	ltoken int NOT NULL,\n".
-		"	remote varchar(255),\n".
-		"	referer text,\n".
-		"	locale varchar(8),\n".
-		"	lastpinguser datetime DEFAULT 0,\n".
-		"	lastpingagent datetime DEFAULT 0\n".
-		") charset $dbencoding\n";
-
-	perform_query($query,$link);	
-
-	$query = 
-		"CREATE TABLE chatmessage\n".
-		"(\n".
-		"	messageid int NOT NULL auto_increment PRIMARY KEY,\n".
-		"	threadid int NOT NULL references chatthread(threadid),\n".
-		"	ikind int NOT NULL,\n".
-		"	tmessage text NOT NULL,\n".
-		"	dtmcreated datetime DEFAULT 0,\n".
-		"	tname varchar(64)\n".
-		") charset $dbencoding\n";
-
-	perform_query($query,$link);	
-
-	perform_query("CREATE TABLE chatrevision (id INT NOT NULL)",$link);	
-	perform_query("INSERT INTO chatrevision VALUES (1)",$link);	
-
-	$query = 
-		"CREATE TABLE chatoperator\n".
-		"(\n".
-		"	operatorid int NOT NULL auto_increment PRIMARY KEY,\n".
-		"	vclogin varchar(64) NOT NULL,\n".
-		"	vcpassword varchar(64) NOT NULL,\n".
-		"	vclocalename varchar(64) NOT NULL,\n".
-		"	vccommonname varchar(64) NOT NULL,\n".
-		"	dtmlastvisited datetime DEFAULT 0\n".
-		") charset $dbencoding\n";
-
-	perform_query($query,$link);	
-
-	mysql_close($link);
-
-	create_operator("admin", "", "Administrator", "Administrator");
-}
-
-drop_tables();
-create_tables();
-
-start_html_output();
-require('view_install.php');
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+
+function drop_tables() {
+	$link = connect();
+	perform_query("DROP TABLE IF EXISTS chatthread",$link);
+	perform_query("DROP TABLE IF EXISTS chatmessage",$link);
+	perform_query("DROP TABLE IF EXISTS chatrevision",$link);
+	perform_query("DROP TABLE IF EXISTS chatoperator",$link);
+	mysql_close($link);
+}
+
+function create_tables() {
+	global $dbencoding;
+	$link = connect();
+
+	// to update from v1
+	// ALTER TABLE chatthread ADD agentId int NOT NULL DEFAULT 0 AFTER agentName
+	// update chatthread,chatoperator set agentId = operatorid where agentId = 0 AND (vclocalename = agentName OR vccommonname = agentName) 
+	// ALTER TABLE chatmessage ADD agentId int NOT NULL DEFAULT 0 AFTER ikind
+	// update chatmessage,chatoperator set agentId = operatorid where agentId = 0 AND ikind = 2 AND (vclocalename = tname OR vccommonname = tname) 
+	
+	$query = 
+		"CREATE TABLE chatthread (\n".
+		"	threadid int NOT NULL auto_increment PRIMARY KEY ,\n".
+		"	userName varchar(64) NOT NULL,\n".
+		"	agentName varchar(64),\n".
+		"   agentId int NOT NULL DEFAULT 0,\n".
+		"	dtmcreated datetime DEFAULT 0,\n".
+		"	dtmmodified datetime DEFAULT 0,\n".
+		"	lrevision int NOT NULL DEFAULT 0,\n".
+		"	istate int NOT NULL DEFAULT 0,\n".
+		"	ltoken int NOT NULL,\n".
+		"	remote varchar(255),\n".
+		"	referer text,\n".
+		"	locale varchar(8),\n".
+		"	lastpinguser datetime DEFAULT 0,\n".
+		"	lastpingagent datetime DEFAULT 0\n".
+		") charset $dbencoding\n";
+
+	perform_query($query,$link);	
+
+	$query = 
+		"CREATE TABLE chatmessage\n".
+		"(\n".
+		"	messageid int NOT NULL auto_increment PRIMARY KEY,\n".
+		"	threadid int NOT NULL references chatthread(threadid),\n".
+		"	ikind int NOT NULL,\n".
+		"   agentId int NOT NULL DEFAULT 0,\n".
+		"	tmessage text NOT NULL,\n".
+		"	dtmcreated datetime DEFAULT 0,\n".
+		"	tname varchar(64)\n".
+		") charset $dbencoding\n";
+
+	perform_query($query,$link);	
+
+	perform_query("CREATE TABLE chatrevision (id INT NOT NULL)",$link);	
+	perform_query("INSERT INTO chatrevision VALUES (1)",$link);	
+
+	$query = 
+		"CREATE TABLE chatoperator\n".
+		"(\n".
+		"	operatorid int NOT NULL auto_increment PRIMARY KEY,\n".
+		"	vclogin varchar(64) NOT NULL,\n".
+		"	vcpassword varchar(64) NOT NULL,\n".
+		"	vclocalename varchar(64) NOT NULL,\n".
+		"	vccommonname varchar(64) NOT NULL,\n".
+		"	dtmlastvisited datetime DEFAULT 0\n".
+		") charset $dbencoding\n";
+
+	perform_query($query,$link);	
+
+	mysql_close($link);
+
+	create_operator("admin", "", "Administrator", "Administrator");
+}
+
+drop_tables();
+create_tables();
+
+start_html_output();
+require('view_install.php');
+
 ?>
\ No newline at end of file
diff --git a/src/webim/install/view_index.php b/src/webim/install/view_index.php
index 5b32c2a2..461ad0c6 100644
--- a/src/webim/install/view_index.php
+++ b/src/webim/install/view_index.php
@@ -1,64 +1,57 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("install.title") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
-		<h1><?php echo getstring("install.title") ?></h1>
-	
-
-	<?php echo getstring("install.message") ?>
-<br/>
-<br/>
-
-<a href="install.php"><?php echo getstring("install.create_db_link") ?></a>
-
-<br/>
-<br/>
-
-<a href="/webim/epl-v10.html" target="_blank"><?php echo getstring("install.license") ?></a>
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("install.title") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+		<h1><?php echo getstring("install.title") ?></h1>
+	
+
+	<?php echo getstring("install.message") ?>
+<br/>
+<br/>
+
+<a href="install.php"><?php echo getstring("install.create_db_link") ?></a>
+
+<br/>
+<br/>
+
+<a href="/webim/epl-v10.html" target="_blank"><?php echo getstring("install.license") ?></a>
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/install/view_install.php b/src/webim/install/view_install.php
index 3e5b5b00..5633634a 100644
--- a/src/webim/install/view_install.php
+++ b/src/webim/install/view_install.php
@@ -1,64 +1,57 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("installed.title") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
-		<h1><?php echo getstring("installed.title") ?></h1>
-	
-
-	<?php echo getstring("installed.message") ?>
-<br/>
-<br/>
-
-<a href="/webim/operator/login.php"><?php echo getstring("installed.login_link") ?></a>
-
-<br/>
-<br/>
-
-<a href="/webim/LICENSE.html" target="_blank"><?php echo getstring("install.license") ?></a>
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("installed.title") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+		<h1><?php echo getstring("installed.title") ?></h1>
+	
+
+	<?php echo getstring("installed.message") ?>
+<br/>
+<br/>
+
+<a href="/webim/operator/login.php"><?php echo getstring("installed.login_link") ?></a>
+
+<br/>
+<br/>
+
+<a href="/webim/LICENSE.html" target="_blank"><?php echo getstring("install.license") ?></a>
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/libs/chat.php b/src/webim/libs/chat.php
index ee7547b7..a09a4515 100644
--- a/src/webim/libs/chat.php
+++ b/src/webim/libs/chat.php
@@ -1,435 +1,438 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- *    Pavel Petroshenko - history search
- */
-
-$connection_timeout = 30; # sec
-
-$namecookie = "WEBIM_Name";
-
-$state_queue = 0;
-$state_waiting = 1;
-$state_chatting = 2;
-$state_closed = 3;
-
-$kind_user = 1;
-$kind_agent = 2;
-$kind_for_agent = 3;
-$kind_info = 4;
-$kind_conn = 5;
-$kind_events = 6;
-
-$kind_to_string = array( $kind_user => "user", $kind_agent => "agent", $kind_for_agent => "hidden",
-	$kind_info => "inf", $kind_conn => "conn", $kind_events => "event" );
-
-
-
-function next_token() {
-	return rand(99999,99999999);
-}
-
-function next_revision($link) {
-	perform_query("update chatrevision set id=LAST_INSERT_ID(id+1)",$link);
-	$val = mysql_insert_id($link);
-	return $val;
-}
-
-function post_message_($threadid,$kind,$message,$link,$from=null,$time=null) {
-	$query = sprintf(
-	    "insert into chatmessage (threadid,ikind,tmessage,tname,dtmcreated) values (%s, %s,'%s',%s,%s)",
-			$threadid,
-			$kind,
-			quote_smart($message,$link),
-			$from ? "'".quote_smart($from,$link)."'" : "null",
-			$time ? "FROM_UNIXTIME($time)" : "CURRENT_TIMESTAMP" );
-
-	perform_query($query,$link);
-}
-
-function post_message($threadid,$kind,$message,$from=null) {
-	$link = connect();
-	post_message_($threadid,$kind,$message,$link,$from);
-	mysql_close($link);
-}
-
-function prepare_html_message($text) {
-	$escaped_text = htmlspecialchars($text);
-	$text_w_links = preg_replace('/(http|ftp):\/\/\S*/','<a href="$0" target="_blank">$0</a>',$escaped_text);
-	$multiline = str_replace("\n","<br/>",$text_w_links);
-	return $multiline;
-}
-
-function message_to_html($msg) {
-	global $kind_to_string;
-	$message = "<span>".date("H:i:s",$msg['created'])."</span> ";
-	$kind = $kind_to_string{$msg['ikind']};
-	if( $msg['tname'] )
-		$message.= "<span class='n$kind'>".htmlspecialchars($msg['tname'])."</span>: ";
-	$message.= "<span class='m$kind'>".prepare_html_message($msg['tmessage'])."</span><br/>";
-	return $message;
-}
-
-function message_to_text($msg) {
-	global $kind_user, $kind_agent, $kind_info;
-	$time = date("H:i:s ",$msg['created']);
-	if($msg['ikind'] == $kind_user || $msg['ikind'] == $kind_agent) {
-		if( $msg['tname'] )
-			return $time.$msg['tname'].": ".$msg['tmessage']."\n";
-		else
-			return $time.$msg['tmessage']."\n";
-	} else if($msg['ikind'] == $kind_info ) {
-		return $time.$msg['tmessage']."\n";
-	} else {
-		return $time."[".$msg['tmessage']."]\n";
-	}
-}
-
-function get_messages($threadid,$meth,$isuser,&$lastid) {
-	global $kind_for_agent;
-	$link = connect();
-
-	$query = sprintf(
-	    "select messageid,ikind,unix_timestamp(dtmcreated) as created,tname,tmessage from chatmessage ".
-	    "where threadid = %s and messageid > %s %s order by messageid",
-	    $threadid, $lastid, $isuser ? "and ikind <> $kind_for_agent" : "" );
-
-	$messages = array();
-	$result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query);
-
-	while ($msg = mysql_fetch_array($result, MYSQL_ASSOC)) {
-		$message = ($meth == 'text') ? message_to_text($msg) : message_to_html($msg);
-		$messages[] = $message;
-		if( $msg['messageid'] > $lastid )
-			$lastid = $msg['messageid'];
-	}
-
-	mysql_free_result($result);
-	mysql_close($link);
-	return $messages;
-} 
-
-function print_thread_mesages($threadid, $token, $lastid, $isuser,$format) {
-	global $webim_encoding, $webimroot;
-	$output = get_messages($threadid,"html",$isuser,$lastid);
-
-	if( $format == "xml" ) {
-		start_xml_output();
-		print("<thread lastID=\"$lastid\">");
-		foreach( $output as $msg ) {
-			print "<message>".myiconv($webim_encoding,"utf-8",escape_with_cdata($msg))."</message>\n";
-		}
-		print("</thread>");
-	} else if( $format == "html" ) {
-		start_html_output();
-		$url = "$webimroot/thread.php?act=refresh&thread=$threadid&token=$token&html=on&user=".($isuser?"true":"false");
-
-		print("<html><head>\n".
-		    "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"$webimroot/chat.css\" />\n".
-		    "<meta http-equiv=\"Refresh\" content=\"7; URL=$url&sn=11\">\n".
-		    "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n".
-		    "</head>".
-		    "<body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400' marginwidth='0' marginheight='0' leftmargin='0' rightmargin='0' topmargin='0' bottommargin='0' onload=\"if( location.hash != '#aend' ){location.hash='#aend';}\">".
-		    "<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message'>" );
-
-		foreach( $output as $msg ) {
-			print $msg;
-		}
-
-		print(
-		    "</td></tr></table><a name='aend'>".
-		    "</body></html>" );
-	}
-}
-
-function get_user_name($name, $id="") {
-	global $presentable_name_pattern;
-       	return str_replace("{id}", $id, str_replace("{name}", $name, $presentable_name_pattern));
-}
-
-function setup_chatview_for_user($thread,$level) {
-	global $page, $webimroot, $user_can_change_name, $company_logo_link, $company_name;
-	$page = array();
-	$page['agent'] = false;
-	$page['user'] = true;
-	$page['canpost'] = true;
-	$nameisset = getstring("chat.default.username") != $thread['userName'];
-	$page['displ1'] = $nameisset ? "none" : "inline";
-	$page['displ2'] = $nameisset ? "inline" : "none";
-	$page['level'] = $level;
-	$page['ct.chatThreadId'] = $thread['threadid'];
-	$page['ct.token'] = $thread['ltoken'];
-	$page['ct.user.name'] = $thread['userName'];
-	$page['canChangeName'] = $user_can_change_name;
-
-	$page['ct.company.name'] = $company_name;
-	$page['ct.company.chatLogoURL'] = $company_logo_link;
-
-	$params = "thread=".$thread['threadid']."&token=".$thread['ltoken'];
-	$page['selfLink'] = "$webimroot/client.php?".$params."&level=".$level;
-}
-
-function setup_chatview_for_operator($thread,$operator) {
-	global $page, $webimroot, $company_logo_link, $company_name;
-	$page = array();
-	$page['agent'] = true;
-	$page['user'] = false;
-	$page['canpost'] = true;
-	$page['ct.chatThreadId'] = $thread['threadid'];
-	$page['ct.token'] = $thread['ltoken'];
-	$page['ct.user.name'] = get_user_name($thread['userName']);
-
-	$page['ct.company.name'] = $company_name;
-	$page['ct.company.chatLogoURL'] = $company_logo_link;
-
-	// TODO
-	$page['namePostfix'] = "";	
-}
-
-function is_ajax_browser($name,$ver,$useragent) {
-	if( $name == "opera" )
-		return $ver >= 8.02;
-	if( $name == "safari" )
-		return $ver >= 125;
-	if( $name == "msie" )
-		return $ver >= 5.5 && !strstr($useragent, "powerpc");
-	if( $name == "netscape" )
-		return $ver >= 7.1;
-	if( $name == "mozilla")
-		return $ver >= 1.4;
-	if( $name == "firefox")
-		return $ver >= 1.0;
-
-	return false;
-}
-
-function is_old_browser($name,$ver) {
-	if( $name == "opera" )
-		return $ver < 7.0;
-	if( $name == "msie" )
-		return $ver < 5.0;
-	return false; 
-}
-
-$knownAgents = array("opera","msie","safari","firefox","netscape","mozilla");
-
-function get_remote_level($useragent) {
-	global $knownAgents;
-	$useragent = strtolower($useragent);
-	foreach( $knownAgents as $agent ) {
-		if( strstr($useragent,$agent) ) {
-			if( preg_match( "/".$agent."[\\s\/]?(\\d+(\\.\\d+)?)/", $useragent, $matches ) ) {
-				$ver = $matches[1];
-
-				if( is_ajax_browser($agent,$ver,$useragent) )
-					return "ajaxed";
-				else if( is_old_browser($agent,$ver) )
-					return "old";
-
-				return "simple";
-			}
-		}
-	}
-	return "simple";
-}
-
-function update_thread_access($threadid, $params, $link) {
-	$clause = "";
-	foreach( $params as $k => $v ) {
-		if( strlen($clause) > 0 )
-			$clause .= ", ";
-	    $clause .= $k."=".$v;
-	}
-	perform_query(
-		 "update chatthread set $clause ".
-		 "where threadid = ".$threadid,$link);
-}
-
-function get_access_time($threadid, $isuser, $link) {
-	return select_one_row(sprintf(
-		 "select unix_timestamp(%s) as lastping, ".
-		 "unix_timestamp(CURRENT_TIMESTAMP) as current ".
-		 "from chatthread where threadid = %s",
-		$isuser ? "lastpinguser" : "lastpingagent",
-		$threadid), $link);
-}
-
-function ping_thread($thread, $isuser) {
-	global $kind_for_agent, $state_chatting, $state_waiting, $kind_conn, $connection_timeout;
-	$link = connect();
-	$params = array(($isuser ? "lastpinguser" : "lastpingagent") => "CURRENT_TIMESTAMP" );
-
-	$access = get_access_time($thread['threadid'], !$isuser, $link);
- 	if( $access['lastping'] > 0 && abs($access['current']-$access['lastping']) > $connection_timeout ) {
-		$params[$isuser ? "lastpingagent" : "lastpinguser"] = "0";
-		if( !$isuser ) {
-			$message_to_post = getstring_("chat.status.user.dead", $thread['locale']);
-			post_message_($thread['threadid'],$kind_for_agent,$message_to_post,$link,null,$access['lastping']+$connection_timeout);
-		} else if( $thread['istate'] == $state_chatting ) {
-
-			$message_to_post = getstring_("chat.status.operator.dead", $thread['locale']);
-			post_message_($thread['threadid'],$kind_conn,$message_to_post,$link,null,$access['lastping']+$connection_timeout);
-			$params['istate'] = $state_waiting;
-			commit_thread($thread['threadid'], $params, $link);
-			mysql_close($link);
-			return;
-		}
-	}
-
-	update_thread_access($thread['threadid'], $params, $link);
-	mysql_close($link);
-}
-
-function commit_thread($threadid,$params,$link) {
-	$query = "update chatthread set lrevision = ".next_revision($link).", dtmmodified = CURRENT_TIMESTAMP";
-	foreach( $params as $k => $v ) {
-	    $query .= ", ".$k."=".$v;
-	}
-	$query .= " where threadid = ".$threadid;
-
-	perform_query($query,$link);
-}
-
-function rename_user($thread, $newname) {
-	global $kind_events;
-
-	$link = connect();
-	commit_thread( $thread['threadid'], array('userName' => "'".mysql_real_escape_string($newname)."'"), $link);
-	mysql_close($link);
-
-	if( $thread['userName'] != $newname ) {
-		post_message($thread['threadid'],$kind_events,
-			getstring2_("chat.status.user.changedname",array($thread['userName'], $newname), $thread['locale']));
-	}
-}
-
-function close_thread($thread,$isuser) {
-	global $state_closed, $kind_events;
-	
-	if( $thread['istate'] != $state_closed ) {
-		$link = connect();
-		commit_thread( $thread['threadid'], array('istate' => $state_closed), $link);
-		mysql_close($link);
-	}
-
-	$message =  $isuser ? getstring2_("chat.status.user.left", array($thread['userName']), $thread['locale'])
-					: getstring2_("chat.status.operator.left", array($thread['agentName']), $thread['locale']);
-	post_message($thread['threadid'], $kind_events, $message);
-}
-
-function create_thread($username,$remote,$referer,$lang) {
-	$link = connect();
-
-	$query = sprintf(
-		 "insert into chatthread (userName,"."ltoken,remote,referer,lrevision,locale,dtmcreated,dtmmodified) values ".
-								 "('%s',"."%s,'%s','%s',%s,'%s',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)",
-			mysql_real_escape_string($username),
-			next_token(),
-			mysql_real_escape_string($remote),
-			mysql_real_escape_string($referer),
-			next_revision($link),
-			mysql_real_escape_string($lang) );
-
-	perform_query($query,$link);
-	$id = mysql_insert_id($link);
-
-	$newthread = select_one_row("select * from chatthread where threadid = ". $id, $link );
-	mysql_close($link);
-	return $newthread;
-}
-
-function do_take_thread($threadid,$operatorName) {
-	global $state_chatting;
-	$link = connect();
-	commit_thread( $threadid, 
-		array("istate" => $state_chatting,
-			  "agentName" => "'".mysql_real_escape_string($operatorName)."'"), $link);
-	mysql_close($link);
-}
-
-function reopen_thread($threadid) {
-	global $state_queue,$state_waiting,$state_chatting,$state_closed,$kind_events;
-	$thread = thread_by_id($threadid);
-
-	if( !$thread )
-		return FALSE;
-
-	if( $thread['istate'] == $state_closed )
-		return FALSE;
-
-	if( $thread['istate'] != $state_chatting && $thread['istate'] != $state_queue ) {
-		$link = connect();
-		commit_thread( $threadid, 
-			array("istate" => $state_waiting ), $link);
-		mysql_close($link);
-	}
-
-	post_message($thread['threadid'], $kind_events, getstring_("chat.status.user.reopenedthread", $thread['locale']));
-	return $thread;
-}
-
-function take_thread($thread,$operator) {
-	global $state_queue, $state_waiting, $state_chatting, $kind_events, $home_locale;
-
-	$state = $thread['istate'];
-	$threadid = $thread['threadid'];
-	$message_to_post = "";
-
-	$operatorName = ($thread['locale'] == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
-
-	if( $state == $state_queue || $state == $state_waiting) {
-		do_take_thread($threadid, $operatorName);
-
-		if( $state == $state_waiting  ) {
-			$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName,$thread['agentName']), $thread['locale']);
-		} else {
-			$message_to_post = getstring2_("chat.status.operator.joined", array($operatorName), $thread['locale']);
-		}
-	} else if( $state == $state_chatting ) {
-		if( $operatorName != $thread['agentName'] ) {
-			do_take_thread($threadid, $operatorName);		
-			$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName, $thread['agentName']), $thread['locale']);
-		}
-	} else {
-		die("cannot take thread");
-	}
-
-	if( $message_to_post )
-		post_message($threadid,$kind_events,$message_to_post);
-}
-
-function check_for_reassign($thread,$operator) {
-	global $state_waiting, $home_locale, $kind_events;
-	$operatorName = ($thread['locale'] == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
-	if( $thread['istate'] == $state_waiting && 
-			(  $thread['agentName'] == $operatorName )) {
-		do_take_thread($thread['threadid'], $operatorName);
-		$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName,$thread['agentName']), $thread['locale']);
-		post_message($thread['threadid'],$kind_events,$message_to_post);
-	}
-}
-
-function thread_by_id($id) {
-	$link = connect();
-	$thread = select_one_row("select * from chatthread where threadid = ". $id, $link );
-	mysql_close($link);
-	return $thread;
-}
-
-function visitor_from_request() {
-	global $namecookie;
-	$userName = isset($_COOKIE[$namecookie]) ? $_COOKIE[$namecookie] : getstring("chat.default.username");
-
-	return array( 'name' => $userName );
-}
-
-?>
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ *    Pavel Petroshenko - history search
+ */
+
+$connection_timeout = 30; # sec
+
+$namecookie = "WEBIM_Name";
+
+$state_queue = 0;
+$state_waiting = 1;
+$state_chatting = 2;
+$state_closed = 3;
+
+$kind_user = 1;
+$kind_agent = 2;
+$kind_for_agent = 3;
+$kind_info = 4;
+$kind_conn = 5;
+$kind_events = 6;
+
+$kind_to_string = array( $kind_user => "user", $kind_agent => "agent", $kind_for_agent => "hidden",
+	$kind_info => "inf", $kind_conn => "conn", $kind_events => "event" );
+
+
+
+function next_token() {
+	return rand(99999,99999999);
+}
+
+function next_revision($link) {
+	perform_query("update chatrevision set id=LAST_INSERT_ID(id+1)",$link);
+	$val = mysql_insert_id($link);
+	return $val;
+}
+
+function post_message_($threadid,$kind,$message,$link,$from=null,$time=null,$opid=null) {
+	$query = sprintf(
+	    "insert into chatmessage (threadid,ikind,tmessage,tname,agentId,dtmcreated) values (%s, %s,'%s',%s,%s,%s)",
+			$threadid,
+			$kind,
+			quote_smart($message,$link),
+			$from ? "'".quote_smart($from,$link)."'" : "null",
+			$opid ? $opid : "0",
+			$time ? "FROM_UNIXTIME($time)" : "CURRENT_TIMESTAMP" );
+
+	perform_query($query,$link);
+}
+
+function post_message($threadid,$kind,$message,$from=null,$agentid=null) {
+	$link = connect();
+	post_message_($threadid,$kind,$message,$link,$from,null,$agentid);
+	mysql_close($link);
+}
+
+function prepare_html_message($text) {
+	$escaped_text = htmlspecialchars($text);
+	$text_w_links = preg_replace('/(http|ftp):\/\/\S*/','<a href="$0" target="_blank">$0</a>',$escaped_text);
+	$multiline = str_replace("\n","<br/>",$text_w_links);
+	return $multiline;
+}
+
+function message_to_html($msg) {
+	global $kind_to_string;
+	$message = "<span>".date("H:i:s",$msg['created'])."</span> ";
+	$kind = $kind_to_string{$msg['ikind']};
+	if( $msg['tname'] )
+		$message.= "<span class='n$kind'>".htmlspecialchars($msg['tname'])."</span>: ";
+	$message.= "<span class='m$kind'>".prepare_html_message($msg['tmessage'])."</span><br/>";
+	return $message;
+}
+
+function message_to_text($msg) {
+	global $kind_user, $kind_agent, $kind_info;
+	$time = date("H:i:s ",$msg['created']);
+	if($msg['ikind'] == $kind_user || $msg['ikind'] == $kind_agent) {
+		if( $msg['tname'] )
+			return $time.$msg['tname'].": ".$msg['tmessage']."\n";
+		else
+			return $time.$msg['tmessage']."\n";
+	} else if($msg['ikind'] == $kind_info ) {
+		return $time.$msg['tmessage']."\n";
+	} else {
+		return $time."[".$msg['tmessage']."]\n";
+	}
+}
+
+function get_messages($threadid,$meth,$isuser,&$lastid) {
+	global $kind_for_agent;
+	$link = connect();
+
+	$query = sprintf(
+	    "select messageid,ikind,unix_timestamp(dtmcreated) as created,tname,tmessage from chatmessage ".
+	    "where threadid = %s and messageid > %s %s order by messageid",
+	    $threadid, $lastid, $isuser ? "and ikind <> $kind_for_agent" : "" );
+
+	$messages = array();
+	$result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query);
+
+	while ($msg = mysql_fetch_array($result, MYSQL_ASSOC)) {
+		$message = ($meth == 'text') ? message_to_text($msg) : message_to_html($msg);
+		$messages[] = $message;
+		if( $msg['messageid'] > $lastid )
+			$lastid = $msg['messageid'];
+	}
+
+	mysql_free_result($result);
+	mysql_close($link);
+	return $messages;
+} 
+
+function print_thread_mesages($threadid, $token, $lastid, $isuser,$format) {
+	global $webim_encoding, $webimroot;
+	$output = get_messages($threadid,"html",$isuser,$lastid);
+
+	if( $format == "xml" ) {
+		start_xml_output();
+		print("<thread lastID=\"$lastid\">");
+		foreach( $output as $msg ) {
+			print "<message>".myiconv($webim_encoding,"utf-8",escape_with_cdata($msg))."</message>\n";
+		}
+		print("</thread>");
+	} else if( $format == "html" ) {
+		start_html_output();
+		$url = "$webimroot/thread.php?act=refresh&thread=$threadid&token=$token&html=on&user=".($isuser?"true":"false");
+
+		print("<html><head>\n".
+		    "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"$webimroot/chat.css\" />\n".
+		    "<meta http-equiv=\"Refresh\" content=\"7; URL=$url&sn=11\">\n".
+		    "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n".
+		    "</head>".
+		    "<body bgcolor='#FFFFFF' text='#000000' link='#C28400' vlink='#C28400' alink='#C28400' marginwidth='0' marginheight='0' leftmargin='0' rightmargin='0' topmargin='0' bottommargin='0' onload=\"if( location.hash != '#aend' ){location.hash='#aend';}\">".
+		    "<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top' class='message'>" );
+
+		foreach( $output as $msg ) {
+			print $msg;
+		}
+
+		print(
+		    "</td></tr></table><a name='aend'>".
+		    "</body></html>" );
+	}
+}
+
+function get_user_name($name, $id="") {
+	global $presentable_name_pattern;
+       	return str_replace("{id}", $id, str_replace("{name}", $name, $presentable_name_pattern));
+}
+
+function setup_chatview_for_user($thread,$level) {
+	global $page, $webimroot, $user_can_change_name, $company_logo_link, $company_name;
+	$page = array();
+	$page['agent'] = false;
+	$page['user'] = true;
+	$page['canpost'] = true;
+	$nameisset = getstring("chat.default.username") != $thread['userName'];
+	$page['displ1'] = $nameisset ? "none" : "inline";
+	$page['displ2'] = $nameisset ? "inline" : "none";
+	$page['level'] = $level;
+	$page['ct.chatThreadId'] = $thread['threadid'];
+	$page['ct.token'] = $thread['ltoken'];
+	$page['ct.user.name'] = $thread['userName'];
+	$page['canChangeName'] = $user_can_change_name;
+
+	$page['ct.company.name'] = $company_name;
+	$page['ct.company.chatLogoURL'] = $company_logo_link;
+
+	$params = "thread=".$thread['threadid']."&token=".$thread['ltoken'];
+	$page['selfLink'] = "$webimroot/client.php?".$params."&level=".$level;
+}
+
+function setup_chatview_for_operator($thread,$operator) {
+	global $page, $webimroot, $company_logo_link, $company_name;
+	$page = array();
+	$page['agent'] = true;
+	$page['user'] = false;
+	$page['canpost'] = true;
+	$page['ct.chatThreadId'] = $thread['threadid'];
+	$page['ct.token'] = $thread['ltoken'];
+	$page['ct.user.name'] = get_user_name($thread['userName']);
+
+	$page['ct.company.name'] = $company_name;
+	$page['ct.company.chatLogoURL'] = $company_logo_link;
+
+	// TODO
+	$page['namePostfix'] = "";	
+}
+
+function is_ajax_browser($name,$ver,$useragent) {
+	if( $name == "opera" )
+		return $ver >= 8.02;
+	if( $name == "safari" )
+		return $ver >= 125;
+	if( $name == "msie" )
+		return $ver >= 5.5 && !strstr($useragent, "powerpc");
+	if( $name == "netscape" )
+		return $ver >= 7.1;
+	if( $name == "mozilla")
+		return $ver >= 1.4;
+	if( $name == "firefox")
+		return $ver >= 1.0;
+
+	return false;
+}
+
+function is_old_browser($name,$ver) {
+	if( $name == "opera" )
+		return $ver < 7.0;
+	if( $name == "msie" )
+		return $ver < 5.0;
+	return false; 
+}
+
+$knownAgents = array("opera","msie","safari","firefox","netscape","mozilla");
+
+function get_remote_level($useragent) {
+	global $knownAgents;
+	$useragent = strtolower($useragent);
+	foreach( $knownAgents as $agent ) {
+		if( strstr($useragent,$agent) ) {
+			if( preg_match( "/".$agent."[\\s\/]?(\\d+(\\.\\d+)?)/", $useragent, $matches ) ) {
+				$ver = $matches[1];
+
+				if( is_ajax_browser($agent,$ver,$useragent) )
+					return "ajaxed";
+				else if( is_old_browser($agent,$ver) )
+					return "old";
+
+				return "simple";
+			}
+		}
+	}
+	return "simple";
+}
+
+function update_thread_access($threadid, $params, $link) {
+	$clause = "";
+	foreach( $params as $k => $v ) {
+		if( strlen($clause) > 0 )
+			$clause .= ", ";
+	    $clause .= $k."=".$v;
+	}
+	perform_query(
+		 "update chatthread set $clause ".
+		 "where threadid = ".$threadid,$link);
+}
+
+function get_access_time($threadid, $isuser, $link) {
+	return select_one_row(sprintf(
+		 "select unix_timestamp(%s) as lastping, ".
+		 "unix_timestamp(CURRENT_TIMESTAMP) as current ".
+		 "from chatthread where threadid = %s",
+		$isuser ? "lastpinguser" : "lastpingagent",
+		$threadid), $link);
+}
+
+function ping_thread($thread, $isuser) {
+	global $kind_for_agent, $state_chatting, $state_waiting, $kind_conn, $connection_timeout;
+	$link = connect();
+	$params = array(($isuser ? "lastpinguser" : "lastpingagent") => "CURRENT_TIMESTAMP" );
+
+	$access = get_access_time($thread['threadid'], !$isuser, $link);
+ 	if( $access['lastping'] > 0 && abs($access['current']-$access['lastping']) > $connection_timeout ) {
+		$params[$isuser ? "lastpingagent" : "lastpinguser"] = "0";
+		if( !$isuser ) {
+			$message_to_post = getstring_("chat.status.user.dead", $thread['locale']);
+			post_message_($thread['threadid'],$kind_for_agent,$message_to_post,$link,null,$access['lastping']+$connection_timeout);
+		} else if( $thread['istate'] == $state_chatting ) {
+
+			$message_to_post = getstring_("chat.status.operator.dead", $thread['locale']);
+			post_message_($thread['threadid'],$kind_conn,$message_to_post,$link,null,$access['lastping']+$connection_timeout);
+			$params['istate'] = $state_waiting;
+			commit_thread($thread['threadid'], $params, $link);
+			mysql_close($link);
+			return;
+		}
+	}
+
+	update_thread_access($thread['threadid'], $params, $link);
+	mysql_close($link);
+}
+
+function commit_thread($threadid,$params,$link) {
+	$query = "update chatthread set lrevision = ".next_revision($link).", dtmmodified = CURRENT_TIMESTAMP";
+	foreach( $params as $k => $v ) {
+	    $query .= ", ".$k."=".$v;
+	}
+	$query .= " where threadid = ".$threadid;
+
+	perform_query($query,$link);
+}
+
+function rename_user($thread, $newname) {
+	global $kind_events;
+
+	$link = connect();
+	commit_thread( $thread['threadid'], array('userName' => "'".mysql_real_escape_string($newname)."'"), $link);
+	mysql_close($link);
+
+	if( $thread['userName'] != $newname ) {
+		post_message($thread['threadid'],$kind_events,
+			getstring2_("chat.status.user.changedname",array($thread['userName'], $newname), $thread['locale']));
+	}
+}
+
+function close_thread($thread,$isuser) {
+	global $state_closed, $kind_events;
+	
+	if( $thread['istate'] != $state_closed ) {
+		$link = connect();
+		commit_thread( $thread['threadid'], array('istate' => $state_closed), $link);
+		mysql_close($link);
+	}
+
+	$message =  $isuser ? getstring2_("chat.status.user.left", array($thread['userName']), $thread['locale'])
+					: getstring2_("chat.status.operator.left", array($thread['agentName']), $thread['locale']);
+	post_message($thread['threadid'], $kind_events, $message);
+}
+
+function create_thread($username,$remote,$referer,$lang) {
+	$link = connect();
+
+	$query = sprintf(
+		 "insert into chatthread (userName,"."ltoken,remote,referer,lrevision,locale,dtmcreated,dtmmodified) values ".
+								 "('%s',"."%s,'%s','%s',%s,'%s',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)",
+			mysql_real_escape_string($username),
+			next_token(),
+			mysql_real_escape_string($remote),
+			mysql_real_escape_string($referer),
+			next_revision($link),
+			mysql_real_escape_string($lang) );
+
+	perform_query($query,$link);
+	$id = mysql_insert_id($link);
+
+	$newthread = select_one_row("select * from chatthread where threadid = ". $id, $link );
+	mysql_close($link);
+	return $newthread;
+}
+
+function do_take_thread($threadid,$operatorId,$operatorName) {
+	global $state_chatting;
+	$link = connect();
+	commit_thread( $threadid, 
+		array("istate" => $state_chatting,
+			  "agentId" => $operatorId,
+			  "agentName" => "'".mysql_real_escape_string($operatorName)."'"), $link);
+	mysql_close($link);
+}
+
+function reopen_thread($threadid) {
+	global $state_queue,$state_waiting,$state_chatting,$state_closed,$kind_events;
+	$thread = thread_by_id($threadid);
+
+	if( !$thread )
+		return FALSE;
+
+	if( $thread['istate'] == $state_closed )
+		return FALSE;
+
+	if( $thread['istate'] != $state_chatting && $thread['istate'] != $state_queue ) {
+		$link = connect();
+		commit_thread( $threadid, 
+			array("istate" => $state_waiting ), $link);
+		mysql_close($link);
+	}
+
+	post_message($thread['threadid'], $kind_events, getstring_("chat.status.user.reopenedthread", $thread['locale']));
+	return $thread;
+}
+
+function take_thread($thread,$operator) {
+	global $state_queue, $state_waiting, $state_chatting, $kind_events, $home_locale;
+
+	$state = $thread['istate'];
+	$threadid = $thread['threadid'];
+	$message_to_post = "";
+
+	$operatorName = ($thread['locale'] == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
+
+	if( $state == $state_queue || $state == $state_waiting) {
+		do_take_thread($threadid, $operator['operatorid'], $operatorName);
+
+		if( $state == $state_waiting  ) {
+			$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName,$thread['agentName']), $thread['locale']);
+		} else {
+			$message_to_post = getstring2_("chat.status.operator.joined", array($operatorName), $thread['locale']);
+		}
+	} else if( $state == $state_chatting ) {
+		if( $operator['operatorid'] != $thread['agentId'] ) {
+			do_take_thread($threadid, $operator['operatorid'], $operatorName);		
+			$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName, $thread['agentName']), $thread['locale']);
+		}
+	} else {
+		die("cannot take thread");
+	}
+
+	if( $message_to_post ) {
+		post_message($threadid,$kind_events,$message_to_post);
+	}
+}
+
+function check_for_reassign($thread,$operator) {
+	global $state_waiting, $home_locale, $kind_events;
+	$operatorName = ($thread['locale'] == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
+	if( $thread['istate'] == $state_waiting && 
+			(  $thread['agentId'] == $operator['operatorid'] )) {
+		do_take_thread($thread['threadid'], $operator['operatorid'], $operatorName);
+		$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName,$thread['agentName']), $thread['locale']);
+		post_message($thread['threadid'],$kind_events,$message_to_post);
+	}
+}
+
+function thread_by_id($id) {
+	$link = connect();
+	$thread = select_one_row("select * from chatthread where threadid = ". $id, $link );
+	mysql_close($link);
+	return $thread;
+}
+
+function visitor_from_request() {
+	global $namecookie;
+	$userName = isset($_COOKIE[$namecookie]) ? $_COOKIE[$namecookie] : getstring("chat.default.username");
+
+	return array( 'name' => $userName );
+}
+
+?>
diff --git a/src/webim/libs/common.php b/src/webim/libs/common.php
index db11676e..c9931e26 100644
--- a/src/webim/libs/common.php
+++ b/src/webim/libs/common.php
@@ -1,293 +1,335 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-session_start();
-
-require(dirname(__FILE__).'/converter.php');
-require(dirname(__FILE__).'/config.php');
-
-$webimroot = "/webim";                      # absolute path on server
-
-function myiconv($in_enc, $out_enc, $string) {
-	global $_utf8win1251, $_win1251utf8;
-	if( function_exists('iconv') ) {
-	    $converted = iconv($in_enc, $out_enc, $string);
-	    if( $converted !== FALSE )
-			return $converted;
-	}
-	if( $in_enc == "cp1251" && $out_enc == "utf-8" )
-		return strtr($string, $_win1251utf8);
-	if( $in_enc == "utf-8" && $out_enc == "cp1251" )
-		return strtr($string, $_utf8win1251);
-
-	return $string; // do not know how to convert
-}
-
-function getrawparam( $name ) {
-	global $webim_encoding, $request_encoding;
-	if( isset($_POST[$name]) )
-		return myiconv($request_encoding,$webim_encoding,$_POST[$name]);
-	die("no ".$name." parameter");
-}
-
-function getparam( $name ) {
-	if( isset($_POST[$name]) )
-		return $_POST[$name];
-	die("no ".$name." parameter");
-}
-
-function verifyparam( $name, $regexp, $default = null ) {
-
-	if( isset( $_GET[$name] ) ) {
-		$val = $_GET[$name];
-		if( preg_match( $regexp, $val ) )
-			return $val;
-
-	} else if( isset( $_POST[$name] ) ) {
-		$val = $_POST[$name];
-		if( preg_match( $regexp, $val ) )
-			return $val;
-
-	} else {
-		if( isset( $default ) )
-			return $default;
-	}
-
-	echo "<html><head></head><body>Wrong parameter used or absent: ".$name."</body></html>";
-	exit;
-}
-
-function debugexit_print( $var ) {
-	echo "<html><body><pre>";
-	print_r( $var );
-	echo "</pre></body></html>";
-	exit;
-}
-
-function get_user_locale() {
-	global $available_locales, $default_locale;
-
-	if( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) {
-		$requested_langs = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
-		foreach( $requested_langs as $requested_lang) {
-			if( strlen($requested_lang) > 2 )
-				$requested_lang = substr($requested_lang,0,2);
-
-			if( in_array($requested_lang,$available_locales) )
-				return $requested_lang;
-		}
-	}
-
-	if( in_array($default_locale,$available_locales) )
-		return $default_locale;
-
-	return 'en';
-}
-
-function get_locale() {
-	global $available_locales;
-
-	$locale = verifyparam("locale", "/^\w\w$/", "");
-
-	if( $locale && in_array($locale,$available_locales) ) {
-		$_SESSION['locale'] = $locale;
-	} else if( isset($_SESSION['locale']) ){
-	    $locale = $_SESSION['locale'];
-	}
-
-	if( !$locale || !in_array($locale,$available_locales) )
-		$locale = get_user_locale();
-	return $locale;
-}
-
-function set_locale($locale) {
-	global $current_locale, $available_locales;
-	if( in_array($locale,$available_locales) )
-		$current_locale = $locale;
-}
-
-$current_locale = get_locale();
-$messages = array();
-
-function load_messages($locale) {
-	global $messages;
-	$hash = array();
-	$fp = fopen(dirname(__FILE__)."/../view/properties_$locale","r");
-	while (!feof($fp)) {
-    	$line = fgets($fp, 4096);
-		$list = split("=", $line, 2 );
-		if( isset($list[1]) ) {
-			$hash[$list[0]] = str_replace("\\n", "\n",trim($list[1]));
-		}
-	}
-	fclose($fp);
-	$messages[$locale] = $hash;
-}
-
-function getstring_($text,$locale) {
-	global $messages;
-	if(!isset($messages[$locale]))
-		load_messages($locale);
-
-	$localized = $messages[$locale];
-	if( isset($localized[$text]) )
-		return $localized[$text];
-
-	return "!".$text;
-}
-
-function getstring($text) {
-	global $current_locale;
-	return getstring_($text,$current_locale);
-}
-
-function getstring2_($text,$params,$locale) {
-	$string = getstring_($text,$locale);
-	for( $i = 0; $i < count($params); $i++ ) {
-		$string = str_replace("{".$i."}", $params[$i], $string);
-	}
-	return $string;
-}
-
-function getstring2($text,$params) {
-	global $current_locale;
-	return getstring2_($text,$params,$current_locale);
-}
-
-function connect() {
-	global $mysqlhost, $mysqllogin, $mysqlpass, $mysqldb, $dbencoding, $force_charset_in_connection;
-	$link = mysql_connect($mysqlhost,$mysqllogin ,$mysqlpass )
-		or die('Could not connect: ' . mysql_error());
-	mysql_select_db($mysqldb) or die('Could not select database');
-	if( $force_charset_in_connection )
-		mysql_query("SET character set $dbencoding", $link);
-	return $link;
-}
-
-function perform_query($query,$link) {
-	mysql_query($query,$link) or die(' Query failed: ' . 
-		mysql_error().": ".$query);
-}
-
-function select_one_row($query,$link) {
-	$result = mysql_query($query,$link) or die(' Query failed: ' . 
-		mysql_error().": ".$query);
-	$line = mysql_fetch_array($result, MYSQL_ASSOC);
-	mysql_free_result($result);
-	return $line;
-}
-
-function start_xml_output() {
-	header("Cache-Control: no-store, no-cache, must-revalidate");
-	header("Content-type: text/xml");
-	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
-}
-
-function start_html_output() {
-	global $output_charset;
-	header("Cache-Control: no-store, no-cache, must-revalidate");
-	header("Content-type: text/html".(isset($output_charset)?"; charset=".$output_charset:""));
-}
-
-function escape_with_cdata($text) {
-	return "<![CDATA[" . str_replace("]]>", "]]>]]&gt;<![CDATA[",$text) . "]]>";
-}
-
-function form_value($key) {
-	global $page;
-	if( isset($page) && isset($page["form$key"]) )
-		return $page["form$key"];
-	return "";
-}
-
-function form_value_cb($key) {
-	global $page;
-	if( isset($page) && isset($page["form$key"]) )
-		return $page["form$key"] === true;
-	return false;
-}
-
-function no_field($key) {
-	return getstring2("errors.required",array(getstring($key)));
-}
-
-function get_popup($href,$message,$title,$wndName,$options) {
-	return "<a href=\"$href\" target=\"_blank\" ".($title?"title=\"$title\" ":"")."onclick=\"this.newWindow = window.open('$href', '$wndName', '$options');this.newWindow.focus();this.newWindow.opener=window;return false;\">$message</a>";
-}
-
-function get_image($href,$width,$height) {
-	if( $width != 0 && $height != 0 )                   
-		return "<img src=\"$href\" border=\"0\" width=\"$width\" height=\"$height\"/>";
-	return "<img src=\"$href\" border=\"0\"/>";
-}
-
-function get_gifimage_size($file) {
-	if( function_exists('gd_info')) {
-		$info = gd_info();
-		if( isset($info['GIF Read Support']) && $info['GIF Read Support'] ) {
-			$img = @imagecreatefromgif($file);
-			if($img) {
-				$height = imagesy($img);
-				$width = imagesx($img);
-				imagedestroy($img);
-				return array($width,$height);
-			}
-		}
-	}
-	return array(0,0);
-}
-
-function add_params($servlet, $params) {
-	$infix = '?';
-	if( strstr($servlet,$infix) !== FALSE )
-		$infix = '&';
-	foreach($params as $k => $v) {
-		$servlet .= $infix.$k."=".$v;
-		$infix = '&';
-	}
-	return $servlet;
-}
-
-function div($a,$b) {
-    return ($a-($a % $b)) / $b;
-}
-
-function date_diff($seconds) {
-    $minutes = div($seconds,60);
-	$seconds = $seconds % 60;
-	if( $minutes < 60 ) {
-		return sprintf("%02d:%02d",$minutes, $seconds);
-	} else {
-		$hours = div($minutes,60);
-		$minutes = $minutes % 60;
-		return sprintf("%02d:%02d:%02d",$hours, $minutes, $seconds);
-	}
-}
-
-function quote_smart($value,$link) {
-	if (get_magic_quotes_gpc()) {
-		$value = stripslashes($value);
-	}
-	return mysql_real_escape_string($value,$link);
-}
-
-function get_app_location($showhost,$issecure) {
-	if( $showhost ) {
-		return ($issecure?"https://":"http://").$_SERVER['HTTP_HOST']."/webim";
-	} else {
-		return "/webim";
-	}
-}
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+session_start();
+
+require(dirname(__FILE__).'/converter.php');
+require(dirname(__FILE__).'/config.php');
+
+$webimroot = "/webim";                      # absolute path on server
+
+function myiconv($in_enc, $out_enc, $string) {
+	global $_utf8win1251, $_win1251utf8;
+	if( function_exists('iconv') ) {
+	    $converted = iconv($in_enc, $out_enc, $string);
+	    if( $converted !== FALSE )
+			return $converted;
+	}
+	if( $in_enc == "cp1251" && $out_enc == "utf-8" )
+		return strtr($string, $_win1251utf8);
+	if( $in_enc == "utf-8" && $out_enc == "cp1251" )
+		return strtr($string, $_utf8win1251);
+
+	return $string; // do not know how to convert
+}
+
+function getrawparam( $name ) {
+	global $webim_encoding, $request_encoding;
+	if( isset($_POST[$name]) )
+		return myiconv($request_encoding,$webim_encoding,$_POST[$name]);
+	die("no ".$name." parameter");
+}
+
+function getparam( $name ) {
+	if( isset($_POST[$name]) )
+		return $_POST[$name];
+	die("no ".$name." parameter");
+}
+
+function verifyparam( $name, $regexp, $default = null ) {
+
+	if( isset( $_GET[$name] ) ) {
+		$val = $_GET[$name];
+		if( preg_match( $regexp, $val ) )
+			return $val;
+
+	} else if( isset( $_POST[$name] ) ) {
+		$val = $_POST[$name];
+		if( preg_match( $regexp, $val ) )
+			return $val;
+
+	} else {
+		if( isset( $default ) )
+			return $default;
+	}
+
+	echo "<html><head></head><body>Wrong parameter used or absent: ".$name."</body></html>";
+	exit;
+}
+
+function debugexit_print( $var ) {
+	echo "<html><body><pre>";
+	print_r( $var );
+	echo "</pre></body></html>";
+	exit;
+}
+
+function get_user_locale() {
+	global $available_locales, $default_locale;
+
+	if( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) {
+		$requested_langs = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
+		foreach( $requested_langs as $requested_lang) {
+			if( strlen($requested_lang) > 2 )
+				$requested_lang = substr($requested_lang,0,2);
+
+			if( in_array($requested_lang,$available_locales) )
+				return $requested_lang;
+		}
+	}
+
+	if( in_array($default_locale,$available_locales) )
+		return $default_locale;
+
+	return 'en';
+}
+
+function get_locale() {
+	global $available_locales;
+
+	$locale = verifyparam("locale", "/^\w\w$/", "");
+
+	if( $locale && in_array($locale,$available_locales) ) {
+		$_SESSION['locale'] = $locale;
+	} else if( isset($_SESSION['locale']) ){
+	    $locale = $_SESSION['locale'];
+	}
+
+	if( !$locale || !in_array($locale,$available_locales) )
+		$locale = get_user_locale();
+	return $locale;
+}
+
+function set_locale($locale) {
+	global $current_locale, $available_locales;
+	if( in_array($locale,$available_locales) )
+		$current_locale = $locale;
+}
+
+$current_locale = get_locale();
+$messages = array();
+
+function load_messages($locale) {
+	global $messages;
+	$hash = array();
+	$fp = fopen(dirname(__FILE__)."/../view/properties_$locale","r");
+	while (!feof($fp)) {
+    	$line = fgets($fp, 4096);
+		$list = split("=", $line, 2 );
+		if( isset($list[1]) ) {
+			$hash[$list[0]] = str_replace("\\n", "\n",trim($list[1]));
+		}
+	}
+	fclose($fp);
+	$messages[$locale] = $hash;
+}
+
+function getstring_($text,$locale) {
+	global $messages;
+	if(!isset($messages[$locale]))
+		load_messages($locale);
+
+	$localized = $messages[$locale];
+	if( isset($localized[$text]) )
+		return $localized[$text];
+
+	return "!".$text;
+}
+
+function getstring($text) {
+	global $current_locale;
+	return getstring_($text,$current_locale);
+}
+
+function getstring2_($text,$params,$locale) {
+	$string = getstring_($text,$locale);
+	for( $i = 0; $i < count($params); $i++ ) {
+		$string = str_replace("{".$i."}", $params[$i], $string);
+	}
+	return $string;
+}
+
+function getstring2($text,$params) {
+	global $current_locale;
+	return getstring2_($text,$params,$current_locale);
+}
+
+function connect() {
+	global $mysqlhost, $mysqllogin, $mysqlpass, $mysqldb, $dbencoding, $force_charset_in_connection;
+	$link = mysql_connect($mysqlhost,$mysqllogin ,$mysqlpass )
+		or die('Could not connect: ' . mysql_error());
+	mysql_select_db($mysqldb) or die('Could not select database');
+	if( $force_charset_in_connection )
+		mysql_query("SET character set $dbencoding", $link);
+	return $link;
+}
+
+function perform_query($query,$link) {
+	mysql_query($query,$link) or die(' Query failed: ' . 
+		mysql_error().": ".$query);
+}
+
+function select_one_row($query,$link) {
+	$result = mysql_query($query,$link) or die(' Query failed: ' . 
+		mysql_error().": ".$query);
+	$line = mysql_fetch_array($result, MYSQL_ASSOC);
+	mysql_free_result($result);
+	return $line;
+}
+
+function select_multi_assoc($query,$link) {
+	$sqlresult = mysql_query($query,$link) or die(' Query failed: ' . 
+		mysql_error().": ".$query);
+
+	$result = array();
+	while ($row = mysql_fetch_array($sqlresult, MYSQL_ASSOC)) {
+		$result[] = $row;
+	}
+	mysql_free_result($sqlresult);
+	return $result;
+}
+
+function start_xml_output() {
+	header("Cache-Control: no-store, no-cache, must-revalidate");
+	header("Content-type: text/xml");
+	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+}
+
+function start_html_output() {
+	global $output_charset;
+	header("Cache-Control: no-store, no-cache, must-revalidate");
+	header("Content-type: text/html".(isset($output_charset)?"; charset=".$output_charset:""));
+}
+
+function escape_with_cdata($text) {
+	return "<![CDATA[" . str_replace("]]>", "]]>]]&gt;<![CDATA[",$text) . "]]>";
+}
+
+function form_value($key) {
+	global $page;
+	if( isset($page) && isset($page["form$key"]) )
+		return $page["form$key"];
+	return "";
+}
+
+function form_value_cb($key) {
+	global $page;
+	if( isset($page) && isset($page["form$key"]) )
+		return $page["form$key"] === true;
+	return false;
+}
+
+function no_field($key) {
+	return getstring2("errors.required",array(getstring($key)));
+}
+
+function get_popup($href,$message,$title,$wndName,$options) {
+	return "<a href=\"$href\" target=\"_blank\" ".($title?"title=\"$title\" ":"")."onclick=\"this.newWindow = window.open('$href', '$wndName', '$options');this.newWindow.focus();this.newWindow.opener=window;return false;\">$message</a>";
+}
+
+function get_image($href,$width,$height) {
+	if( $width != 0 && $height != 0 )                   
+		return "<img src=\"$href\" border=\"0\" width=\"$width\" height=\"$height\"/>";
+	return "<img src=\"$href\" border=\"0\"/>";
+}
+
+function get_gifimage_size($file) {
+	if( function_exists('gd_info')) {
+		$info = gd_info();
+		if( isset($info['GIF Read Support']) && $info['GIF Read Support'] ) {
+			$img = @imagecreatefromgif($file);
+			if($img) {
+				$height = imagesy($img);
+				$width = imagesx($img);
+				imagedestroy($img);
+				return array($width,$height);
+			}
+		}
+	}
+	return array(0,0);
+}
+
+function add_params($servlet, $params) {
+	$infix = '?';
+	if( strstr($servlet,$infix) !== FALSE )
+		$infix = '&';
+	foreach($params as $k => $v) {
+		$servlet .= $infix.$k."=".$v;
+		$infix = '&';
+	}
+	return $servlet;
+}
+
+function div($a,$b) {
+    return ($a-($a % $b)) / $b;
+}
+
+function date_diff($seconds) {
+    $minutes = div($seconds,60);
+	$seconds = $seconds % 60;
+	if( $minutes < 60 ) {
+		return sprintf("%02d:%02d",$minutes, $seconds);
+	} else {
+		$hours = div($minutes,60);
+		$minutes = $minutes % 60;
+		return sprintf("%02d:%02d:%02d",$hours, $minutes, $seconds);
+	}
+}
+
+function quote_smart($value,$link) {
+	if (get_magic_quotes_gpc()) {
+		$value = stripslashes($value);
+	}
+	return mysql_real_escape_string($value,$link);
+}
+
+function get_app_location($showhost,$issecure) {
+	if( $showhost ) {
+		return ($issecure?"https://":"http://").$_SERVER['HTTP_HOST']."/webim";
+	} else {
+		return "/webim";
+	}
+}
+
+function get_month_selection($fromtime,$totime) {
+	$start = getdate($fromtime);
+	$month = $start['mon'];
+	$year = $start['year'];
+	$result = array();
+	do {
+		$current = mktime(0,0,0,$month,1,$year);
+		$result[date("m.y",$current)] = date("M, Y",$current);
+		$month++;
+		if( $month > 12 ) {
+			$month = 1;
+			$year++; 
+		}
+	} while( $current < $totime );
+	return $result;
+}
+
+function get_form_date($day,$month) {
+	if( preg_match('/^(\d{2}).(\d{2})$/', $month, $matches)) {
+		return mktime(0,0,0,$matches[1],$day,$matches[2]);
+	}
+	return 0;
+}
+
+function set_form_date($time,$prefix) {
+	global $page;
+	$page["form${prefix}day"] = date("d", $time);
+	$page["form${prefix}month"] = date("m.y", $time);
+}
+
 ?>
\ No newline at end of file
diff --git a/src/webim/libs/config.php b/src/webim/libs/config.php
index 28d877d4..25d6d74f 100644
--- a/src/webim/libs/config.php
+++ b/src/webim/libs/config.php
@@ -1,89 +1,89 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-/*
- *  MySQL Database parameters
- */
-$mysqlhost = "localhost";
-$mysqldb = "webim_db";
-$mysqllogin = "webim_lite";
-$mysqlpass = "123";
-
-/*
- *  Localization parameters
- */
-
-// Use CP-1251 database
-$dbencoding = "cp1251";
-$webim_encoding = "cp1251";
-$request_encoding = "utf-8";
-$output_charset = "Windows-1251";
-$force_charset_in_connection = true;
-
-
-// Use UTF-8 database
-/*
-$dbencoding = "utf8";
-$webim_encoding = "cp1251";
-$request_encoding = "utf-8";
-$output_charset = "Windows-1251";
-$force_charset_in_connection = true;
-*/
-
-/*
- *   From field in outgoing mail.
- */
-$webim_from_email = "webim@yourdomain.com"; // email from field
-
-/*
- *   Company international name.
- */
-$company_name = "My Company Ltd.";
-
-/*
- *   Company logo. 
- */
-$company_logo_link = "";
-
-/*
- *   Locales 
- */
-$available_locales = array("en", "ru");
-$home_locale = "ru";                        // native name will be used in this locale
-$default_locale = "en";                     // if user does not provide known lang
-
-/*
- *   Allows users to change their names
- */
-$user_can_change_name = true;
-
-/*
- *   How to build presentable visitor name from {name}. Default: {name}
- */ 
-$presentable_name_pattern = "{name}";
-
-/*
- *   Method of getting information about remote user. For example, you could
- *   have user name or id in session. Default value: visitor_from_request
- */
-$remote_visitor = 'visitor_from_request';
-
-/*
- *   Timeout (in seconds) when online operator becomes offline.
- */
-$online_timeout = 30;
-
-
-
-?>
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+/*
+ *  MySQL Database parameters
+ */
+$mysqlhost = "localhost";
+$mysqldb = "webim_db";
+$mysqllogin = "webim_lite";
+$mysqlpass = "123";
+
+/*
+ *  Localization parameters
+ */
+
+// Use CP-1251 database
+$dbencoding = "cp1251";
+$webim_encoding = "cp1251";
+$request_encoding = "utf-8";
+$output_charset = "Windows-1251";
+$force_charset_in_connection = true;
+
+
+// Use UTF-8 database
+/*
+$dbencoding = "utf8";
+$webim_encoding = "cp1251";
+$request_encoding = "utf-8";
+$output_charset = "Windows-1251";
+$force_charset_in_connection = true;
+*/
+
+/*
+ *   From field in outgoing mail.
+ */
+$webim_from_email = "webim@yourdomain.com"; // email from field
+
+/*
+ *   Company international name.
+ */
+$company_name = "My Company Ltd.";
+
+/*
+ *   Company logo. 
+ */
+$company_logo_link = "";
+
+/*
+ *   Locales 
+ */
+$available_locales = array("en", "ru");
+$home_locale = "ru";                        // native name will be used in this locale
+$default_locale = "en";                     // if user does not provide known lang
+
+/*
+ *   Allows users to change their names
+ */
+$user_can_change_name = true;
+
+/*
+ *   How to build presentable visitor name from {name}. Default: {name}
+ */ 
+$presentable_name_pattern = "{name}";
+
+/*
+ *   Method of getting information about remote user. For example, you could
+ *   have user name or id in session. Default value: visitor_from_request
+ */
+$remote_visitor = 'visitor_from_request';
+
+/*
+ *   Timeout (in seconds) when online operator becomes offline.
+ */
+$online_timeout = 30;
+
+
+
+?>
diff --git a/src/webim/libs/converter.php b/src/webim/libs/converter.php
index ff12a479..34145ede 100644
--- a/src/webim/libs/converter.php
+++ b/src/webim/libs/converter.php
@@ -1,48 +1,48 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-$_utf8win1251 = array(
-"\xD0\x90"=>"\xC0","\xD0\x91"=>"\xC1","\xD0\x92"=>"\xC2","\xD0\x93"=>"\xC3","\xD0\x94"=>"\xC4",
-"\xD0\x95"=>"\xC5","\xD0\x81"=>"\xA8","\xD0\x96"=>"\xC6","\xD0\x97"=>"\xC7","\xD0\x98"=>"\xC8",
-"\xD0\x99"=>"\xC9","\xD0\x9A"=>"\xCA","\xD0\x9B"=>"\xCB","\xD0\x9C"=>"\xCC","\xD0\x9D"=>"\xCD",
-"\xD0\x9E"=>"\xCE","\xD0\x9F"=>"\xCF","\xD0\xA0"=>"\xD0","\xD0\xA1"=>"\xD1","\xD0\xA2"=>"\xD2",
-"\xD0\xA3"=>"\xD3","\xD0\xA4"=>"\xD4","\xD0\xA5"=>"\xD5","\xD0\xA6"=>"\xD6","\xD0\xA7"=>"\xD7",
-"\xD0\xA8"=>"\xD8","\xD0\xA9"=>"\xD9","\xD0\xAA"=>"\xDA","\xD0\xAB"=>"\xDB","\xD0\xAC"=>"\xDC",
-"\xD0\xAD"=>"\xDD","\xD0\xAE"=>"\xDE","\xD0\xAF"=>"\xDF","\xD0\x87"=>"\xAF","\xD0\x86"=>"\xB2",
-"\xD0\x84"=>"\xAA","\xD0\x8E"=>"\xA1","\xD0\xB0"=>"\xE0","\xD0\xB1"=>"\xE1","\xD0\xB2"=>"\xE2",
-"\xD0\xB3"=>"\xE3","\xD0\xB4"=>"\xE4","\xD0\xB5"=>"\xE5","\xD1\x91"=>"\xB8","\xD0\xB6"=>"\xE6",
-"\xD0\xB7"=>"\xE7","\xD0\xB8"=>"\xE8","\xD0\xB9"=>"\xE9","\xD0\xBA"=>"\xEA","\xD0\xBB"=>"\xEB",
-"\xD0\xBC"=>"\xEC","\xD0\xBD"=>"\xED","\xD0\xBE"=>"\xEE","\xD0\xBF"=>"\xEF","\xD1\x80"=>"\xF0",
-"\xD1\x81"=>"\xF1","\xD1\x82"=>"\xF2","\xD1\x83"=>"\xF3","\xD1\x84"=>"\xF4","\xD1\x85"=>"\xF5",
-"\xD1\x86"=>"\xF6","\xD1\x87"=>"\xF7","\xD1\x88"=>"\xF8","\xD1\x89"=>"\xF9","\xD1\x8A"=>"\xFA",
-"\xD1\x8B"=>"\xFB","\xD1\x8C"=>"\xFC","\xD1\x8D"=>"\xFD","\xD1\x8E"=>"\xFE","\xD1\x8F"=>"\xFF",
-"\xD1\x96"=>"\xB3","\xD1\x97"=>"\xBF","\xD1\x94"=>"\xBA","\xD1\x9E"=>"\xA2");
-$_win1251utf8 = array(
-"\xC0"=>"\xD0\x90","\xC1"=>"\xD0\x91","\xC2"=>"\xD0\x92","\xC3"=>"\xD0\x93","\xC4"=>"\xD0\x94",
-"\xC5"=>"\xD0\x95","\xA8"=>"\xD0\x81","\xC6"=>"\xD0\x96","\xC7"=>"\xD0\x97","\xC8"=>"\xD0\x98",
-"\xC9"=>"\xD0\x99","\xCA"=>"\xD0\x9A","\xCB"=>"\xD0\x9B","\xCC"=>"\xD0\x9C","\xCD"=>"\xD0\x9D",
-"\xCE"=>"\xD0\x9E","\xCF"=>"\xD0\x9F","\xD0"=>"\xD0\xA0","\xD1"=>"\xD0\xA1","\xD2"=>"\xD0\xA2",
-"\xD3"=>"\xD0\xA3","\xD4"=>"\xD0\xA4","\xD5"=>"\xD0\xA5","\xD6"=>"\xD0\xA6","\xD7"=>"\xD0\xA7",
-"\xD8"=>"\xD0\xA8","\xD9"=>"\xD0\xA9","\xDA"=>"\xD0\xAA","\xDB"=>"\xD0\xAB","\xDC"=>"\xD0\xAC",
-"\xDD"=>"\xD0\xAD","\xDE"=>"\xD0\xAE","\xDF"=>"\xD0\xAF","\xAF"=>"\xD0\x87","\xB2"=>"\xD0\x86",
-"\xAA"=>"\xD0\x84","\xA1"=>"\xD0\x8E","\xE0"=>"\xD0\xB0","\xE1"=>"\xD0\xB1","\xE2"=>"\xD0\xB2",
-"\xE3"=>"\xD0\xB3","\xE4"=>"\xD0\xB4","\xE5"=>"\xD0\xB5","\xB8"=>"\xD1\x91","\xE6"=>"\xD0\xB6",
-"\xE7"=>"\xD0\xB7","\xE8"=>"\xD0\xB8","\xE9"=>"\xD0\xB9","\xEA"=>"\xD0\xBA","\xEB"=>"\xD0\xBB",
-"\xEC"=>"\xD0\xBC","\xED"=>"\xD0\xBD","\xEE"=>"\xD0\xBE","\xEF"=>"\xD0\xBF","\xF0"=>"\xD1\x80",
-"\xF1"=>"\xD1\x81","\xF2"=>"\xD1\x82","\xF3"=>"\xD1\x83","\xF4"=>"\xD1\x84","\xF5"=>"\xD1\x85",
-"\xF6"=>"\xD1\x86","\xF7"=>"\xD1\x87","\xF8"=>"\xD1\x88","\xF9"=>"\xD1\x89","\xFA"=>"\xD1\x8A",
-"\xFB"=>"\xD1\x8B","\xFC"=>"\xD1\x8C","\xFD"=>"\xD1\x8D","\xFE"=>"\xD1\x8E","\xFF"=>"\xD1\x8F",
-"\xB3"=>"\xD1\x96","\xBF"=>"\xD1\x97","\xBA"=>"\xD1\x94","\xA2"=>"\xD1\x9E");
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+$_utf8win1251 = array(
+"\xD0\x90"=>"\xC0","\xD0\x91"=>"\xC1","\xD0\x92"=>"\xC2","\xD0\x93"=>"\xC3","\xD0\x94"=>"\xC4",
+"\xD0\x95"=>"\xC5","\xD0\x81"=>"\xA8","\xD0\x96"=>"\xC6","\xD0\x97"=>"\xC7","\xD0\x98"=>"\xC8",
+"\xD0\x99"=>"\xC9","\xD0\x9A"=>"\xCA","\xD0\x9B"=>"\xCB","\xD0\x9C"=>"\xCC","\xD0\x9D"=>"\xCD",
+"\xD0\x9E"=>"\xCE","\xD0\x9F"=>"\xCF","\xD0\xA0"=>"\xD0","\xD0\xA1"=>"\xD1","\xD0\xA2"=>"\xD2",
+"\xD0\xA3"=>"\xD3","\xD0\xA4"=>"\xD4","\xD0\xA5"=>"\xD5","\xD0\xA6"=>"\xD6","\xD0\xA7"=>"\xD7",
+"\xD0\xA8"=>"\xD8","\xD0\xA9"=>"\xD9","\xD0\xAA"=>"\xDA","\xD0\xAB"=>"\xDB","\xD0\xAC"=>"\xDC",
+"\xD0\xAD"=>"\xDD","\xD0\xAE"=>"\xDE","\xD0\xAF"=>"\xDF","\xD0\x87"=>"\xAF","\xD0\x86"=>"\xB2",
+"\xD0\x84"=>"\xAA","\xD0\x8E"=>"\xA1","\xD0\xB0"=>"\xE0","\xD0\xB1"=>"\xE1","\xD0\xB2"=>"\xE2",
+"\xD0\xB3"=>"\xE3","\xD0\xB4"=>"\xE4","\xD0\xB5"=>"\xE5","\xD1\x91"=>"\xB8","\xD0\xB6"=>"\xE6",
+"\xD0\xB7"=>"\xE7","\xD0\xB8"=>"\xE8","\xD0\xB9"=>"\xE9","\xD0\xBA"=>"\xEA","\xD0\xBB"=>"\xEB",
+"\xD0\xBC"=>"\xEC","\xD0\xBD"=>"\xED","\xD0\xBE"=>"\xEE","\xD0\xBF"=>"\xEF","\xD1\x80"=>"\xF0",
+"\xD1\x81"=>"\xF1","\xD1\x82"=>"\xF2","\xD1\x83"=>"\xF3","\xD1\x84"=>"\xF4","\xD1\x85"=>"\xF5",
+"\xD1\x86"=>"\xF6","\xD1\x87"=>"\xF7","\xD1\x88"=>"\xF8","\xD1\x89"=>"\xF9","\xD1\x8A"=>"\xFA",
+"\xD1\x8B"=>"\xFB","\xD1\x8C"=>"\xFC","\xD1\x8D"=>"\xFD","\xD1\x8E"=>"\xFE","\xD1\x8F"=>"\xFF",
+"\xD1\x96"=>"\xB3","\xD1\x97"=>"\xBF","\xD1\x94"=>"\xBA","\xD1\x9E"=>"\xA2");
+$_win1251utf8 = array(
+"\xC0"=>"\xD0\x90","\xC1"=>"\xD0\x91","\xC2"=>"\xD0\x92","\xC3"=>"\xD0\x93","\xC4"=>"\xD0\x94",
+"\xC5"=>"\xD0\x95","\xA8"=>"\xD0\x81","\xC6"=>"\xD0\x96","\xC7"=>"\xD0\x97","\xC8"=>"\xD0\x98",
+"\xC9"=>"\xD0\x99","\xCA"=>"\xD0\x9A","\xCB"=>"\xD0\x9B","\xCC"=>"\xD0\x9C","\xCD"=>"\xD0\x9D",
+"\xCE"=>"\xD0\x9E","\xCF"=>"\xD0\x9F","\xD0"=>"\xD0\xA0","\xD1"=>"\xD0\xA1","\xD2"=>"\xD0\xA2",
+"\xD3"=>"\xD0\xA3","\xD4"=>"\xD0\xA4","\xD5"=>"\xD0\xA5","\xD6"=>"\xD0\xA6","\xD7"=>"\xD0\xA7",
+"\xD8"=>"\xD0\xA8","\xD9"=>"\xD0\xA9","\xDA"=>"\xD0\xAA","\xDB"=>"\xD0\xAB","\xDC"=>"\xD0\xAC",
+"\xDD"=>"\xD0\xAD","\xDE"=>"\xD0\xAE","\xDF"=>"\xD0\xAF","\xAF"=>"\xD0\x87","\xB2"=>"\xD0\x86",
+"\xAA"=>"\xD0\x84","\xA1"=>"\xD0\x8E","\xE0"=>"\xD0\xB0","\xE1"=>"\xD0\xB1","\xE2"=>"\xD0\xB2",
+"\xE3"=>"\xD0\xB3","\xE4"=>"\xD0\xB4","\xE5"=>"\xD0\xB5","\xB8"=>"\xD1\x91","\xE6"=>"\xD0\xB6",
+"\xE7"=>"\xD0\xB7","\xE8"=>"\xD0\xB8","\xE9"=>"\xD0\xB9","\xEA"=>"\xD0\xBA","\xEB"=>"\xD0\xBB",
+"\xEC"=>"\xD0\xBC","\xED"=>"\xD0\xBD","\xEE"=>"\xD0\xBE","\xEF"=>"\xD0\xBF","\xF0"=>"\xD1\x80",
+"\xF1"=>"\xD1\x81","\xF2"=>"\xD1\x82","\xF3"=>"\xD1\x83","\xF4"=>"\xD1\x84","\xF5"=>"\xD1\x85",
+"\xF6"=>"\xD1\x86","\xF7"=>"\xD1\x87","\xF8"=>"\xD1\x88","\xF9"=>"\xD1\x89","\xFA"=>"\xD1\x8A",
+"\xFB"=>"\xD1\x8B","\xFC"=>"\xD1\x8C","\xFD"=>"\xD1\x8D","\xFE"=>"\xD1\x8E","\xFF"=>"\xD1\x8F",
+"\xB3"=>"\xD1\x96","\xBF"=>"\xD1\x97","\xBA"=>"\xD1\x94","\xA2"=>"\xD1\x9E");
+
 ?>
\ No newline at end of file
diff --git a/src/webim/libs/operator.php b/src/webim/libs/operator.php
index 027ad70e..3282ef62 100644
--- a/src/webim/libs/operator.php
+++ b/src/webim/libs/operator.php
@@ -1,150 +1,150 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-function operator_by_login($login) {
-	$link = connect();
-	$operator = select_one_row(
-		 "select * from chatoperator where vclogin = '".mysql_real_escape_string($login)."'", $link );
-	mysql_close($link);
-	return $operator;
-}
-
-function operator_by_id_($id,$link) {
-	return select_one_row(
-		 "select * from chatoperator where operatorid = $id", $link );
-}
-
-function operator_by_id($id) {
-	$link = connect();
-	$operator = operator_by_id_($id,$link);
-	mysql_close($link);
-	return $operator;
-}
-
-function get_operators() {
-	$link = connect();
-
-	$query = "select * from chatoperator order by vclogin";
-	$result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query);
-
-	$operators = array();
-	while ($op = mysql_fetch_array($result, MYSQL_ASSOC)) {
-		$operators[] = $op;
-	}
-
-	mysql_free_result($result);
-	mysql_close($link);
-	return $operators;
-} 
-
-function update_operator($operatorid,$login,$password,$localename,$commonname) {
-	$link = connect();
-	$query = sprintf(
-		"update chatoperator set vclogin = '%s',%s vclocalename = '%s',vccommonname = '%s' where operatorid = %s",
-		mysql_real_escape_string($login),
-		($password ? " vcpassword='".md5($password)."'," : ""),
-		mysql_real_escape_string($localename),
-		mysql_real_escape_string($commonname),
-		$operatorid );
-
-	perform_query($query,$link);
-	mysql_close($link);
-}
-
-function create_operator($login,$password,$localename,$commonname) {
-	$link = connect();
-
-	$query = sprintf(
-		"insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname) values ('%s','%s','%s','%s')",
-			mysql_real_escape_string($login),
-			md5($password),
-			mysql_real_escape_string($localename),
-			mysql_real_escape_string($commonname) );
-
-	perform_query($query,$link);
-	$id = mysql_insert_id($link);
-
-	$newop = select_one_row("select * from chatoperator where operatorid = $id", $link );
-	mysql_close($link);
-	return $newop;
-}
-
-function notify_operator_alive($operatorid) {
-	$link = connect();
-	perform_query("update chatoperator set dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid",$link);
-	mysql_close($link);
-}
-
-function has_online_operators() {
-	global $online_timeout;
-	$link = connect();
-	$row = select_one_row("select min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from chatoperator",$link);
-	mysql_close($link);
-	return $row['time'] < $online_timeout;
-}
-
-function get_operator_name($operator) {
-	global $home_locale, $current_locale;
-	if( $home_locale == $current_locale )
-		return $operator['vclocalename'];
-	else
-		return $operator['vccommonname'];
-}
-
-function generate_button($title,$locale,$inner,$showhost,$forcesecure) {
-	$link = get_app_location($showhost,$forcesecure)."/client.php". ($locale?"?locale=".$locale : "");
-	return "<!-- webim button -->".get_popup($link, $inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=600,height=420,resizable=1" )."<!-- /webim button -->";
-}
-
-function check_login() {
-	if( !isset( $_SESSION['operator'] ) ) {
-		if( isset($_COOKIE['webim_lite']) ) {
-			list($login,$pwd) = split(",", $_COOKIE['webim_lite'], 2);
-			$op = operator_by_login($login);
-			if( $op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd ) {
-				$_SESSION['operator'] = $op;
-				return $op;
-			}
-		}
-		$_SESSION['backpath'] = $_SERVER['PHP_SELF'];
-		header("Location: /webim/operator/login.php");
-		exit;
-	}
-	return $_SESSION['operator'];
-}
-
-function get_logged_in() {
-	return isset( $_SESSION['operator'] ) ? $_SESSION['operator'] : FALSE;
-}
-
-function login_operator($operator,$remember) {
-	$_SESSION['operator'] = $operator;
-	if( $remember ) {
-		$value = $operator['vclogin'].",".md5($operator['vcpassword']);
-		setcookie('webim_lite', $value, time()+60*60*24*1000, "/webim/");
-
-	} else if( isset($_COOKIE['webim_lite']) ) {
-		setcookie('webim_lite', '', time() - 3600, "/webim/");
-	}
-}
-
-function logout_operator() {
-	$_SESSION['operator'] = NULL;
-	$_SESSION['backpath'] = NULL;
-	if( isset($_COOKIE['webim_lite']) ) {
-		setcookie('webim_lite', '', time() - 3600, "/webim/");
-	}
-}
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+function operator_by_login($login) {
+	$link = connect();
+	$operator = select_one_row(
+		 "select * from chatoperator where vclogin = '".mysql_real_escape_string($login)."'", $link );
+	mysql_close($link);
+	return $operator;
+}
+
+function operator_by_id_($id,$link) {
+	return select_one_row(
+		 "select * from chatoperator where operatorid = $id", $link );
+}
+
+function operator_by_id($id) {
+	$link = connect();
+	$operator = operator_by_id_($id,$link);
+	mysql_close($link);
+	return $operator;
+}
+
+function get_operators() {
+	$link = connect();
+
+	$query = "select * from chatoperator order by vclogin";
+	$result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query);
+
+	$operators = array();
+	while ($op = mysql_fetch_array($result, MYSQL_ASSOC)) {
+		$operators[] = $op;
+	}
+
+	mysql_free_result($result);
+	mysql_close($link);
+	return $operators;
+} 
+
+function update_operator($operatorid,$login,$password,$localename,$commonname) {
+	$link = connect();
+	$query = sprintf(
+		"update chatoperator set vclogin = '%s',%s vclocalename = '%s',vccommonname = '%s' where operatorid = %s",
+		mysql_real_escape_string($login),
+		($password ? " vcpassword='".md5($password)."'," : ""),
+		mysql_real_escape_string($localename),
+		mysql_real_escape_string($commonname),
+		$operatorid );
+
+	perform_query($query,$link);
+	mysql_close($link);
+}
+
+function create_operator($login,$password,$localename,$commonname) {
+	$link = connect();
+
+	$query = sprintf(
+		"insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname) values ('%s','%s','%s','%s')",
+			mysql_real_escape_string($login),
+			md5($password),
+			mysql_real_escape_string($localename),
+			mysql_real_escape_string($commonname) );
+
+	perform_query($query,$link);
+	$id = mysql_insert_id($link);
+
+	$newop = select_one_row("select * from chatoperator where operatorid = $id", $link );
+	mysql_close($link);
+	return $newop;
+}
+
+function notify_operator_alive($operatorid) {
+	$link = connect();
+	perform_query("update chatoperator set dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid",$link);
+	mysql_close($link);
+}
+
+function has_online_operators() {
+	global $online_timeout;
+	$link = connect();
+	$row = select_one_row("select min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from chatoperator",$link);
+	mysql_close($link);
+	return $row['time'] < $online_timeout;
+}
+
+function get_operator_name($operator) {
+	global $home_locale, $current_locale;
+	if( $home_locale == $current_locale )
+		return $operator['vclocalename'];
+	else
+		return $operator['vccommonname'];
+}
+
+function generate_button($title,$locale,$inner,$showhost,$forcesecure) {
+	$link = get_app_location($showhost,$forcesecure)."/client.php". ($locale?"?locale=".$locale : "");
+	return "<!-- webim button -->".get_popup($link, $inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=600,height=420,resizable=1" )."<!-- /webim button -->";
+}
+
+function check_login() {
+	if( !isset( $_SESSION['operator'] ) ) {
+		if( isset($_COOKIE['webim_lite']) ) {
+			list($login,$pwd) = split(",", $_COOKIE['webim_lite'], 2);
+			$op = operator_by_login($login);
+			if( $op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd ) {
+				$_SESSION['operator'] = $op;
+				return $op;
+			}
+		}
+		$_SESSION['backpath'] = $_SERVER['PHP_SELF'];
+		header("Location: /webim/operator/login.php");
+		exit;
+	}
+	return $_SESSION['operator'];
+}
+
+function get_logged_in() {
+	return isset( $_SESSION['operator'] ) ? $_SESSION['operator'] : FALSE;
+}
+
+function login_operator($operator,$remember) {
+	$_SESSION['operator'] = $operator;
+	if( $remember ) {
+		$value = $operator['vclogin'].",".md5($operator['vcpassword']);
+		setcookie('webim_lite', $value, time()+60*60*24*1000, "/webim/");
+
+	} else if( isset($_COOKIE['webim_lite']) ) {
+		setcookie('webim_lite', '', time() - 3600, "/webim/");
+	}
+}
+
+function logout_operator() {
+	$_SESSION['operator'] = NULL;
+	$_SESSION['backpath'] = NULL;
+	if( isset($_COOKIE['webim_lite']) ) {
+		setcookie('webim_lite', '', time() - 3600, "/webim/");
+	}
+}
+
 ?>
\ No newline at end of file
diff --git a/src/webim/libs/pagination.php b/src/webim/libs/pagination.php
index 627de9cf..34a57f63 100644
--- a/src/webim/libs/pagination.php
+++ b/src/webim/libs/pagination.php
@@ -1,99 +1,99 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-$pagination_spacing = "&nbsp;&nbsp;&nbsp;";
-$links_on_page = 5;
-
-function generate_pagination_link($page,$title) {
-	$lnk = $_SERVER['REQUEST_URI'];
-	$href = preg_replace("/\?page=\d+\&/", "?", preg_replace("/\&page=\d+/", "", $lnk));
-	$href .= strstr($href,"?") ? "&page=$page" : "?page=$page";
-	return "<a href=\"$href\" class=\"pagelink\">$title</a>";
-}
-
-function generate_pagination_image($id) {
-	global $webimroot;
-	return "<img src=\"$webimroot/images/$id.gif\" border=\"0\"/>";
-}
-
-function setup_pagination($items,$default_items_per_page=15) {
-	global $page;
-
-	if( $items ) {
-		$items_per_page = verifyparam("items", "/^\d{1,3}$/", $default_items_per_page);
-		if( $items_per_page < 2 )
-			$items_per_page = 2;
-	
-		$total_pages = div(count($items) + $items_per_page - 1, $items_per_page);
-		$curr_page = verifyparam("page", "/^\d{1,6}$/", 1);
-	
-		if( $curr_page < 1 )
-			$curr_page = 1;
-		if( $curr_page > $total_pages )
-			$curr_page = $total_pages;
-	
-		$start_index = ($curr_page-1)*$items_per_page;
-		$end_index = min($start_index+$items_per_page, count($items));
-	    $page['pagination.items'] = array_slice($items, $start_index, $end_index-$start_index);
-	    $page['pagination'] = 
-	    	array(  "page" => $curr_page, "items" => $items_per_page, "total" => $total_pages, 
-	    			"count" => count($items), "start" => $start_index, "end" => $end_index );
-	} else {
-    	$page['pagination.items'] = false;
-    	$page['pagination'] = true;
-	}
-}
-
-function setup_empty_pagination() {
-	global $page;
-    $page['pagination.items'] = false;
-    $page['pagination'] = false;
-}
-
-function generate_pagination($pagination) {
-	global $pagination_spacing, $links_on_page;
-	$result = getstring2("tag.pagination.info",
-		array($pagination['page'],$pagination['total'],$pagination['start']+1,$pagination['end'],$pagination['count']))."<br/>";
-
-	if( $pagination['total'] > 1 ) {
-		$result.="<br/><div class='pagination'>";
-		$curr_page = $pagination['page'];
-
-		$minPage = max( $curr_page - $links_on_page, 1 );
-		$maxPage = min( $curr_page + $links_on_page, $pagination['total'] );
-		
-		if( $curr_page > 1 ) {
-			$result .= generate_pagination_link($curr_page-1, generate_pagination_image("prevpage")).$pagination_spacing;
-		}
-
-		for($i = $minPage; $i <= $maxPage; $i++ ) {
-			$title = abs($curr_page-$i) >= $links_on_page && $i != 1 ? "..." : $i;
-			if( $i != $curr_page)
-				$result .= generate_pagination_link($i, $title);
-			else
-				$result .= "<span class=\"pagecurrent\">$title</span>";
-			if( $i < $maxPage )
-				$result .= $pagination_spacing;
-		}
-
-
-		if( $curr_page < $pagination['total'] ) {
-			$result .= $pagination_spacing.generate_pagination_link($curr_page+1, generate_pagination_image("nextpage"));
-		}
-		$result.="</div>";
-	}
-	return $result;
-}
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+$pagination_spacing = "&nbsp;&nbsp;&nbsp;";
+$links_on_page = 5;
+
+function generate_pagination_link($page,$title) {
+	$lnk = $_SERVER['REQUEST_URI'];
+	$href = preg_replace("/\?page=\d+\&/", "?", preg_replace("/\&page=\d+/", "", $lnk));
+	$href .= strstr($href,"?") ? "&page=$page" : "?page=$page";
+	return "<a href=\"$href\" class=\"pagelink\">$title</a>";
+}
+
+function generate_pagination_image($id) {
+	global $webimroot;
+	return "<img src=\"$webimroot/images/$id.gif\" border=\"0\"/>";
+}
+
+function setup_pagination($items,$default_items_per_page=15) {
+	global $page;
+
+	if( $items ) {
+		$items_per_page = verifyparam("items", "/^\d{1,3}$/", $default_items_per_page);
+		if( $items_per_page < 2 )
+			$items_per_page = 2;
+	
+		$total_pages = div(count($items) + $items_per_page - 1, $items_per_page);
+		$curr_page = verifyparam("page", "/^\d{1,6}$/", 1);
+	
+		if( $curr_page < 1 )
+			$curr_page = 1;
+		if( $curr_page > $total_pages )
+			$curr_page = $total_pages;
+	
+		$start_index = ($curr_page-1)*$items_per_page;
+		$end_index = min($start_index+$items_per_page, count($items));
+	    $page['pagination.items'] = array_slice($items, $start_index, $end_index-$start_index);
+	    $page['pagination'] = 
+	    	array(  "page" => $curr_page, "items" => $items_per_page, "total" => $total_pages, 
+	    			"count" => count($items), "start" => $start_index, "end" => $end_index );
+	} else {
+    	$page['pagination.items'] = false;
+    	$page['pagination'] = true;
+	}
+}
+
+function setup_empty_pagination() {
+	global $page;
+    $page['pagination.items'] = false;
+    $page['pagination'] = false;
+}
+
+function generate_pagination($pagination) {
+	global $pagination_spacing, $links_on_page;
+	$result = getstring2("tag.pagination.info",
+		array($pagination['page'],$pagination['total'],$pagination['start']+1,$pagination['end'],$pagination['count']))."<br/>";
+
+	if( $pagination['total'] > 1 ) {
+		$result.="<br/><div class='pagination'>";
+		$curr_page = $pagination['page'];
+
+		$minPage = max( $curr_page - $links_on_page, 1 );
+		$maxPage = min( $curr_page + $links_on_page, $pagination['total'] );
+		
+		if( $curr_page > 1 ) {
+			$result .= generate_pagination_link($curr_page-1, generate_pagination_image("prevpage")).$pagination_spacing;
+		}
+
+		for($i = $minPage; $i <= $maxPage; $i++ ) {
+			$title = abs($curr_page-$i) >= $links_on_page && $i != 1 ? "..." : $i;
+			if( $i != $curr_page)
+				$result .= generate_pagination_link($i, $title);
+			else
+				$result .= "<span class=\"pagecurrent\">$title</span>";
+			if( $i < $maxPage )
+				$result .= $pagination_spacing;
+		}
+
+
+		if( $curr_page < $pagination['total'] ) {
+			$result .= $pagination_spacing.generate_pagination_link($curr_page+1, generate_pagination_image("nextpage"));
+		}
+		$result.="</div>";
+	}
+	return $result;
+}
+
 ?>
\ No newline at end of file
diff --git a/src/webim/mail.php b/src/webim/mail.php
index 89fffbb4..5944a5a0 100644
--- a/src/webim/mail.php
+++ b/src/webim/mail.php
@@ -1,50 +1,50 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('libs/common.php');
-require('libs/chat.php');
-
-$token = verifyparam( "token", "/^\d{1,8}$/");
-$threadid = verifyparam( "thread", "/^\d{1,8}$/");
-
-$thread = thread_by_id($threadid);
-if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
-	die("wrong thread");
-}
-
-$mail = getparam('email');
-$page['email'] = $mail;
-
-// TODO check email
-
-$history = "";
-$lastid = -1;
-$output = get_messages( $threadid,"text",true,$lastid );
-foreach( $output as $msg ) {
-	$history .= $msg;
-}
-
-$subject = getstring("mail.user.history.subject");
-$body = getstring2("mail.user.history.body", array($thread['userName'],$history) ); 
-
-$headers = 'From: '.$webim_from_email."\r\n" .
-   'Reply-To: '.$webim_from_email."\r\n" .
-   'X-Mailer: PHP/'.phpversion();
-
-mail($mail,$subject,wordwrap($body,70),$headers);
-
-start_html_output();
-require('view/chat_mailsent.php');
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('libs/common.php');
+require('libs/chat.php');
+
+$token = verifyparam( "token", "/^\d{1,8}$/");
+$threadid = verifyparam( "thread", "/^\d{1,8}$/");
+
+$thread = thread_by_id($threadid);
+if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
+	die("wrong thread");
+}
+
+$mail = getparam('email');
+$page['email'] = $mail;
+
+// TODO check email
+
+$history = "";
+$lastid = -1;
+$output = get_messages( $threadid,"text",true,$lastid );
+foreach( $output as $msg ) {
+	$history .= $msg;
+}
+
+$subject = getstring("mail.user.history.subject");
+$body = getstring2("mail.user.history.body", array($thread['userName'],$history) ); 
+
+$headers = 'From: '.$webim_from_email."\r\n" .
+   'Reply-To: '.$webim_from_email."\r\n" .
+   'X-Mailer: PHP/'.phpversion();
+
+mail($mail,$subject,wordwrap($body,70),$headers);
+
+start_html_output();
+require('view/chat_mailsent.php');
+
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/agent.php b/src/webim/operator/agent.php
index 732fdcf1..8da7a2b0 100644
--- a/src/webim/operator/agent.php
+++ b/src/webim/operator/agent.php
@@ -1,56 +1,56 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/chat.php');
-require('../libs/operator.php');
-
-$operator = check_login();
-
-$threadid = verifyparam( "thread", "/^\d{1,8}$/");
-
-if( !isset($_GET['token']) ) {
-
-	if( get_remote_level($_SERVER['HTTP_USER_AGENT']) != "ajaxed" ) {
-		die("old browser is used, please update it");
-	}
-
-	$thread = thread_by_id($threadid);
-	if( !$thread || !isset($thread['ltoken']) ) {
-		die("wrong thread");
-	}
-
-	
-	take_thread($thread,$operator);
-
-	$token = $thread['ltoken'];
-	header("Location: ".$_SERVER['PHP_SELF']."?thread=$threadid&token=$token");
-	exit;
-}
-
-$token = verifyparam( "token", "/^\d{1,8}$/");
-
-$thread = thread_by_id($threadid);
-if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
-	die("wrong thread");
-}
-
-setup_chatview_for_operator($thread, $operator);
-
-start_html_output();
-
-
-	require('../view/chat_ajaxed.php');
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/chat.php');
+require('../libs/operator.php');
+
+$operator = check_login();
+
+$threadid = verifyparam( "thread", "/^\d{1,8}$/");
+
+if( !isset($_GET['token']) ) {
+
+	if( get_remote_level($_SERVER['HTTP_USER_AGENT']) != "ajaxed" ) {
+		die("old browser is used, please update it");
+	}
+
+	$thread = thread_by_id($threadid);
+	if( !$thread || !isset($thread['ltoken']) ) {
+		die("wrong thread");
+	}
+
+	
+	take_thread($thread,$operator);
+
+	$token = $thread['ltoken'];
+	header("Location: ".$_SERVER['PHP_SELF']."?thread=$threadid&token=$token");
+	exit;
+}
+
+$token = verifyparam( "token", "/^\d{1,8}$/");
+
+$thread = thread_by_id($threadid);
+if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
+	die("wrong thread");
+}
+
+setup_chatview_for_operator($thread, $operator);
+
+start_html_output();
+
+
+	require('../view/chat_ajaxed.php');
+
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/getcode.php b/src/webim/operator/getcode.php
index a16926b3..1ec7c1dd 100644
--- a/src/webim/operator/getcode.php
+++ b/src/webim/operator/getcode.php
@@ -1,65 +1,65 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-
-$operator = check_login();
-
-// collect available images and locales
-$imageLocales = array();
-$imagesDir = '../images/webim';
-if($handle = opendir($imagesDir)) {
-	while (false !== ($file = readdir($handle))) {
-		if (preg_match("/^(\w+)_([\w-]+)_on.gif$/", $file, $matches) 
-				&& is_file("$imagesDir/".$matches[1]."_".$matches[2]."_off.gif")) {
-			$image = $matches[1];
-			if( !isset($imageLocales[$image]) ) {
-				$imageLocales[$image] = array();
-			}
-			$imageLocales[$image][] = $matches[2];
-		}
-	}
-	closedir($handle);
-}
-
-$image = verifyparam("image","/^\w+$/", "webim");
-$image_locales = $imageLocales[$image];
-
-$showhost = verifyparam("hostname","/^on$/", "") == "on";
-$forcesecure = verifyparam("secure","/^on$/", "") == "on";
-
-$lang = verifyparam("lang", "/^\w\w$/", "");
-if( !$lang || !in_array($lang,$image_locales) )
-	$lang = in_array($current_locale,$image_locales) ? $current_locale : $image_locales[0];
-
-$file = "../images/webim/${image}_${lang}_on.gif";
-$size = get_gifimage_size($file);
-
-$message = get_image(get_app_location($showhost,$forcesecure)."/button.php?image=$image&lang=$lang",$size[0],$size[1]);
-
-$page = array();
-$page['operator'] = get_operator_name($operator);
-$page['buttonCode'] = generate_button("",$lang,$message,$showhost,$forcesecure);
-$page['availableImages'] = array_keys($imageLocales);
-$page['availableLocales'] = $image_locales;
-
-$page['formimage'] = $image;
-$page['formlang'] = $lang;
-$page['formhostname'] = $showhost;
-$page['formsecure'] = $forcesecure;
-
-start_html_output();
-require('../view/gen_button.php');
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+
+$operator = check_login();
+
+// collect available images and locales
+$imageLocales = array();
+$imagesDir = '../images/webim';
+if($handle = opendir($imagesDir)) {
+	while (false !== ($file = readdir($handle))) {
+		if (preg_match("/^(\w+)_([\w-]+)_on.gif$/", $file, $matches) 
+				&& is_file("$imagesDir/".$matches[1]."_".$matches[2]."_off.gif")) {
+			$image = $matches[1];
+			if( !isset($imageLocales[$image]) ) {
+				$imageLocales[$image] = array();
+			}
+			$imageLocales[$image][] = $matches[2];
+		}
+	}
+	closedir($handle);
+}
+
+$image = verifyparam("image","/^\w+$/", "webim");
+$image_locales = $imageLocales[$image];
+
+$showhost = verifyparam("hostname","/^on$/", "") == "on";
+$forcesecure = verifyparam("secure","/^on$/", "") == "on";
+
+$lang = verifyparam("lang", "/^\w\w$/", "");
+if( !$lang || !in_array($lang,$image_locales) )
+	$lang = in_array($current_locale,$image_locales) ? $current_locale : $image_locales[0];
+
+$file = "../images/webim/${image}_${lang}_on.gif";
+$size = get_gifimage_size($file);
+
+$message = get_image(get_app_location($showhost,$forcesecure)."/button.php?image=$image&lang=$lang",$size[0],$size[1]);
+
+$page = array();
+$page['operator'] = get_operator_name($operator);
+$page['buttonCode'] = generate_button("",$lang,$message,$showhost,$forcesecure);
+$page['availableImages'] = array_keys($imageLocales);
+$page['availableLocales'] = $image_locales;
+
+$page['formimage'] = $image;
+$page['formlang'] = $lang;
+$page['formhostname'] = $showhost;
+$page['formsecure'] = $forcesecure;
+
+start_html_output();
+require('../view/gen_button.php');
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/history.php b/src/webim/operator/history.php
index 052a4b91..341b727a 100644
--- a/src/webim/operator/history.php
+++ b/src/webim/operator/history.php
@@ -1,55 +1,55 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Pavel Petroshenko - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-require('../libs/chat.php');
-require('../libs/pagination.php');
-
-$operator = check_login();
-
-$page = array( 'operator' => get_operator_name($operator) );
-$query = isset($_GET['q']) ? $_GET['q'] : false;
-
-if($query !== false) {
-	$link = connect();
-
-	$result = mysql_query(
-		 "select DISTINCT unix_timestamp(chatthread.dtmcreated) as created, ". 
-    	 "unix_timestamp(chatthread.dtmmodified) as modified, chatthread.threadid, ".
-		 "chatthread.remote, chatthread.agentName, chatthread.userName ".
-		 "from chatthread, chatmessage ".
-		 "where chatmessage.threadid = chatthread.threadid and ".
-			"((chatthread.userName LIKE '%%$query%%') or ".
-			" (chatmessage.tmessage LIKE '%%$query%%'))".
-		 "order by created DESC", $link) 
-							or die(' Query failed: ' .mysql_error().": ".$query);
-
-	$foundThreads = array();
-	while ($thread = mysql_fetch_array($result, MYSQL_ASSOC)) {
-		$foundThreads[] = $thread;
-	}
-
-	mysql_free_result($result);
-	mysql_close($link);
-
-	$page['formq'] = $query;
-	setup_pagination($foundThreads);
-} else {
-	setup_empty_pagination();
-}
-
-start_html_output();
-require('../view/thread_search.php');
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Pavel Petroshenko - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+require('../libs/chat.php');
+require('../libs/pagination.php');
+
+$operator = check_login();
+
+$page = array( 'operator' => get_operator_name($operator) );
+$query = isset($_GET['q']) ? $_GET['q'] : false;
+
+if($query !== false) {
+	$link = connect();
+
+	$result = mysql_query(
+		 "select DISTINCT unix_timestamp(chatthread.dtmcreated) as created, ". 
+    	 "unix_timestamp(chatthread.dtmmodified) as modified, chatthread.threadid, ".
+		 "chatthread.remote, chatthread.agentName, chatthread.userName ".
+		 "from chatthread, chatmessage ".
+		 "where chatmessage.threadid = chatthread.threadid and ".
+			"((chatthread.userName LIKE '%%$query%%') or ".
+			" (chatmessage.tmessage LIKE '%%$query%%'))".
+		 "order by created DESC", $link) 
+							or die(' Query failed: ' .mysql_error().": ".$query);
+
+	$foundThreads = array();
+	while ($thread = mysql_fetch_array($result, MYSQL_ASSOC)) {
+		$foundThreads[] = $thread;
+	}
+
+	mysql_free_result($result);
+	mysql_close($link);
+
+	$page['formq'] = $query;
+	setup_pagination($foundThreads);
+} else {
+	setup_empty_pagination();
+}
+
+start_html_output();
+require('../view/thread_search.php');
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/index.php b/src/webim/operator/index.php
index 7cb3c7f4..cfa3ef61 100644
--- a/src/webim/operator/index.php
+++ b/src/webim/operator/index.php
@@ -1,39 +1,39 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-
-$operator = check_login();
-
-$page = array( 
-	'operator' => get_operator_name($operator),
-	'version' => 'v1.0.7'
-);
-
-$localeLinks = "";
-foreach($available_locales as $k) {
-	if( strlen($localeLinks) > 0 )
-		$localeLinks .= " &bull; ";
-	if( $k == $current_locale )
-		$localeLinks .= $k;
-	else
-		$localeLinks .= "<a href=\"/webim/operator/index.php?locale=$k\">$k</a>";
-}
-
-$page['localeLinks'] = $localeLinks;
-
-start_html_output();
-require('../view/menu.php');
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+
+$operator = check_login();
+
+$page = array( 
+	'operator' => get_operator_name($operator),
+	'version' => 'v1.0.7'
+);
+
+$localeLinks = "";
+foreach($available_locales as $k) {
+	if( strlen($localeLinks) > 0 )
+		$localeLinks .= " &bull; ";
+	if( $k == $current_locale )
+		$localeLinks .= $k;
+	else
+		$localeLinks .= "<a href=\"/webim/operator/index.php?locale=$k\">$k</a>";
+}
+
+$page['localeLinks'] = $localeLinks;
+
+start_html_output();
+require('../view/menu.php');
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/login.php b/src/webim/operator/login.php
index 00ada2c8..68f789cc 100644
--- a/src/webim/operator/login.php
+++ b/src/webim/operator/login.php
@@ -1,42 +1,42 @@
-<?php         
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-
-$errors = array();
-if( isset($_POST['login']) && isset($_POST['password']) ) {
-	$login = getparam('login');
-	$password = getparam('password');
-	$remember = isset($_POST['isRemember']) && $_POST['isRemember'] == "on";
-
-	$operator = operator_by_login( $login );
-	if( $operator && isset($operator['vcpassword']) && $operator['vcpassword'] == md5($password) ) {
-
-		$target = isset($_SESSION['backpath']) 
-				? $_SESSION['backpath'] 
-				: dirname($_SERVER['PHP_SELF'])."/index.php";
-		
-        login_operator($operator,$remember);
-		header("Location: $target");
-		exit;
-	} else {
-		$errors[] = getstring("page_login.error");
-	}
-}
-
-$page = array( 'backPath' => '', 'formisRemember' => true );
-start_html_output();
-require('../view/login.php');
+<?php         
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+
+$errors = array();
+if( isset($_POST['login']) && isset($_POST['password']) ) {
+	$login = getparam('login');
+	$password = getparam('password');
+	$remember = isset($_POST['isRemember']) && $_POST['isRemember'] == "on";
+
+	$operator = operator_by_login( $login );
+	if( $operator && isset($operator['vcpassword']) && $operator['vcpassword'] == md5($password) ) {
+
+		$target = isset($_SESSION['backpath']) 
+				? $_SESSION['backpath'] 
+				: dirname($_SERVER['PHP_SELF'])."/index.php";
+		
+        login_operator($operator,$remember);
+		header("Location: $target");
+		exit;
+	} else {
+		$errors[] = getstring("page_login.error");
+	}
+}
+
+$page = array( 'backPath' => '', 'formisRemember' => true );
+start_html_output();
+require('../view/login.php');
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/logout.php b/src/webim/operator/logout.php
index 01215e2d..e71918a6 100644
--- a/src/webim/operator/logout.php
+++ b/src/webim/operator/logout.php
@@ -1,24 +1,24 @@
-<?php         
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-
-logout_operator();
-
-$target = dirname($_SERVER['PHP_SELF'])."/login.php";
-header("Location: $target");
-exit;
-
+<?php         
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+
+logout_operator();
+
+$target = dirname($_SERVER['PHP_SELF'])."/login.php";
+header("Location: $target");
+exit;
+
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/operator.php b/src/webim/operator/operator.php
index a25f7e26..618aff09 100644
--- a/src/webim/operator/operator.php
+++ b/src/webim/operator/operator.php
@@ -1,85 +1,85 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-
-$operator = check_login();
-
-$page = array('agentId' => '');
-$errors = array();
-
-if( isset($_POST['login']) && isset($_POST['password']) ) {
-	$agentId = verifyparam( "agentId", "/^(\d{1,9})?$/", "");
-	$login = getparam('login');
-	$password = getparam('password');
-	$passwordConfirm = getparam('passwordConfirm');
-	$name = getparam('name');
-	$commonname = getparam('commonname');
-
-	if( !$name )
-		$errors[] = no_field("form.field.agent_name");
-
-	if( !$commonname )
-		$errors[] = no_field("form.field.agent_commonname");
-
-	if( !$login )
-		$errors[] = no_field("form.field.login");
-
-	if( !$agentId && !$password )
-		$errors[] = no_field("form.field.password");
-
-	if( $password != $passwordConfirm )
-		$errors[] = getstring("my_settings.error.password_match");
-
-	$login_operator = operator_by_login($login);
-	if( (!$agentId && $login_operator) || 
-		( $agentId && $login_operator && $agentId != $login_operator['operatorid']) )
-		$errors[] = getstring("page_agent.error.duplicate_login");
-
-	if( count($errors) == 0 ) {
-		if( $agentId ) {
-			update_operator($agentId,$login,$password,$name,$commonname);
-		} else {
-			create_operator($login,$password,$name,$commonname);
-		}
-		header("Location: ".dirname($_SERVER['PHP_SELF'])."/operators.php");
-		exit;
-	} else {
-		$page['formlogin'] = $login;
-		$page['formname'] = $name;
-		$page['formcommonname'] = $commonname;
-		$page['agentId'] = $agentId;
-	}
-
-} else if( isset($_GET['op']) ) {
-	$login = verifyparam( 'op', "/^[\w_]+$/");
-	$op = operator_by_login( $login );
-
-	if( !$op ) {
-		$errors[] = getstring("no_such_operator");
-		$page['formlogin'] = $login;
-	} else {
-		$page['formlogin'] = $op['vclogin'];
-		$page['formname'] = $op['vclocalename'];
-		$page['formcommonname'] = $op['vccommonname'];
-		$page['agentId'] = $op['operatorid'];
-	}
-}
-
-$page['operator'] = get_operator_name($operator);
-
-start_html_output();
-require('../view/agent.php');
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+
+$operator = check_login();
+
+$page = array('agentId' => '');
+$errors = array();
+
+if( isset($_POST['login']) && isset($_POST['password']) ) {
+	$agentId = verifyparam( "agentId", "/^(\d{1,9})?$/", "");
+	$login = getparam('login');
+	$password = getparam('password');
+	$passwordConfirm = getparam('passwordConfirm');
+	$name = getparam('name');
+	$commonname = getparam('commonname');
+
+	if( !$name )
+		$errors[] = no_field("form.field.agent_name");
+
+	if( !$commonname )
+		$errors[] = no_field("form.field.agent_commonname");
+
+	if( !$login )
+		$errors[] = no_field("form.field.login");
+
+	if( !$agentId && !$password )
+		$errors[] = no_field("form.field.password");
+
+	if( $password != $passwordConfirm )
+		$errors[] = getstring("my_settings.error.password_match");
+
+	$login_operator = operator_by_login($login);
+	if( (!$agentId && $login_operator) || 
+		( $agentId && $login_operator && $agentId != $login_operator['operatorid']) )
+		$errors[] = getstring("page_agent.error.duplicate_login");
+
+	if( count($errors) == 0 ) {
+		if( $agentId ) {
+			update_operator($agentId,$login,$password,$name,$commonname);
+		} else {
+			create_operator($login,$password,$name,$commonname);
+		}
+		header("Location: ".dirname($_SERVER['PHP_SELF'])."/operators.php");
+		exit;
+	} else {
+		$page['formlogin'] = $login;
+		$page['formname'] = $name;
+		$page['formcommonname'] = $commonname;
+		$page['agentId'] = $agentId;
+	}
+
+} else if( isset($_GET['op']) ) {
+	$login = verifyparam( 'op', "/^[\w_]+$/");
+	$op = operator_by_login( $login );
+
+	if( !$op ) {
+		$errors[] = getstring("no_such_operator");
+		$page['formlogin'] = $login;
+	} else {
+		$page['formlogin'] = $op['vclogin'];
+		$page['formname'] = $op['vclocalename'];
+		$page['formcommonname'] = $op['vccommonname'];
+		$page['agentId'] = $op['operatorid'];
+	}
+}
+
+$page['operator'] = get_operator_name($operator);
+
+start_html_output();
+require('../view/agent.php');
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/operators.php b/src/webim/operator/operators.php
index f6daac45..a63bf6bf 100644
--- a/src/webim/operator/operators.php
+++ b/src/webim/operator/operators.php
@@ -1,26 +1,26 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-
-$operator = check_login();
-
-$page = array();
-$page['allowedAgents'] = get_operators();
-$page['operator'] = get_operator_name($operator);
-
-start_html_output();
-require('../view/agents.php');
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+
+$operator = check_login();
+
+$page = array();
+$page['allowedAgents'] = get_operators();
+$page['operator'] = get_operator_name($operator);
+
+start_html_output();
+require('../view/agents.php');
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/threadprocessor.php b/src/webim/operator/threadprocessor.php
index e87d88ec..3eb81df7 100644
--- a/src/webim/operator/threadprocessor.php
+++ b/src/webim/operator/threadprocessor.php
@@ -1,32 +1,32 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-require('../libs/chat.php');
-
-$operator = check_login();
-
-$page = array( 'operator' => get_operator_name($operator) );
-
-
-if( isset($_GET['threadid'])) {
-        $threadid = verifyparam( "threadid", "/^(\d{1,9})?$/", "");
-	$lastid = -1;
-	$page['threadMessages'] = get_messages($threadid,"html",false,$lastid);
-}
-
-start_html_output();
-require('../view/thread_log.php');
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+require('../libs/chat.php');
+
+$operator = check_login();
+
+$page = array( 'operator' => get_operator_name($operator) );
+
+
+if( isset($_GET['threadid'])) {
+        $threadid = verifyparam( "threadid", "/^(\d{1,9})?$/", "");
+	$lastid = -1;
+	$page['threadMessages'] = get_messages($threadid,"html",false,$lastid);
+}
+
+start_html_output();
+require('../view/thread_log.php');
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/update.php b/src/webim/operator/update.php
index 91abdc2e..b4fdfe1a 100644
--- a/src/webim/operator/update.php
+++ b/src/webim/operator/update.php
@@ -1,98 +1,98 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/chat.php');
-require('../libs/operator.php');
-
-$operator = get_logged_in();
-if( !$operator ) {
-	start_xml_output();
-	echo "<error><descr>".myiconv($webim_encoding,"utf-8",escape_with_cdata(getstring("agent.not_logged_in")))."</descr></error>";
-	exit;
-}
-
-$threadstate_to_string = array(
-	$state_queue => "wait",
-	$state_waiting => "prio",
-	$state_chatting => "chat",
-	$state_closed => "closed"
-);
-
-$threadstate_key = array(
-	$state_queue => "chat.thread.state_wait",
-	$state_waiting => "chat.thread.state_wait_for_another_agent",
-	$state_chatting => "chat.thread.state_chatting_with_agent",
-	$state_closed => "chat.thread.state_closed"
-);
-
-function thread_to_xml($thread) {
-	global $threadstate_to_string, $threadstate_key;
-	$state = $threadstate_to_string[$thread['istate']];
-	$result = "<thread id=\"".$thread['threadid']."\" stateid=\"$state\"";
-	if( $state == "closed" )
-		return $result."/>";
-
-	$state = getstring($threadstate_key[$thread['istate']]);
-	$threadoperator = ($thread['agentName'] ? $thread['agentName'] : "-");
-
-	$result .= " canopen=\"true\"";
-	$result .= " state=\"$state\">";
-	$result .= "<name>".htmlspecialchars(htmlspecialchars(get_user_name($thread['userName'])))."</name>";
-	$result .= "<addr>".htmlspecialchars(htmlspecialchars($thread['remote']))."</addr>";
-	$result .= "<agent>".htmlspecialchars(htmlspecialchars($threadoperator))."</agent>";
-	$result .= "<time>".$thread['unix_timestamp(dtmcreated)']."000</time>";
-	$result .= "<modified>".$thread['unix_timestamp(dtmmodified)']."000</modified>";
-	$result .= "</thread>";
-	return $result;
-}
-
-function print_pending_threads($since) {
-	global $webim_encoding;
-	$link = connect();
-
-	$revision = $since;
-	$output = array();
-	$query = "select threadid, userName, agentName, unix_timestamp(dtmcreated), ".
-			 "unix_timestamp(dtmmodified), lrevision, istate, remote ".
-			 "from chatthread where lrevision > $since ORDER BY threadid";
-	$result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query);
-
-	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
-		$thread = thread_to_xml($row);
-		$output[] = $thread;
-		if( $row['lrevision'] > $revision )
-			$revision = $row['lrevision'];
-	}
-
-	mysql_free_result($result);
-	mysql_close($link);
-
-	start_xml_output();
-	echo "<threads revision=\"$revision\" time=\"".time()."000\">";
-	foreach( $output as $thr ) {
-		print myiconv($webim_encoding,"utf-8",$thr);
-	}
-	echo "</threads>";
-}
-
-////////
-
-$since = verifyparam( "since", "/^\d{1,9}$/", 0);
-
-print_pending_threads($since);
-notify_operator_alive($operator['operatorid']);
-exit;
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/chat.php');
+require('../libs/operator.php');
+
+$operator = get_logged_in();
+if( !$operator ) {
+	start_xml_output();
+	echo "<error><descr>".myiconv($webim_encoding,"utf-8",escape_with_cdata(getstring("agent.not_logged_in")))."</descr></error>";
+	exit;
+}
+
+$threadstate_to_string = array(
+	$state_queue => "wait",
+	$state_waiting => "prio",
+	$state_chatting => "chat",
+	$state_closed => "closed"
+);
+
+$threadstate_key = array(
+	$state_queue => "chat.thread.state_wait",
+	$state_waiting => "chat.thread.state_wait_for_another_agent",
+	$state_chatting => "chat.thread.state_chatting_with_agent",
+	$state_closed => "chat.thread.state_closed"
+);
+
+function thread_to_xml($thread) {
+	global $threadstate_to_string, $threadstate_key;
+	$state = $threadstate_to_string[$thread['istate']];
+	$result = "<thread id=\"".$thread['threadid']."\" stateid=\"$state\"";
+	if( $state == "closed" )
+		return $result."/>";
+
+	$state = getstring($threadstate_key[$thread['istate']]);
+	$threadoperator = ($thread['agentName'] ? $thread['agentName'] : "-");
+
+	$result .= " canopen=\"true\"";
+	$result .= " state=\"$state\">";
+	$result .= "<name>".htmlspecialchars(htmlspecialchars(get_user_name($thread['userName'])))."</name>";
+	$result .= "<addr>".htmlspecialchars(htmlspecialchars($thread['remote']))."</addr>";
+	$result .= "<agent>".htmlspecialchars(htmlspecialchars($threadoperator))."</agent>";
+	$result .= "<time>".$thread['unix_timestamp(dtmcreated)']."000</time>";
+	$result .= "<modified>".$thread['unix_timestamp(dtmmodified)']."000</modified>";
+	$result .= "</thread>";
+	return $result;
+}
+
+function print_pending_threads($since) {
+	global $webim_encoding;
+	$link = connect();
+
+	$revision = $since;
+	$output = array();
+	$query = "select threadid, userName, agentName, unix_timestamp(dtmcreated), ".
+			 "unix_timestamp(dtmmodified), lrevision, istate, remote ".
+			 "from chatthread where lrevision > $since ORDER BY threadid";
+	$result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query);
+
+	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
+		$thread = thread_to_xml($row);
+		$output[] = $thread;
+		if( $row['lrevision'] > $revision )
+			$revision = $row['lrevision'];
+	}
+
+	mysql_free_result($result);
+	mysql_close($link);
+
+	start_xml_output();
+	echo "<threads revision=\"$revision\" time=\"".time()."000\">";
+	foreach( $output as $thr ) {
+		print myiconv($webim_encoding,"utf-8",$thr);
+	}
+	echo "</threads>";
+}
+
+////////
+
+$since = verifyparam( "since", "/^\d{1,9}$/", 0);
+
+print_pending_threads($since);
+notify_operator_alive($operator['operatorid']);
+exit;
+
 ?>
\ No newline at end of file
diff --git a/src/webim/operator/users.php b/src/webim/operator/users.php
index b1c954ac..55aed786 100644
--- a/src/webim/operator/users.php
+++ b/src/webim/operator/users.php
@@ -1,26 +1,26 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('../libs/common.php');
-require('../libs/operator.php');
-
-$operator = check_login();
-
-notify_operator_alive($operator['operatorid']);
-
-$page = array( 'operator' => get_operator_name($operator) );
-
-start_html_output();
-require('../view/pending_users.php');
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('../libs/common.php');
+require('../libs/operator.php');
+
+$operator = check_login();
+
+notify_operator_alive($operator['operatorid']);
+
+$page = array( 'operator' => get_operator_name($operator) );
+
+start_html_output();
+require('../view/pending_users.php');
 ?>
\ No newline at end of file
diff --git a/src/webim/thread.php b/src/webim/thread.php
index 18ea0b75..53a679da 100644
--- a/src/webim/thread.php
+++ b/src/webim/thread.php
@@ -1,87 +1,87 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-
-require('libs/common.php');
-require('libs/chat.php');
-require('libs/operator.php');
-
-$act = verifyparam( "act", "/^(refresh|post|rename|close|ping)$/");
-$token = verifyparam( "token", "/^\d{1,9}$/");
-$threadid = verifyparam( "thread", "/^\d{1,9}$/");
-$isuser = verifyparam( "user", "/^true$/", "false") == 'true';
-$outformat = (verifyparam( "html", "/^on$/", "off") == 'on') ? "html" : "xml";
-
-$thread = thread_by_id($threadid);
-if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
-	die("wrong thread");
-}
-
-# This code helps in simulation of operator connection problems
-# if( !$isuser )     die("error");
-
-ping_thread($thread, $isuser);
-
-if( !$isuser && $act != "rename" ) {
-	$operator = check_login();
-	check_for_reassign($thread,$operator);
-}
-
-if( $act == "refresh" ) {
-	$lastid = verifyparam( "lastid", "/^\d{1,9}$/", -1);
-	print_thread_mesages($threadid, $token, $lastid, $isuser,$outformat);
-	exit;
-
-} else if( $act == "post" ) {
-	$lastid = verifyparam( "lastid", "/^\d{1,9}$/", -1);
-	$message = getrawparam('message');
-
-	$kind = $isuser ? $kind_user : $kind_agent;
-	$from = $isuser ? $thread['userName'] : $thread['agentName'];
-
-	post_message($threadid,$kind,$message,$from);
-	print_thread_mesages($threadid, $token, $lastid, $isuser, $outformat);
-	exit;
-
-} else if( $act == "rename" ) {
-
-	if( !$user_can_change_name ) {
-		start_xml_output();
-		echo "<error></error>";
-		exit;
-	}
-
-	$newname = getrawparam('name');
-
-	rename_user($thread, $newname);
-	setcookie($namecookie, $newname, time()+60*60*24*365); 
-	start_xml_output();
-	echo "<changedname></changedname>";
-	exit;
-
-} else if( $act == "ping" ) {
-
-	start_xml_output();
-	echo "<ping></ping>";
-	exit;
-
-} else if( $act == "close" ) {
-
-	close_thread($thread, $isuser);
-	start_xml_output();
-	echo "<closed></closed>";
-	exit;
-
-}
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+
+require('libs/common.php');
+require('libs/chat.php');
+require('libs/operator.php');
+
+$act = verifyparam( "act", "/^(refresh|post|rename|close|ping)$/");
+$token = verifyparam( "token", "/^\d{1,9}$/");
+$threadid = verifyparam( "thread", "/^\d{1,9}$/");
+$isuser = verifyparam( "user", "/^true$/", "false") == 'true';
+$outformat = (verifyparam( "html", "/^on$/", "off") == 'on') ? "html" : "xml";
+
+$thread = thread_by_id($threadid);
+if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
+	die("wrong thread");
+}
+
+# This code helps in simulation of operator connection problems
+# if( !$isuser )     die("error");
+
+ping_thread($thread, $isuser);
+
+if( !$isuser && $act != "rename" ) {
+	$operator = check_login();
+	check_for_reassign($thread,$operator);
+}
+
+if( $act == "refresh" ) {
+	$lastid = verifyparam( "lastid", "/^\d{1,9}$/", -1);
+	print_thread_mesages($threadid, $token, $lastid, $isuser,$outformat);
+	exit;
+
+} else if( $act == "post" ) {
+	$lastid = verifyparam( "lastid", "/^\d{1,9}$/", -1);
+	$message = getrawparam('message');
+
+	$kind = $isuser ? $kind_user : $kind_agent;
+	$from = $isuser ? $thread['userName'] : $thread['agentName'];
+
+	post_message($threadid,$kind,$message,$from, $isuser ? null : $operator['operatorid'] );
+	print_thread_mesages($threadid, $token, $lastid, $isuser, $outformat);
+	exit;
+
+} else if( $act == "rename" ) {
+
+	if( !$user_can_change_name ) {
+		start_xml_output();
+		echo "<error></error>";
+		exit;
+	}
+
+	$newname = getrawparam('name');
+
+	rename_user($thread, $newname);
+	setcookie($namecookie, $newname, time()+60*60*24*365); 
+	start_xml_output();
+	echo "<changedname></changedname>";
+	exit;
+
+} else if( $act == "ping" ) {
+
+	start_xml_output();
+	echo "<ping></ping>";
+	exit;
+
+} else if( $act == "close" ) {
+
+	close_thread($thread, $isuser);
+	start_xml_output();
+	echo "<closed></closed>";
+	exit;
+
+}
+
 ?>
\ No newline at end of file
diff --git a/src/webim/view/agent.php b/src/webim/view/agent.php
index 91134ad3..f498cafc 100644
--- a/src/webim/view/agent.php
+++ b/src/webim/view/agent.php
@@ -1,144 +1,129 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("page_agent.title") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
- <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
-		<h1><?php echo getstring("page_agent.title") ?></h1>
- </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/operators.php" title="<?php echo getstring("menu.agents") ?>"><?php echo getstring("menu.agents") ?></a></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
-	
-
-	<?php if( $page['agentId'] ) { ?>
-<?php echo getstring("page_agent.intro") ?>
-<?php } ?>
-<?php if( !$page['agentId'] ) { ?>
-<?php echo getstring("page_agent.create_new") ?>
-<?php } ?>
-<br />
-<br />
-
-
-
-
-
-
-
-
-<?php if( isset($errors) && count($errors) > 0 ) { ?>
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td valign="top"><img src='/webim/images/icon_err.gif' width="40" height="40" border="0" alt="" /></td>
-	    <td width="10"></td>
-	    <td class="text">
-		    <?php	if( isset($errors) && count($errors) > 0 ) {
-		print getstring("errors.header");
-		foreach( $errors as $e ) {
-			print getstring("errors.prefix");
-			print $e;
-			print getstring("errors.suffix");
-		}
-		print getstring("errors.footer");
-	} ?>
-
-		</td>
-		</tr>
-		</table>
-	<?php } ?>
-
-<form name="agentForm" method="post" action="/webim/operator/operator.php">
-	<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
-		<tr><td class='formauth'><?php echo getstring('form.field.login') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
-			<input type="text" name="login" size="40" value="<?php echo form_value('login') ?>" class="formauth"/>
-		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.login.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
-
-		<tr><td class='formauth'><?php echo getstring('form.field.password') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
-			<input type="password" name="password" size="40" value="" class="formauth"/>
-		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.password.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
-
-		<tr><td class='formauth'><?php echo getstring('form.field.password_confirm') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
-			<input type="password" name="passwordConfirm" size="40" value="" class="formauth"/>
-		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.password_confirm.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
-
-		<tr><td class='formauth'><?php echo getstring('form.field.agent_name') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
-			<input type="text" name="name" size="40" value="<?php echo form_value('name') ?>" class="formauth"/>
-		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.agent_name.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
-
-		<tr><td class='formauth'><?php echo getstring('form.field.agent_commonname') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
-			<input type="text" name="commonname" size="40" value="<?php echo form_value('commonname') ?>" class="formauth"/>
-		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.agent_commonname.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
-
-		<tr><td colspan='3' height='20'></td></tr><tr><td colspan='3' background='/webim/images/formline.gif'><img src='/webim/images/formline.gif' width='1' height='2' border='0' alt=''></td></tr><tr><td colspan='3' height='10'></td></tr>
-		<tr>
-			<td class="formauth"><input type="hidden" name="agentId" value="<?php echo $page['agentId'] ?>"/> 
-			        <input type="image" name="" src='<?php echo getstring("image.button.save") ?>' border="0" alt='<?php echo getstring("button.save") ?>'/>
-			</td>
-			<td></td>
-			<td></td>
-		</tr>
-
-	</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
-
-	
-
-
-
-
-<table cellspacing="0" cellpadding="0" border="0">
-	<tr>
-		<td colspan="2" height="10"></td>
-	</tr>
-	<tr>
-		<td width="30"></td>
-		<td class="formauth"><span class="formdescr"><?php echo getstring("common.asterisk_explanation") ?></span></td>
-	</tr>
-</table>
-
-
-</form>
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("page_agent.title") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
+		<h1><?php echo getstring("page_agent.title") ?></h1>
+ </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/operators.php" title="<?php echo getstring("menu.agents") ?>"><?php echo getstring("menu.agents") ?></a></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
+	
+
+	<?php if( $page['agentId'] ) { ?>
+<?php echo getstring("page_agent.intro") ?>
+<?php } ?>
+<?php if( !$page['agentId'] ) { ?>
+<?php echo getstring("page_agent.create_new") ?>
+<?php } ?>
+<br />
+<br />
+<?php if( isset($errors) && count($errors) > 0 ) { ?>
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td valign="top"><img src='/webim/images/icon_err.gif' width="40" height="40" border="0" alt="" /></td>
+	    <td width="10"></td>
+	    <td class="text">
+		    <?php	if( isset($errors) && count($errors) > 0 ) {
+		print getstring("errors.header");
+		foreach( $errors as $e ) {
+			print getstring("errors.prefix");
+			print $e;
+			print getstring("errors.suffix");
+		}
+		print getstring("errors.footer");
+	} ?>
+
+		</td>
+		</tr>
+		</table>
+	<?php } ?>
+
+<form name="agentForm" method="post" action="/webim/operator/operator.php">
+	<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
+		<tr><td class='formauth'><?php echo getstring('form.field.login') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
+			<input type="text" name="login" size="40" value="<?php echo form_value('login') ?>" class="formauth"/>
+		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.login.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
+
+		<tr><td class='formauth'><?php echo getstring('form.field.password') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
+			<input type="password" name="password" size="40" value="" class="formauth"/>
+		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.password.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
+
+		<tr><td class='formauth'><?php echo getstring('form.field.password_confirm') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
+			<input type="password" name="passwordConfirm" size="40" value="" class="formauth"/>
+		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.password_confirm.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
+
+		<tr><td class='formauth'><?php echo getstring('form.field.agent_name') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
+			<input type="text" name="name" size="40" value="<?php echo form_value('name') ?>" class="formauth"/>
+		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.agent_name.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
+
+		<tr><td class='formauth'><?php echo getstring('form.field.agent_commonname') ?><b><font class='red'>*</font></b></td><td width='10'><img width='10' height='1' border='0' alt='' src='/webim/images/free.gif'></td><td></td></tr><tr><td height='2' colspan='3'></td></tr><tr><td>
+			<input type="text" name="commonname" size="40" value="<?php echo form_value('commonname') ?>" class="formauth"/>
+		</td><td></td><td class='formauth'><span class='formdescr'> &mdash; <?php echo getstring('form.field.agent_commonname.description') ?></span></td></tr><tr><td colspan='3' height='10'></td></tr>
+
+		<tr><td colspan='3' height='20'></td></tr><tr><td colspan='3' background='/webim/images/formline.gif'><img src='/webim/images/formline.gif' width='1' height='2' border='0' alt=''></td></tr><tr><td colspan='3' height='10'></td></tr>
+		<tr>
+			<td class="formauth"><input type="hidden" name="agentId" value="<?php echo $page['agentId'] ?>"/> 
+			        <input type="image" name="" src='<?php echo getstring("image.button.save") ?>' border="0" alt='<?php echo getstring("button.save") ?>'/>
+			</td>
+			<td></td>
+			<td></td>
+		</tr>
+
+	</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
+
+	
+
+
+
+
+<table cellspacing="0" cellpadding="0" border="0">
+	<tr>
+		<td colspan="2" height="10"></td>
+	</tr>
+	<tr>
+		<td width="30"></td>
+		<td class="formauth"><span class="formdescr"><?php echo getstring("common.asterisk_explanation") ?></span></td>
+	</tr>
+</table>
+
+
+</form>
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/agents.php b/src/webim/view/agents.php
index 567ea504..4064b6b3 100644
--- a/src/webim/view/agents.php
+++ b/src/webim/view/agents.php
@@ -1,122 +1,115 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("page_agents.title") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
- <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
-		<h1><?php echo getstring("page_agents.title") ?></h1>
- </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
-	
-
-	<?php echo getstring("page_agents.intro") ?>
-
-<br><br>
-
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-   <td class="text"><b><?php echo getstring("page_agents.agents") ?></b></td>
-   <td align="right">
-	<table cellspacing="0" cellpadding="0" border="0">
-	<tr>
-    <td><img src='/webim/images/buttons/createagent.gif' border="0" altKey="page_agents.new_agent" /></td>
-   	<td width="10"></td>
-    <td class="text">
-		<a href='/webim/operator/operator.php' title="<?php echo getstring("page_agents.new_agent") ?>">
-			<?php echo getstring("page_agents.new_agent") ?>
-		</a>
-    </td>
-	</tr>
-	</table>
-</td>
-</tr>
-<tr>
-   <td colspan="2" height="15"></td>
-</tr>
-</table>
-
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-	<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page_agents.login") ?></span></td><td width='3'></td>
-	<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page_agents.agent_name") ?></span></td><td width='3'></td>
-	<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page_agents.agent_commonname") ?></span></td>
-</tr>
-<?php foreach( $page['allowedAgents'] as $a ) { ?>
-<tr>
-	<td height='45' class='table'>
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><img src='/webim/images/tbliclogin.gif' width="10" height="15" border="0" alt="" /></td>
-    	<td class="table">
-    		<a href='/webim/operator/operator.php?op=<?php echo $a['vclogin'] ?>'>
-    			<?php echo htmlspecialchars($a['vclogin']) ?>
-    		</a>
-    	</td>
-		</tr>
-		</table>
-	</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
-	<td height='45' class='table'>
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><img src='/webim/images/tbllabyel.gif' width="5" height="5" border="0" alt="" /></td>
-    	<td class="table"><?php echo htmlspecialchars($a['vclocalename']) ?></td>
-		</tr>
-		</table>
-	</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
-	<td height='45' class='table'>
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><img src='/webim/images/tbllabyel.gif' width="5" height="5" border="0" alt="" /></td>
-    	<td class="table"><?php echo htmlspecialchars($a['vccommonname']) ?></td>
-		</tr>
-		</table>
-	</td>
-</tr>
-<tr><td height='2' colspan='7'></td></tr><tr><td bgcolor='#e1e1e1' colspan='7'><img width='1' height='1' border='0' alt='' src='/webim/images/free.gif'></td></tr><tr><td height='2' colspan='7'></td></tr>
-<?php } ?>
-</table>
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("page_agents.title") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
+		<h1><?php echo getstring("page_agents.title") ?></h1>
+ </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
+	
+
+	<?php echo getstring("page_agents.intro") ?>
+
+<br><br>
+
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+   <td class="text"><b><?php echo getstring("page_agents.agents") ?></b></td>
+   <td align="right">
+	<table cellspacing="0" cellpadding="0" border="0">
+	<tr>
+    <td><img src='/webim/images/buttons/createagent.gif' border="0" altKey="page_agents.new_agent" /></td>
+   	<td width="10"></td>
+    <td class="text">
+		<a href='/webim/operator/operator.php' title="<?php echo getstring("page_agents.new_agent") ?>">
+			<?php echo getstring("page_agents.new_agent") ?>
+		</a>
+    </td>
+	</tr>
+	</table>
+</td>
+</tr>
+<tr>
+   <td colspan="2" height="15"></td>
+</tr>
+</table>
+
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+	<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page_agents.login") ?></span></td><td width='3'></td>
+	<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page_agents.agent_name") ?></span></td><td width='3'></td>
+	<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page_agents.agent_commonname") ?></span></td>
+</tr>
+<?php foreach( $page['allowedAgents'] as $a ) { ?>
+<tr>
+	<td height='45' class='table'>
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><img src='/webim/images/tbliclogin.gif' width="10" height="15" border="0" alt="" /></td>
+    	<td class="table">
+    		<a href='/webim/operator/operator.php?op=<?php echo $a['vclogin'] ?>'>
+    			<?php echo htmlspecialchars($a['vclogin']) ?>
+    		</a>
+    	</td>
+		</tr>
+		</table>
+	</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
+	<td height='45' class='table'>
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><img src='/webim/images/tbllabyel.gif' width="5" height="5" border="0" alt="" /></td>
+    	<td class="table"><?php echo htmlspecialchars($a['vclocalename']) ?></td>
+		</tr>
+		</table>
+	</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
+	<td height='45' class='table'>
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><img src='/webim/images/tbllabyel.gif' width="5" height="5" border="0" alt="" /></td>
+    	<td class="table"><?php echo htmlspecialchars($a['vccommonname']) ?></td>
+		</tr>
+		</table>
+	</td>
+</tr>
+<tr><td height='2' colspan='7'></td></tr><tr><td bgcolor='#e1e1e1' colspan='7'><img width='1' height='1' border='0' alt='' src='/webim/images/free.gif'></td></tr><tr><td height='2' colspan='7'></td></tr>
+<?php } ?>
+</table>
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/chat_ajaxed.php b/src/webim/view/chat_ajaxed.php
index a614648e..cf92be3d 100644
--- a/src/webim/view/chat_ajaxed.php
+++ b/src/webim/view/chat_ajaxed.php
@@ -1,252 +1,252 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<title><?php echo getstring("chat.window.title.agent") ?></title>
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<meta http-equiv="Content-Type" content="text/html; charset=Windows-1251">
-<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
-<script type="text/javascript" language="javascript" src="/webim/js/common.js"></script>
-<script type="text/javascript" language="javascript" src="/webim/js/brws.js"></script>
-<script language="javascript"><!--
-var threadParams = { servl:"/webim/thread.php",frequency:2,<?php if( $page['user'] ) { ?>user:"true",<?php } ?>threadid:<?php echo $page['ct.chatThreadId'] ?>,token:<?php echo $page['ct.token'] ?> };
-//--></script>
-<script type="text/javascript" language="javascript" src="/webim/js/page_chat.js"></script>
-</head>
-
-<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
-
-<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td valign="top">
-
-	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-	<tr>
-    <td></td>
-    <td colspan="2" height="100" background="/webim/images/banner.gif" valign="top" class="bgrn">
-		<table width="100%" cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td width="50%" valign="top">
-			<table width="135" cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td height="25"></td>
-			</tr>
-			<tr>
-		    <td align="center"><?php if( $page['ct.company.chatLogoURL'] ) { ?><img src="<?php echo $page['ct.company.chatLogoURL'] ?>" width="85" height="45" border="0" alt=""><?php } ?></td>
-			</tr>
-			<tr>
-		    <td height="5"></td>
-			</tr>
-			<tr>
-		    <td align="center" class="text"><?php echo $page['ct.company.name'] ?></td>
-			</tr>
-			</table>
-		</td>
-    	<td width="50%" align="right" valign="top">
-			<table cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td height="25" align="right">
-
-				<table cellspacing="0" cellpadding="0" border="0">
-				<tr>
-			    <td class="text"><?php echo getstring("chat.window.product_name") ?></td>
-			    <td width="5"></td>
-			    <td>
-					<table cellspacing="0" cellpadding="0" border="0">
-					<tr>
-				    <td width="95" height="13" bgcolor="#D09221" align="center" class="www"><a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("site.title") ?></a></td>
-					</tr>
-					</table>
-				</td>
-			    <td width="5"></td>
-			    <td><a class="closethread" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.close_title") ?>"><img src='/webim/images/buttons/closewin.gif' width="15" height="15" border="0" altKey="chat.window.close_link_text"/></a></td>
-			    <td width="5"></td>
-				</tr>
-				</table>
-
-			</td>
-			</tr>
-
-			<tr>
-		    <td height="60" align="right">
-				
-				<table cellspacing="0" cellpadding="0" border="0">
-				<tr>
-<?php if( $page['agent'] ) { ?>
-				<td class="text" nowrap>
-					<?php echo getstring("chat.window.chatting_with") ?> <b><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.chatting_with") ?> <?php echo htmlspecialchars($page['ct.user.name']) ?><?php echo $page['namePostfix'] ?>"><?php echo htmlspecialchars($page['ct.user.name']) ?></a></b><br>
-				</td>
-<?php } ?><?php if( $page['user'] && $page['canChangeName'] ) { ?>
-				<td class="text" nowrap>
-				<div id="changename1" style="display:<?php echo $page['displ1'] ?>;">
-					<table cellspacing="0" cellpadding="0" border="0"><tr>
-					<td class="text" nowrap><?php echo getstring("chat.client.name") ?></td> 
-					<td width="10" valign="top"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
-					<td><input id="uname" type="text" size="12" value="<?php echo $page['ct.user.name'] ?>" class="username"></td>
-					<td width="5" valign="top"><img src='/webim/images/free.gif' width="5" height="1" border="0" alt="" /></td>
-					<td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.client.changename") ?>"><img src='/webim/images/buttons/exec.gif' width="25" height="25" border="0" alt="&gt;&gt;" /></a></td>
-					</tr></table>
-				</div>
-				<div id="changename2" style="display:<?php echo $page['displ2'] ?>;">
-					<table cellspacing="0" cellpadding="0" border="0"><tr>
-					<td class="text" nowrap><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.client.changename") ?>"><?php echo getstring("chat.client.changename") ?></a></td>
-					<td width="10" valign="top"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
-					<td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.client.changename") ?>"><img src='/webim/images/buttons/changeuser.gif' width="25" height="25" border="0" alt="" /></a></td>
-					</tr></table>
-				</div>
-				</td>
-<?php } ?>
-<?php if( $page['agent'] ) { ?>
-				<td width="10" valign="top"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
-				<td><a class="closethread" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.close_title") ?>">
-				<img src='/webim/images/buttons/close.gif' width="25" height="25" border="0" altKey="chat.window.close_link_text"/></a></td>
-<?php } ?>
-<!--
-				<td><img src='/webim/images/buttons/changeuser.gif' width="25" height="25" border="0" alt="Change User" /></td>
- -->
-
-			    <td><img src='/webim/images/buttondiv.gif' width="35" height="45" border="0" alt="" /></td>
-<?php if( $page['user'] ) { ?>
-				<td><a href="<?php echo $page['selfLink'] ?>&act=mailthread" target="_blank" title="<?php echo getstring("chat.window.toolbar.mail_history") ?>" onclick="this.newWindow = window.open('<?php echo $page['selfLink'] ?>&act=mailthread', 'ForwardMail', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,width=603,height=204,resizable=0');this.newWindow.focus();this.newWindow.opener=window;return false;"><img src='/webim/images/buttons/email.gif' width="25" height="25" border="0" alt="Mail&nbsp;"/></a></td>
-<?php } ?>
-
-				<td><a id="refresh" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.toolbar.refresh") ?>">
-				<img src='/webim/images/buttons/refresh.gif' width="25" height="25" border="0" alt="Refresh&nbsp;" /></a></td>
-
-				<td width="20" valign="top"><img src='/webim/images/free.gif' width="20" height="1" border="0" alt="" /></td>
-				</tr>
-				</table>
-
-			</td>
-			</tr>
-			</table>
-		</td>
-		</tr>
-		</table>
-	</td>
-	</tr>
-
-	<tr>
-    <td></td>
-    <td valign="top">
-
-		<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td width="20" valign="top"><img src='<?php echo getstring("image.chat.history") ?>' width="20" height="80" border="0" alt="" /></td>
-    	<td colspan="2" width="100%" height="100%" valign="top" id="chatwndtd">
-			<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			<tr>
-		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-		    <td width="100%" height="100%" bgcolor="#FFFFFF" valign="top">
-				<iframe id="chatwnd" width="100%" height="100%" src='/webim/images/free.gif' frameborder="0" style="overflow:auto;">
-				Sorry, your browser does not support iframes; try a browser that supports W3 standards.
-				</iframe>
-			</td>
-		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			<tr>
-		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			</table>
-		</td>
-		</tr>
-<?php if( $page['canpost'] ) { ?>
-		<tr>
-	    <td colspan="3" height="5" style="cursor:n-resize;" id="spl1"></td>
-		</tr>
-
-		<tr>
-	    <td width="20" valign="top"><img src='<?php echo getstring("image.chat.message") ?>' width="20" height="85" border="0" alt="" /></td>
-    	<td width="100%" height="100" valign="top" id="msgwndtd">
-			<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			<tr>
-		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-		    <td width="100%" height="100%" bgcolor="#FFFFFF" valign="top">
-				<textarea id="msgwnd" class="message" tabindex="0"></textarea>
-			</td>
-		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			<tr>
-		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			</table>
-		</td>
-	    <td valign="center" id="avatarwnd"></td>
-		</tr>
-<?php } ?>	
-		</table>
-
-	</td>
-    <td></td>
-	</tr>
-
-	<tr>
-    <td height="45"></td>
-    <td>
-		<table width="100%" cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td width="33%">
-			<table cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td width="20"></td>
-
-
-			</tr>
-			</table>
-		</td>
-		<td width="33%" align="center" class="copyr"><?php echo getstring("chat.window.poweredby") ?> <a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("chat.window.poweredreftext") ?></a></td>
-		<td width="33%" align="right">
-		
-<?php if( $page['canpost'] ) { ?>
-			<table cellspacing="0" cellpadding="0" border="0" id="postmessage">
-
-			<tr>
-		    <td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='/webim/images/submit.gif' width="40" height="35" border="0" alt="" /></a></td>
-		    <td background="/webim/images/submitbg.gif" valign="top" class="submit">
-				<img src='/webim/images/free.gif' width="1" height="10" border="0" alt="" /><br>
-				<a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><?php echo getstring("chat.window.send_message_short") ?></a><br>
-			</td>
-			<td width="10"><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='/webim/images/submitrest.gif' width="10" height="35" border="0" alt="" /></a></td>
-			</tr>
-			</table>
-<?php } ?>
-		</td>
-		</tr>
-		</table>
-	</td>
-    <td></td>
-	</tr>
-
-	<tr>
-    <td width="10"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
-    <td width="100%"><img src='/webim/images/free.gif' width="585" height="1" border="0" alt="" /></td>
-    <td width="5"><img src='/webim/images/free.gif' width="5" height="1" border="0" alt="" /></td>
-	</tr>
-	</table>
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title><?php echo getstring("chat.window.title.agent") ?></title>
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<meta http-equiv="Content-Type" content="text/html; charset=Windows-1251">
+<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
+<script type="text/javascript" language="javascript" src="/webim/js/common.js"></script>
+<script type="text/javascript" language="javascript" src="/webim/js/brws.js"></script>
+<script language="javascript"><!--
+var threadParams = { servl:"/webim/thread.php",frequency:2,<?php if( $page['user'] ) { ?>user:"true",<?php } ?>threadid:<?php echo $page['ct.chatThreadId'] ?>,token:<?php echo $page['ct.token'] ?> };
+//--></script>
+<script type="text/javascript" language="javascript" src="/webim/js/page_chat.js"></script>
+</head>
+
+<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
+
+<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td valign="top">
+
+	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+	<tr>
+    <td></td>
+    <td colspan="2" height="100" background="/webim/images/banner.gif" valign="top" class="bgrn">
+		<table width="100%" cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td width="50%" valign="top">
+			<table width="135" cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td height="25"></td>
+			</tr>
+			<tr>
+		    <td align="center"><?php if( $page['ct.company.chatLogoURL'] ) { ?><img src="<?php echo $page['ct.company.chatLogoURL'] ?>" width="85" height="45" border="0" alt=""><?php } ?></td>
+			</tr>
+			<tr>
+		    <td height="5"></td>
+			</tr>
+			<tr>
+		    <td align="center" class="text"><?php echo $page['ct.company.name'] ?></td>
+			</tr>
+			</table>
+		</td>
+    	<td width="50%" align="right" valign="top">
+			<table cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td height="25" align="right">
+
+				<table cellspacing="0" cellpadding="0" border="0">
+				<tr>
+			    <td class="text"><?php echo getstring("chat.window.product_name") ?></td>
+			    <td width="5"></td>
+			    <td>
+					<table cellspacing="0" cellpadding="0" border="0">
+					<tr>
+				    <td width="95" height="13" bgcolor="#D09221" align="center" class="www"><a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("site.title") ?></a></td>
+					</tr>
+					</table>
+				</td>
+			    <td width="5"></td>
+			    <td><a class="closethread" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.close_title") ?>"><img src='/webim/images/buttons/closewin.gif' width="15" height="15" border="0" altKey="chat.window.close_link_text"/></a></td>
+			    <td width="5"></td>
+				</tr>
+				</table>
+
+			</td>
+			</tr>
+
+			<tr>
+		    <td height="60" align="right">
+				
+				<table cellspacing="0" cellpadding="0" border="0">
+				<tr>
+<?php if( $page['agent'] ) { ?>
+				<td class="text" nowrap>
+					<?php echo getstring("chat.window.chatting_with") ?> <b><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.chatting_with") ?> <?php echo htmlspecialchars($page['ct.user.name']) ?><?php echo $page['namePostfix'] ?>"><?php echo htmlspecialchars($page['ct.user.name']) ?></a></b><br>
+				</td>
+<?php } ?><?php if( $page['user'] && $page['canChangeName'] ) { ?>
+				<td class="text" nowrap>
+				<div id="changename1" style="display:<?php echo $page['displ1'] ?>;">
+					<table cellspacing="0" cellpadding="0" border="0"><tr>
+					<td class="text" nowrap><?php echo getstring("chat.client.name") ?></td> 
+					<td width="10" valign="top"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
+					<td><input id="uname" type="text" size="12" value="<?php echo $page['ct.user.name'] ?>" class="username"></td>
+					<td width="5" valign="top"><img src='/webim/images/free.gif' width="5" height="1" border="0" alt="" /></td>
+					<td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.client.changename") ?>"><img src='/webim/images/buttons/exec.gif' width="25" height="25" border="0" alt="&gt;&gt;" /></a></td>
+					</tr></table>
+				</div>
+				<div id="changename2" style="display:<?php echo $page['displ2'] ?>;">
+					<table cellspacing="0" cellpadding="0" border="0"><tr>
+					<td class="text" nowrap><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.client.changename") ?>"><?php echo getstring("chat.client.changename") ?></a></td>
+					<td width="10" valign="top"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
+					<td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.client.changename") ?>"><img src='/webim/images/buttons/changeuser.gif' width="25" height="25" border="0" alt="" /></a></td>
+					</tr></table>
+				</div>
+				</td>
+<?php } ?>
+<?php if( $page['agent'] ) { ?>
+				<td width="10" valign="top"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
+				<td><a class="closethread" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.close_title") ?>">
+				<img src='/webim/images/buttons/close.gif' width="25" height="25" border="0" altKey="chat.window.close_link_text"/></a></td>
+<?php } ?>
+<!--
+				<td><img src='/webim/images/buttons/changeuser.gif' width="25" height="25" border="0" alt="Change User" /></td>
+ -->
+
+			    <td><img src='/webim/images/buttondiv.gif' width="35" height="45" border="0" alt="" /></td>
+<?php if( $page['user'] ) { ?>
+				<td><a href="<?php echo $page['selfLink'] ?>&act=mailthread" target="_blank" title="<?php echo getstring("chat.window.toolbar.mail_history") ?>" onclick="this.newWindow = window.open('<?php echo $page['selfLink'] ?>&act=mailthread', 'ForwardMail', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,width=603,height=204,resizable=0');this.newWindow.focus();this.newWindow.opener=window;return false;"><img src='/webim/images/buttons/email.gif' width="25" height="25" border="0" alt="Mail&nbsp;"/></a></td>
+<?php } ?>
+
+				<td><a id="refresh" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.toolbar.refresh") ?>">
+				<img src='/webim/images/buttons/refresh.gif' width="25" height="25" border="0" alt="Refresh&nbsp;" /></a></td>
+
+				<td width="20" valign="top"><img src='/webim/images/free.gif' width="20" height="1" border="0" alt="" /></td>
+				</tr>
+				</table>
+
+			</td>
+			</tr>
+			</table>
+		</td>
+		</tr>
+		</table>
+	</td>
+	</tr>
+
+	<tr>
+    <td></td>
+    <td valign="top">
+
+		<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td width="20" valign="top"><img src='<?php echo getstring("image.chat.history") ?>' width="20" height="80" border="0" alt="" /></td>
+    	<td colspan="2" width="100%" height="100%" valign="top" id="chatwndtd">
+			<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			<tr>
+		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+		    <td width="100%" height="100%" bgcolor="#FFFFFF" valign="top">
+				<iframe id="chatwnd" width="100%" height="100%" src='/webim/images/free.gif' frameborder="0" style="overflow:auto;">
+				Sorry, your browser does not support iframes; try a browser that supports W3 standards.
+				</iframe>
+			</td>
+		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			<tr>
+		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			</table>
+		</td>
+		</tr>
+<?php if( $page['canpost'] ) { ?>
+		<tr>
+	    <td colspan="3" height="5" style="cursor:n-resize;" id="spl1"></td>
+		</tr>
+
+		<tr>
+	    <td width="20" valign="top"><img src='<?php echo getstring("image.chat.message") ?>' width="20" height="85" border="0" alt="" /></td>
+    	<td width="100%" height="100" valign="top" id="msgwndtd">
+			<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			<tr>
+		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+		    <td width="100%" height="100%" bgcolor="#FFFFFF" valign="top">
+				<textarea id="msgwnd" class="message" tabindex="0"></textarea>
+			</td>
+		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			<tr>
+		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			</table>
+		</td>
+	    <td valign="center" id="avatarwnd"></td>
+		</tr>
+<?php } ?>	
+		</table>
+
+	</td>
+    <td></td>
+	</tr>
+
+	<tr>
+    <td height="45"></td>
+    <td>
+		<table width="100%" cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td width="33%">
+			<table cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td width="20"></td>
+
+
+			</tr>
+			</table>
+		</td>
+		<td width="33%" align="center" class="copyr"><?php echo getstring("chat.window.poweredby") ?> <a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("chat.window.poweredreftext") ?></a></td>
+		<td width="33%" align="right">
+		
+<?php if( $page['canpost'] ) { ?>
+			<table cellspacing="0" cellpadding="0" border="0" id="postmessage">
+
+			<tr>
+		    <td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='/webim/images/submit.gif' width="40" height="35" border="0" alt="" /></a></td>
+		    <td background="/webim/images/submitbg.gif" valign="top" class="submit">
+				<img src='/webim/images/free.gif' width="1" height="10" border="0" alt="" /><br>
+				<a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><?php echo getstring("chat.window.send_message_short") ?></a><br>
+			</td>
+			<td width="10"><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='/webim/images/submitrest.gif' width="10" height="35" border="0" alt="" /></a></td>
+			</tr>
+			</table>
+<?php } ?>
+		</td>
+		</tr>
+		</table>
+	</td>
+    <td></td>
+	</tr>
+
+	<tr>
+    <td width="10"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
+    <td width="100%"><img src='/webim/images/free.gif' width="585" height="1" border="0" alt="" /></td>
+    <td width="5"><img src='/webim/images/free.gif' width="5" height="1" border="0" alt="" /></td>
+	</tr>
+	</table>
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/chat_error.php b/src/webim/view/chat_error.php
index 4b28d55d..99ae633f 100644
--- a/src/webim/view/chat_error.php
+++ b/src/webim/view/chat_error.php
@@ -1,108 +1,104 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<title><?php echo getstring("chat.error_page.title") ?></title>
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
-</head>
-<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
-<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td valign="top">
-
-
-
-
-
-<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td height="75"></td>
-<td class="window">
-	<h1><?php echo getstring("chat.error_page.head") ?></h1>
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td height="100%"></td>
-<td>
-
-	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0"><tr>
-    <td width="15"><img src='/webim/images/wincrnlt.gif' width="15" height="15" border="0" alt="" /></td>
-	<td width="100%" background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-    <td width="15"><img src='/webim/images/wincrnrt.gif' width="15" height="15" border="0" alt="" /></td>
-	</tr><tr><td height="100%" bgcolor="#FED840"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-	<td background="/webim/images/winbg.gif" class="bgcy">
-
-		<?php	if( isset($errors) && count($errors) > 0 ) {
-		print getstring("errors.header");
-		foreach( $errors as $e ) {
-			print getstring("errors.prefix");
-			print $e;
-			print getstring("errors.suffix");
-		}
-		print getstring("errors.footer");
-	} ?>
-
-
-	</td><td bgcolor="#E8A400"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-	</tr><tr><td><img src='/webim/images/wincrnlb.gif' width="15" height="15" border="0" alt="" /></td>
-	<td background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-    <td><img src='/webim/images/wincrnrb.gif' width="15" height="15" border="0" alt="" /></td>
-	</tr>
-	</table>
-
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td height="70"></td>
-<td>
-
-	<table width="100%" cellspacing="0" cellpadding="0" border="0">
-	<tr>
-    <td width="100%" align="right">
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><a href="javascript:window.close();" title="<?php echo getstring("chat.error_page.close") ?>"><img src='/webim/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>
-	    <td width="5"></td>
-	    <td class="button"><a href="javascript:window.close();" title="<?php echo getstring("chat.error_page.close") ?>"><?php echo getstring("chat.error_page.close") ?></a></td>
-		</tr>
-		</table>
-	</td>
-	</tr>
-	</table>
-	
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
-<td width="100%"><img src='/webim/images/free.gif' width="540" height="1" border="0" alt="" /></td>
-<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
-</tr>
-</table>
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title><?php echo getstring("chat.error_page.title") ?></title>
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
+</head>
+<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
+<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td valign="top">
+
+<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td height="75"></td>
+<td class="window">
+	<h1><?php echo getstring("chat.error_page.head") ?></h1>
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td height="100%"></td>
+<td>
+
+	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0"><tr>
+    <td width="15"><img src='/webim/images/wincrnlt.gif' width="15" height="15" border="0" alt="" /></td>
+	<td width="100%" background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+    <td width="15"><img src='/webim/images/wincrnrt.gif' width="15" height="15" border="0" alt="" /></td>
+	</tr><tr><td height="100%" bgcolor="#FED840"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+	<td background="/webim/images/winbg.gif" class="bgcy">
+
+		<?php	if( isset($errors) && count($errors) > 0 ) {
+		print getstring("errors.header");
+		foreach( $errors as $e ) {
+			print getstring("errors.prefix");
+			print $e;
+			print getstring("errors.suffix");
+		}
+		print getstring("errors.footer");
+	} ?>
+
+
+	</td><td bgcolor="#E8A400"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+	</tr><tr><td><img src='/webim/images/wincrnlb.gif' width="15" height="15" border="0" alt="" /></td>
+	<td background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+    <td><img src='/webim/images/wincrnrb.gif' width="15" height="15" border="0" alt="" /></td>
+	</tr>
+	</table>
+
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td height="70"></td>
+<td>
+
+	<table width="100%" cellspacing="0" cellpadding="0" border="0">
+	<tr>
+    <td width="100%" align="right">
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><a href="javascript:window.close();" title="<?php echo getstring("chat.error_page.close") ?>"><img src='/webim/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>
+	    <td width="5"></td>
+	    <td class="button"><a href="javascript:window.close();" title="<?php echo getstring("chat.error_page.close") ?>"><?php echo getstring("chat.error_page.close") ?></a></td>
+		</tr>
+		</table>
+	</td>
+	</tr>
+	</table>
+	
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
+<td width="100%"><img src='/webim/images/free.gif' width="540" height="1" border="0" alt="" /></td>
+<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
+</tr>
+</table>
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/chat_mailsent.php b/src/webim/view/chat_mailsent.php
index 779a63e6..0ef9799a 100644
--- a/src/webim/view/chat_mailsent.php
+++ b/src/webim/view/chat_mailsent.php
@@ -1,108 +1,104 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<title><?php echo getstring("chat.window.title.user") ?></title>
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
-</head>
-<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
-<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td valign="top">
-
-
-
-
-
-<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td height="75"></td>
-<td class="window">
-	<h1><?php echo getstring("chat.mailthread.sent.title") ?></h1>
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td height="100%"></td>
-<td>
-
-	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-	<tr>
-    <td width="15"><img src='/webim/images/wincrnlt.gif' width="15" height="15" border="0" alt="" /></td>
-	<td width="100%" background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-    <td width="15"><img src='/webim/images/wincrnrt.gif' width="15" height="15" border="0" alt="" /></td>
-	</tr>
-
-	<tr>
-    <td height="100%" bgcolor="#FED840"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-	<td background="/webim/images/winbg.gif" class="bgcy">
-
-		<?php echo getstring2("chat.mailthread.sent.content",array($page['email'])) ?><br/>
-		<a href="javascript:window.close();"><?php echo getstring("chat.mailthread.sent.closewindow") ?></a>
-
-	</td>
-    <td bgcolor="#E8A400"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-	</tr>
-
-	<tr>
-    <td><img src='/webim/images/wincrnlb.gif' width="15" height="15" border="0" alt="" /></td>
-	<td background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-    <td><img src='/webim/images/wincrnrb.gif' width="15" height="15" border="0" alt="" /></td>
-	</tr>
-	</table>
-
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td height="70"></td>
-<td>
-
-	<table width="100%" cellspacing="0" cellpadding="0" border="0">
-	<tr>
-    <td width="100%" align="right">
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><a href="javascript:window.close();" title="<?php echo getstring("chat.mailthread.sent.close") ?>"><img src='/webim/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>
-	    <td width="5"></td>
-	    <td class="button"><a href="javascript:window.close();" title="<?php echo getstring("chat.mailthread.sent.close") ?>"><?php echo getstring("chat.mailthread.sent.close") ?></a></td>
-		</tr>
-		</table>
-	</td>
-	</tr>
-	</table>
-	
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
-<td width="100%"><img src='/webim/images/free.gif' width="540" height="1" border="0" alt="" /></td>
-<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
-</tr>
-</table>
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title><?php echo getstring("chat.window.title.user") ?></title>
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
+</head>
+<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
+<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td valign="top">
+
+<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td height="75"></td>
+<td class="window">
+	<h1><?php echo getstring("chat.mailthread.sent.title") ?></h1>
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td height="100%"></td>
+<td>
+
+	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+	<tr>
+    <td width="15"><img src='/webim/images/wincrnlt.gif' width="15" height="15" border="0" alt="" /></td>
+	<td width="100%" background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+    <td width="15"><img src='/webim/images/wincrnrt.gif' width="15" height="15" border="0" alt="" /></td>
+	</tr>
+
+	<tr>
+    <td height="100%" bgcolor="#FED840"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+	<td background="/webim/images/winbg.gif" class="bgcy">
+
+		<?php echo getstring2("chat.mailthread.sent.content",array($page['email'])) ?><br/>
+		<a href="javascript:window.close();"><?php echo getstring("chat.mailthread.sent.closewindow") ?></a>
+
+	</td>
+    <td bgcolor="#E8A400"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+	</tr>
+
+	<tr>
+    <td><img src='/webim/images/wincrnlb.gif' width="15" height="15" border="0" alt="" /></td>
+	<td background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+    <td><img src='/webim/images/wincrnrb.gif' width="15" height="15" border="0" alt="" /></td>
+	</tr>
+	</table>
+
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td height="70"></td>
+<td>
+
+	<table width="100%" cellspacing="0" cellpadding="0" border="0">
+	<tr>
+    <td width="100%" align="right">
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><a href="javascript:window.close();" title="<?php echo getstring("chat.mailthread.sent.close") ?>"><img src='/webim/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>
+	    <td width="5"></td>
+	    <td class="button"><a href="javascript:window.close();" title="<?php echo getstring("chat.mailthread.sent.close") ?>"><?php echo getstring("chat.mailthread.sent.close") ?></a></td>
+		</tr>
+		</table>
+	</td>
+	</tr>
+	</table>
+	
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
+<td width="100%"><img src='/webim/images/free.gif' width="540" height="1" border="0" alt="" /></td>
+<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
+</tr>
+</table>
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/chat_mailthread.php b/src/webim/view/chat_mailthread.php
index 0a0d7ac5..380fce47 100644
--- a/src/webim/view/chat_mailthread.php
+++ b/src/webim/view/chat_mailthread.php
@@ -1,132 +1,128 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<title><?php echo getstring("chat.window.title.user") ?></title>
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
-</head>
-<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
-<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td valign="top">
-
-
-
-
-
-<form name="mailThreadForm" method="post" action="/webim/mail.php">
-<input type="hidden" name="thread" value="<?php echo $page['ct.chatThreadId'] ?>"/><input type="hidden" name="token" value="<?php echo $page['ct.token'] ?>"/><input type="hidden" name="level" value="<?php echo $page['level'] ?>"/>
-
-<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td height="75"></td>
-<td class="window">
-	<h1><?php echo getstring("mailthread.title") ?></h1>
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td height="60"></td>
-<td>
-
-	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-	<tr>
-    <td width="15"><img src='/webim/images/wincrnlt.gif' width="15" height="15" border="0" alt="" /></td>
-	<td width="100%" background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-    <td width="15"><img src='/webim/images/wincrnrt.gif' width="15" height="15" border="0" alt="" /></td>
-	</tr>
-
-	<tr>
-    <td height="100%" bgcolor="#FED840"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-	<td background="/webim/images/winbg.gif" class="bgcy">
-		
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td class="text"><?php echo getstring("mailthread.enter_email") ?></td>
-	    <td width="10"></td>
-	    <td><input type="text" name="email" size="20" value="<?php echo form_value('email') ?>" class="username"/></td>
-		</tr>
-		</table>
-
-	</td>
-    <td bgcolor="#E8A400"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-	</tr>
-
-	<tr>
-    <td><img src='/webim/images/wincrnlb.gif' width="15" height="15" border="0" alt="" /></td>
-	<td background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-    <td><img src='/webim/images/wincrnrb.gif' width="15" height="15" border="0" alt="" /></td>
-	</tr>
-	</table>
-
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td height="70"></td>
-<td>
-
-	<table width="100%" cellspacing="0" cellpadding="0" border="0">
-	<tr>
-    <td width="50%">
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><a href="javascript:document.mailThreadForm.submit();" title="<?php echo getstring("mailthread.perform") ?>"><img src='/webim/images/submit.gif' width="40" height="35" border="0" alt="" /></a></td>
-	    <td background="/webim/images/submitbg.gif" valign="top" class="submit">
-			<img src='/webim/images/free.gif' width="1" height="10" border="0" alt="" /><br>
-			<a href="javascript:document.mailThreadForm.submit();" title="<?php echo getstring("mailthread.perform") ?>"><?php echo getstring("mailthread.perform") ?></a><br>
-		</td>
-	    <td width="10"><a href="javascript:document.mailThreadForm.submit();" title="<?php echo getstring("mailthread.perform") ?>"><img src='/webim/images/submitrest.gif' width="10" height="35" border="0" alt="" /></a></td>
-		</tr>
-		</table>
-	</td>
-    <td width="50%" align="right">
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><a href="javascript:window.close();" title="<?php echo getstring("mailthread.close") ?>"><img src='/webim/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>
-	    <td width="5"></td>
-	    <td class="button"><a href="javascript:window.close();" title="<?php echo getstring("mailthread.close") ?>"><?php echo getstring("mailthread.close") ?></a></td>
-		</tr>
-		</table>
-	</td>
-	</tr>
-	</table>
-	
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
-<td width="100%"><img src='/webim/images/free.gif' width="540" height="1" border="0" alt="" /></td>
-<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
-</tr>
-</table>
-
-</form>
-
-
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title><?php echo getstring("chat.window.title.user") ?></title>
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
+</head>
+<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
+<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td valign="top">
+
+<form name="mailThreadForm" method="post" action="/webim/mail.php">
+<input type="hidden" name="thread" value="<?php echo $page['ct.chatThreadId'] ?>"/><input type="hidden" name="token" value="<?php echo $page['ct.token'] ?>"/><input type="hidden" name="level" value="<?php echo $page['level'] ?>"/>
+
+<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td height="75"></td>
+<td class="window">
+	<h1><?php echo getstring("mailthread.title") ?></h1>
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td height="60"></td>
+<td>
+
+	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+	<tr>
+    <td width="15"><img src='/webim/images/wincrnlt.gif' width="15" height="15" border="0" alt="" /></td>
+	<td width="100%" background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+    <td width="15"><img src='/webim/images/wincrnrt.gif' width="15" height="15" border="0" alt="" /></td>
+	</tr>
+
+	<tr>
+    <td height="100%" bgcolor="#FED840"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+	<td background="/webim/images/winbg.gif" class="bgcy">
+		
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td class="text"><?php echo getstring("mailthread.enter_email") ?></td>
+	    <td width="10"></td>
+	    <td><input type="text" name="email" size="20" value="<?php echo form_value('email') ?>" class="username"/></td>
+		</tr>
+		</table>
+
+	</td>
+    <td bgcolor="#E8A400"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+	</tr>
+
+	<tr>
+    <td><img src='/webim/images/wincrnlb.gif' width="15" height="15" border="0" alt="" /></td>
+	<td background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+    <td><img src='/webim/images/wincrnrb.gif' width="15" height="15" border="0" alt="" /></td>
+	</tr>
+	</table>
+
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td height="70"></td>
+<td>
+
+	<table width="100%" cellspacing="0" cellpadding="0" border="0">
+	<tr>
+    <td width="50%">
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><a href="javascript:document.mailThreadForm.submit();" title="<?php echo getstring("mailthread.perform") ?>"><img src='/webim/images/submit.gif' width="40" height="35" border="0" alt="" /></a></td>
+	    <td background="/webim/images/submitbg.gif" valign="top" class="submit">
+			<img src='/webim/images/free.gif' width="1" height="10" border="0" alt="" /><br>
+			<a href="javascript:document.mailThreadForm.submit();" title="<?php echo getstring("mailthread.perform") ?>"><?php echo getstring("mailthread.perform") ?></a><br>
+		</td>
+	    <td width="10"><a href="javascript:document.mailThreadForm.submit();" title="<?php echo getstring("mailthread.perform") ?>"><img src='/webim/images/submitrest.gif' width="10" height="35" border="0" alt="" /></a></td>
+		</tr>
+		</table>
+	</td>
+    <td width="50%" align="right">
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><a href="javascript:window.close();" title="<?php echo getstring("mailthread.close") ?>"><img src='/webim/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>
+	    <td width="5"></td>
+	    <td class="button"><a href="javascript:window.close();" title="<?php echo getstring("mailthread.close") ?>"><?php echo getstring("mailthread.close") ?></a></td>
+		</tr>
+		</table>
+	</td>
+	</tr>
+	</table>
+	
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
+<td width="100%"><img src='/webim/images/free.gif' width="540" height="1" border="0" alt="" /></td>
+<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
+</tr>
+</table>
+
+</form>
+
+
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/chat_oldbrowser.php b/src/webim/view/chat_oldbrowser.php
index 4c3a3b05..88913dfd 100644
--- a/src/webim/view/chat_oldbrowser.php
+++ b/src/webim/view/chat_oldbrowser.php
@@ -1,99 +1,95 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<title><?php echo getstring("page.chat.old_browser.title") ?></title>
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
-</head>
-<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
-<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td valign="top">
-
-
-
-
-
-<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td height="20"></td>
-<td class="window">
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td height="100%"></td>
-<td>
-
-	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0"><tr>
-    <td width="15"><img src='/webim/images/wincrnlt.gif' width="15" height="15" border="0" alt="" /></td>
-	<td width="100%" background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-    <td width="15"><img src='/webim/images/wincrnrt.gif' width="15" height="15" border="0" alt="" /></td>
-	</tr><tr><td height="100%" bgcolor="#FED840"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-	<td background="/webim/images/winbg.gif" class="bgcy">
-
-		<?php echo getstring("page.chat.old_browser.content") ?>
-
-	</td><td bgcolor="#E8A400"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-	</tr><tr><td><img src='/webim/images/wincrnlb.gif' width="15" height="15" border="0" alt="" /></td>
-	<td background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-    <td><img src='/webim/images/wincrnrb.gif' width="15" height="15" border="0" alt="" /></td>
-	</tr>
-	</table>
-
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td height="70"></td>
-<td>
-
-	<table width="100%" cellspacing="0" cellpadding="0" border="0">
-	<tr>
-    <td width="100%" align="right">
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><a href="javascript:window.close();" title="<?php echo getstring("page.chat.old_browser.close") ?>"><img src='/webim/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>
-	    <td width="5"></td>
-	    <td class="button"><a href="javascript:window.close();" title="<?php echo getstring("page.chat.old_browser.close") ?>"><?php echo getstring("page.chat.old_browser.close") ?></a></td>
-		</tr>
-		</table>
-	</td>
-	</tr>
-	</table>
-	
-</td>
-<td></td>
-</tr>
-
-<tr>
-<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
-<td width="100%"><img src='/webim/images/free.gif' width="540" height="1" border="0" alt="" /></td>
-<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
-</tr>
-</table>
-
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title><?php echo getstring("page.chat.old_browser.title") ?></title>
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
+</head>
+<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
+<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td valign="top">
+
+<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td height="20"></td>
+<td class="window">
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td height="100%"></td>
+<td>
+
+	<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0"><tr>
+    <td width="15"><img src='/webim/images/wincrnlt.gif' width="15" height="15" border="0" alt="" /></td>
+	<td width="100%" background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+    <td width="15"><img src='/webim/images/wincrnrt.gif' width="15" height="15" border="0" alt="" /></td>
+	</tr><tr><td height="100%" bgcolor="#FED840"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+	<td background="/webim/images/winbg.gif" class="bgcy">
+
+		<?php echo getstring("page.chat.old_browser.content") ?>
+
+	</td><td bgcolor="#E8A400"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+	</tr><tr><td><img src='/webim/images/wincrnlb.gif' width="15" height="15" border="0" alt="" /></td>
+	<td background="/webim/images/winbg.gif" class="bgcy"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+    <td><img src='/webim/images/wincrnrb.gif' width="15" height="15" border="0" alt="" /></td>
+	</tr>
+	</table>
+
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td height="70"></td>
+<td>
+
+	<table width="100%" cellspacing="0" cellpadding="0" border="0">
+	<tr>
+    <td width="100%" align="right">
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><a href="javascript:window.close();" title="<?php echo getstring("page.chat.old_browser.close") ?>"><img src='/webim/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>
+	    <td width="5"></td>
+	    <td class="button"><a href="javascript:window.close();" title="<?php echo getstring("page.chat.old_browser.close") ?>"><?php echo getstring("page.chat.old_browser.close") ?></a></td>
+		</tr>
+		</table>
+	</td>
+	</tr>
+	</table>
+	
+</td>
+<td></td>
+</tr>
+
+<tr>
+<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
+<td width="100%"><img src='/webim/images/free.gif' width="540" height="1" border="0" alt="" /></td>
+<td width="30"><img src='/webim/images/free.gif' width="30" height="1" border="0" alt="" /></td>
+</tr>
+</table>
+
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/chat_simple.php b/src/webim/view/chat_simple.php
index d5d1376f..964c62bc 100644
--- a/src/webim/view/chat_simple.php
+++ b/src/webim/view/chat_simple.php
@@ -1,239 +1,239 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<title><?php echo getstring("chat.window.title.user") ?></title>
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<meta http-equiv="Content-Type" content="text/html; charset=Windows-1251">
-<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
-<script type="text/javascript" language="javascript" src="/webim/js/brws.js"></script>
-</head>
-
-<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
-
-<table width="600" cellspacing="0" cellpadding="0" border="0">
-<tr>
-<td valign="top">
-
-	<table width="600" cellspacing="0" cellpadding="0" border="0">
-	<tr>
-    <td></td>
-    <td colspan="2" height="100" background="/webim/images/banner.gif" valign="top" class="bgrn">
-		<table width="590" cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td width="135" valign="top">
-			<table width="135" cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td height="25"></td>
-			</tr>
-			<tr>
-		    <td align="center"><?php if( $page['ct.company.chatLogoURL'] ) { ?><img src="<?php echo $page['ct.company.chatLogoURL'] ?>" width="85" height="45" border="0" alt="<?php echo $page['ct.company.name'] ?>"><?php } ?></td>
-			</tr>
-			<tr>
-		    <td height="5"></td>
-			</tr>
-			<tr>
-		    <td align="center" class="text"><?php echo $page['ct.company.name'] ?></td>
-			</tr>
-			</table>
-		</td>
-    	<td width="455" align="right" valign="top">
-			<table cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td height="25" align="right">
-
-				<table cellspacing="0" cellpadding="0" border="0">
-				<tr>
-			    <td class="text"><?php echo getstring("chat.window.product_name") ?></td>
-			    <td width="5"></td>
-			    <td>
-					<table cellspacing="0" cellpadding="0" border="0">
-					<tr>
-				    <td width="95" height="13" bgcolor="#D09221" align="center" class="www"><a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("site.title") ?></a></td>
-					</tr>
-					</table>
-				</td>
-			    <td width="5"></td>
-			    <td><a class="closethread" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.close_title") ?>"><img src='/webim/images/buttons/closewin.gif' width="15" height="15" border="0" altKey="chat.window.close_title"/></a></td>
-			    <td width="5"></td>
-				</tr>
-				</table>
-
-			</td>
-			</tr>
-
-			<tr>
-		    <td height="60" align="right">
-				
-				<table cellspacing="0" cellpadding="0" border="0">
-				<tr>
-
-				<td class="text" nowrap><?php echo getstring("chat.client.name") ?></td> 
-				<td width="10" valign="top"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
-				<td><input id="uname" type="text" size="12" value="<?php echo $page['ct.user.name'] ?>" class="username"></td>
-				<td width="5" valign="top"><img src='/webim/images/free.gif' width="5" height="1" border="0" alt="" /></td>
-				<td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.client.changename") ?>"><img src='/webim/images/buttons/exec.gif' width="25" height="25" border="0" alt="&gt;&gt;" /></a></td>
-
-			    <td><img src='/webim/images/buttondiv.gif' width="35" height="45" border="0" alt="" /></td>
-
-				<td><a href="<?php echo $page['selfLink'] ?>&act=mailthread" target="_blank" title="<?php echo getstring("chat.window.toolbar.mail_history") ?>" onclick="this.newWindow = window.open('<?php echo $page['selfLink'] ?>&act=mailthread', 'ForwardMail', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,width=603,height=204,resizable=0');this.newWindow.focus();this.newWindow.opener=window;return false;"><img src='/webim/images/buttons/email.gif' width="25" height="25" border="0" alt="Mail" /></a></td>
-
-				<td><a id="refresh" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.toolbar.refresh") ?>">
-				<img src='/webim/images/buttons/refresh.gif' width="25" height="25" border="0" alt="Refresh" /></a></td>
-
-			    
-
-			    <td width="20"></td>
-				</tr>
-				</table>
-
-			</td>
-			</tr>
-			</table>
-		</td>
-		</tr>
-		</table>
-	</td>
-	</tr>
-
-	<tr>
-    <td></td>
-    <td valign="top">
-
-		<table width="585" cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td width="20" valign="top"><img src='<?php echo getstring("image.chat.history") ?>' width="20" height="80" border="0" alt="History" /></td>
-    	<td width="565" valign="top" id="chatwndtd">
-			<table width="100%" cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			<tr>
-		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-		    <td width="100%" bgcolor="#FFFFFF" valign="top">
-				<iframe name="chatwndiframe" width="100%" height="175" src="/webim/thread.php?act=refresh&thread=<?php echo $page['ct.chatThreadId'] ?>&token=<?php echo $page['ct.token'] ?>&html=on&user=true" frameborder="0" style="overflow:auto;">
-				Sorry, your browser does not support iframes; try a browser that supports W3 standards.
-				</iframe>
-			</td>
-		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			<tr>
-		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			</table>
-		</td>
-		</tr>
-
-		<tr>
-	    <td colspan="2" height="5"></td>
-		</tr>
-
-		<tr>
-	    <td width="20" valign="top"><img src='<?php echo getstring("image.chat.message") ?>' width="20" height="85" border="0" alt="Message" /></td>
-    	<td width="565" valign="top">
-			<table width="100%" cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			<tr>
-		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-		    <td width="565" height="85" bgcolor="#FFFFFF" valign="top">
-				<form id="messageform" method="post" action="/webim/thread.php" target="chatwndiframe" width="565" height="85">
-				<input type="hidden" name="act" value="post"/><input type="hidden" name="html" value="on"/><input type="hidden" name="thread" value="<?php echo $page['ct.chatThreadId'] ?>"/><input type="hidden" name="token" value="<?php echo $page['ct.token'] ?>"/><input type="hidden" name="user" value="true"/>
-				<input type="hidden" id="message" name="message" value=""/>
-				<textarea id="messagetext" cols="50" rows="4" class="message" style="width:550px;" tabindex="0"></textarea>
-				</form>
-			</td>
-		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			<tr>
-		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-			</tr>
-			</table>
-		</td>
-		</tr>
-		</table>
-
-	</td>
-    <td></td>
-	</tr>
-
-	<tr>
-    <td height="45"></td>
-    <td>
-		<table width="100%" cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td width="33%">
-			<table cellspacing="0" cellpadding="0" border="0">
-			<tr>
-		    <td width="20"></td>
-
-			</tr>
-			</table>
-		</td>
-		<td width="33%" align="center" class="copyr"><?php echo getstring("chat.window.poweredby") ?> <a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("chat.window.poweredreftext") ?></a></td>
-		<td width="33%" align="right">
-			<table cellspacing="0" cellpadding="0" border="0" id="postmessage">
-
-			<tr>
-		    <td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='/webim/images/submit.gif' width="40" height="35" border="0" altKey="chat.window.send_message_short"/></a></td>
-		    <td background="/webim/images/submitbg.gif" valign="top" class="submit">
-				<img src='/webim/images/free.gif' width="1" height="10" border="0" alt="" /><br>
-				<a id="msgsend1" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><?php echo getstring("chat.window.send_message_short") ?></a><br>
-			</td>
-			<td width="10"><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='/webim/images/submitrest.gif' width="10" height="35" border="0" altKey="chat.window.send_message_short"/></a></td>
-			</tr>
-			</table>
-		</td>
-		</tr>
-		</table>
-	</td>
-    <td></td>
-	</tr>
-
-	<tr>
-    <td width="10"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
-    <td width="585"><img src='/webim/images/free.gif' width="585" height="1" border="0" alt="" /></td>
-    <td width="5"><img src='/webim/images/free.gif' width="5" height="1" border="0" alt="" /></td>
-	</tr>
-	</table>
-
-</td>
-</tr>
-</table>
-
-<script type="text/javascript"><!--
-function sendmessage(){
-	getEl('message').value = getEl('messagetext').value;
-	getEl('messagetext').value = '';
-	getEl('messageform').submit();
-}
-getEl('messagetext').onkeydown = function(k) {
-	if( k ){ ctrl=k.ctrlKey;k=k.which; } else { k=event.keyCode;ctrl=event.ctrlKey;	}
-	if( (k==13 && ctrl) || (k==10) ) {
-		sendmessage();
-		return false;
-	}
-	return true;
-}
-getEl('msgsend1').onclick = function() {
-	sendmessage();
-	return false;
-}
-//--></script>
-
-</body>
-</html>
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title><?php echo getstring("chat.window.title.user") ?></title>
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<meta http-equiv="Content-Type" content="text/html; charset=Windows-1251">
+<link rel="stylesheet" type="text/css" href="/webim/chat.css" />
+<script type="text/javascript" language="javascript" src="/webim/js/brws.js"></script>
+</head>
+
+<body bgcolor="#FFFFFF" background="/webim/images/bg.gif" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
+
+<table width="600" cellspacing="0" cellpadding="0" border="0">
+<tr>
+<td valign="top">
+
+	<table width="600" cellspacing="0" cellpadding="0" border="0">
+	<tr>
+    <td></td>
+    <td colspan="2" height="100" background="/webim/images/banner.gif" valign="top" class="bgrn">
+		<table width="590" cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td width="135" valign="top">
+			<table width="135" cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td height="25"></td>
+			</tr>
+			<tr>
+		    <td align="center"><?php if( $page['ct.company.chatLogoURL'] ) { ?><img src="<?php echo $page['ct.company.chatLogoURL'] ?>" width="85" height="45" border="0" alt="<?php echo $page['ct.company.name'] ?>"><?php } ?></td>
+			</tr>
+			<tr>
+		    <td height="5"></td>
+			</tr>
+			<tr>
+		    <td align="center" class="text"><?php echo $page['ct.company.name'] ?></td>
+			</tr>
+			</table>
+		</td>
+    	<td width="455" align="right" valign="top">
+			<table cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td height="25" align="right">
+
+				<table cellspacing="0" cellpadding="0" border="0">
+				<tr>
+			    <td class="text"><?php echo getstring("chat.window.product_name") ?></td>
+			    <td width="5"></td>
+			    <td>
+					<table cellspacing="0" cellpadding="0" border="0">
+					<tr>
+				    <td width="95" height="13" bgcolor="#D09221" align="center" class="www"><a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("site.title") ?></a></td>
+					</tr>
+					</table>
+				</td>
+			    <td width="5"></td>
+			    <td><a class="closethread" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.close_title") ?>"><img src='/webim/images/buttons/closewin.gif' width="15" height="15" border="0" altKey="chat.window.close_title"/></a></td>
+			    <td width="5"></td>
+				</tr>
+				</table>
+
+			</td>
+			</tr>
+
+			<tr>
+		    <td height="60" align="right">
+				
+				<table cellspacing="0" cellpadding="0" border="0">
+				<tr>
+
+				<td class="text" nowrap><?php echo getstring("chat.client.name") ?></td> 
+				<td width="10" valign="top"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
+				<td><input id="uname" type="text" size="12" value="<?php echo $page['ct.user.name'] ?>" class="username"></td>
+				<td width="5" valign="top"><img src='/webim/images/free.gif' width="5" height="1" border="0" alt="" /></td>
+				<td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.client.changename") ?>"><img src='/webim/images/buttons/exec.gif' width="25" height="25" border="0" alt="&gt;&gt;" /></a></td>
+
+			    <td><img src='/webim/images/buttondiv.gif' width="35" height="45" border="0" alt="" /></td>
+
+				<td><a href="<?php echo $page['selfLink'] ?>&act=mailthread" target="_blank" title="<?php echo getstring("chat.window.toolbar.mail_history") ?>" onclick="this.newWindow = window.open('<?php echo $page['selfLink'] ?>&act=mailthread', 'ForwardMail', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,width=603,height=204,resizable=0');this.newWindow.focus();this.newWindow.opener=window;return false;"><img src='/webim/images/buttons/email.gif' width="25" height="25" border="0" alt="Mail" /></a></td>
+
+				<td><a id="refresh" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.toolbar.refresh") ?>">
+				<img src='/webim/images/buttons/refresh.gif' width="25" height="25" border="0" alt="Refresh" /></a></td>
+
+			    
+
+			    <td width="20"></td>
+				</tr>
+				</table>
+
+			</td>
+			</tr>
+			</table>
+		</td>
+		</tr>
+		</table>
+	</td>
+	</tr>
+
+	<tr>
+    <td></td>
+    <td valign="top">
+
+		<table width="585" cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td width="20" valign="top"><img src='<?php echo getstring("image.chat.history") ?>' width="20" height="80" border="0" alt="History" /></td>
+    	<td width="565" valign="top" id="chatwndtd">
+			<table width="100%" cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			<tr>
+		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+		    <td width="100%" bgcolor="#FFFFFF" valign="top">
+				<iframe name="chatwndiframe" width="100%" height="175" src="/webim/thread.php?act=refresh&thread=<?php echo $page['ct.chatThreadId'] ?>&token=<?php echo $page['ct.token'] ?>&html=on&user=true" frameborder="0" style="overflow:auto;">
+				Sorry, your browser does not support iframes; try a browser that supports W3 standards.
+				</iframe>
+			</td>
+		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			<tr>
+		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			</table>
+		</td>
+		</tr>
+
+		<tr>
+	    <td colspan="2" height="5"></td>
+		</tr>
+
+		<tr>
+	    <td width="20" valign="top"><img src='<?php echo getstring("image.chat.message") ?>' width="20" height="85" border="0" alt="Message" /></td>
+    	<td width="565" valign="top">
+			<table width="100%" cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			<tr>
+		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+		    <td width="565" height="85" bgcolor="#FFFFFF" valign="top">
+				<form id="messageform" method="post" action="/webim/thread.php" target="chatwndiframe" width="565" height="85">
+				<input type="hidden" name="act" value="post"/><input type="hidden" name="html" value="on"/><input type="hidden" name="thread" value="<?php echo $page['ct.chatThreadId'] ?>"/><input type="hidden" name="token" value="<?php echo $page['ct.token'] ?>"/><input type="hidden" name="user" value="true"/>
+				<input type="hidden" id="message" name="message" value=""/>
+				<textarea id="messagetext" cols="50" rows="4" class="message" style="width:550px;" tabindex="0"></textarea>
+				</form>
+			</td>
+		    <td bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			<tr>
+		    <td colspan="3" bgcolor="#A1A1A1"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+			</tr>
+			</table>
+		</td>
+		</tr>
+		</table>
+
+	</td>
+    <td></td>
+	</tr>
+
+	<tr>
+    <td height="45"></td>
+    <td>
+		<table width="100%" cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td width="33%">
+			<table cellspacing="0" cellpadding="0" border="0">
+			<tr>
+		    <td width="20"></td>
+
+			</tr>
+			</table>
+		</td>
+		<td width="33%" align="center" class="copyr"><?php echo getstring("chat.window.poweredby") ?> <a href="<?php echo getstring("site.url") ?>" title="<?php echo getstring("company.title") ?>" target="_blank"><?php echo getstring("chat.window.poweredreftext") ?></a></td>
+		<td width="33%" align="right">
+			<table cellspacing="0" cellpadding="0" border="0" id="postmessage">
+
+			<tr>
+		    <td><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='/webim/images/submit.gif' width="40" height="35" border="0" altKey="chat.window.send_message_short"/></a></td>
+		    <td background="/webim/images/submitbg.gif" valign="top" class="submit">
+				<img src='/webim/images/free.gif' width="1" height="10" border="0" alt="" /><br>
+				<a id="msgsend1" href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><?php echo getstring("chat.window.send_message_short") ?></a><br>
+			</td>
+			<td width="10"><a href="javascript:void(0)" onclick="return false;" title="<?php echo getstring("chat.window.send_message") ?>"><img src='/webim/images/submitrest.gif' width="10" height="35" border="0" altKey="chat.window.send_message_short"/></a></td>
+			</tr>
+			</table>
+		</td>
+		</tr>
+		</table>
+	</td>
+    <td></td>
+	</tr>
+
+	<tr>
+    <td width="10"><img src='/webim/images/free.gif' width="10" height="1" border="0" alt="" /></td>
+    <td width="585"><img src='/webim/images/free.gif' width="585" height="1" border="0" alt="" /></td>
+    <td width="5"><img src='/webim/images/free.gif' width="5" height="1" border="0" alt="" /></td>
+	</tr>
+	</table>
+
+</td>
+</tr>
+</table>
+
+<script type="text/javascript"><!--
+function sendmessage(){
+	getEl('message').value = getEl('messagetext').value;
+	getEl('messagetext').value = '';
+	getEl('messageform').submit();
+}
+getEl('messagetext').onkeydown = function(k) {
+	if( k ){ ctrl=k.ctrlKey;k=k.which; } else { k=event.keyCode;ctrl=event.ctrlKey;	}
+	if( (k==13 && ctrl) || (k==10) ) {
+		sendmessage();
+		return false;
+	}
+	return true;
+}
+getEl('msgsend1').onclick = function() {
+	sendmessage();
+	return false;
+}
+//--></script>
+
+</body>
+</html>
diff --git a/src/webim/view/gen_button.php b/src/webim/view/gen_button.php
index 965be715..67f7ce64 100644
--- a/src/webim/view/gen_button.php
+++ b/src/webim/view/gen_button.php
@@ -1,134 +1,127 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("page.gen_button.title") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
- <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
-		<h1><?php echo getstring("page.gen_button.title") ?></h1>
- </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
-	
-
-	<?php echo getstring("page.gen_button.intro") ?>
-<br />
-<br />
-
-<form name="buttonCodeForm" method="get" action="/webim/operator/getcode.php">
-<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
-	<tr>
-		<td colspan="3" class="formauth"><?php echo getstring("page.gen_button.choose_image") ?></td>
-	</tr>
-	<tr><td colspan="3" height="2"></td></tr>
-	<tr>
-		<td colspan="3">
-			<select name="image" onchange="this.form.submit();"><?php foreach($page['availableImages'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("image") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
-		</td>
-	</tr>
-	<tr><td colspan="3" height="5"></td></tr>
-	<tr>
-		<td colspan="3" class="formauth"><?php echo getstring("page.gen_button.choose_locale") ?></td>
-	</tr>
-	<tr><td colspan="3" height="2"></td></tr>
-	<tr>
-		<td colspan="3">
-			<select name="lang" onchange="this.form.submit();"><?php foreach($page['availableLocales'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("lang") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
-		</td>
-	</tr>
-	<tr><td colspan="3" height="5"></td></tr>
-	<tr>
-		<td colspan="3" class="formauth"><?php echo getstring("page.gen_button.include_site_name") ?></td>
-	</tr>
-	<tr><td colspan="3" height="2"></td></tr>
-	<tr>
-		<td colspan="3">
-			<input type="checkbox" name="hostname" value="on"<?php echo form_value_cb('hostname') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
-		</td>
-	</tr>
-<?php if( $page['formhostname'] ) { ?>
-	<tr><td colspan="3" height="5"></td></tr>
-	<tr>
-		<td colspan="3" class="formauth"><?php echo getstring("page.gen_button.secure_links") ?></td>
-	</tr>
-	<tr><td colspan="3" height="2"></td></tr>
-	<tr>
-		<td colspan="3">
-			<input type="checkbox" name="secure" value="on"<?php echo form_value_cb('secure') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
-		</td>
-	</tr>
-<?php } ?>
-	<tr><td colspan="3" height="5"></td></tr>
-	<tr>
-		<td class="formauth"><?php echo getstring("page.gen_button.code") ?></td>
-		<td width="10"><img src="/webim/images/free.gif" width="10" height="1" border="0" alt=""></td>
-		<td></td>
-	</tr>
-	<tr><td colspan="3" height="2"></td></tr>
-	<tr>
-		<td><textarea cols="60" rows="15"><?php echo $page['buttonCode'] ?></textarea></td>
-		<td></td>
-		<td class="formauth" valign="top" nowrap><span class="formdescr"><?php echo getstring("page.gen_button.code.description") ?></span></td>
-	</tr>
-	<tr>
-		<td colspan="3" height="10"></td>
-	</tr>
-
-	<tr>
-		<td class="formauth"><?php echo getstring("page.gen_button.sample") ?></td>
-		<td></td>
-		<td></td>
-	</tr>
-	<tr>
-		<td colspan="3" height="2"></td>
-	</tr>
-	<tr>
-		<td><?php echo $page['buttonCode'] ?></td>
-		<td></td>
-		<td class="formauth" valign="top" nowrap><span class="formdescr"></span></td>
-	</tr>
-</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
-</form>
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("page.gen_button.title") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
+		<h1><?php echo getstring("page.gen_button.title") ?></h1>
+ </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
+	
+
+	<?php echo getstring("page.gen_button.intro") ?>
+<br />
+<br />
+
+<form name="buttonCodeForm" method="get" action="/webim/operator/getcode.php">
+<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
+	<tr>
+		<td colspan="3" class="formauth"><?php echo getstring("page.gen_button.choose_image") ?></td>
+	</tr>
+	<tr><td colspan="3" height="2"></td></tr>
+	<tr>
+		<td colspan="3">
+			<select name="image" onchange="this.form.submit();"><?php foreach($page['availableImages'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("image") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
+		</td>
+	</tr>
+	<tr><td colspan="3" height="5"></td></tr>
+	<tr>
+		<td colspan="3" class="formauth"><?php echo getstring("page.gen_button.choose_locale") ?></td>
+	</tr>
+	<tr><td colspan="3" height="2"></td></tr>
+	<tr>
+		<td colspan="3">
+			<select name="lang" onchange="this.form.submit();"><?php foreach($page['availableLocales'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("lang") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
+		</td>
+	</tr>
+	<tr><td colspan="3" height="5"></td></tr>
+	<tr>
+		<td colspan="3" class="formauth"><?php echo getstring("page.gen_button.include_site_name") ?></td>
+	</tr>
+	<tr><td colspan="3" height="2"></td></tr>
+	<tr>
+		<td colspan="3">
+			<input type="checkbox" name="hostname" value="on"<?php echo form_value_cb('hostname') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
+		</td>
+	</tr>
+<?php if( $page['formhostname'] ) { ?>
+	<tr><td colspan="3" height="5"></td></tr>
+	<tr>
+		<td colspan="3" class="formauth"><?php echo getstring("page.gen_button.secure_links") ?></td>
+	</tr>
+	<tr><td colspan="3" height="2"></td></tr>
+	<tr>
+		<td colspan="3">
+			<input type="checkbox" name="secure" value="on"<?php echo form_value_cb('secure') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
+		</td>
+	</tr>
+<?php } ?>
+	<tr><td colspan="3" height="5"></td></tr>
+	<tr>
+		<td class="formauth"><?php echo getstring("page.gen_button.code") ?></td>
+		<td width="10"><img src="/webim/images/free.gif" width="10" height="1" border="0" alt=""></td>
+		<td></td>
+	</tr>
+	<tr><td colspan="3" height="2"></td></tr>
+	<tr>
+		<td><textarea cols="60" rows="15"><?php echo $page['buttonCode'] ?></textarea></td>
+		<td></td>
+		<td class="formauth" valign="top" nowrap><span class="formdescr"><?php echo getstring("page.gen_button.code.description") ?></span></td>
+	</tr>
+	<tr>
+		<td colspan="3" height="10"></td>
+	</tr>
+
+	<tr>
+		<td class="formauth"><?php echo getstring("page.gen_button.sample") ?></td>
+		<td></td>
+		<td></td>
+	</tr>
+	<tr>
+		<td colspan="3" height="2"></td>
+	</tr>
+	<tr>
+		<td><?php echo $page['buttonCode'] ?></td>
+		<td></td>
+		<td class="formauth" valign="top" nowrap><span class="formdescr"></span></td>
+	</tr>
+</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
+</form>
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/login.php b/src/webim/view/login.php
index c9da53aa..d221fb17 100644
--- a/src/webim/view/login.php
+++ b/src/webim/view/login.php
@@ -1,143 +1,124 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("page_login.title") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
-		<h1><?php echo getstring("page_login.title") ?></h1>
-	
-
-	
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<?php if( isset($errors) && count($errors) > 0 ) { ?>
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td valign="top"><img src='/webim/images/icon_err.gif' width="40" height="40" border="0" alt="" /></td>
-	    <td width="10"></td>
-	    <td class="text">
-		    <?php	if( isset($errors) && count($errors) > 0 ) {
-		print getstring("errors.header");
-		foreach( $errors as $e ) {
-			print getstring("errors.prefix");
-			print $e;
-			print getstring("errors.suffix");
-		}
-		print getstring("errors.footer");
-	} ?>
-
-		</td>
-		</tr>
-		</table>
-	<?php } ?>
-
-<form name="loginForm" method="post" action="/webim/operator/login.php">
-	<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
-		<tr>
-			<td colspan="2">
-			<table cellspacing="0" cellpadding="0" border="0">
-				<tr>
-					<td class="formauth"><?php echo getstring("page_login.login") ?></td>
-					<td width="20"></td>
-					<td><input type="text" name="login" size="20" value="<?php echo form_value('login') ?>" class="formauth"/></td>
-				</tr>
-
-				<tr>
-					<td colspan="3" height="10"></td>
-				</tr>
-
-				<tr>
-					<td class="formauth"><?php echo getstring("page_login.password") ?></td>
-					<td></td>
-					<td><input type="password" name="password" size="20" value="" class="formauth"/></td>
-				</tr>
-
-				<tr>
-					<td colspan="3" height="5"></td>
-				</tr>
-
-				<tr>
-					<td class="formauth"></td>
-					<td></td>
-					<td>
-					<table cellspacing="0" cellpadding="0" border="0">
-						<tr>
-							<td><input type="checkbox" name="isRemember" value="on"<?php echo form_value_cb('isRemember') ? " checked=\"checked\"" : "" ?> /></td>
-							<td width="5"></td>
-							<td class="formauth" nowrap><span><?php echo getstring("page_login.remember") ?></span></td>
-						</tr>
-					</table>
-					</td>
-				</tr>
-			</table>
-			</td>
-		</tr>
-
-		<tr><td colspan='2' height='20'></td></tr><tr><td colspan='2' background='/webim/images/formline.gif'><img src='/webim/images/formline.gif' width='1' height='2' border='0' alt=''></td></tr><tr><td colspan='2' height='10'></td></tr>
-
-		<tr>
-			<td><input type="hidden" name="backPath" value="<?php echo $page['backPath'] ?>"/> <input type="image" name="" src='<?php echo getstring("image.button.login") ?>' border="0" alt='<?php echo getstring("button.enter") ?>'/>
-			</td>
-			
-		</tr>
-	</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
-</form>
-
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("page_login.title") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+		<h1><?php echo getstring("page_login.title") ?></h1>
+	
+
+	
+
+
+<?php if( isset($errors) && count($errors) > 0 ) { ?>
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td valign="top"><img src='/webim/images/icon_err.gif' width="40" height="40" border="0" alt="" /></td>
+	    <td width="10"></td>
+	    <td class="text">
+		    <?php	if( isset($errors) && count($errors) > 0 ) {
+		print getstring("errors.header");
+		foreach( $errors as $e ) {
+			print getstring("errors.prefix");
+			print $e;
+			print getstring("errors.suffix");
+		}
+		print getstring("errors.footer");
+	} ?>
+
+		</td>
+		</tr>
+		</table>
+	<?php } ?>
+
+<form name="loginForm" method="post" action="/webim/operator/login.php">
+	<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
+		<tr>
+			<td colspan="2">
+			<table cellspacing="0" cellpadding="0" border="0">
+				<tr>
+					<td class="formauth"><?php echo getstring("page_login.login") ?></td>
+					<td width="20"></td>
+					<td><input type="text" name="login" size="20" value="<?php echo form_value('login') ?>" class="formauth"/></td>
+				</tr>
+
+				<tr>
+					<td colspan="3" height="10"></td>
+				</tr>
+
+				<tr>
+					<td class="formauth"><?php echo getstring("page_login.password") ?></td>
+					<td></td>
+					<td><input type="password" name="password" size="20" value="" class="formauth"/></td>
+				</tr>
+
+				<tr>
+					<td colspan="3" height="5"></td>
+				</tr>
+
+				<tr>
+					<td class="formauth"></td>
+					<td></td>
+					<td>
+					<table cellspacing="0" cellpadding="0" border="0">
+						<tr>
+							<td><input type="checkbox" name="isRemember" value="on"<?php echo form_value_cb('isRemember') ? " checked=\"checked\"" : "" ?> /></td>
+							<td width="5"></td>
+							<td class="formauth" nowrap><span><?php echo getstring("page_login.remember") ?></span></td>
+						</tr>
+					</table>
+					</td>
+				</tr>
+			</table>
+			</td>
+		</tr>
+
+		<tr><td colspan='2' height='20'></td></tr><tr><td colspan='2' background='/webim/images/formline.gif'><img src='/webim/images/formline.gif' width='1' height='2' border='0' alt=''></td></tr><tr><td colspan='2' height='10'></td></tr>
+
+		<tr>
+			<td><input type="hidden" name="backPath" value="<?php echo $page['backPath'] ?>"/> <input type="image" name="" src='<?php echo getstring("image.button.login") ?>' border="0" alt='<?php echo getstring("button.enter") ?>'/>
+			</td>
+			
+		</tr>
+	</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
+</form>
+
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/menu.php b/src/webim/view/menu.php
index 945292cd..cb664dde 100644
--- a/src/webim/view/menu.php
+++ b/src/webim/view/menu.php
@@ -1,88 +1,81 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("topMenu.admin") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
- <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
-		<h1><?php echo getstring("topMenu.admin") ?></h1>
- </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td></tr></table></td></tr></table> 
-	
-
-	<?php echo getstring("admin.content.description") ?>
-<br>
-<br>
-
-<table cellspacing="0" cellpadding="0" border="0">
-
-	<tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/operators.php'><?php echo getstring('leftMenu.client_agents') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('admin.content.client_agents') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
-
-	<tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/users.php'><?php echo getstring('topMenu.users') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('page_client.pending_users') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
-
-	<tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/getcode.php'><?php echo getstring('leftMenu.client_gen_button') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('admin.content.client_gen_button') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
-        
-        <tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/history.php'><?php echo getstring('page_analysis.search.title') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('content.history') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
-
-	<tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/logout.php'><?php echo getstring('topMenu.logoff') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('content.logoff') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
-
-</table>
-
-<table width="200" cellspacing="0" cellpadding="0" border="0">
-<tr>
-  <td height="10"></td>
-</tr>
-<tr>
-  <td bgcolor="#D6D6D6"><img src="/webim/images/free.gif" height="1" width="1" border="0" alt=""></td>
-</tr>
-<tr>
-  <td height="7"></td>
-</tr>
-</table>
-
-Web Messenger/<?php echo $page['version'] ?> &bull; <?php echo $page['localeLinks'] ?>
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("topMenu.admin") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
+		<h1><?php echo getstring("topMenu.admin") ?></h1>
+ </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td></tr></table></td></tr></table> 
+	
+
+	<?php echo getstring("admin.content.description") ?>
+<br>
+<br>
+
+<table cellspacing="0" cellpadding="0" border="0">
+
+	<tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/operators.php'><?php echo getstring('leftMenu.client_agents') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('admin.content.client_agents') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
+
+	<tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/users.php'><?php echo getstring('topMenu.users') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('page_client.pending_users') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
+
+	<tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/getcode.php'><?php echo getstring('leftMenu.client_gen_button') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('admin.content.client_gen_button') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
+
+	<tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/history.php'><?php echo getstring('page_analysis.search.title') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('content.history') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
+
+	<tr><td width='20' valign='top'><img src='/webim/images/lidiv.gif' width='5' height='45' border='0' alt=''></td><td valign='top' class='text'><a href='/webim/operator/logout.php'><?php echo getstring('topMenu.logoff') ?></a><br><img src='/webim/images/free.gif' width='1' height='10' border='0' alt=''><br><?php echo getstring('content.logoff') ?><br></td></tr><tr><td colspan='2' height='20'></td></tr>
+
+</table>
+
+<table width="200" cellspacing="0" cellpadding="0" border="0">
+<tr>
+  <td height="10"></td>
+</tr>
+<tr>
+  <td bgcolor="#D6D6D6"><img src="/webim/images/free.gif" height="1" width="1" border="0" alt=""></td>
+</tr>
+<tr>
+  <td height="7"></td>
+</tr>
+</table>
+
+Web Messenger/<?php echo $page['version'] ?> &bull; <?php echo $page['localeLinks'] ?>
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/pending_users.php b/src/webim/view/pending_users.php
index e515d5fe..ca1a8c34 100644
--- a/src/webim/view/pending_users.php
+++ b/src/webim/view/pending_users.php
@@ -1,176 +1,156 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-<script type="text/javascript" language="javascript" src="/webim/js/common.js"></script>
-
-
-
-
-
-
-
-
-<script><!--
-var localized = new Array(
-    "<?php echo getstring("pending.table.speak") ?>",
-    "<?php echo getstring("pending.table.view") ?>",
-    "<?php echo getstring("pending.table.ban") ?>"
-);
-var updaterOptions = {
-	url:"/webim/operator/update.php", 
-
-	agentservl:"/webim/operator/agent.php",
-	noclients:"<?php echo getstring("clients.no_clients") ?>" };
-//--></script>
-<script type="text/javascript" language="javascript" src="/webim/js/page_pendingclients.js"></script>
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("clients.title") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
- <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
-		<h1><?php echo getstring("clients.title") ?></h1>
- </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
-	
-
-	
-
-
-
-
-<?php echo getstring("clients.intro") ?><br>
-
-<?php echo getstring("clients.how_to") ?><br>
-<br>
-
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
-<tr><td colspan="3" bgcolor="#DADADA"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td></tr>
-<tr><td bgcolor="#DADADA"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-   <td width="100%">
-   
-   <!-- Pending -->
-
-<table width="100%" id="threadlist" cellspacing="0" cellpadding="0" border="0">
-<tr>
-    <td width="150" height="30" bgcolor="#276DB8" class="table"><span class="header"><?php echo getstring("pending.table.head.name") ?></span></td>
-    <td width="3"></td>
-    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.contactid") ?></span></td>
-    <td width="3"></td>
-    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.state") ?></span></td>
-    <td width="3"></td>
-    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.operator") ?></span></td>
-    <td width="3"></td>
-    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.total") ?></span></td>
-    <td width="3"></td>
-    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.waittime") ?></span></td>
-    <td width="3"></td>
-    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.etc") ?></span></td>
-</tr>
-
-<tr>
-    <td colspan="13" height="2"></td>
-</tr>
-
-<tr id="prio">
-    <td colspan="13" height="30" bgcolor="#F5F5F5" class="table">
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><img src='/webim/images/tblicusers.gif' width="15" height="15" border="0" alt="" /></td>
-    	<td class="table"><span class="black"><?php echo getstring("clients.queue.prio") ?></span></td>
-		</tr>
-		</table>
-	</td>
-</tr>
-
-<tr id="prioend">
-    <td colspan="13" height="30" class="table" id="status"></td>
-</tr>
-
-<tr id="wait">
-    <td colspan="13" height="30" bgcolor="#F5F5F5" class="table">
-		<table cellspacing="0" cellpadding="0" border="0">
-		<tr>
-	    <td><img src='/webim/images/tblicusers2.gif' width="15" height="15" border="0" alt="" /></td>
-    	<td class="table"><span class="black"><?php echo getstring("clients.queue.wait") ?></span></td>
-		</tr>	
-		</table>
-	</td>
-</tr>
-
-<tr id="waitend">
-    <td colspan="13" height="30" class="table" id="status"></td>
-</tr>
-
-<tr id="chat">
-    <td colspan="13" height="30" bgcolor="#F5F5F5" class="table">
-		<table cellspacing="0" cellpadding="0" border="0"><tr>
-	    <td><img src='/webim/images/tblicusers3.gif' width="30" height="15" border="0" alt="" /></td>
-    	<td class="table"><span class="black"><?php echo getstring("clients.queue.chat") ?></span></td>
-		</tr>
-		</table>
-	</td>
-</tr>
-
-<tr id="chatend">
-    <td colspan="13" height="30" class="table" id="status"></td>
-</tr>
-
-</table>
-
-</td><td bgcolor="#DADADA"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-</tr><tr>
-   <td colspan="3" bgcolor="#DADADA"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
-</tr></table>
-
-<table width="100%" cellspacing="0" cellpadding="0" border="0">
-	<tr><td colspan="2" height="15"></td></tr>
-	<tr>
-    <td class="text"></td>
-    <td align="right" class="text" id="connstatus">
-    </td>
-	</tr>
-
-</table>
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+<script type="text/javascript" language="javascript" src="/webim/js/common.js"></script>
+<script><!--
+var localized = new Array(
+    "<?php echo getstring("pending.table.speak") ?>",
+    "<?php echo getstring("pending.table.view") ?>",
+    "<?php echo getstring("pending.table.ban") ?>"
+);
+var updaterOptions = {
+	url:"/webim/operator/update.php", 
+
+	agentservl:"/webim/operator/agent.php",
+	noclients:"<?php echo getstring("clients.no_clients") ?>" };
+//--></script>
+<script type="text/javascript" language="javascript" src="/webim/js/page_pendingclients.js"></script>
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("clients.title") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
+		<h1><?php echo getstring("clients.title") ?></h1>
+ </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
+	
+
+	<?php echo getstring("clients.intro") ?><br>
+
+<?php echo getstring("clients.how_to") ?><br>
+<br>
+
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+<tr><td colspan="3" bgcolor="#DADADA"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td></tr>
+<tr><td bgcolor="#DADADA"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+   <td width="100%">
+   
+   <!-- Pending -->
+
+<table width="100%" id="threadlist" cellspacing="0" cellpadding="0" border="0">
+<tr>
+    <td width="150" height="30" bgcolor="#276DB8" class="table"><span class="header"><?php echo getstring("pending.table.head.name") ?></span></td>
+    <td width="3"></td>
+    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.contactid") ?></span></td>
+    <td width="3"></td>
+    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.state") ?></span></td>
+    <td width="3"></td>
+    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.operator") ?></span></td>
+    <td width="3"></td>
+    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.total") ?></span></td>
+    <td width="3"></td>
+    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.waittime") ?></span></td>
+    <td width="3"></td>
+    <td bgcolor="#276DB8" align="center" class="table" nowrap><span class="header"><?php echo getstring("pending.table.head.etc") ?></span></td>
+</tr>
+
+<tr>
+    <td colspan="13" height="2"></td>
+</tr>
+
+<tr id="prio">
+    <td colspan="13" height="30" bgcolor="#F5F5F5" class="table">
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><img src='/webim/images/tblicusers.gif' width="15" height="15" border="0" alt="" /></td>
+    	<td class="table"><span class="black"><?php echo getstring("clients.queue.prio") ?></span></td>
+		</tr>
+		</table>
+	</td>
+</tr>
+
+<tr id="prioend">
+    <td colspan="13" height="30" class="table" id="status"></td>
+</tr>
+
+<tr id="wait">
+    <td colspan="13" height="30" bgcolor="#F5F5F5" class="table">
+		<table cellspacing="0" cellpadding="0" border="0">
+		<tr>
+	    <td><img src='/webim/images/tblicusers2.gif' width="15" height="15" border="0" alt="" /></td>
+    	<td class="table"><span class="black"><?php echo getstring("clients.queue.wait") ?></span></td>
+		</tr>	
+		</table>
+	</td>
+</tr>
+
+<tr id="waitend">
+    <td colspan="13" height="30" class="table" id="status"></td>
+</tr>
+
+<tr id="chat">
+    <td colspan="13" height="30" bgcolor="#F5F5F5" class="table">
+		<table cellspacing="0" cellpadding="0" border="0"><tr>
+	    <td><img src='/webim/images/tblicusers3.gif' width="30" height="15" border="0" alt="" /></td>
+    	<td class="table"><span class="black"><?php echo getstring("clients.queue.chat") ?></span></td>
+		</tr>
+		</table>
+	</td>
+</tr>
+
+<tr id="chatend">
+    <td colspan="13" height="30" class="table" id="status"></td>
+</tr>
+
+</table>
+
+</td><td bgcolor="#DADADA"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+</tr><tr>
+   <td colspan="3" bgcolor="#DADADA"><img src='/webim/images/free.gif' width="1" height="1" border="0" alt="" /></td>
+</tr></table>
+
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+	<tr><td colspan="2" height="15"></td></tr>
+	<tr>
+    <td class="text"></td>
+    <td align="right" class="text" id="connstatus">
+    </td>
+	</tr>
+
+</table>
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/properties_en b/src/webim/view/properties_en
index 6aede895..5c06e5e9 100644
--- a/src/webim/view/properties_en
+++ b/src/webim/view/properties_en
@@ -1,152 +1,152 @@
-app.title=Web Instant Messenger
-site.url=http://i-services.ru
-site.title=i-services.ru
-company.title=Internet Services
-page.main_layout.meta_keyword=live chat,live help,live support
-page.main_layout.meta_description=Live chat, live help, and live support for websites
-page_login.title=Login
-page_login.login=Login:
-page_login.password=Password:
-page_login.remember=Remember
-page_login.error=Entered login/password is incorrect
-agent.not_logged_in=Your session is expired please login again
-page_client.pending_users=Your can find awaiting visitors.
-chat.window.title.agent=Web Messenger
-chat.window.title.user=Web Messenger
-chat.window.product_name=Web <span class="grey">Messenger</span>
-chat.window.close_title=Close chat
-chat.window.chatting_with=You chat with:
-chat.window.poweredby=Powered by:
-chat.window.poweredreftext=i-services.ru
-chat.window.send_message=Send message
-chat.window.send_message_short=Send (Ctrl-Enter)
-chat.window.toolbar.mail_history=Send chat history by e-mail
-chat.window.toolbar.refresh=Refresh
-chat.client.name=Your name:
-chat.client.changename=Change name
-chat.status.operator.left=Operator {0} left the chat
-chat.status.user.left=Visitor {0} left the chat
-chat.status.user.dead=Visitor closed chat window
-chat.status.operator.dead=Operator has connection issues, we temporarily moved you to foreground queue. Sorry for keeping you waiting.
-chat.status.operator.joined=Operator {0} joined the chat
-chat.status.user.changedname=Visitor changed the name {0} to {1}
-chat.status.user.reopenedthread=Visitor joined chat again
-chat.status.operator.changed=Operator {0} changed operator {1}
-chat.default.username=Visitor
-chat.error_page.title=Error
-chat.error_page.head=Error occurred:
-chat.error_page.close=Close...
-page.chat.old_browser.title=Please, use newer browser
-page.chat.old_browser.close=Close...
-page.chat.old_browser.content=Your web browser is not fully supported by Web Messenger. \nPlease, use one of the following web browsers: \n<p><ul>\n<li>Internet Explorer 5.5+\n<li>Firefox 1.0+\n<li>Opera 8.0+\n<li>Mozilla 1.4+\n<li>Netscape 7.1+\n<li>Safari 1.2+\n</ul></p>\nAlso, we support some old browsers:\n<p><ul>\n<li>Internet Explorer 5.0\n<li>Opera 7.0\n</ul></p>
-chat.wait=Thank you for contacting us. An operator will be with you shortly...
-mailthread.title=Send chat history<br>by mail
-mailthread.enter_email=Enter your e-mail:
-mailthread.perform=Send
-mailthread.close=Close...
-chat.mailthread.sent.title=Sent
-chat.mailthread.sent.content=History of your chat was sent on address {0}
-chat.mailthread.sent.closewindow=Click on this link to close the window
-chat.mailthread.sent.close=Close...
-chat.thread.state_wait=In queue
-chat.thread.state_wait_for_another_agent=Waiting for operator
-chat.thread.state_chatting_with_agent=In chat
-chat.thread.state_closed=Closed
-clients.title=List of awaiting visitors
-clients.no_clients=The of awaiting visitors is empty
-clients.intro=The page displays list of awaiting visitors.
-clients.how_to=To answer the visitor click on his/her name in the list.
-clients.queue.prio=Priority visitors queue
-clients.queue.wait=Waiting for operator for the first time
-clients.queue.chat=Visitors in dialogs
-pending.table.head.name=Name
-pending.table.head.contactid=Visitor's address
-pending.table.head.state=State
-pending.table.head.operator=Operator
-pending.table.head.total=Total time
-pending.table.head.waittime=Waiting time
-pending.table.head.etc=Misc
-pending.table.speak=Click to chat with the visitor
-pending.table.view=Watch the chat
-pending.table.ban=Ban the visitor
-thread.chat_log=Chat log
-thread.back_to_search=Go to search
-thread.intro=The page displays chat
-page_analysis.search.title=Chats history
-page.analysis.search.head_name=Name
-page.analysis.search.head_host=Visitor's address
-page.analysis.search.head_operator=Operator
-page.analysis.search.head_time=Time in chat
-common.asterisk_explanation=<b><font class="red">*</font></b> - mandatory fields
-page_agents.title=Agents
-page_agents.agents=Agents full list:
-page_agents.new_agent=Create new agent...
-page_agents.agent_name=Name
-page_agents.login=Login
-page_agents.intro=This page displays list of company agents it also allows add new ones if you permissions
-page_agent.title=Operator details
-page_agent.intro=This page displays agent details, if you have access rights you can edit them.
-page_agent.error.duplicate_login=Please choose another login, because agent with entered login is already registered in the system.
-my_settings.error.password_match=Entered passwords do not match
-topMenu.admin=Administration
-topMenu.users=Visitors
-topMenu.logoff=Exit
-leftMenu.client_agents=Agents
-leftMenu.client_gen_button=Button code
-admin.content.description=Functions available for power users.
-admin.content.client_agents=Create, delete company agents. Manage theirs permissions.
-admin.content.client_gen_button=Button HTML code generation.
-page.gen_button.title=Button HTML code generation
-page.gen_button.intro=You can generate HTML code to place at your site here.
-page.gen_button.code=HTML code
-page.gen_button.sample=Example
-page.gen_button.code.description=<strong>Caution!</strong> Please don't change<br/> the code manually because<br/> we don't guarantee that<br/> it will work!
-mail.user.history.subject=Web Messenger: dialog history
-mail.user.history.body=Hello, {0}!\n\nYour chat history: \n\n{1}\n--- \nKind Regards,\nThe I-Services Support Team
-errors.header=<font color="#c13030"><b>Correct the mistakes:</b><br/><br/><ul>
-errors.prefix=<li class="error">
-errors.suffix=</li>
-errors.footer=</ul></font>
-errors.required=Please fill "{0}".  
-form.field.login=Login
-form.field.login.description=Login can consist of small Latin letters<br/> and underscore.
-form.field.agent_name=Name
-form.field.agent_name.description=This name will be seen by your visitors.
-form.field.password_confirm=Confirmation
-form.field.password_confirm.description=Confirm new password
-form.field.password=Password
-form.field.password.description=
-button.enter=Enter
-button.save=Save
-button.search=Search
-tag.pagination.info=Page {0} of {1}, {2}-{3} from {4}
-tag.pagination.no_items=Found 0 elements
-image.chat.history=/webim/images/en/history.gif
-image.chat.message=/webim/images/en/message.gif
-image.button.login=/webim/images/en/login.gif
-image.button.save=/webim/images/en/save.gif
-image.button.search=/webim/images/en/search.gif
-chat.came.from=Vistor came from page {0}
-content.history=Search the dialogs history
-content.logoff=Log out of the system.
-form.field.agent_commonname=International name (Latin)
-form.field.agent_commonname.description=This name will be seen by your visitors
-install.create_db_link=Create tables in MySQL database
-install.license=Software license agreement
-install.message=We are ready to complete installation by creating tables.
-install.title=System setup
-installed.login_link=Proceed to login page
-installed.message=Tables were created successfully. You can logon as admin with empty password. For security reasons, please <br/>change your password immediately and remove /webim/install folder from your server.
-installed.title=Application installed successfully
-menu.agents=Agents list
-menu.main=Main
-menu.operator=You are {0}
-no_such_operator=No such operator
-page.gen_button.choose_image=Choose image
-page.gen_button.choose_locale=Target locale
-page.gen_button.include_site_name=Include host name into code
-page.gen_button.secure_links=Use secure links (https)
-page_agent.create_new=Here you can create new operator
-page_agents.agent_commonname=International name
-page_analysis.full.text.search=User name or message text search:
-page_search.intro=Search for chat history of a specified user or a specified phrase in a message.
+app.title=Web Instant Messenger
+site.url=http://i-services.ru
+site.title=i-services.ru
+company.title=Internet Services
+page.main_layout.meta_keyword=live chat,live help,live support
+page.main_layout.meta_description=Live chat, live help, and live support for websites
+page_login.title=Login
+page_login.login=Login:
+page_login.password=Password:
+page_login.remember=Remember
+page_login.error=Entered login/password is incorrect
+agent.not_logged_in=Your session is expired please login again
+page_client.pending_users=Your can find awaiting visitors.
+chat.window.title.agent=Web Messenger
+chat.window.title.user=Web Messenger
+chat.window.product_name=Web <span class="grey">Messenger</span>
+chat.window.close_title=Close chat
+chat.window.chatting_with=You chat with:
+chat.window.poweredby=Powered by:
+chat.window.poweredreftext=i-services.ru
+chat.window.send_message=Send message
+chat.window.send_message_short=Send (Ctrl-Enter)
+chat.window.toolbar.mail_history=Send chat history by e-mail
+chat.window.toolbar.refresh=Refresh
+chat.client.name=Your name:
+chat.client.changename=Change name
+chat.status.operator.left=Operator {0} left the chat
+chat.status.user.left=Visitor {0} left the chat
+chat.status.user.dead=Visitor closed chat window
+chat.status.operator.dead=Operator has connection issues, we temporarily moved you to foreground queue. Sorry for keeping you waiting.
+chat.status.operator.joined=Operator {0} joined the chat
+chat.status.user.changedname=Visitor changed the name {0} to {1}
+chat.status.user.reopenedthread=Visitor joined chat again
+chat.status.operator.changed=Operator {0} changed operator {1}
+chat.default.username=Visitor
+chat.error_page.title=Error
+chat.error_page.head=Error occurred:
+chat.error_page.close=Close...
+page.chat.old_browser.title=Please, use newer browser
+page.chat.old_browser.close=Close...
+page.chat.old_browser.content=Your web browser is not fully supported by Web Messenger. \nPlease, use one of the following web browsers: \n<p><ul>\n<li>Internet Explorer 5.5+\n<li>Firefox 1.0+\n<li>Opera 8.0+\n<li>Mozilla 1.4+\n<li>Netscape 7.1+\n<li>Safari 1.2+\n</ul></p>\nAlso, we support some old browsers:\n<p><ul>\n<li>Internet Explorer 5.0\n<li>Opera 7.0\n</ul></p>
+chat.wait=Thank you for contacting us. An operator will be with you shortly...
+mailthread.title=Send chat history<br>by mail
+mailthread.enter_email=Enter your e-mail:
+mailthread.perform=Send
+mailthread.close=Close...
+chat.mailthread.sent.title=Sent
+chat.mailthread.sent.content=History of your chat was sent on address {0}
+chat.mailthread.sent.closewindow=Click on this link to close the window
+chat.mailthread.sent.close=Close...
+chat.thread.state_wait=In queue
+chat.thread.state_wait_for_another_agent=Waiting for operator
+chat.thread.state_chatting_with_agent=In chat
+chat.thread.state_closed=Closed
+clients.title=List of awaiting visitors
+clients.no_clients=The of awaiting visitors is empty
+clients.intro=The page displays list of awaiting visitors.
+clients.how_to=To answer the visitor click on his/her name in the list.
+clients.queue.prio=Priority visitors queue
+clients.queue.wait=Waiting for operator for the first time
+clients.queue.chat=Visitors in dialogs
+pending.table.head.name=Name
+pending.table.head.contactid=Visitor's address
+pending.table.head.state=State
+pending.table.head.operator=Operator
+pending.table.head.total=Total time
+pending.table.head.waittime=Waiting time
+pending.table.head.etc=Misc
+pending.table.speak=Click to chat with the visitor
+pending.table.view=Watch the chat
+pending.table.ban=Ban the visitor
+thread.chat_log=Chat log
+thread.back_to_search=Go to search
+thread.intro=The page displays chat
+page_analysis.search.title=Chats history
+page.analysis.search.head_name=Name
+page.analysis.search.head_host=Visitor's address
+page.analysis.search.head_operator=Operator
+page.analysis.search.head_time=Time in chat
+common.asterisk_explanation=<b><font class="red">*</font></b> - mandatory fields
+page_agents.title=Agents
+page_agents.agents=Agents full list:
+page_agents.new_agent=Create new agent...
+page_agents.agent_name=Name
+page_agents.login=Login
+page_agents.intro=This page displays list of company agents it also allows add new ones if you permissions
+page_agent.title=Operator details
+page_agent.intro=This page displays agent details, if you have access rights you can edit them.
+page_agent.error.duplicate_login=Please choose another login, because agent with entered login is already registered in the system.
+my_settings.error.password_match=Entered passwords do not match
+topMenu.admin=Administration
+topMenu.users=Visitors
+topMenu.logoff=Exit
+leftMenu.client_agents=Agents
+leftMenu.client_gen_button=Button code
+admin.content.description=Functions available for power users.
+admin.content.client_agents=Create, delete company agents. Manage theirs permissions.
+admin.content.client_gen_button=Button HTML code generation.
+page.gen_button.title=Button HTML code generation
+page.gen_button.intro=You can generate HTML code to place at your site here.
+page.gen_button.code=HTML code
+page.gen_button.sample=Example
+page.gen_button.code.description=<strong>Caution!</strong> Please don't change<br/> the code manually because<br/> we don't guarantee that<br/> it will work!
+mail.user.history.subject=Web Messenger: dialog history
+mail.user.history.body=Hello, {0}!\n\nYour chat history: \n\n{1}\n--- \nKind Regards,\nThe I-Services Support Team
+errors.header=<font color="#c13030"><b>Correct the mistakes:</b><br/><ul>
+errors.prefix=<li class="error">
+errors.suffix=</li>
+errors.footer=</ul></font>
+errors.required=Please fill "{0}".  
+form.field.login=Login
+form.field.login.description=Login can consist of small Latin letters<br/> and underscore.
+form.field.agent_name=Name
+form.field.agent_name.description=This name will be seen by your visitors.
+form.field.password_confirm=Confirmation
+form.field.password_confirm.description=Confirm new password
+form.field.password=Password
+form.field.password.description=
+button.enter=Enter
+button.save=Save
+button.search=Search
+tag.pagination.info=Page {0} of {1}, {2}-{3} from {4}
+tag.pagination.no_items=Found 0 elements
+image.chat.history=/webim/images/en/history.gif
+image.chat.message=/webim/images/en/message.gif
+image.button.login=/webim/images/en/login.gif
+image.button.save=/webim/images/en/save.gif
+image.button.search=/webim/images/en/search.gif
+chat.came.from=Vistor came from page {0}
+content.history=Search the dialogs history
+content.logoff=Log out of the system.
+form.field.agent_commonname=International name (Latin)
+form.field.agent_commonname.description=This name will be seen by your visitors
+install.create_db_link=Create tables in MySQL database
+install.license=Software license agreement
+install.message=We are ready to complete installation by creating tables.
+install.title=System setup
+installed.login_link=Proceed to login page
+installed.message=Tables were created successfully. You can logon as admin with empty password. For security reasons, please <br/>change your password immediately and remove /webim/install folder from your server.
+installed.title=Application installed successfully
+menu.agents=Agents list
+menu.main=Main
+menu.operator=You are {0}
+no_such_operator=No such operator
+page.gen_button.choose_image=Choose image
+page.gen_button.choose_locale=Target locale
+page.gen_button.include_site_name=Include host name into code
+page.gen_button.secure_links=Use secure links (https)
+page_agent.create_new=Here you can create new operator
+page_agents.agent_commonname=International name
+page_analysis.full.text.search=User name or message text search:
+page_search.intro=Search for chat history of a specified user or a specified phrase in a message.
diff --git a/src/webim/view/properties_ru b/src/webim/view/properties_ru
index cd200fec..43271c1a 100644
--- a/src/webim/view/properties_ru
+++ b/src/webim/view/properties_ru
@@ -1,152 +1,152 @@
-app.title=��� ����������
-site.url=http://i-services.ru
-site.title=i-services.ru
-company.title=Internet Services
-page.main_layout.meta_keyword=������ ���������,������ �����������,������ ������,��������� �������,��������� ��������,����� ���������,��������� �� �����,����� ���������,����������� ���������,����� ���������� ���������,��������� ������ �������� ��������,�������� �������,������ �������,�������� �������,����������,����������,��������� ������������ ���������,online ���������,online �������, online ������������,online �����������,online ������,������������ �����������,������������ ��������,�������� ������������,������-������������,crm 
-page.main_layout.meta_description=��������� �����������, ��������� ���������, ���������� �������� �����������,���������� ����������� � online �����������,������ � �����������,��� � �����������
-page_login.title=���� � �������
-page_login.login=�����:
-page_login.password=������:
-page_login.remember=���������
-page_login.error=������ ������������ ����� ��� ������
-agent.not_logged_in=���� ������ ��������, �������, ����������, �����
-page_client.pending_users=�� ���� �������� ����� ����������� ������ ��������� ������ �����������.
-chat.window.title.agent=��� ����������
-chat.window.title.user=��� ����������
-chat.window.product_name=��� <span class="grey">����������</span>
-chat.window.close_title=������� ������
-chat.window.chatting_with=�� ��������� �:
-chat.window.poweredby=�������������:
-chat.window.poweredreftext=i-services.ru
-chat.window.send_message=��������� ���������
-chat.window.send_message_short=��������� (Ctrl-Enter)
-chat.window.toolbar.mail_history=��������� ������� ������� �� ����������� �����
-chat.window.toolbar.refresh=�������� ���������� �������
-chat.client.name=���� ���:
-chat.client.changename=�������� ���
-chat.status.operator.left=�������� {0} ������� ������
-chat.status.user.left=���������� {0} ������� ������
-chat.status.user.dead=���������� ������ ���� �������
-chat.status.operator.dead=� ��������� �������� �������� �� ������, �� �������� �������� ��� � ������������ �������. �������� ��������� �� ���� ��������.
-chat.status.operator.joined=�������� {0} ��������� � ��������
-chat.status.user.changedname=���������� ������ ��� {0} �� {1}
-chat.status.user.reopenedthread=���������� ������ ����� � ������
-chat.status.operator.changed=�������� {0} ������ ��������� {1}
-chat.default.username=����������
-chat.error_page.title=������
-chat.error_page.head=��������� ������:
-chat.error_page.close=�������...
-page.chat.old_browser.title=����������� ����� ����� browser
-page.chat.old_browser.close=�������...
-page.chat.old_browser.content=� ���������, ��� ������ ���� �������� ��������� ����� ����� �������. ��� ������� ��������� �����������:\n<p><ul>\n<li>Internet Explorer 5.5+\n<li>Firefox 1.0+\n<li>Opera 8.0+\n<li>Mozilla 1.4+\n<li>Netscape 7.1+\n<li>Safari 1.2+\n</ul></p>\n����� �������������� ��������� ������ ��������:\n<p><ul>\n<li>Internet Explorer 5.0\n<li>Opera 7.0\n</ul></p>
-chat.wait=����������, ��������� �������, � ��� ������������� ��������..
-mailthread.title=��������� ������� ���������<br>�� �������� ����
-mailthread.enter_email=������� ��� E-mail:
-mailthread.perform=���������
-mailthread.close=�������...
-chat.mailthread.sent.title=����������
-chat.mailthread.sent.content=������� ������ ��������� ���� ���������� �� ����� {0}
-chat.mailthread.sent.closewindow=������� �� ��� ������ ����� ������� ����
-chat.mailthread.sent.close=�������...
-chat.thread.state_wait=� �������
-chat.thread.state_wait_for_another_agent=�������� ���������
-chat.thread.state_chatting_with_agent=� �������
-chat.thread.state_closed=�������
-clients.title=������ ��������� �����������
-clients.no_clients=� ���� ������� ��������� ����������� ���
-clients.intro=�� ���� �������� ����� ����������� ������ ��������� ������ �����������.
-clients.how_to=��� ������ ���������� �������� �� ��������������� ��� � ������.
-clients.queue.prio=������������ ������� �����������
-clients.queue.wait=��������� ��������� � ������ ���
-clients.queue.chat=���������� � ��������
-pending.table.head.name=���
-pending.table.head.contactid=����� ����������
-pending.table.head.state=���������
-pending.table.head.operator=��������
-pending.table.head.total=����� �����
-pending.table.head.waittime=����� ��������
-pending.table.head.etc=������
-pending.table.speak=������� ��� ����, ����� ��������� ����������
-pending.table.view=������������ � ������� � ������ ���������
-pending.table.ban=�������� ���������� ��� ��������������
-thread.chat_log=�������� ���������
-thread.back_to_search=������� � �����
-thread.intro=�� ������ �������� �� ������ ����������� ������.
-page_analysis.search.title=������� ��������
-page.analysis.search.head_name=���
-page.analysis.search.head_host=����� ����������
-page.analysis.search.head_operator=��������
-page.analysis.search.head_time=����� � �������
-common.asterisk_explanation=<b><font class="red">*</font></b> - ����, ������������ ��� ����������
-page_agents.title=������
-page_agents.agents=������ ������ �������:
-page_agents.new_agent=������� ������ ������...
-page_agents.agent_name=���
-page_agents.login=�����
-page_agents.intro=�� ���� �������� ����� ����������� ������ ������� ��������, �������� ������ ��� ������� ��������������� ���� �������
-page_agent.title=������ ������
-page_agent.intro=�� ���� �������� �� ������ ����������� ������ � �������� ������ � ��������������� ��
-page_agent.error.duplicate_login=�������� ������ �����, �.�. ����� � ��������� ������� ��� ��������������� � �������.
-my_settings.error.password_match=��������� ������ ������ ���������
-topMenu.admin=������������ ����
-topMenu.users=����������
-topMenu.logoff=�����
-leftMenu.client_agents=������
-leftMenu.client_gen_button=��� ������
-admin.content.description=����� �������, ��������� ������ ������������������ ����������
-admin.content.client_agents=��������, �������� ������� ��������. ���������� �� ������� � �������������.
-admin.content.client_gen_button=��������� HTML-���� ��� ������ "��� �����������".
-page.gen_button.title=��������� HTML-���� ������
-page.gen_button.intro=�� ���� �������� �� ������ �������� HTML-��� ������ "��� �����������" ��� ���������� �� ����� �����.
-page.gen_button.code=HTML-���
-page.gen_button.sample=������
-page.gen_button.code.description=<strong>��������!</strong> ��� ��������<br/> �����-���� ���������<br/> � ���� ��� �����������������<br/> ������ �� �������������!
-mail.user.history.subject=��� ����������: ������� �������
-mail.user.history.body=�����������, {0}!\n\n�� ������ �������, �������� �������: \n\n{1}\n--- \n� ���������,\n������ ��������� i-services.ru
-errors.header=<font color="#c13030"><b>��������� ������:</b><br/><br/><ul>
-errors.prefix=<li class="error">
-errors.suffix=</li>
-errors.footer=</ul></font>
-errors.required=��������� ���� "{0}".  
-form.field.login=�����
-form.field.login.description=����� ����� �������� �� ��������� ���������<br/> ���� � ����� �������������.
-form.field.agent_name=���
-form.field.agent_name.description=��� ���� ������ ��� ������ ���� ����������, <br/> �� ���� �� � ��� ����� ���������� �������.
-form.field.password_confirm=�������������
-form.field.password_confirm.description=����������� ��������� ������
-form.field.password=������
-form.field.password.description=
-button.enter=�����
-button.save=���������
-button.search=������
-tag.pagination.info=�������� {0} �� {1}, �������� {2}-{3} �� {4}
-tag.pagination.no_items=������ �� �������
-image.chat.history=/webim/images/ru/history.gif
-image.chat.message=/webim/images/ru/message.gif
-image.button.login=/webim/images/ru/login.gif
-image.button.save=/webim/images/ru/save.gif
-image.button.search=/webim/images/ru/search.gif
-chat.came.from=���������� ������ �� �������� {0}
-content.history=����� �� ������� ��������
-content.logoff=�������� �������.
-form.field.agent_commonname=����������������� ��� (���������)
-form.field.agent_commonname.description=��� ���� ������ ��� ������ ���� ���������� �� ������ �����
-install.create_db_link=������� ����������� ������� � ���� ������
-install.license=������������ ���������� � ����������� �����������
-install.message=��� ��������� ��������� ���������� ������� �������.
-install.title=���������
-installed.login_link=����� � �������
-installed.message=����������� ������� ���� �������. �� ������ ����� � ������� ��� admin � ������ �������.<br/>� ����� ������������, �������, ����������, ������� /webim/install � ������ ������� � ��������� ������.
-installed.title=��������� ���������
-menu.agents=������ �������
-menu.main=�������
-menu.operator=�� {0}
-no_such_operator=������������� ������� ������ �� ����������
-page.gen_button.choose_image=����� ��������
-page.gen_button.choose_locale=��� ����� ������ ��������� ������
-page.gen_button.include_site_name=�������� ��� ����� � ���
-page.gen_button.secure_links=������������ ���������� ���������� (https)
-page_agent.create_new=�������� ������ ���������
-page_agents.agent_commonname=����������������� ���
-page_analysis.full.text.search=����� �� ����� ���������� ��� �� ������ ���������:
-page_search.intro=�� ������ �������� ����� ����������� ����� �������� �� ����� ������������ ��� �����, ������������� � ���������.
+app.title=��� ����������
+site.url=http://i-services.ru
+site.title=i-services.ru
+company.title=Internet Services
+page.main_layout.meta_keyword=������ ���������,������ �����������,������ ������,��������� �������,��������� ��������,����� ���������,��������� �� �����,����� ���������,����������� ���������,����� ���������� ���������,��������� ������ �������� ��������,�������� �������,������ �������,�������� �������,����������,����������,��������� ������������ ���������,online ���������,online �������, online ������������,online �����������,online ������,������������ �����������,������������ ��������,�������� ������������,������-������������,crm 
+page.main_layout.meta_description=��������� �����������, ��������� ���������, ���������� �������� �����������,���������� ����������� � online �����������,������ � �����������,��� � �����������
+page_login.title=���� � �������
+page_login.login=�����:
+page_login.password=������:
+page_login.remember=���������
+page_login.error=������ ������������ ����� ��� ������
+agent.not_logged_in=���� ������ ��������, �������, ����������, �����
+page_client.pending_users=�� ���� �������� ����� ����������� ������ ��������� ������ �����������.
+chat.window.title.agent=��� ����������
+chat.window.title.user=��� ����������
+chat.window.product_name=��� <span class="grey">����������</span>
+chat.window.close_title=������� ������
+chat.window.chatting_with=�� ��������� �:
+chat.window.poweredby=�������������:
+chat.window.poweredreftext=i-services.ru
+chat.window.send_message=��������� ���������
+chat.window.send_message_short=��������� (Ctrl-Enter)
+chat.window.toolbar.mail_history=��������� ������� ������� �� ����������� �����
+chat.window.toolbar.refresh=�������� ���������� �������
+chat.client.name=���� ���:
+chat.client.changename=�������� ���
+chat.status.operator.left=�������� {0} ������� ������
+chat.status.user.left=���������� {0} ������� ������
+chat.status.user.dead=���������� ������ ���� �������
+chat.status.operator.dead=� ��������� �������� �������� �� ������, �� �������� �������� ��� � ������������ �������. �������� ��������� �� ���� ��������.
+chat.status.operator.joined=�������� {0} ��������� � ��������
+chat.status.user.changedname=���������� ������ ��� {0} �� {1}
+chat.status.user.reopenedthread=���������� ������ ����� � ������
+chat.status.operator.changed=�������� {0} ������ ��������� {1}
+chat.default.username=����������
+chat.error_page.title=������
+chat.error_page.head=��������� ������:
+chat.error_page.close=�������...
+page.chat.old_browser.title=����������� ����� ����� browser
+page.chat.old_browser.close=�������...
+page.chat.old_browser.content=� ���������, ��� ������ ���� �������� ��������� ����� ����� �������. ��� ������� ��������� �����������:\n<p><ul>\n<li>Internet Explorer 5.5+\n<li>Firefox 1.0+\n<li>Opera 8.0+\n<li>Mozilla 1.4+\n<li>Netscape 7.1+\n<li>Safari 1.2+\n</ul></p>\n����� �������������� ��������� ������ ��������:\n<p><ul>\n<li>Internet Explorer 5.0\n<li>Opera 7.0\n</ul></p>
+chat.wait=����������, ��������� �������, � ��� ������������� ��������..
+mailthread.title=��������� ������� ���������<br>�� �������� ����
+mailthread.enter_email=������� ��� E-mail:
+mailthread.perform=���������
+mailthread.close=�������...
+chat.mailthread.sent.title=����������
+chat.mailthread.sent.content=������� ������ ��������� ���� ���������� �� ����� {0}
+chat.mailthread.sent.closewindow=������� �� ��� ������ ����� ������� ����
+chat.mailthread.sent.close=�������...
+chat.thread.state_wait=� �������
+chat.thread.state_wait_for_another_agent=�������� ���������
+chat.thread.state_chatting_with_agent=� �������
+chat.thread.state_closed=�������
+clients.title=������ ��������� �����������
+clients.no_clients=� ���� ������� ��������� ����������� ���
+clients.intro=�� ���� �������� ����� ����������� ������ ��������� ������ �����������.
+clients.how_to=��� ������ ���������� �������� �� ��������������� ��� � ������.
+clients.queue.prio=������������ ������� �����������
+clients.queue.wait=��������� ��������� � ������ ���
+clients.queue.chat=���������� � ��������
+pending.table.head.name=���
+pending.table.head.contactid=����� ����������
+pending.table.head.state=���������
+pending.table.head.operator=��������
+pending.table.head.total=����� �����
+pending.table.head.waittime=����� ��������
+pending.table.head.etc=������
+pending.table.speak=������� ��� ����, ����� ��������� ����������
+pending.table.view=������������ � ������� � ������ ���������
+pending.table.ban=�������� ���������� ��� ��������������
+thread.chat_log=�������� ���������
+thread.back_to_search=������� � �����
+thread.intro=�� ������ �������� �� ������ ����������� ������.
+page_analysis.search.title=������� ��������
+page.analysis.search.head_name=���
+page.analysis.search.head_host=����� ����������
+page.analysis.search.head_operator=��������
+page.analysis.search.head_time=����� � �������
+common.asterisk_explanation=<b><font class="red">*</font></b> - ����, ������������ ��� ����������
+page_agents.title=������
+page_agents.agents=������ ������ �������:
+page_agents.new_agent=������� ������ ������...
+page_agents.agent_name=���
+page_agents.login=�����
+page_agents.intro=�� ���� �������� ����� ����������� ������ ������� ��������, �������� ������ ��� ������� ��������������� ���� �������
+page_agent.title=������ ������
+page_agent.intro=�� ���� �������� �� ������ ����������� ������ � �������� ������ � ��������������� ��
+page_agent.error.duplicate_login=�������� ������ �����, �.�. ����� � ��������� ������� ��� ��������������� � �������.
+my_settings.error.password_match=��������� ������ ������ ���������
+topMenu.admin=������������ ����
+topMenu.users=����������
+topMenu.logoff=�����
+leftMenu.client_agents=������
+leftMenu.client_gen_button=��� ������
+admin.content.description=����� �������, ��������� ������ ������������������ ����������
+admin.content.client_agents=��������, �������� ������� ��������. ���������� �� ������� � �������������.
+admin.content.client_gen_button=��������� HTML-���� ��� ������ "��� �����������".
+page.gen_button.title=��������� HTML-���� ������
+page.gen_button.intro=�� ���� �������� �� ������ �������� HTML-��� ������ "��� �����������" ��� ���������� �� ����� �����.
+page.gen_button.code=HTML-���
+page.gen_button.sample=������
+page.gen_button.code.description=<strong>��������!</strong> ��� ��������<br/> �����-���� ���������<br/> � ���� ��� �����������������<br/> ������ �� �������������!
+mail.user.history.subject=��� ����������: ������� �������
+mail.user.history.body=�����������, {0}!\n\n�� ������ �������, �������� �������: \n\n{1}\n--- \n� ���������,\n������ ��������� i-services.ru
+errors.header=<font color="#c13030"><b>��������� ������:</b><br/><ul>
+errors.prefix=<li class="error">
+errors.suffix=</li>
+errors.footer=</ul></font>
+errors.required=��������� ���� "{0}".  
+form.field.login=�����
+form.field.login.description=����� ����� �������� �� ��������� ���������<br/> ���� � ����� �������������.
+form.field.agent_name=���
+form.field.agent_name.description=��� ���� ������ ��� ������ ���� ����������, <br/> �� ���� �� � ��� ����� ���������� �������.
+form.field.password_confirm=�������������
+form.field.password_confirm.description=����������� ��������� ������
+form.field.password=������
+form.field.password.description=
+button.enter=�����
+button.save=���������
+button.search=������
+tag.pagination.info=�������� {0} �� {1}, �������� {2}-{3} �� {4}
+tag.pagination.no_items=������ �� �������
+image.chat.history=/webim/images/ru/history.gif
+image.chat.message=/webim/images/ru/message.gif
+image.button.login=/webim/images/ru/login.gif
+image.button.save=/webim/images/ru/save.gif
+image.button.search=/webim/images/ru/search.gif
+chat.came.from=���������� ������ �� �������� {0}
+content.history=����� �� ������� ��������
+content.logoff=�������� �������.
+form.field.agent_commonname=����������������� ��� (���������)
+form.field.agent_commonname.description=��� ���� ������ ��� ������ ���� ���������� �� ������ �����
+install.create_db_link=������� ����������� ������� � ���� ������
+install.license=������������ ���������� � ����������� �����������
+install.message=��� ��������� ��������� ���������� ������� �������.
+install.title=���������
+installed.login_link=����� � �������
+installed.message=����������� ������� ���� �������. �� ������ ����� � ������� ��� admin � ������ �������.<br/>� ����� ������������, �������, ����������, ������� /webim/install � ������ ������� � ��������� ������.
+installed.title=��������� ���������
+menu.agents=������ �������
+menu.main=�������
+menu.operator=�� {0}
+no_such_operator=������������� ������� ������ �� ����������
+page.gen_button.choose_image=����� ��������
+page.gen_button.choose_locale=��� ����� ������ ��������� ������
+page.gen_button.include_site_name=�������� ��� ����� � ���
+page.gen_button.secure_links=������������ ���������� ���������� (https)
+page_agent.create_new=�������� ������ ���������
+page_agents.agent_commonname=����������������� ���
+page_analysis.full.text.search=����� �� ����� ���������� ��� �� ������ ���������:
+page_search.intro=�� ������ �������� ����� ����������� ����� �������� �� ����� ������������ ��� �����, ������������� � ���������.
diff --git a/src/webim/view/thread_log.php b/src/webim/view/thread_log.php
index 08e6b1c0..3a5bd124 100644
--- a/src/webim/view/thread_log.php
+++ b/src/webim/view/thread_log.php
@@ -1,88 +1,76 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-<link rel="stylesheet" type="text/css" media="all" href="/webim/chat.css" />
-
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("thread.chat_log") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
-		<h1><?php echo getstring("thread.chat_log") ?></h1>
-	
-
-	
-
-
-
-
-
-<?php echo getstring("thread.intro") ?>
-
-<br/><br/>
-
-<table border="0" cellpadding="0" cellspacing="0">
-<tr>
-	<td class='table' bgcolor='#276db8' height='30'><span class='header'>
-		<?php echo getstring("thread.chat_log") ?>
-	</span></td>
-</tr>
-<tr>
-	<td height='45' class='table'>
-		<span class="message">
-                        <?php foreach( $page['threadMessages'] as $message ) { ?>
-                        	<?php echo $message ?>	
-                        <?php } ?>			
-		</span>
-	</td>
-</tr>
-<tr><td height='2' colspan='1'></td></tr><tr><td bgcolor='#e1e1e1' colspan='1'><img width='1' height='1' border='0' alt='' src='/webim/images/free.gif'></td></tr><tr><td height='2' colspan='1'></td></tr>
-</table>
-
-<br />
-<a href="/webim/operator/history.php">
-	<?php echo getstring("thread.back_to_search") ?></a>
-<br />
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+<link rel="stylesheet" type="text/css" media="all" href="/webim/chat.css" />
+
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("thread.chat_log") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+		<h1><?php echo getstring("thread.chat_log") ?></h1>
+	
+
+	
+<?php echo getstring("thread.intro") ?>
+
+<br/><br/>
+
+<table border="0" cellpadding="0" cellspacing="0">
+<tr>
+	<td class='table' bgcolor='#276db8' height='30'><span class='header'>
+		<?php echo getstring("thread.chat_log") ?>
+	</span></td>
+</tr>
+<tr>
+	<td height='45' class='table'>
+		<span class="message">
+                        <?php foreach( $page['threadMessages'] as $message ) { ?>
+                        	<?php echo $message ?>	
+                        <?php } ?>			
+		</span>
+	</td>
+</tr>
+<tr><td height='2' colspan='1'></td></tr><tr><td bgcolor='#e1e1e1' colspan='1'><img width='1' height='1' border='0' alt='' src='/webim/images/free.gif'></td></tr><tr><td height='2' colspan='1'></td></tr>
+</table>
+
+<br />
+<a href="/webim/operator/history.php">
+	<?php echo getstring("thread.back_to_search") ?></a>
+<br />
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+
diff --git a/src/webim/view/thread_search.php b/src/webim/view/thread_search.php
index 613386b4..1103c6c7 100644
--- a/src/webim/view/thread_search.php
+++ b/src/webim/view/thread_search.php
@@ -1,117 +1,111 @@
-<?php
-/*
- * This file is part of Web Instant Messenger project.
- *
- * Copyright (c) 2005-2007 Internet Services Ltd.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Evgeny Gryaznov - initial API and implementation
- */
-?>
-<html>
-<head>
-
-
-
-<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
-
-
-
-
-
-<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
-<title>
-	<?php echo getstring("app.title") ?>	- <?php echo getstring("page_analysis.search.title") ?>
-</title>
-
-<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
-<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
-
-
-
-
-</head>
-
-<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<tr>
-<td valign="top" class="text">
-	
- <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
-		<h1><?php echo getstring("page_analysis.search.title") ?></h1>
- </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
-	
-
-	<?php echo getstring("page_search.intro") ?>
-<br />
-<br />
-
-
-
-
-<form name="searchForm" method="get" action="/webim/operator/history.php">
-<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
-	<tr>
-		<td class="formauth" colspan="3"><?php echo getstring("page_analysis.full.text.search") ?></td>
-	</tr>
-	<tr>
-		<td class="formauth"><input type="text" name="q" size="80" value="<?php echo form_value('q') ?>" class="formauth"/></td>
-		<td width="10"><img src="/webim/images/free.gif" width="10" height="1" border="0" alt=""></td>
-		<td class="formauth">
-			<input type="image" name="" src='<?php echo getstring("image.button.search") ?>' border="0" alt='<?php echo getstring("button.search") ?>'/>
-		</td>
-	</tr>
-</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
-</form>
-
-<br/>
-<?php if( $page['pagination'] && $page['pagination.items'] ) { ?>
-	<table cellpadding="0" cellspacing="0" border="0" width="100%">
-		<tr>
-			<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page.analysis.search.head_name") ?></span></td><td width='3'></td>
-			<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page.analysis.search.head_host") ?></span></td><td width='3'></td>
-			<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page.analysis.search.head_operator") ?></span></td><td width='3'></td>
-			<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page.analysis.search.head_time") ?></span></td>
-		</tr>
-		<?php foreach( $page['pagination.items'] as $chatthread ) { ?>
-			<tr>
-				<td height='30' class='table'>
-					<a href="/webim/operator/threadprocessor.php?threadid=<?php echo $chatthread['threadid'] ?>" target="_blank" onclick="this.newWindow = window.open('/webim/operator/threadprocessor.php?threadid=<?php echo $chatthread['threadid'] ?>', '', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=600,height=420,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;"><?php echo htmlspecialchars($chatthread['userName']) ?></a>
-				</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
-				<td height='30' class='table'>
-					<?php echo htmlspecialchars($chatthread['remote']) ?>
-				</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
-				<td height='30' class='table'>
-        			<?php if( $chatthread['agentName'] ) { ?><?php echo htmlspecialchars($chatthread['agentName']) ?><?php } ?>
-				</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
-				<td height='30' class='table'>
-					<?php echo date("d M Y H:i:s", $chatthread['created']) ?>,  <?php echo date_diff($chatthread['modified']-$chatthread['created']) ?>
-				</td>
-			</tr>
-			<tr><td height='2' colspan='7'></td></tr><tr><td bgcolor='#e1e1e1' colspan='7'><img width='1' height='1' border='0' alt='' src='/webim/images/free.gif'></td></tr><tr><td height='2' colspan='7'></td></tr>
-		<?php } ?>
-	</table>
-	<br />
-	<?php echo generate_pagination($page['pagination']) ?>
-<?php } ?>
-<?php if( $page['pagination'] && !$page['pagination.items'] ) { ?>
-	<br/><br/>
-	<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
-		<span class="table">
-			<?php echo getstring("tag.pagination.no_items") ?>
-		</span>
-	</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
-<?php } ?>
-
-</td>
-</tr>
-</table>
-
-</body>
-</html>
-
+<?php
+/*
+ * This file is part of Web Instant Messenger project.
+ *
+ * Copyright (c) 2005-2007 Internet Services Ltd.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Evgeny Gryaznov - initial API and implementation
+ */
+?>
+<html>
+<head>
+
+
+
+<link rel="stylesheet" type="text/css" media="all" href="/webim/styles.css" />
+
+
+<link rel="shortcut icon" href="/webim/images/favicon.ico" type="image/x-icon"/>
+<title>
+	<?php echo getstring("app.title") ?>	- <?php echo getstring("page_analysis.search.title") ?>
+</title>
+
+<meta http-equiv="keywords" content="<?php echo getstring("page.main_layout.meta_keyword") ?>">
+<meta http-equiv="description" content="<?php echo getstring("page.main_layout.meta_description") ?>">
+</head>
+
+<body bgcolor="#FFFFFF" text="#000000" link="#2971C1" vlink="#2971C1" alink="#2971C1">
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+<td valign="top" class="text">
+	
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="top"> 
+		<h1><?php echo getstring("page_analysis.search.title") ?></h1>
+ </td><td align="right" class="text" valign="top"><table cellspacing="0" cellpadding="0" border="0"><tr><td class="textform"><?php echo getstring2("menu.operator",array($page['operator'])) ?></td><td class="textform"><img src='/webim/images/topdiv.gif' width="25" height="15" border="0" alt="|" /></td><td class="textform"><a href="/webim/operator/index.php" title="<?php echo getstring("menu.main") ?>"><?php echo getstring("menu.main") ?></a></td></tr></table></td></tr></table> 
+	
+
+	<?php echo getstring("page_search.intro") ?>
+<br />
+<br />
+
+
+
+
+<form name="searchForm" method="get" action="/webim/operator/history.php">
+<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
+	<tr>
+		<td class="formauth" colspan="3"><?php echo getstring("page_analysis.full.text.search") ?></td>
+	</tr>
+	<tr><td colspan="3" height="2"></td></tr>
+	<tr>
+		<td class="formauth"><input type="text" name="q" size="80" value="<?php echo form_value('q') ?>" class="formauth"/></td>
+		<td width="10"><img src="/webim/images/free.gif" width="10" height="1" border="0" alt=""></td>
+		<td class="formauth">
+			<input type="image" name="" src='<?php echo getstring("image.button.search") ?>' border="0" alt='<?php echo getstring("button.search") ?>'/>
+		</td>
+	</tr>
+</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
+</form>
+
+<br/>
+<?php if( $page['pagination'] && $page['pagination.items'] ) { ?>
+	<table cellpadding="0" cellspacing="0" border="0" width="100%">
+		<tr>
+			<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page.analysis.search.head_name") ?></span></td><td width='3'></td>
+			<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page.analysis.search.head_host") ?></span></td><td width='3'></td>
+			<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page.analysis.search.head_operator") ?></span></td><td width='3'></td>
+			<td class='table' bgcolor='#276db8' height='30'><span class='header'><?php echo getstring("page.analysis.search.head_time") ?></span></td>
+		</tr>
+		<?php foreach( $page['pagination.items'] as $chatthread ) { ?>
+			<tr>
+				<td height='30' class='table'>
+					<a href="/webim/operator/threadprocessor.php?threadid=<?php echo $chatthread['threadid'] ?>" target="_blank" onclick="this.newWindow = window.open('/webim/operator/threadprocessor.php?threadid=<?php echo $chatthread['threadid'] ?>', '', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=600,height=420,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;"><?php echo htmlspecialchars($chatthread['userName']) ?></a>
+				</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
+				<td height='30' class='table'>
+					<?php echo htmlspecialchars($chatthread['remote']) ?>
+				</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
+				<td height='30' class='table'>
+        			<?php if( $chatthread['agentName'] ) { ?><?php echo htmlspecialchars($chatthread['agentName']) ?><?php } ?>
+				</td><td background='/webim/images/tablediv3.gif'><img width='3' height='1' border='0' alt='' src='/webim/images/free.gif'></td>
+				<td height='30' class='table'>
+					<?php echo date("d M Y H:i:s", $chatthread['created']) ?>,  <?php echo date_diff($chatthread['modified']-$chatthread['created']) ?>
+				</td>
+			</tr>
+			<tr><td height='2' colspan='7'></td></tr><tr><td bgcolor='#e1e1e1' colspan='7'><img width='1' height='1' border='0' alt='' src='/webim/images/free.gif'></td></tr><tr><td height='2' colspan='7'></td></tr>
+		<?php } ?>
+	</table>
+	<br />
+	<?php echo generate_pagination($page['pagination']) ?>
+<?php } ?>
+<?php if( $page['pagination'] && !$page['pagination.items'] ) { ?>
+	<br/><br/>
+	<table cellspacing='0' cellpadding='0' border='0'><tr><td background='/webim/images/loginbg.gif'><table cellspacing='0' cellpadding='0' border='0'><tr><td><img src='/webim/images/logincrnlt.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrt.gif' width='16' height='16' border='0' alt=''></td></tr><tr><td></td><td align='center'><table border='0' cellspacing='0' cellpadding='0'>
+		<span class="table">
+			<?php echo getstring("tag.pagination.no_items") ?>
+		</span>
+	</table></td><td></td></tr><tr><td><img src='/webim/images/logincrnlb.gif' width='16' height='16' border='0' alt=''></td><td></td><td><img src='/webim/images/logincrnrb.gif' width='16' height='16' border='0' alt=''></td></tr></table></td></tr></table>
+<?php } ?>
+
+</td>
+</tr>
+</table>
+
+</body>
+</html>
+