function info_sotr(i,idsotr,idmenu,type) {
	$("#info_sotr").html('');
	$("#info_sotr").html('Идет загрузка данных...');
	if (i==1) { $('.menu_sotr2').removeClass('menu_sotr2'); $("#about").addClass('menu_sotr2'); }
	if (i==2) { $('.menu_sotr2').removeClass('menu_sotr2'); $("#about").addClass('menu_sotr1');$("#edu").addClass('menu_sotr2'); }
	if (i==3) { $('.menu_sotr2').removeClass('menu_sotr2'); $("#about").addClass('menu_sotr1');$("#nir").addClass('menu_sotr2'); }
	if (i==4) { $('.menu_sotr2').removeClass('menu_sotr2'); $("#about").addClass('menu_sotr1');$("#discipline").addClass('menu_sotr2'); }
	if (i==5) { $('.menu_sotr2').removeClass('menu_sotr2'); $("#about").addClass('menu_sotr1');$("#grant").addClass('menu_sotr2'); }
	if (i==6) { $('.menu_sotr2').removeClass('menu_sotr2'); $("#about").addClass('menu_sotr1');$("#public").addClass('menu_sotr2'); }
	$.ajax({
		type: "GET",
		url: "/ajax/info_sotr.php",
		data: "i="+i+"&idsotr="+idsotr+"&idmenu="+idmenu+"&type="+type,
		success: function(html) {
			$("#info_sotr").html('');
			$("#info_sotr").html(html);
			$("#info_sotr").show();
		}
	});
}

function reiting() {
	$("#reiting").show();
	var idmenu=$("#faculty").val();
	var spec=$("#idspec").val();
	var idtipobrazov=$("#idtipobrazov").val();

	var url=window.location.pathname;
	if (url=='/spisok_pretendentov/') { type="1";}
	else if (url=='/reiting/') {type="0";}
	else if (url=='/zachislenie/') {type="2";}

	if (type==0) {
		$.ajax({
			type:"GET",
			url: "/ajax/reiting.php",
			data:"idmenu="+idmenu+"&idspec="+spec+"&idtipobrazov="+idtipobrazov,
			success: function(html) {
				$("#reiting").html('');
				$("#reiting").html(html);
				$("#reiting").show();
			}
		});	
	}
	else if (type==1) {
		$.ajax({
			type:"GET",
			url: "/ajax/spisok_pretendentov.php",
			data:"idmenu="+idmenu+"&idspec="+spec+"&idtipobrazov="+idtipobrazov,
			success: function(html) {
				$("#reiting").html('');
				$("#reiting").html(html);
				$("#reiting").show();
			}
		});
	}
	else if (type==2) {
		$.ajax({
			type:"GET",
			url: "/ajax/zachislenie.php",
			data:"idmenu="+idmenu+"&idspec="+spec+"&idtipobrazov="+idtipobrazov,
			success: function(html) {
				$("#reiting").html('');
				$("#reiting").html(html);
				$("#reiting").show();
			}
		});
	}
}

function tipobrazov() {
	$("#reiting").hide();
	$.ajax({
		type:"GET",
		url: "/ajax/tipobrazov.php",
		success: function(html) {
			$("#tipobrazov").html('');
			$("#tipobrazov").html(html);
			$("#tipobrazov").show();
		}
	});
}

function spec() {
	$("#reiting").hide();
	$("#spec").show();
	var idmenu=$("#faculty").val();
	$.ajax({
		type:"GET",
		url: "/ajax/spec.php",
		data:"idmenu="+idmenu,
		success: function(html) {
			$("#spec").html('');
			$("#spec").html(html);
			$("#spec").show();
		}
	});
}

function dr(type) {
	$.ajax({
		type: "GET",
		url: "/ajax/dr.php",
		data: "type="+type,
		success: function(html) {
			$("#denrozhd").html('');
			$("#denrozhd").html(html);
			$("#denrozhd").show();
		}
	});
}

function shedule() {
	$("#shedule").html("Идет загрузка...");
	$("#shedule").show();
	var idgruppa=$("#idgruppa").val();
	$.ajax({
		type:"POST",
		url: "/ajax/shedule.php",
		data:"idgruppa="+idgruppa,
		success: function(html) {
			$("#shedule").html('');
			$("#shedule").html(html);
			$("#shedule").show();
		}
	});
}

function faculty() {
	$("#shedule").html('');
	$("#gruppa").show();
	var idmenu=$("#idfaculty").val();
	$.ajax({
		type:"POST",
		url: "/ajax/faculty.php",
		data:"idmenu="+idmenu,
		success: function(html) {
			$("#gruppa").html('');
			$("#gruppa").html(html);
			$("#gruppa").show();
		}
	});
}

function closefon() {
	$("#fon").hide();
	$("#idfoto").hide();
}

function idfoto(idimg,idgallery) {
	$("#fotoalbum td").css({"background":"#ffffff"});
	$("#idfoto"+idimg).css({"background":"#d4d4d4"});
	$.ajax({
		type:"GET",
		url:"/ajax/idfoto.php",
		data:"idimg="+idimg+"&idgallery="+idgallery,
		success: function(html) {
			$("#idfoto").html('');
			$("#idfoto").html(html);
			$("#idfoto").show();
		}
	});
}

function fotoalbum(idmenu,idgallery) {
	$("#foto").html('');
	$("#foto").html("Идет загрузка...");
	$("#foto").show();
	$('#multi-derevo a').css("color","#363636");
	$("#"+idgallery).css("color","#213ff2");
	$.ajax({
		type: "GET",
		url: "/ajax/fotoalbum.php",
		data: "idmenu="+idmenu+"&idgallery="+idgallery,
		success: function(html) {
			$("#foto").html('');
			$("#foto").html(html);
			$("#foto").show();
		}
	});	
}

function catalog(idmenu,idcatalog) {
	$("#file").append("Идет загрузка...");
	$("#multi-derevo a").css({"color":"#363636"});
	$("#"+idcatalog).css({"color":"#213ff2"});
	$.ajax({
		type: "GET",
		url: "/ajax/catalog.php",
		data: "idmenu="+idmenu+"&idcatalog="+idcatalog,
		success: function(html) {
			$("#file").html('');
			$("#file").html(html);
			$("#file").show();
		}
	});	
}

$(document).ready(function () {

$("table td #td1").hover(function() {$("table tr td #td1").css({"background":"#008aff"});}, function() {$("table tr td #td1").css("background-image","url(/images/fonmenu.gif)");});
$("table td #td2").hover(function() {$("table tr td #td2").css({"background":"#008aff"});}, function() {$("table tr td #td2").css("background-image","url(/images/fonmenu.gif)");});
$("table td #td3").hover(function() {$("table tr td #td3").css({"background":"#008aff"});}, function() {$("table tr td #td3").css("background-image","url(/images/fonmenu.gif)");});
$("table td #td4").hover(function() {$("table tr td #td4").css({"background":"#008aff"});}, function() {$("table tr td #td4").css("background-image","url(/images/fonmenu.gif)");});
$("table td #td5").hover(function() {$("table tr td #td5").css({"background":"#008aff"});}, function() {$("table tr td #td5").css("background-image","url(/images/fonmenu.gif)");});

$('#multi-derevo').find('a').prepend('<em class="marker"></em>');
$('#multi-derevo li span').click(function () {
  $('a.current').removeClass('current');
  var a = $('a:first',this.parentNode);
  a.toggleClass('current');
  var li=$(this.parentNode);
  if (!li.next().length) {
    /* берем корень разветвления <li>, в нем находим поддерево <ul>,
     выбираем прямых потомков ul > li, назначаем им класс 'last' */
    li.find('ul:first > li').addClass('last');
  }
  // анимация раскрытия узла и изменение состояния маркера
  var ul=$('ul:first',this.parentNode);// Находим поддерево
  if (ul.length) {// поддерево есть
   ul.slideToggle(300); //свернуть или развернуть
   // Меняем сосотояние маркера на закрыто/открыто
   var em=$('em:first',this.parentNode);// this = 'li span'
   // было em.hasClass('open')?em.removeClass('open'):em.addClass('open');
   em.toggleClass('open');
 }
});
})