
function showForm(action, hidden_id,name_field, content)
{
	var MainDivElement = document.getElementById('MainDivHelper');
	var ContentDivElement = document.getElementById('ContentDivHelper');

	x = 30 + document.body.scrollLeft;
	y = 30 + document.body.scrollTop;
	ContentDivElement.innerHTML = '	<form action="'+action+'" name="mainForm" method="POST"><input type="hidden" name="'+name_field+'" value="'+hidden_id+'">'+content+'</form>';
	MainDivElement.style.left = x + "px";
	MainDivElement.style.top  = y + "px";
	MainDivElement.style.display = "block";
}
/**
	Форма для магии нападения
*/
function showUnlockForm(id)
{
	var str = "Разблокировать бой игрока для нападения.<br/>";
	str += "Логин : <input id=\'targetLogin\' /><br/>";
	str += "<input type=\'submit\' value=\'Напасть\' onclick='server.doTargetMagic("+id+", document.getElementById(\"targetLogin\").value);hideForm();'/>";
	showFormSimple(str);
}
function showOffensForm(id)
{
	var str = "Внимание! Если Вы вторгнетесь в бой Царя Горы с Вас возьмут плату за вход в размере 7 слв.<br/>";
	str += "Логин : <input id=\'targetLogin\' /><br/>";
	str += "<input type=\'submit\' value=\'Напасть\' onclick='server.doTargetMagic("+id+", document.getElementById(\"targetLogin\").value);hideForm();'/>";
	showFormSimple(str);
}
function showHealForm(id)
{
	var str = "Вылечить игрока.<br/>";
	str += "Логин : <input id=\'targetLogin\' /><br/>";
	str += "<input type=\'submit\' value=\'Напасть\' onclick='server.doTargetMagic("+id+", document.getElementById(\"targetLogin\").value);hideForm();'/>";
	showFormSimple(str);
}
/**
	Более простая форма
*/
function showFormSimple( content)
{
	var MainDivElement = document.getElementById('MainDivHelper');
	var ContentDivElement = document.getElementById('ContentDivHelper');

	x = 30 + document.body.scrollLeft;
	y = 30 + document.body.scrollTop;
	ContentDivElement.innerHTML = content;
	MainDivElement.style.left = x + "px";
	MainDivElement.style.top  = y + "px";
	MainDivElement.style.display = "block";
}

function hideForm(){
	var MainDivElement = document.getElementById('MainDivHelper');
	MainDivElement.style.display = "none";
}
function confirmGoTo(goToLink,showText)
{

	if (confirm(showText)) {
		location.replace(goToLink);

	}
}
function smiles()
{
	var x = event.screenX - 180;
	var y = event.screenY - 390;
	var sFeatures = 'dialogLeft:'+x+'px;dialogTop:'+y+'px;dialogHeight:400px;dialogWidth:365px;help:no;status:no;unadorned:yes';
	window.showModelessDialog("smiles.php", window, sFeatures);
}
function addMessage(login, typeSend){
	if(typeSend=='private'){
		parent.bottomFrame.sendMessageForm.text.value =
		'приватно['+login+'] ' +
		parent.bottomFrame.sendMessageForm.text.value;
	}else{
		parent.bottomFrame.sendMessageForm.text.value =
		'для['+login+'] ' +
		parent.bottomFrame.sendMessageForm.text.value;
	}
}
function hideInfoTable(){
	var MainDivElement = document.getElementById('MainInfoTableDiv');
	MainDivElement.style.display = "none";
}
function showInfoTable(login){
	var MainDivElement = document.getElementById('MainInfoTableDiv');
	var ContentDivElement = document.getElementById('ContentInfoTableDiv');
	x =  5 + event.clientX + document.body.scrollLeft;
	y =  event.clientY + document.body.scrollTop - 125;
	if(y<20){
	y = 5 + event.clientY + document.body.scrollTop;
	}
	MainDivElement.style.left = x + "px";
	MainDivElement.style.top  = y + "px";
	MainDivElement.style.display = "block";
	ContentDivElement.innerHTML = "<table width='100'><tr><td><a href=\"javascript:addMessage('"+login+"', 'to');hideInfoTable();\">Для</a></td></tr><tr><td><a href=\"javascript:addMessage('"+login+"', 'private');hideInfoTable();\">Приватно</a></td></tr><tr><td><a href=\"javascript:window.open('info.php?personage_login="+login+"');hideInfoTable();\">Информация</a></td></tr><tr><td><a href=\"javascript:buferCopy('"+login+"');hideInfoTable();\">Копировать</a></td></tr></table>";
}
function buferCopy(someText){
window.clipboardData.setData('text', someText);
}
function buttonControl(login, ctrlValue, shiftValue, typeMess, someText){

	if(event.button==2){
	showInfoTable(login);
	}else{
	if(ctrlValue==true){
		if(typeMess=='private'){
			addMessage(login, 'private');
		}else{
			addMessage(login, 'to');
		}
	}else {
		if(shiftValue==true){
			window.open("info.php?personage_login="+login+"");
		}else{
			parent.bottomFrame.sendMessageForm.text.value =
			someText +
			parent.bottomFrame.sendMessageForm.text.value;
		}
	}
	}


}
function clearChat()
{
	if (sendMessageForm.text.value == '') {
		if (confirm('Очистить окно чата?')) parent.chatFrame.document.getElementById('chatBody').innerHTML='';
	} else { sendMessageForm.text.value=''; }
	sendMessageForm.text.focus();
}
function insertBB(obj,start,finish)
{
	var ObName=document.getElementById(obj);
	ObName.focus();
	var rng=document.selection.createRange();
	rng.select();
	if(rng.text!=''){
		ObName.value=ObName.value.replace(rng.text,start+""+rng.text+""+finish);
	}else{
		ObName.value+=start+""+finish;
	}
}


function specialFocus(){
parent.bottomFrame.sendMessageForm.text.focus()
parent.bottomFrame.sendMessageForm.text.value=parent.bottomFrame.sendMessageForm.text.value;
}