
function $(divName)
{
	return document.getElementById(divName);
}

function writeLiveInternetCounter()
{
	document.write("<a href='http://www.liveinternet.ru/click;inthemusic' target=_blank><img src='http://counter.yadro.ru/hit;inthemusic?t45.5;r" + escape(document.referrer) + ((typeof(screen)=="undefined")?"":";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?screen.colorDepth:screen.pixelDepth)) + ";u" + escape(document.URL) + ";" + Math.random() + "' border=0 width=31 height=31 alt='' title='LiveInternet'><\/a>");
}

function writeMail(value)
{
	mail = 'inthemusic.ru';
	mail = value + '@' + mail;
	mail = '<a href=' + 'mailto:' + mail + '>' + mail + '</a>';
	
	document.write(mail);
}

function showStandartDialog(url, w, h)
{
	var x = 100;
	var y = 100;
	
	if (window.screen)
	{
		x = (screen.width - w) / 2;
		y = (screen.height - h) / 2 - 100;
	}
	
	window.open(url, '', 'width=' + w + ',height=' + h + ',top=' + y + ',left=' + x);
}

function showComplaintDialog(comment)
{
	showStandartDialog('/complaint/' + comment + '/', 300, 150);
}

// navigation

document.onkeydown = navigate;

function navigate(event)
{
	if (!document.getElementById)
	{
		return;
	}

	if (window.event)
	{
		event = window.event;
	}
	
	if (event.ctrlKey)
	{
		var link = null;
		var href = null;
		
		switch (event.keyCode ? event.keyCode : event.which ? event.which : null)
		{
			case 37:
				link = document.getElementById('prev-link');
				break;
			case 39:
				link = document.getElementById('next-link');
				break;
			case 38:
				link = document.getElementById('up-link');
				break;
		}

		if (link && link.href)
		{
			document.location = link.href;
		}
	}			
}

// comments

function showCommentDeleteDialog(comment, module, itemId)
{
	showStandartDialog('/moderate/comment/delete/' + comment + '/' + module + '/' + itemId + '/', 300, 150);
}

function showCommentEditDialog(comment, module, itemId)
{
	showStandartDialog('/moderate/comment/edit/' + comment + '/' + module + '/' + itemId + '/', 500, 400);
}

function addAppeal(name)
{
	var o = $(message);
	
	if (o.value != '')
	{
		o.value += '\n\n';
	}
	
	o.value += '2 ' + name + ':\n\n';
	o.focus();
}

