var agt = navigator.userAgent.toLowerCase();
var ver = parseInt(navigator.appVersion);
var ie = ((agt.indexOf('msie') != -1) && (agt.indexOf('opera') == -1));
var ie5 = (ie && (ver == 4) && (agt.indexOf('msie 5.0')!= -1) );
var opera = (agt.indexOf("opera") != -1);
var opera8 = (agt.indexOf("opera 8") != -1);

// - position bottom (для IE5 Opera8)
function position_bottom()
{
	var e = (document.body ? document.body : document.documentElement);
	var m = document.getElementById('bodyBlock');
	var b = document.getElementById('bottom');

	if(e.clientHeight < m.clientHeight)
	{
		b.style.top = m.clientHeight - b.clientHeight;
	}
	else
	{
		b.style.top = e.clientHeight - b.clientHeight;
	}
}

if(ie5 || opera8)
{
	window.onload = function(){position_bottom();}
	window.onresize = function(){position_bottom();}
}
//*******************************************************************

var d = document
var win;

function setCookie(name, value, expires, path, domain, secure)
{
	path = '/';
	var curCookie = name + '=' + escape(value) +
	((expires) ? ';expires=' + expires : '') +
	((path) ? ';path=' + path : '') +
	((domain) ? ';domain=' + domain : '') +
	((secure) ? ';secure' : '');
	if ((escape(value)).length <= 4000)
	{
		document.cookie = curCookie+';';
	}
}

function getCookie(name)
{
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1) return null;
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function newWin(url,w,h)
{
	var left = (screen.availWidth/2) - w/2;
	var top = 0;

	if(opera)
	{
		top = Math.floor((d.body.clientHeight/2) - h/2);
	}
	else
	{
		top = Math.floor((screen.availHeight/2) - h/2);
	}
	
	var features = 'width=' + w + ',height=' + h + ',scrollbars=1,status=no,resizable,left=' + left + ',top=' + top + ',screenX=' + left + ',screenY=' + top + '';
	win = window.open("" + url + "", "", features);
}
//*******************************************************************
// - enter flash
function shSWFile(swf,width,height,backcolor,vars)
{
	d.write(
		'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'">' +
		'<param name="movie" value="'+swf+'">' +
		'<param name="quality" value="best">' +
		'<param name="bgcolor" value="'+backcolor+'">' +
		'<param name="wmode" value="window">' +
		'<param name="FlashVars" value="'+vars+'">' +
		'<embed src="'+swf+'" quality="best" bgcolor="'+backcolor+'" width="'+width+'" height="'+height+'" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+vars+'"></embed>' +
		'</object>'
		);
}
//*******************************************************************

function replaceMult()
{
	var obj = d.getElementById('topclip');
	var h = obj.offsetHeight;
	if(h == 550){minMult(); setCookie('statusClip',0);}
	else if(h == 150){maxMult(); setCookie('statusClip',1);}
}
function minMult()
{
	var obj = d.getElementById('topclip');
	var objMiddle = d.getElementById('middle');
	var h = obj.offsetHeight;
	var step = 50;
	obj.style.height = (h - step) + 'px';
	if(h > 200)
	{
		window.setTimeout('minMult()', 1);
		objMiddle.style.paddingTop = 24 + 'px';
	}
	
		
}
function maxMult()
{
	var obj = d.getElementById('topclip');
	var objMiddle = d.getElementById('middle');
	var h = obj.offsetHeight;
	var step = 50;
	obj.style.height = (h + step) + 'px';
	if(h < 500)
	{
		window.setTimeout('maxMult()', 1);
		objMiddle.style.paddingTop = 0 + 'px';
		obj.onmousemove = function(){return false}
	}
}
function ChangeSection(id){
	if(!$("div.backNav").length)
		$("div.content").before($(jQuery('<div class="backNav"></div>')));
	if(!$("h1.contentHead").length)
		$("div.content").before($(jQuery('<h1 class="contentHead"></h1>')));

	$("h1.contentHead").load("/ajax/section/title/", {SECTION: id});
	$("div.backNav").load("/" + id + "/ajax_backnav.php");
	$("div.content").load("/ajax/section/", {SECTION: id});
	$("div.blank > div.left_").load("/" + id + "/ajax_left.php");
}