(function(){
		var scaler=Scaler('bg'),els=$('#bg').children(),width=100/els.length;
		var float=$('<span />').css({position:'absolute',color:'#fff',cursor:'pointer',zIndex:2});
		var div=$('<div/>').css({position:'absolute',left:0,bottom:0,marginRight:-20,height:'100%'});
		div.width(els.css({float:'left',width:width+'%'}).length+'00%').append(els);

		var move=function(e){
			float[0].style.left=(e=e||window.event).clientX+20+'px';
			float[0].style.top=e.clientY+20+'px';
		},
		swap=function(e){
			var key=e.type=='click'?(e.clientX>(document.body.clientWidth/2)?40:37):e.keyCode;
			if(key>36&&key<41)div.animate({left:(scaler(key>38?'+1':'-1').to*-1)+'00%'});
		}
		
		$(window).bind('keydown',swap);
		$('#bg').css('cursor','default').append(div,float);
		
		$(".next").click(function(){
			$("#bg").trigger(jQuery.Event("keydown", { keyCode: 39 }));
		});
		$(".prev").click(function(){
				$("#bg").trigger(jQuery.Event("keydown", { keyCode: 37 }));
		});
		$("a.contact").click(function(){
			if($("div.info").css('bottom')=="0px") $("div.info").animate({'bottom':'-90px'},500,'swing');
			else $("div.info").animate({'bottom':0},500,'swing');
		});
})();

function resize() {
	// Calculate window width
	windowWidth = $(window).width();
	
	if((windowWidth>=1920)) {
		$('body').removeClass();
		$('body').addClass('res1920');
	
	// 1600px?
	} else if((windowWidth>=1600)) {
		$('body').removeClass();
		$('body').addClass('res1600');

	// 1440px?
	} else if(windowWidth>=1440) {
		$('body').removeClass();
		$('body').addClass('res1440');

	// 1280px?
	} else if(windowWidth>=1280) {
		$('body').removeClass();
		$('body').addClass('res1280');

	// 1024 and above
	} else if(windowWidth>1130) {
		$('body').removeClass();
		$('body').addClass('res1024plus');
		
	// 1024px and below
	} else {
		$('body').removeClass();
	}
}

// Assign event-handlers
$(document).ready(resize);
$(window).resize(resize);
