/*******

	***	Anchor Slider by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	Never have an anchor jumping your content, slide it.

	Don't forget to put an id to your anchor !
	You can use and modify this script for any project you want, but please leave this comment as credit.
	
*****/

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1200
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault();
			var locationHref = window.location.href;
			var elementClick = $(caller).attr("href");
			
			if (secure==1) var destination = $(elementClick).offset().top+document.documentElement.scrollTop; // ie7 und 8
			else var destination = $(elementClick).offset().top;
			$(".content").fadeOut("fast");
			$(".footer").fadeOut("fast");
			
				$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
					window.location.hash = elementClick;
					$(".content").fadeIn("slow");
					$(".footer").fadeIn("slow");
					$("ol.menu a").removeClass("active");
					$(caller).addClass("active");
			});
		  	return false;
		})
	})
}


		
		
function getheight() {
	if (window.innerHeight) return window.innerHeight;
	else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
	else return 0;
	}

var x=0;
var mobile;

$(document).ready(function(){
						   
	$("ol.menu a").anchorAnimate()
	$(document).pngFix(); 	
	$(".scrollable").scrollable({circular:true,
								onSeek: function() {
									$(this).pngFix(); 	
								}
								});
	$(".scrollable2").scrollable({circular:true,
								onSeek: function() {
									$(this).pngFix(); 	
								}
								});
	if (mobile!=1) {
		x=getheight();
		if (x>560) $("body").addClass("noscroll"); else $("body").removeClass("noscroll");
		}
	
	if (mobile==1) $("body").removeClass("noscroll");
	
	if (window.location.hash) {
		$("ol.menu a").removeClass("active");
		$("#m"+window.location.hash.split("#")[1]).addClass("active");
		}
		
	if (mobile!=1) {
		$(window).resize(function(settings) {
			var x=getheight();
			if (x>560) $("body").addClass("noscroll"); else $("body").removeClass("noscroll");			
			document.location.href=window.location.href;
			});
		}
		
		
	});
