$(document).ready(function(){
	$('ul.ajaxLoader a.upper').click(function(){		
		var item = this.getAttribute('item');
		
		document.getElementById('textContent'+item).style.display = 'block';
		//nowActiveItem = this.href.charAt(this.href.length-1);

		$('#mainContentBlock'+item).animate({opacity: 1}, 300, function(){
			$(this).css({height: this.offsetHeight+'px'});
			$(this).html('<p>Пожалуйста подождите...</p>');
			$(this).css({opacity:1});
			scrollingToY(500);
			$(this).load('/j4y-programms/?'+'item='+item, {}, function(){
				$(this).css({opacity:1}, 300);
				$(this).css({height: 'auto'});
			});
		});
		
		$('#contentMenuDays'+item).animate({opacity: 1}, 300, function(){
			$(this).css({height: this.offsetHeight+'px'});
			$(this).html('<p>Пожалуйста подождите...</p>');
			$(this).css({opacity:1});
			$(this).load('/j4y-programms/?'+'item='+item+'&day=1', {}, function(){
				$(this).css({opacity:1}, 300);
				$(this).css({height: 'auto'});
			});
		});
		
		$(this).parent().parent().find('li').removeClass('alt');
		$(this).parent().addClass('alt');
		$('#menuDays'+item+'>li').removeClass('alt');
		$('#menuDays'+item+'>li:first').addClass('alt');
		return false;
	});
	$('ul.menu_days a').click(function(){		
		var day = this.getAttribute('day');
		var item = this.getAttribute('item');
		$('#contentMenuDays'+item).animate({opacity: 1}, 300, function(){
			$(this).css({height: this.offsetHeight+'px'});
			$(this).html('<p>Пожалуйста подождите...</p>');
			$(this).css({opacity:1});
			$(this).load('/j4y-programms/?'+'item='+item+'&day='+day, {}, function(){
				$(this).css({opacity:1}, 300);
				$(this).css({height: 'auto'});
			});
		});
		$(this).parent().parent().find('li').removeClass('alt');
		$(this).parent().addClass('alt');
		return false;
	});
});


/* */
scrollingToY = function(){
	var scrollX, scrollY;

	if (document.all)
	{
	 if (!document.documentElement.scrollLeft)
		scrollX = document.body.scrollLeft;
	 else
		scrollX = document.documentElement.scrollLeft;
		   
	 if (!document.documentElement.scrollTop)
		scrollY = document.body.scrollTop;
	 else
		scrollY = document.documentElement.scrollTop;
	}   
	else
	{
	 scrollX = window.pageXOffset;
	 scrollY = window.pageYOffset;
	}
	if ( scrollY < 400 ){
		window.scrollTo( scrollX , scrollY + 50  );
		setTimeout( 'scrollingToY()', 5 );
	}
}