if (navigator.userAgent.indexOf("Opera")!=-1) {document.write('<link rel="stylesheet" href="/usr/templates/opera.css" type="text/css" media="screen"/>');};

// перерисовка страницы - чтобы браузеры не перло при динамическом изменении контента
function reloadPage(){$('body').css("display","inline").css("display","block");}

var last, def, current;


// выбор страниц для отображения
function openPage(current) {
	var pos = current.href.lastIndexOf("#");
	where=current.href.slice(pos+1);
	where = document.getElementById(where);

	nav = document.getElementById("right").getElementsByTagName('div');
	for(var i=0; i<nav.length; i++) {
		var navClass=nav[i].className;
		if (nav[i]==where & current.className!="active") where.className+=" on";
		if (nav[i]==where & current.className=="active") nav[i].className=navClass.replace(" on", "");
	}

	if (current.className!="active") current.className="active"; else current.className="";
	reloadPage();

	return false;
}

// наведение на пункт меню
function jsHover() {
	function doFirst(two) {$('#illustration').find('.bg').css("z-index","1").show().end().find('.bg-'+two).css("z-index","3");}
	if ($.browser.msie) {$('#main li').each(function(){$(this).hover(function(){$(this).addClass("jshover")},function(){$(this).removeClass("jshover")});})}
	def = $('#illustration').attr('class');
	def=def.replace("illustration-", "");
	last=def;

	$('#main a').each(function(){$(this).hover(
		function(){
			current=this.className;
			if (current!=last) {
				if (current=='index') {$('#main').addClass('blue');} else {$('#main').removeClass('blue');}
				$('#illustration').find('.txt').hide().end().find('.txt-'+current).show();
				$('#illustration').find('.bg-'+current).css("z-index","2").show().end().find('.bg-'+last).fadeOut("fast",function(){doFirst(current);});
				last=current;
			}
		},function(){});
	});

	$('#space').hover(
		function(){
			if (def!=last) {
				if (def=='index') $('#main').addClass('blue'); else $('#main').removeClass('blue');
				$('#illustration').find('.txt').hide().end().find('.txt-'+def).show();
				$('#illustration').find('.bg-'+def).css("z-index","2").show().end().find('.bg-'+last).fadeOut("fast",function(){doFirst(def);});
				last=def;
			};
		},function(){}
	);
}

$(document).ready(function(){
	if ($("*").index($('#illustration')[0])>0) jsHover();
});
