function openContact(url, name, width, height)
	{
		if (!width) width = 500;
		if (!height) height = 550;
		var w = window.open(url, name,"width="+500+",height="+700+",resizable=1,toolbar=0,location=0,status=0,menubar=0,directories=0,scrollbars=yes,top=0,left=0");
		w.focus();
	}

	/**
	 * Определим не нужно ли нам открыть попап?!
	 */
	var myregexp	= new RegExp('cid=([0-9]+)');
	var match		= myregexp.exec(document.location.href);
	if( match != null )
	{
		var contactId = (match[1] * 1);
		if( contactId )
		{
			if( document.location.href.indexOf('#cid' + contactId) == -1 )
			{
				document.location.href += ('#cid' + contactId);
				openContact('message.phtml?cid=' + contactId, 'message_' + contactId);
			}
		}
	}

function smile(tag) {
var myField;
myField = document.getElementById('message');

if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = ' ' + tag + ' ';
myField.focus();
}
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
var cursorPos = endPos;
myField.value = myField.value.substring(0, startPos)
+ ' ' + tag + ' '
+ myField.value.substring(endPos, myField.value.length);
cursorPos += tag.length + 2;
myField.focus();
myField.selectionStart = cursorPos;
myField.selectionEnd = cursorPos;
}
else {
myField.value += tag;
myField.focus();
}
if (si==1) {close_smiles();}
if (si_2==1) {close_smiles_2();}
}


