//toplink
jQuery.fn.topLink = function(settings) {
	settings = jQuery.extend({
		min: 1,
		fadeSpeed: 200
	}, settings);
	return this.each(function() {
		//listen for scroll
		var el = jQuery(this);
		el.hide(); //in case the user forgot
		jQuery(window).scroll(function() {
			if(jQuery(window).scrollLeft() >= settings.min)
			{
				el.fadeIn(settings.fadeSpeed);
			}
			else
			{
				el.fadeOut(settings.fadeSpeed);
			}
		});
	});
};



	
	$.easing.backout = function (x, t, b, c, d, s) {
		if (s == undefined) s = 0.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	};
	$.easing.easeOutExpo = function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	};





////////**********************************************************///////////////////
////////********************document ready************************///////////////////
////////**********************************************************///////////////////

$.noConflict();
jQuery(document).ready(function($) {

	$("body").removeClass("nojs");
	
	//set the link
	$('#top-link').topLink({
		min: 800,
		fadeSpeed: 500
	});
	//smoothscroll
	$('#top-link').click(function(e) {
		e.preventDefault();
		//$.scrollTo(0,300);
		$.scrollTo(0,350,{easing:'easeOutExpo',axis:'x'});
	});
	
	scrollTips.init();
	
});

var scrollTips = {
	dx : null,
	init : function() {	
		if (window.addEventListener) {
		window.addEventListener("DOMMouseScroll", this.mouseScroll, false);
		} else 	window.onmousewheel = document.onmousewheel = this.mouseScroll;
	},

	mouseScroll : function(e) {
		if (!e) var e = window.event;
		if (window.opera) {delta = event.wheelDelta/120; delta = -delta;}
		if (e.wheelDelta <= 0 || e.detail>=0){  
		window.scrollBy(80,0);
		} else  window.scrollBy(-80,0) ; 
	}
};
