$(document).ready(function() {

	//////////////////// GO TO TOP ////////////////////
	//Hide skGoToTop
	$("#skGoToTop").hide();

	//Event handler for window scroll
	$(window).scroll(function() {
		$("#skGoToTop").show();
		var scrollTop = $(window).scrollTop();

		var uA = navigator.userAgent;
		
		if (uA.match(/iPhone/i) || uA.match(/iPad/i) || uA.match(/iPod/i) || uA.match(/Android/i)) {
			return;
		}
		else {
			if (scrollTop > 150){
				//$("#skGoToTop").stop().animate({'opacity': '1'}, 'slow');
				$("#skGoToTop").stop().fadeTo("slow",1);
			}
			else {
				//$("#skGoToTop").stop().animate({'opacity': '0'}, 'slow');
				$("#skGoToTop").stop().fadeTo("slow",0, function() {
					$("#skGoToTop").hide();	
					});
			}
		}
	});

	
	//Event handler
	$('a[href=#top]').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});

	//Event handler
	$('a[href=#top]').hover(
		function() {
			var image = "url(./images/skGoToTop_hover.png)";
			$("#skGoToTop").css('background-image',image);
		},
		function() {
			var image = "url(./images/skGoToTop.png)";
			$("#skGoToTop").css('background-image',image);
	});
	//////////////////// GO TO TOP ////////////////////
});

