$(document).ready(function() {
	$(".seats li a").click(function () {
		if ($(this).attr('id') != 'hall_schemas_all') {
			var new_schema = new Image;
			new_schema.src = $(this).attr('href');
			if ($(this).attr('id') != 'hall_link_visited') {
				$(this).attr('id', 'hall_link_visited')
				$(new_schema).unbind('load');
				$(new_schema).bind('load', function () {
					$("#hall_schema img").animate({'opacity':'0.0'}, 300, function () {
						$("#hall_schema img").attr('src', new_schema.src);
						$("#hall_schema img").animate({'opacity':'1.0'}, 300);
					});
				});
			} else {
				$("#hall_schema img").animate({'opacity':'0.0'}, 300, function () {
					$("#hall_schema img").attr('src', new_schema.src);
					$("#hall_schema img").animate({'opacity':'1.0'}, 300);
				});
			}
			var i = 0;
			for (i = 0; i < $(".seats li").length; i++) {
				$(".seats li").eq(i).removeClass('selected');
			}
			$(this).parent().addClass('selected');
		
			return false;
		}
	});
});


//Подключаем вертикальную стилизованную прокрутку
$(document).ready(function() {
	//alert('!');
	$('.scroll-pane').jScrollPane();
});


//Подключаем превьюшки для ленты событий
$(document).ready(function() {
	//alert('!');
	$('.events_new_list ul li h5 a').mouseover(function(){
		$(this).parent().parent().find('div.preview').css({'display':'block'});
	});
	$('.events_new_list ul li h5 a').mouseout(function(){
		$(this).parent().parent().find('div.preview').css({'display':'none'});
	});
});


//Запускаем ротацию новостей снизу
var interval = '';
$(document).ready(function() {
	//get_bottom_news('bottom_news');
	interval = setInterval("get_bottom_news('bottom_news')", 15000);
});


//Растягиваем контент до высоты полного заполнения страницы
$(document).ready(function() {
	if ($(".content").height() < ($(".block").height() - 20)) {
		//alert('smaller!');
		$(".content .middle .relative").css({'height' : ($(".block").height() - 50) + "px"})
	}
});


function get_bottom_news(container_id)
{
	var xmlhttp;
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
	} else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5
	} else {
		alert("Your browser does not support XMLHTTP!");
	}
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState==4) {
			if (xmlhttp.responseText == 'false') {
				//alert('false');
			} else {
				div = document.getElementById(container_id);
				if (navigator.userAgent.toLowerCase().indexOf('msie') > -1) {
					div.innerHTML = xmlhttp.responseText;
				} else {
					$(div).find('li').animate({'opacity':'0.0'}, 300, function() {
						div.innerHTML = xmlhttp.responseText;
						$(div).find('li').css({'opacity':'0.0'});
						$(div).find('li').animate({'opacity':'1.0'}, 300);
					});
				}
			}
	  	}
	}
	xmlhttp.open("GET", "/scripts_ajax/get_bottom_news.php", true);
	xmlhttp.send(null);
}


function get_block_calendar_1x1_month(date, dir, container_id)
{
	var xmlhttp;
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
	} else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5
	} else {
		alert("Your browser does not support XMLHTTP!");
	}
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState==4) {
			if (xmlhttp.responseText == 'false') {
				//alert('false');
			} else {
				div = document.getElementById(container_id);
				if (navigator.userAgent.toLowerCase().indexOf('msie') > -1) {
					div.innerHTML = xmlhttp.responseText;
				} else {
					$(div).find('ul').animate({'opacity':'0.0'}, 300, function() {
						div.innerHTML = xmlhttp.responseText;
						$(div).find('ul').css({'opacity':'0.0'});
						$(div).find('ul').animate({'opacity':'1.0'}, 300);
					});
				}
			}
	  	}
	}
	xmlhttp.open("GET", "/scripts_ajax/get_block_calendar_1x1_month.php?date="+date+"&dir="+dir, true);
	xmlhttp.send(null);
}


function get_block_calendar_archive_month(date, dir, container_id)
{
	var xmlhttp;
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
	} else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5
	} else {
		alert("Your browser does not support XMLHTTP!");
	}
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState==4) {
			if (xmlhttp.responseText == 'false') {
				//alert('false');
			} else {
				div = document.getElementById(container_id);
				if (navigator.userAgent.toLowerCase().indexOf('msie') > -1) {
					div.innerHTML = xmlhttp.responseText;
				} else {
					$(div).find('ul').animate({'opacity':'0.0'}, 300, function() {
						div.innerHTML = xmlhttp.responseText;
						$(div).find('ul').css({'opacity':'0.0'});
						$(div).find('ul').animate({'opacity':'1.0'}, 300);
					});
				}
			}
	  	}
	}
	xmlhttp.open("GET", "/scripts_ajax/get_block_calendar_archive_month.php?date="+date+"&dir="+dir, true);
	xmlhttp.send(null);
}

