jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	}
});

function animateScroll(name){
     	$('html,body').animate({scrollTop: $("a[name='"+name+"']").offset().top},{ "duration":800,"easing":"easeOutExpo"});		
}

$(function(){
	$("#play-video").click(function(){
		//if (ready_for_HTML5) { 
			$("#video-section h1").after('<iframe src="http://www.youtube.com/embed/uFVcM93-pXQ?autoplay=1" frameborder="0" allowfullscreen class="canvas video"></iframe>')
		//} else {
		//	$("#video-section h1").after('<video src="video/infoskjermen.mov" controls="controls" class="canvas"></video>')
		//	document.getElementsByTagName('video')[0].play();
		//}
		$("#video-section").addClass("playing")
		animateScroll("#video")
		
		//document.getElementsByTagName('video')[0].play();
	})	
	$("#hide-video").click(function(){
		//if (ready_for_HTML5) { 
		//	document.getElementsByTagName('video')[0].pause();
		//	$("#video-section").removeClass("playing")
		//} else {
			$("#video-section").removeClass("playing")
			$("iframe.video").remove()
		//}
		animateScroll("#up")
		
	})

	$('a[href*=#]').each(function () {
        $(this).click(function(){
			animateScroll(this.href.split("#")[1])
			return false
		})
    });
})

//function ready_for_HTML5(){
//    return (
//        (navigator.platform.indexOf("iPhone") != -1) ||
//		(navigator.platform.indexOf("iPad") != -1) ||
//        (navigator.platform.indexOf("iPod") != -1)
//    );
//}

