jQuery.fn.spotlight = function () {
	var viewportwidth;
	var viewportheight;
	if (typeof window.innerWidth != 'undefined')
	{
	  viewportwidth = window.innerWidth,
	  viewportheight = window.innerHeight
	}
	else if (typeof document.documentElement != 'undefined'
	 && typeof document.documentElement.clientWidth !=
	 'undefined' && document.documentElement.clientWidth != 0)
	{
	   viewportwidth = document.documentElement.clientWidth,
	   viewportheight = document.documentElement.clientHeight
	}
	else
	{
	   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	var halfwidth = viewportwidth / 2;
	var firstmove = halfwidth + 60;
	var secondmove = halfwidth + -485;
	var maxheight = viewportheight + 800;
	var maxwidth = viewportwidth + 800;
	var leftfirstmove = halfwidth + -61;
	var leftsecondmove = halfwidth + 482;
	var rightfirstmove = halfwidth + 508;
	var rightsecondmove = halfwidth + 492;
	var topfirstmove = viewportheight - 1;
	var finalmove = viewportwidth + 300;
	jQuery.fn.bgleftstart = function () {
		this.css("position","absolute");
		this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() - (halfwidth + 267) + "px");
		return this;
	}
	jQuery.fn.bgrightstart = function () {
		this.css("position","absolute");
		this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + (halfwidth + 487) + "px");
		return this;
	}
	$('#bg-repeat-l').bgleftstart();
	$('#bg-repeat-r').bgrightstart();
	jQuery.fn.spotstart = function () {
		this.css("position","absolute");
		this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + 203 + "px");
		return this;
	}
	jQuery.fn.leftstart = function () {
		this.css("position","absolute");
		this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() - (halfwidth - 203) + "px");
		return this;
	}
	jQuery.fn.rightstart = function () {
		this.css("position","absolute");
		this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + (halfwidth + 202) + "px");
		return this;
	}
	jQuery.fn.topstart = function () {
		this.css("position","absolute");
		this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() - (viewportheight) + 371 + "px");
		return this;
	}
	jQuery.fn.bottomstart = function () {
		this.css("position","absolute");
		this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + (viewportheight) - 370 + "px");
		return this;
	}
		$('#spot').spotstart().animate({
				left: firstmove,
				top: '0',
				height: '+720',
				width: '+460',
				easing: 'linear'
			}, 7000, function(){
				$(this).animate({
					left: secondmove,
					top: '0',
					height: '+750',
					width: '+980',
					easing: 'linear'
					}, 5000, function(){
						$(this).animate({
							left: '-400',
							top: '-400',
							height: maxheight,
							width: maxwidth,
							easing: 'linear'
						}, 3000, function(){$(this).fadeOut().hide(function(){
							$('#image').animate({opacity:0}, 3000);
							$('#static-logo-black').animate({opacity:0}, 3000);
							$('#bg-repeat-l').animate({opacity:0}, 3000);
							$('#bg-repeat-r').animate({opacity:0}, 3000);
							$('#static-logo-white').fadeIn(5000);
							$('#line-x ').fadeIn(5000);
						});});
					});
		});
		$('.left-container').leftstart().animate({
			left: '-'+leftfirstmove,
			top: '0',
			easing: 'linear'
		}, 7000, function(){
			$(this).animate({
				left: '-'+leftsecondmove,
				top: '0',
				easing: 'linear'
			}, 5000, function(){
				$(this).animate({
					left: '-'+finalmove
				}, 3000, function(){$(this).fadeOut().hide();});
			});
		});
		$('.right-container').rightstart().animate({
			left: rightfirstmove,
			top: '0',
			easing: 'linear'
		}, 7000, function(){
			$(this).animate({
				left: rightsecondmove,
				top: '0',
				easing: 'linear'
			}, 5000, function(){
				$(this).animate({
					left: finalmove
				}, 3000, function(){$(this).fadeOut().hide();});
			});
		});
		$('.top-container').topstart().animate({
			top: '-'+topfirstmove,
			easing: 'linear'
		}, 7000, function(){$(this).fadeOut().hide();});
		$('.bottom-container').animate({
			top: '720',
			easing: 'linear'
		}, 7000, function(){$(this).fadeOut().hide();});
	$('.left-container').click(function() {$('#spot').mousedown();});	
	$('.right-container').click(function() {$('#spot').mousedown();});	
	$('.top-container').click(function() {$('#spot').mousedown();});	
	$('.bottom-container').click(function() {$('#spot').mousedown();});	
	$('#spot').mousedown(function() {
		$('.right-container').stop(true, true).hide();
		$('.left-container').stop(true, true).hide();
		$('.top-container').stop(true, true).hide();
		$('.bottom-container').stop(true, true).hide();
		$('#spot').stop(true, true).hide();
		$('#image').animate({opacity:0}, 3000);
		$('#static-logo-black').animate({opacity:0}, 3000);
		$('#bg-repeat-l').animate({opacity:0}, 3000);
		$('#bg-repeat-r').animate({opacity:0}, 3000);
		$('#static-logo-white').fadeIn(5000);
		$('#line-x ').fadeIn(5000);
	});
}
