(
	function()
	{

		var scene,
			camera,
			light,
			stats,
			mouseX = 0,
			mouseY = 0,
			windowHalfX = window.innerWidth / 2,
			windowHalfY = window.innerHeight / 2,
			logo,
			LuckLabsL = function ()
			{
				var points = [
					new THREE.Vector2(0, 0),
					new THREE.Vector2(50, 0),
					new THREE.Vector2(50, 200),
					new THREE.Vector2(150, 200),
					new THREE.Vector2(150, 250),
					new THREE.Vector2(0, 250),
					new THREE.Vector2(0, 0)
				];
				THREE.Shape.call( this, points );
			}
			;

		LuckLabsL.prototype = new THREE.Shape();
		LuckLabsL.prototype.constructor = LuckLabsL;

		function initScene()
		{
			var stage = document.getElementById('stage');

			scene = new THREE.Scene();

			camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
			camera.position.z = 1200;
			camera.position.y = 125;
			scene.add(camera);

			light = new THREE.PointLight(0xcccccc, 2);
			light.position.set(0, 500, 1010);
			scene.add(light);

			renderer = new THREE.WebGLRenderer();
			renderer.setSize(window.innerWidth, window.innerHeight);
			
			stage.style.background = '#fff';
			stage.appendChild(renderer.domElement);
		}

		function pointMarker(col)
		{
			var material = new THREE.MeshBasicMaterial(
					{
						color: col || 0xff0000,
						wireframe: false
					}
				),
				geometery = new THREE.SphereGeometry(60),
				mesh = new THREE.Mesh(geometery, material)
				;
			return mesh;
		}

		function initLogo()
		{
			var material = new THREE.MeshLambertMaterial(
					{
						color: 0xffffff,
						wireframe: false
					}
				),
				l1 = (new LuckLabsL()).extrude({amount: 50, bevelEnabled: false}),
				l2 = (new LuckLabsL()).extrude({amount: 50, bevelEnabled: false}),
				mesh1 = new THREE.Mesh(l1, material),
				mesh2 = new THREE.Mesh(l2, material),
				plane = new THREE.Mesh(
					new THREE.PlaneGeometry(400, 400),
					new THREE.MeshLambertMaterial(
						{
							color: 0x23577B,
							doubleSided: true
						}
					)
				)
				;


			logo = new THREE.Object3D();
			logo.add(mesh1);
			logo.add(mesh2);
			mesh1.position.x = -125;
			mesh2.rotation.x = Math.PI;
			mesh2.rotation.y = Math.PI;
			mesh2.position.x = 125;
			mesh2.position.y = 250;
			plane.position.y = 140;
			logo.add(plane);
			scene.add(logo);
		}

		function initStats()
		{
			stats = new Stats();
			stats.domElement.style.position = 'absolute';
			stats.domElement.style.top = '0';
//			document.getElementById('stage').appendChild(stats.domElement);

		}

		function animate()
		{
			requestAnimationFrame( animate );
			render();
			stats.update();
		}

		function render()
		{
//			logo.rotation.y += .01;
			camera.position.x += (mouseX - camera.position.x) * .1;
			camera.position.y += (mouseY - camera.position.y) * .1;
			camera.lookAt(logo);
			renderer.render(scene, camera);
		}

		document.addEventListener(
			'mousemove',
			function(e)
			{
				mouseX = (windowHalfX - e.clientX);
				mouseY = 125 - (windowHalfY - e.clientY);
			},
			false
		);

		initScene();
		initStats();
		initLogo();
		animate();
	}
)();


