$(document).ready(function() {

	Shadowbox.init({
		"overlayColor" : "#fff"
	});

	$('.show').cycle({
		delay : 1000,
		speed : 2000,
		prev  : '.prev', 
		next  : '.next',
		pause : 1
	});
	
	$('.btn .play').hide();
	
	$('.pause').click(function() { 
		$('.show').cycle('pause');
		$(this).hide();
		$('.play').show();
	});
	
	$('.btn .play').click(function() { 
		$('.show').cycle('resume');
		$(this).hide();
		$('.pause').show();
	});

	
	$('.rating a').each(function(){
		$(this).click(function(){
			
			$('.rating a').each(function(){
				$(this).parent().removeClass('active');
			});
		
			$('#currentRating').val($(this).attr('class'));
			$(this).parent().toggleClass('active');
		
			return false;
		});
		
		if($(this).hasClass($('#currentRating').val())) $(this).parent().toggleClass('active');
	});
	
	var isIE = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	
	if($('.sharemailform')) {
		var get = location.href;
		get = get.split('?');
		get = jQuery.inArray('&sharemail=', get);
		
		if(get >= 0) {
			if(isIE) {
				$('.overlay').show().fadeTo('normal', 0.8);
			} else {
				$('.overlay').fadeIn('normal');
			}
		}
	}
	
	$('.sharemailform .close').click(function(){
		$('.overlay').fadeOut('normal');
	});
	
	$('.sharemail').each(function(){
		$(this).click(function(){
			if(isIE) {
				$('.overlay').show().fadeTo('normal', 0.8);
			} else {
				$('.overlay').fadeIn('normal');
			}
		});
	});
	
	function getDim() {
		var doc = document;
		return {
			'width' :  + $(doc.body).width() + 'px',
			'height' : + $(doc.body).height() + $(window).scrollTop() + 'px'
		}
	}
	
	$(window).bind('resize, scroll', function() {
		dimensions = getDim();
		$('.overlay').css(dimensions);
	});
	
//	if(!isIE){
//		$(function() {
//			$(window).scroll(function() {
//				$('#menu').stop(true);
//				$('#menu').animate( { top: $('#menu').position().top }, 100,'easeOutBack', function() {
//					$('#menu').animate({top: ($(window).scrollTop() == 0 ? 0 : $(window).scrollTop() + 10) /* Abstand von oben hinzuaddieren */}, 500, 'easeOutBack');
//				});
//			});
//		});
//	}
});