$(document).ready(function () {

	function tip() {
		xOffset = 10;
		yOffset = 10;
		
		$('.movie p a.link').hover(function(e){											  
			this.t = this.title;
			this.title = "";									  
			$('body').append('<p id="tip">'+ this.t +'</p>');
			$('#tip')
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");		
	    },
		function(){
			this.title = this.t;		
			$('#tip').remove();
	    });	
		$('.movie p a.link').mousemove(function(e){
			$('#tip')
				.css('top',(e.pageY - xOffset) + 'px')
				.css('left',(e.pageX + yOffset) + 'px');
		});
	}
	
	tip();
	function footertip() {
		xOffset = 10;
		yOffset = 10;
		
		$('#footer img').hover(function(e){											  
			this.t = this.title;
			this.title = "";									  
			$('body').append('<p id="tip">'+ this.t +'</p>');
			$('#tip')
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");		
	    },
		function(){
			this.title = this.t;		
			$('#tip').remove();
	    });	
		$('#footer img').mousemove(function(e){
			$('#tip')
				.css('top',(e.pageY - xOffset) + 'px')
				.css('left',(e.pageX + yOffset) + 'px');
		});
	}
	
	footertip();
	
	if($.browser.msie && $.browser.version.substr(0,3)=="7.0"){
		var horizontal = false;
	} else {
		var horizontal = true;
	}
	
	
	var $panels = $('#schedule #scheduleContainer > div');
	var $container = $('#schedule #scheduleContainer');
	var $scroll = $('#schedule #scheduleScroll');
	
	$scroll.css('overflow', 'hidden');

	if (horizontal) {
		$panels.css({
			'float' : 'left',
			'position' : 'relative'
		});
		
		$container.css('width', $panels[0].offsetWidth * $panels.length);
	}
	
	$('#scheduleMenu .scheduleNavigation a').click(selectNav);
	
	function selectNav() {
		$(this)
			.parents('ul:first')
				.find('a')
					.removeClass('active')
		 		.end()
		 	.end()
			.addClass('active');
	}
	
	function trigger(data) {
		var el = $('#scheduleMenu .scheduleNavigation').find('a[href$="' + data.id + '"]').get(0);		
		selectNav.call(el);		

		var dh = $('#scheduleContainer div#'+ data.id).height();
						
		$scroll.animate({ 
			height : dh
		}, 500);	
	}
	
	var d = new Date();
	var wd = new Array(7);
		wd[1]="ma";
		wd[2]="ti";
		wd[3]="ke";
		wd[4]="to";
		wd[5]="pe";
		wd[6]="la";
		wd[0]="su";
		
	if (window.location.hash) {
		trigger({ id : window.location.hash.substr(1) });
	} else {
		trigger({id : wd[d.getDay()] });
	}

	var scrollOptions = {
			target: $scroll,
			items: $panels,
			navigation: '.scheduleNavigation a',
			onAfter: trigger, 		
			axis: 'xy',
			duration: 1000,
			easing: 'swing'
		};
		
		// $('#schedule').serialScroll(scrollOptions);
		
		$.localScroll(scrollOptions);
	
		scrollOptions.duration = 1;
		$.localScroll.hash(scrollOptions);
	
});