$(document).ready(function(){	
	$.reject({		
		reject: {
			unknown: true
		},
		header: 'Ваш Интернет-браузер устарел и не поддерживается этим сайтом!',		
		paragraph1: 'Ниже Вы можете видеть список самых популярных браузеров, поддерживаемых этим сайтом.',
		paragraph2: 'Пожалуйста, скачайте и установите один из них:',
		browserInfo: {
			msie: {
				text: 'Internet Explorer 8+'
			}
		},
		close: false,
		imagePath: '../images/browsers/',
		overlayOpacity: 1
	});
	
	$('div[id*=proj_]').each(function (i) {
		var link = $("li [class*=" + $(this).attr("id") + "]").text();				
		$('<a class="ext" href="' + link + '" title="Ссылка на проект">Ссылка<sup><img src="images/markers/external.png" alt="Ссылка на проект" \/><\/sup><\/a>').appendTo('div#' + $(this).attr("id") + " p span");
	});
	
	$('a[class*=ext]').click( function() {
        window.open(this.href);
        return false;
    });
	
	var prevId;
	var hintImg, hintText;
	var clickFlag;
	var divId;				
	$("a[class*=menu_]").hover( function() {					
		$(this).next().hide();
		$(this).next().next().show();					
	}, function() {
		if(!clickFlag || prevId!=$(this).attr("id")) {
			$(this).next().next().hide();
			$(this).next().show();									
		}
		else
			return false;
	});				
	$("a[class*=menu_]").click(function() {					
		if(divId)
			$(divId).hide();
		else
			false;
		$($(this).attr("id").replace("menu_","#")).fadeIn();
		if(hintImg && hintText && prevId!=$(this).attr("id")) {
			hintText.hide();
			hintImg.show();
		}
		else
			false;
		if(prevId)
			$("#" + prevId).attr("class",prevId);						
		else 
			false;
		$(this).attr("class","active");
		prevId = $(this).attr("id");
		clickFlag = true;
		hintImg = $(this).next();
		hintText = $(this).next().next();
		divId = $(this).attr("id").replace("menu_","#");
	});
	
	var liClick, prevDiv, prevLi, prevLiClass;
	$("div#c_1 li [class*=project]").click(function() {	
		if(liClick)
			$(prevDiv).hide();
		else
			false;
		liClick = true;
		if(prevLi)
			prevLi.css({fontWeight: "normal", color: "#000"});
		else
			false;
		prevLi = $(this);		
		$(this).css({fontWeight: "bold", color: "#000"});
		$("#"+$(this).attr("class").replace("project ","")).fadeIn();
		prevDiv = "#"+$(this).attr("class").replace("project ","");
		prevLiClass = $(this).attr("class").replace("project ","");
	});	
	
	$("div#c_1 li [class*=project]").hover(function() {	
		if(prevLiClass==$(this).attr("class").replace("project ",""))
			return false;
		else
			$(this).css({fontWeight: "bold", color: "#19B14C"});
	}, function() {			
		if(!liClick)
			$(this).css({fontWeight: "normal", color: "#000"});
		if(prevLiClass && prevLiClass!=$(this).attr("class").replace("project ",""))
			$(this).css({fontWeight: "normal", color: "#000"});
		else
			return false;
	});

	var anchor = $.url.attr("anchor");	
	if(anchor) {	
		$("a#menu_"+anchor).next().hide();
		$("a#menu_"+anchor).next().next().show();
		$("a#menu_"+anchor).click();			
	}
	else {
		$("a#menu_about").next().hide();
		$("a#menu_about").next().next().show();
		$("a#menu_about").click();;		
	}
	
	
});
