// Объявим глобальные переменные
// Переменная состояния, по умолчанию ничего не двигается = false
var moveState = false;
// Переменные координат мыши в начале перемещения, пока неизвестны
var x0, y0;
// Начальные координаты элемента, пока неизвестны
var divX0, divY0, obj;

function mouseup()
{
	moveState = false;
}
function mousemove()
{
	moveHandler(obj, event);
}
// Объявим функцию для определения координат мыши
function defPosition(event) {
    var x = y = 0;
    if (document.attachEvent != null) { // Internet Explorer & Opera
        x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
        y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
    }
    if (!document.attachEvent && document.addEventListener) { // Gecko
        x = event.clientX + window.scrollX;
        y = event.clientY + window.scrollY;
    }
    return {x:x, y:y};
}

// Функция инициализации движения
// Записываем всё параметры начального состояния
function initMove(div, event) {
	obj=div;
    var event = event || window.event;
    x0 = defPosition(event).x;
    y0 = defPosition(event).y;
    divX0 = parseInt(div.style.left);
    divY0 = parseInt(div.style.top);
    moveState = true;
	document.documentElement.onmousemove = moveHandler;
	document.documentElement.onmouseup = mouseup;
}

// И последнее
// Функция обработки движения:
function moveHandler(event) {
    var event = event || window.event;
    if (moveState) {
        obj.style.left = divX0 + defPosition(event).x - x0;
        obj.style.top  = divY0 + defPosition(event).y - y0;
    }
}
function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
function open_mail_form(id)
{
	if(document.getElementById(id).style.display!="inline")
	{
		document.getElementById(id).style.left=document.documentElement.scrollLeft+document.body.scrollLeft+getClientWidth()/2-200;
		document.getElementById(id).style.top=document.documentElement.scrollTop+document.body.scrollTop+getClientHeight()/2-200;
		document.getElementById(id).style.display="inline";
	}else{
		document.getElementById(id).style.display="none";
	}
}
function open_guestbook(id,aid)
{
	if(document.getElementById(id).style.display!="inline")
	{
		document.getElementById(id).style.left=document.documentElement.scrollLeft+document.body.scrollLeft+getClientWidth()/2-200;
		document.getElementById(id).style.top=document.documentElement.scrollTop+document.body.scrollTop+getClientHeight()/2-200;
		document.getElementById('id_guestbook_header').innerHTML=document.getElementById(aid).innerHTML;
		document.getElementById('guestbook_type').value=aid;
		document.getElementById(id).style.display="inline";
	}else{
		document.getElementById(id).style.display="none";
	}
}
function OpenWin(id) 
{
  myWin= open("/mail_resume/"+id, "displayWindow", 
       "width=400,height=400,status=no,toolbar=no,menubar=no");
}
var open_comment='no';
function open_fast_comment(id)
{
	if(document.getElementById(id).style.display!="block")
	{
		document.getElementById(id).style.display="block";
		if(open_comment!='no')
		{
			document.getElementById(open_comment).style.display="none";
		}
		open_comment=id;
	}else{
		document.getElementById(id).style.display="none";
		open_comment='no';
	}
	return false;
}
