$(document).ready(function()
{
	$(document).on('mouseenter mouseleave', '.head_button div div', function()
	{
		$(this).toggleClass('head_button_active');
	});

	$.fn.center = function() 
	{
		var w = $(window);
		this.css('position', 'fixed');
		this.css('top', (w.height() - this.height()) / 2 + w.scrollTop() + 'px');
		this.css('left', (w.width() - this.width()) / 2 + w.scrollLeft() + 'px');

		if ($(this).width() > w.width()) $(this).css('left', '10px').css('width', (w.width() - 20) + 'px');
		if ($(this).height() > w.height()) $(this).css('top', '10px').css('height', (w.height() - 20) + 'px');

		$('.winFrame').css('height', (this.height() - 85) + 'px');

		return this;
	};

	$(document).on('click', 'a.findMistake', function()
	{
		var url = $(this).data('url');

		var win = window.open('mistake.php?url=' + url, 'name', 'width=525,height=360,scrollbars=1');

		if (window.focus) {win.focus();}

		return false;
	});

	/** Alerts **/

	$(document).on('click', 'a.confirm_delete', function()
	{
		if (!confirm('Удалить?')) return false;
	});
});

function openNewWindow(url, winName, x, y)
{	
	var df = window.open(url,winName,'width='+x+',height='+y);
	df.focus();
	return false;
	alert(window.winName.windowName);
}
