<!--
PLAY_NOW='';
if (!window.opera) {
    try {
	  document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
}

function setLazyScroll(lazyScrollObj, lazyScrollName, lazyScrollVisible, lazyScrollKey, lazyScrollDuration) {
	var shiftTotal, shiftCur, shiftFull;
	if ($(lazyScrollObj).length>lazyScrollKey) {
		if ($(lazyScrollObj).length>lazyScrollKey)
			$(lazyScrollName+'_btn2').show();
		shiftTotal = $(lazyScrollObj).length-lazyScrollKey;
		shiftCur = 0;
		(parseInt(shiftTotal/lazyScrollKey)==shiftTotal/lazyScrollKey) ? shiftFull = shiftTotal/lazyScrollKey : shiftFull = parseInt(shiftTotal/lazyScrollKey)+1;
		
		$(lazyScrollName+'_btn1').click(function(){
			if (shiftCur==shiftFull*lazyScrollVisible)
				$(lazyScrollName+'_btn2:hidden').show();
			shiftCur = shiftCur-lazyScrollVisible;
			if (shiftCur>=0) {
				$(lazyScrollName+'_slider').animate({marginLeft : (0-shiftCur)+'px'}, lazyScrollDuration);
				if (shiftCur==0)
					$(this).hide();
			} else 
				shiftCur = shiftCur+lazyScrollVisible;
			return false;
		})
		
		$(lazyScrollName+'_btn2').click(function(){
			if (shiftCur==0)
				$(lazyScrollName+'_btn1:hidden').show();
			shiftCur = shiftCur+lazyScrollVisible;
			if (shiftCur<=shiftFull*lazyScrollVisible) {
				$(lazyScrollName+'_slider').animate({marginLeft : (0-shiftCur)+'px'}, lazyScrollDuration);
				if (shiftCur==shiftFull*lazyScrollVisible)
					$(this).hide();
			} else 
				shiftCur = shiftCur-lazyScrollVisible;
			return false;
		})
	}
}

function playlistClose() {
	if (ie7) {
		$('#playlist').hide();
		$('#player').removeClass('act');
	}
	$('#playlist').fadeOut(200);
}

function prepTime(tm) {
    tm=parseInt(tm/1000);
	var m=parseInt(tm/60);
	tm=tm-m*60;
	return ((m<10? '0':'')+m+':'+(tm<10? '0':'')+tm)
}

function changeTrack(nextTrack) {
    curTrack += nextTrack;
	if (curTrack>$(allTracks).length-1)
		curTrack = 0;
	else if (curTrack<0)
		curTrack = $(allTracks).length-1;
	$(allTracks).eq(curTrack).click();
}

function recalcNewsScroll() {
    curNewsScroll = allNewsScroll - $('#news_notice_in').scrollTop();
	allNewsTimeDown = parseInt(curNewsScroll/0.212);
	allNewsTimeUp = parseInt($('#news_notice_in').scrollTop()/0.212);
}

ipad = (navigator.userAgent.match(/iPad|iPhone|iPod/i)) ? true : false;

if (ipad) {
    clickTrigger = overTrigger = 'touchstart';
	outTrigger = 'touchend';
} else {
	clickTrigger = 'click';
	overTrigger = 'mouseover';
	outTrigger = 'mouseout';
}

inits=[];

$(document).ready(
	function() {
		((!-[1,])&&(jQuery.browser.version < 9)) ? ie = true : ie = false;
		((!-[1,])&&(jQuery.browser.version == 7)) ? ie7 = true : ie7 = false;
		
		//common deeds ---------------------------------------------------------------------------
		if ($('#menu li').length<7) {
    		$('#menu ul').css('text-align','center');
			$('#menu li:last').css('border','none');
		}
		allSubMenus = $('div.submenu').parent();
		$(allSubMenus).mouseenter(function(){
			$('#menu li.act').removeClass('act');
			subMenuNum = $(allSubMenus).index(this);
			t3 = setTimeout("$(allSubMenus).eq(subMenuNum).addClass('act')",300);
		})
		$(allSubMenus).mouseleave(function(){
			$('#menu li.act').removeClass('act');
			if (typeof(t3)!='undefined') clearTimeout(t3);
		})
		
        playTarget = $('#jquery_jplayer_1');
    	allTracks = $("#playlist li a");
		curTrack = 0;
		$('#ptn1').text(' / '+$(allTracks).length);
		
        if (ie7) $('#player_trackbar').wrap('<div style="width: 230px;"></div>');
        
		//player init
		setTimeout(function() {
	        $(playTarget).jPlayer({
	            ready: function () {					            
	    			if(PLAY_NOW!=null && PLAY_NOW!='') 
                        $(allTracks).eq(0).click();
	    		},
	    		swfPath: "/js",
	    		customCssIds: true,
				volume: 10
	    	})
	    	.jPlayer("onProgressChange", function(lp,ppr,ppa,pt,tt) {
	            $("#player_track_load").css("width",lp+"%");
	            $("#player_track_elapse").css("width",ppa+"%");
	            $("#player_track_time").html(prepTime(pt)+'<span> / '+prepTime(tt)+'</span>');
	    	})
	    	.jPlayer("onSoundComplete", function() {
				changeTrack(1);
	    	});
	        
	        // play/pause/stop buttons init
	        $("a.player_controls,#player_btn_mute").click(function() {            
	            $(playTarget).jPlayer($(this).attr("cmd"))
	            return false;
	        });
	        
	        $("#player_btn_mute").click(function() {
	            var cmd=$(this).attr("cmd");
	            var vol;
	            if (cmd=="mute") {
	               $(this).attr("cmd","unmute");
	               vol=0;
	            } else {
	               $(this).attr("cmd","mute"); 
	               vol=10;
	            }
	            $(playTarget).jPlayer('volume',vol);
	            return false;
	        });
	        
			$('#player_control_prev').click(function(){
				changeTrack(-1);
                $('a.track_play.act').removeClass('act');
				return false;
			})
			
			$('#player_control_next').click(function(){
				changeTrack(1);
                $('a.track_play.act').removeClass('act');
				return false;
			})
			
	        // change tracks
	        $(allTracks).click(function() {
				if (!$(this).hasClass('act')) {
		            var l = this.id;
		            $(playTarget).jPlayer('stop').jPlayer('setFile',l).jPlayer('play');
					$(allTracks).not(':not(.act)').add('a.player_controls.act').not('#player_control_play').removeClass('act');
					$(this).add('#player_control_play').addClass('act');
					$('#player_track_name').text($(this).text());
					$('#ptn2').text($(allTracks).index(this)+1);
				}
	            return false;
	        });
	     },1000);
        
		$('#player').mouseenter(function(){
			$('#player_cover').slideUp(100);
			if (typeof(t2)!='undefined') clearTimeout(t2);
		})
		$('#player').mouseleave(function(){
			t2 = setTimeout("$('#player_cover').slideDown(100)", 20000);
		})
		$('#player_btn_mute').click(function(){
			$(this).toggleClass('mute');
            ($(this).hasClass('mute')) ? $(this).attr('title','включить звук') : $(this).attr('title','выключить звук');
			return false;
		})
    	$('#player_control_play').click(function(){
            if ($('player_track_name').text()=='')
    			$(allTracks).eq(0).click();
    		$('a.player_controls.act').removeClass('act');
			$(this).addClass('act');
			return false;
		})
		$('#player_control_pause').click(function(){
			if ($('#player_control_play').hasClass('act')) {
				$('#player_control_play').removeClass('act');
				$(this).addClass('act');
			}
			return false;
		})
		$('#player_control_stop').click(function(){
			$(allTracks).not(':not(.act)').add('a.player_controls.act').removeClass('act');
			$(this).addClass('act');
            $('a.track_play.act').removeClass('act');
			return false;
		})
		$('#player_btn_list').click(function(){
			if (ie7) $('#player').addClass('act');
			$('#playlist').slideDown(100);
			return false;
		})
		$('#playlist a.close').click(function(){
			playlistClose();
			return false;
		})
		$('#playlist').mouseenter(function(){
			if (typeof(t1)!='undefined') clearTimeout(t1);
		})
		$('#playlist').mouseleave(function(){
			t1 = setTimeout('playlistClose()', 1000);
		})
		playlistThumbs = $('#playlist li');
		setLazyScroll(playlistThumbs, '#playlist', 730, 3, 400);
		
		if ($('#main_sched').length>0) {
    		monthThumbs = $('#month table');
			mapMarks = $('#main_sched_map a');
			mapCities = $('#sched_cities a');
			setLazyScroll(monthThumbs, '#month', 380, 2, 300);		
			$('#main_sched td:empty').addClass('no_date');
			$('#main_sched td.the_date').hover(function(){
				$(this).toggleClass('the_date_hover');
			});
			$('#main_sched td.the_date').add(mapMarks).add(mapCities).bind(clickTrigger, function(){
				$('#month:visible').hide();
				if ($('#sched_single_show').is(':visible')) {
					$('#sched_single_show').hide();
					$('#afishadesc').empty();
				}
				if ($(this).attr('date')!=null) {
					$.post("/",{getact:$(this).attr('date')},function(t) {
						if(t!='') {
							$('#afishadesc').html(t);   
						}
					})
	            }
				$('#sched_single_show').slideDown(200);
				return false;
			});
			$('#sched_single_show a.close').click(function(){
				$('#sched_single_show').hide();
				$('#afishadesc').empty();
				$('#month').fadeIn(400);
				$(mapMarks).fadeTo(0,1);
				return false;
			})
			$(mapCities).bind(clickTrigger, function(){
				$(mapMarks).fadeTo(0,1);
				curCity = $(mapCities).index(this);
				$(mapMarks).not(':eq('+curCity+')').fadeTo(200,0);
                return false;
			})
            if (ipad) {
    			$(mapCities).click(function(){
					return false;
				})
			}
			$('#main_sched_btn2 a').click(function(){
				if ($('#sched_shows').is(':visible')) {
					$('#sched_shows').hide();
					$('#main_sched_map,#month,#sched_cities').fadeIn(400);
				} else {
					$(mapMarks).fadeTo(0,1);
					$('#main_sched_map,#month,#sched_single_show,#sched_cities').hide();
					$('#afishadesc').empty();
					$('#sched_shows').slideDown(200);
				}
				$(this).toggleClass('act');
				return false;
			})
			showThumbs = $('#sched_shows li');
			setLazyScroll(showThumbs, '#sched_shows', 776, 3, 400);
		}
		
		if (!$('body').hasClass('inner')) { //main page only ---------------------------------------------------------------------------
			
			$('#jumbo a.close').click(function(){
				$('#jumbo').fadeOut(400);
				return false;
			})
			
			$('#top_video li a').click(function(){
    			if (!$(this).parents('li').hasClass('act')) {
					$('#jquery_jplayer_1').jPlayer("pause");
                    $('#player_control_pause').click();
                    tubeCode = $(this).attr('href');
					$('#top_video li.act').removeClass('act');
					$(this).parents('li').addClass('act');
					$('#screen:hidden').fadeIn(400);
					$('#screen_in').html('<iframe width="560" height="315" src="http://www.youtube.com/embed/'+tubeCode+'?autoplay=1&rel=0&hd=1" frameborder="0" allowfullscreen></iframe>').not(':visible').show();                    
				}
				return false;
			})
            
            $('#video_run a').click(function(){
               $('#jquery_jplayer_1').jPlayer("pause");
               $('#player_control_pause').click();
               $(this).parent().html('<iframe width="640"  height="360" src="'+this.href+'" frameborder="0" allowfullscreen></iframe>'); 
               return false;
            });
			
			videoThumbs = $('#top_video li');
			setLazyScroll(videoThumbs, '#top_video', 899, 6, 600);
			
			$('#top_video_switch').click(function(){
				if (!$(this).hasClass('act')) {
					$('#top_video').animate({height:'128px'}, 200, function(){
						$('#top_video_switch').addClass('act').text('Закрыть видео');
						$('#top_video_container').fadeIn(400);
					});
				} else {
					$(this).removeClass('act').text('Посмотреть видео');
					$('#top_video_container').hide();
					$('#top_video li.act').removeClass('act');
					$('#top_video').animate({height:'26px'}, 200, function(){
						$('#screen_in').hide().empty();
						$('#screen').fadeOut(400);
					});
				}
				return false;
			})
			
			if (ipad) $('#news_notice_in').css('margin-right','0');
    		$('#news_notice_in').scrollTop(0);
			var allNewsHeight = 0;
			$('.news_notice').each(function(){
				allNewsHeight += $(this).height()+25;
			})
			if (allNewsHeight>319) {
				$('#news_notice_btn2').show();
				allNewsScroll = curNewsScroll = allNewsHeight - 319;
				allNewsTimeDown = parseInt(allNewsScroll/0.212);
			}
			$('a.news_notice_btn').click(function(){
				if (!ipad) return false;
			})
			$('#news_notice_btn1').bind(overTrigger, function(){
				setTimeout("$('#news_notice_btn2').show()",200);
				$('#news_notice_in').animate({'scrollTop': 0}, allNewsTimeUp, function(){
					$('#news_notice_btn1').hide();
				});
				return false;
			})
			$('#news_notice_btn2').bind(overTrigger, function(){
				setTimeout("$('#news_notice_btn1').show()",200);
				$('#news_notice_in').animate({'scrollTop': $('#news_notice_in').scrollTop()+curNewsScroll}, allNewsTimeDown, function(){
					$('#news_notice_btn2').hide();
				});
				return false;
			})
			$('a.news_notice_btn').bind(outTrigger, function(){
				recalcNewsScroll();
				$("#news_notice_in").stop(true);
			})
			
			$('#news_notice_in').mouseout(function(){
				recalcNewsScroll();
			})
		    
            if (ipad) {
    			$('#album_slider').width($('div.album_case1').length*124);
				$('#album_container').show();
				var myScroll = new iScroll('album_container', { hScrollbar: false, vScroll: false, bounce: false });
			} else {
				$('#album_slider').width($('div.album_case1').length*124+35);
				$('#album_container').show();
				allAlbums = $('div.album_case1 a');
				
				$(allAlbums).mouseenter(function(){
					if ($(allAlbums).index(this)==$(allAlbums).length-1) {
						$('#album_container').width(912);
					}
					$(this).parents('div.album_case1').animate({
						top: '0',
						width: '165px'
					},200)
					$(this).parents('div.album_case2').animate({
						height: '150px',
						marginLeft: '14px'
					},200)
					$(this).parents('div.album_cover').animate({
						height: '177px'
					},200)
				})
				
				$(allAlbums).mouseleave(function(){
					curAlbum = $(this);
					$(this).parents('div.album_case1').animate({
						top: '9px',
						width: '100px'
					},200)
					$(this).parents('div.album_case2').animate({
						height: '92px',
						marginLeft: '7px'
					},200)
					$(this).parents('div.album_cover').animate({
						height: '120px'
					},200)
				})
				
				scrollPane = $('#album_container')
				scrollContent = $('#album_slider');
				if ($(allAlbums).length>7) {
					$('#album_scroll_wrapper').show();
					$('#album_scroll').slider({
						slide: function(event,ui) {
							scrollContent.css('margin-left', Math.round(ui.value/100*(scrollPane.width()-scrollContent.width()))+'px');
						},
						start: function(event,ui) {
							$('#album_container').width(872);
							$('#album_scroll_wrapper').addClass('act');
						},
						stop: function(event,ui) {
							$('#album_scroll_wrapper').removeClass('act');
						}
					});
				}
			}
            
		} else { //inner pages only ---------------------------------------------------------------------------
            
            if (ie7) $('#progress1-scale').wrap('<div style="width: 304px;"></div>');
            
            $('.form_input').focus(function(){
    			$(this).css({'border-color':'#085495','color':'#000'})
			})
			$('.form_input').blur(function(){
				$(this).removeAttr('style');
			})
			$('button').mouseover(function(){
				$(this).css({'color':'#bd151a'})
			})
			$('button').mouseout(function(){
				$(this).removeAttr('style');
			})
            
            $('a.thickbox,a.lightbox').thickbox();
		}
        
        for(var i=0;i<inits.length;i++) inits[i]();           
	}
);

$(window).load(
    function() {
		pageHeight = $('#page_container').height();
		$('div.page_border').height(pageHeight-122);
		if (pageHeight<1500) $('#page_back').height(1500-(1500-pageHeight));
	}
);

// -->

