function popup_image(url, w, h) {

	wWidth = w;
	wHeight = h + 20;
	if (wWidth > screen.width) wWidth = screen.width - 100;
	if (wHeight > screen.height) wHeight = screen.height - 200;

	wnd=window.open("", "imgWin", 'width=' + wWidth + ',height=' + wHeight + ',resizable=no,scrollbars=no,toolbar=no,menubar=no');
	wnd.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Увеличенное изображение</title><link rel="stylesheet" href="/style.css" type="text/css" /></head><body style="margin:0; padding:0;">');
	wnd.document.write('<div align="center" style="width:100%">');
	wnd.document.write('<img src="' + url + '" width="' + w + '" height="' + h + '" border="0" alt="" /><br />');
	wnd.document.write('<p style="text-align:center; margin:0; font-size:10px;"><a href="javascript:window.close();">Закрыть окно</a></p>');
	wnd.document.write('</div>');
	wnd.document.write('</body></html>');
	wnd.document.close();
	wnd.focus();

}


function popup_flash( url, title, w, h ) {

	wWidth = w;
	wHeight = h + 40;
	if (wWidth > screen.width) wWidth = screen.width - 100;
	if (wHeight > screen.height) wHeight = screen.height - 200;

	wnd=window.open( "", "flashWin", 'width=' + wWidth + ',height=' + wHeight + ',resizable=no,scrollbars=no,toolbar=no,menubar=no' );
	wnd.document.write( '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>'+title+'</title><link rel="stylesheet" href="/style.css" type="text/css" /></head><body style="margin:0; padding:0; background-color:darkGray;">' );
	wnd.document.write( '<div align="center" style="width:100%">' );
	wnd.document.write( '<object type="application/x-shockwave-flash" data="'+url+'" width="'+w+'" height="'+h+'"><param name="movie" value="'+url+'" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="quality" value="high" /></object><br />' );
	wnd.document.write( '<p style="text-align:center; color:white; font-size:10pt; font-weight:bold;">'+title+'</p>' );
	wnd.document.write( '</div>' );
	wnd.document.write( '</body></html>' );
	wnd.document.close();
	wnd.focus();

}


function popup_text(txt, w, h) {

	wWidth = w + 50;
	wHeight = h + 200;
	if (wWidth > screen.width) wWidth = screen.width - 100;
	if (wHeight > screen.height) wHeight = screen.height - 200;

	wnd=window.open("", "imgWin", 'width=' + wWidth + ',height=' + wHeight + ',resizable=1,scrollbars=1,toolbar=no,menubar=no');
	wnd.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Просмотр текста</title><link rel="stylesheet" href="/style.css" type="text/css" /></script></head><body>');
	wnd.document.write('<div style="margin:10px; padding:10px; border:1px solid #DEDEDE;">');
	wnd.document.write('<p>'+txt+'</p>');
	wnd.document.write('<div align="center"><a href="javascript:window.close();">Закрыть окно</a></div>');
	wnd.document.write('</div>');
	wnd.document.write('</body></html>');
	wnd.document.close();
	wnd.focus();

}

function popup_win( url, w, h )
{
	var wWidth = w;
	var wHeight = h;

	if (wWidth > screen.width) wWidth = screen.width - 100;
	if (wHeight > screen.height) wHeight = screen.height - 200;

	wnd=window.open( url, "ppWin", 'width=' + wWidth + ',height=' + wHeight + ',resizable=1,scrollbars=1,toolbar=no,menubar=no');
	wnd.focus();
}


function gtu(u)
{
	wnd = window.open('http://'+u, '_blank');
	wnd.focus();
}


/*************** для выплывающих меню ****************/

function findPos(Id)
{
	var x = 0;
	var y = 0;

	var el,temp;
	el = document.getElementById(Id);

	if ( el.offsetParent )
	{
		temp = el;
		while ( temp.offsetParent ) //Looping parent elements to get the offset of them as well
		{
			temp=temp.offsetParent;
			x+=temp.offsetLeft
			y+=temp.offsetTop;
		}
	}
	x+=el.offsetLeft
	y+=el.offsetTop

	return [x,y];
}


var menus = Array();

function sh(u)
{

	if ( !document.getElementById('box'+u) ) return;
	box = document.getElementById('box'+u).style;
	td = document.getElementById('td'+u).style;

	if( menus[u] == true )
	{
		box.visibility = "visible";
		pos = findPos( 'td'+u );
		box.left = pos[0]+'px';
		box.top = pos[1] + parseInt(25);
//alert( pos[1] + ' ' + box.top );
		//box.top = box.top + 'px';
	}
}

function shFirstLevel( u )
{
	//alert('sadf'); return;
	menus[u] = true;
}

function hd(u)
{
	if ( !document.getElementById('box'+u) ) return;
	box = document.getElementById('box'+u).style;
	box.visibility = "hidden";
}

function hd1(u)
{
	menus[u] = false;
}

function zzz( u )
{
	alert( u );
}

/*****************************************************/

function setCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}


// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function getCookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

$(document).ready(function(){
	$('button, input:submit, input:reset, input:button, a.button, span.button').button();
});
