var ki_ua = window.navigator.userAgent;
if (ki_ua.indexOf ("MSIE") >= 0) {
    if( parseInt(ki_ua.substr(ki_ua.indexOf("MSIE")+5, 3)) < 7 ){
        document.write('<div id=\"kickie\" style=\"text-align:center;position:absolute;top:0px;right:0px;width:100%;background-color:#F2F4FF;color:#0f0f0f;font-family:tahoma,arial,verdana;font-size:11px;padding:10px 0 10px 0;z-index:10000;border-bottom:1px solid #b4b4b4;\">Вы используете устаревший браузер. <a onclick=\"$(\'#cosm\').toggle();\" style=\"cursor:pointer;text-decoration:none;color:blue;\">Подробнее &#187;</a><table id=\"cosm\" class=\"notable\" style=\"display:none;width: 500px; height: 100px; text-align: center; margin-left: auto; margin-right: auto; background-color: #F2F4FF; color: #2B587A; font-size: 11px; font-family: tahoma, arial, verdana;\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><caption style=\"text-align:center;padding:10px 0 10px 0;\">Чтобы использовать все возможности сайта, загрузите и установите один из этих браузеров:</caption><tbody><tr><td style=\"width: 25%;\"><a href=\"http://www.google.com/chrome/?hl=ru\" target=\"_blank\"><img src=\"http://vkontakte.ru/images/chrome.gif\" style=\"border: none;\"/></a></td><td style=\"width: 25%;\"><a href=\"http://www.mozilla-europe.org/ru/\" target=\"_blank\"><img src=\"http://vkontakte.ru/images/firefox.gif\" style=\"border: none;\"/></a></td><td style=\"width: 25%;\"><a href=\"http://www.opera.com/browser/\" target=\"_blank\"><img src=\"http://vkontakte.ru/images/opera.gif\" style=\"border: none;\"/></a></td><td style=\"width: 25%;\"><a href=\"http://www.apple.com/ru/safari/download/\" target=\"_blank\"><img src=\"http://vkontakte.ru/images/safari.gif\" style=\"border: none;\"/></a></td></tr><tr><td>Google Chrome</td><td>Mozilla Firefox</td><td>Opera</td><td>Safari</td></tr></tbody></table></div>');
    }
}
if(!jQuery("body").find("#TB_overlay").is("div")) /* если фон уже добавлен не добавляем повторно */
{
   if(!jQuery.browser.msie) /* если браузер не ИЕ фоном будет div */
   {jQuery("body").append("<div id='TB_overlay'></div>");}
   else /* иначе добавляем iframe */
   {jQuery("body").append("<div id='TB_overlay'><iframe scrolling='no' frameborder='0' style='position: absolute; top: 0; left: 0; width: 100%; height: 100%; filter:alpha(opacity=0)'></iframe></div>");}
}
function check_flash_hide() {

	
		if ( $("#sq1").hasClass("sq_sel") )	
		{
			//$("#flashcontent1").css({'display': 'none'});
			$("#flashcontent2").css({'display': 'none'});
			$("#flashcontent3").css({'display': 'none'});
			$("#flashcontent4").css({'display': 'none'});
		}
		if ( $("#sq2").hasClass("sq_sel") )	
		{
			$("#flashcontent1").css({'display': 'none'});
			//$("#flashcontent2").css({'display': 'none'});
			$("#flashcontent3").css({'display': 'none'});
			$("#flashcontent4").css({'display': 'none'});
		}
		if ( $("#sq3").hasClass("sq_sel") )	
		{
			$("#flashcontent1").css({'display': 'none'});
			$("#flashcontent2").css({'display': 'none'});
			//$("#flashcontent3").css({'display': 'none'});
			$("#flashcontent4").css({'display': 'none'});
		}
		if ( $("#sq4").hasClass("sq_sel") )	
		{
			$("#flashcontent1").css({'display': 'none'});
			$("#flashcontent2").css({'display': 'none'});
			$("#flashcontent3").css({'display': 'none'});
			//$("#flashcontent4").css({'display': 'none'});
		}
}

function rotate() {	

		

       //clearInterval( int );
       //int = setInterval('rotate()',15000);

		
		if ( next_flash == 1 )	
		{
			flash1	= "#flashcontent4";
			flash2	= "#flashcontent1";
			sq	=	"#sq1";
		}
		if ( next_flash == 2 )	
		{
			flash1	= "#flashcontent1";
			flash2	= "#flashcontent2";
			sq	=	"#sq2";
		}
		if ( next_flash == 3 )	
		{
			flash1	= "#flashcontent2";
			flash2	= "#flashcontent3";
			sq	=	"#sq3";
		}
		if ( next_flash == 4 )	
		{
			flash1	= "#flashcontent3";
			flash2	= "#flashcontent4";
			sq	=	"#sq4";
		}
		
		$(".sq").removeClass("sq_sel");
		$(".sq").css({'background': '#C1C2C2'});
		
		$(sq).addClass("sq_sel");
		$(sq).css({'background': '#FAED0E'});
		
		$("#flashcontent1").css({'display': 'none'});
		$("#flashcontent2").css({'display': 'none'});
		$("#flashcontent3").css({'display': 'none'});
		$("#flashcontent4").css({'display': 'none'});
		//$(flash2).css({'display': 'block'});
		//$(flash1).fadeOut(400);
		$(flash2).fadeIn(1000);
		
		next_flash = next_flash + 1;
		if (next_flash == 5) next_flash = 1;
};

$(function(){

	var $sl = $(".nc_news > .row").slice(12, 100);
	$sl.css({'display': 'none'});

	$(".sub-list h1").click(
		function(){
			
			var atr	=	$(this).attr('rel');
			var $kids = $(this).children();
			
			if (atr == '0')  
			{
					$(this).attr( 'rel', '1' );
					$kids.css({'background': 'url(/images/new/sub/img/round.png)'});
					$kids.html( '&nbsp;' );
			}
			else
			{
					$(this).attr( 'rel', '0' );
					$kids.css({'background': 'url(/images/new/sub/img/yellow-round.png)'});
					$kids.html( '&nbsp;' );
			}
			
			$(this).nextAll().toggle( 700 );
		}
	);
	
	
	$(".sub-list h2").click(
		function(){
			
			var atr	=	$(this).attr('rel');
			var $kids = $(this).children();
			
			if (atr == '0')  
			{
					$(this).attr( 'rel', '1' );
					$kids.css({'background': 'url(/images/new/sub/img/round.png)'});
					$kids.html( '&nbsp;' );
			}
			else
			{
					$(this).attr( 'rel', '0' );
					$kids.css({'background': 'url(/images/new/sub/img/yellow-round.png)'});
					$kids.html( '&nbsp;' );
			}
			
			$(this).nextAll().toggle( 700 );
		}
	);


	$(".sq").click(
		function(){
			$("#sq1").css({'background': '#C1C2C2'});
			$("#sq2").css({'background': '#C1C2C2'});
			$("#sq3").css({'background': '#C1C2C2'});
			$("#sq4").css({'background': '#C1C2C2'});
		}
	);


	$(".sq").hover( 
		function(){
			$(this).css({'background': '#2e92db'});
		}, 
		function(){
			if ( $(this).hasClass("sq_sel") )
				{ $(this).css({'background': '#FAED0E'}); }
			else
				{ $(this).css({'background': '#C1C2C2'}); }
		} 
	);
	
	
	next_flash = 2;
	int = setInterval('rotate()',15000);
	chk = setInterval('check_flash_hide()',500); // обновление для флеша на главной

	if ( $.cookie('personal_hide') == 'yes' )
	{
		$('#personal_block').hide(0); 
		$('#login_block').show(0);
//		alert($.cookie('personal_hide'));
	}
	else 
	{
		$('#personal_block').show(0); 
		$('#login_block').hide(0);
		$('#exx').css({left: '15px'});
//		alert($.cookie('personal_hide'));	
	}


	$("#change-map-visibility").click( function(){ $("#ymaps-sem").toggle();} );
	
});






/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
 
var horizontal_offset="9px" //horizontal offset of hint box from anchor link
 
/////No further editting needed
 
var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all
 
function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}
 
function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
 
function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}
 
function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}
 
function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}
 
function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}
 
if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

