/*
* FPLLP Website animation
* 
* Version: 1.0
*
*
*
*
*
*
*/
		/* -------------------------------------------------------------------- */
 
		var canvas, ctx;
		var canvasWidth, halfCanvasWidth;
		var canvasHeight, halfCanvasHeight;
 
		var space;  // 3D Engine
		var scene;  // 3D Scene
 
		/* -------------------------------------------------------------------- */
 
		/**
		 * Space is a simple 3D system.
		 *
		 * Y+ = up
		 * Z+ = into screen
		 * X+ = right
		 */
		 
		function Space() {
			this.m = this.createMatrixIdentity();
			this.mStack = [];
		}
 
		Space.prototype.createMatrixIdentity = function() {
			return [
				[1, 0, 0, 0],
				[0, 1, 0, 0],
				[0, 0, 1, 0],
				[0, 0, 0, 1]
			];
		}
 
		/**
		 * Multiplies two 4x4 matricies together.
		 */
		Space.prototype.matrixMultiply = function(m1, m2) {
			var result = this.createMatrixIdentity();
 
			var width = m1[0].length;
			var height = m1.length;
 
			if (width != m2.length) {
				// error
			}
 
			for (var x = 0; x < width; x++) {
				for (var y = 0; y < height; y++) {
					var sum = 0;
 
					for (var z = 0; z < width; z++) {
						sum += m1[y][z] * m2[z][x];
					}
 
					result[y][x] = sum;
				}
			}
 
			return result;
		}
 
		/**
		 * Transforms a coordinate using the current transformation
		 * matrix, then flattens it using the projection matrix.
		 */
		Space.prototype.flatten = function(point) {
			var p = [[point.x, point.y, point.z, 1]];
			var pm = this.matrixMultiply(p, this.m);
 
			point.tx = pm[0][0];
			point.ty = pm[0][1];
			point.tz = pm[0][2];
 
			// lazy projection
			point.fx = halfCanvasWidth + (canvasWidth * point.tx / point.tz);
			point.fy = halfCanvasHeight -(canvasWidth * point.ty / point.tz);
		}
 
		/**
		 * Translate (move) the current transformation matrix
		 */
		Space.prototype.translate = function(x, y, z) {
			var m = [
				[1, 0, 0, 0],
				[0, 1, 0, 0],
				[0, 0, 1, 0],
				[x, y, z, 1]
			];
 
			this.m = this.matrixMultiply(m, this.m);
		}
 
		/**
		 * Rotate the current transformation matrix. Rotations are
		 * world-oriented, and occur in y,x,z order.
		 */
		Space.prototype.rotate = function(x, y, z) {
			if (y) {
				var cosY = Math.cos(y);
				var sinY = Math.sin(y);
				var rotY = [
					[cosY, 0, sinY, 0],
					[0, 1, 0, 0],
					[-sinY, 0, cosY, 0],
					[0, 0, 0, 1]
				];
 
				this.m = this.matrixMultiply(this.m, rotY);
			}
 
			if (x) {
				var cosX = Math.cos(x);
				var sinX = Math.sin(x);
				var rotX = [
					[1, 0, 0, 0],
					[0, cosX, -sinX, 0],
					[0, sinX, cosX,0],
					[0, 0, 0, 1]
				];
				this.m = this.matrixMultiply(this.m, rotX);
			}
 
			if (z) {
				var cosZ = Math.cos(z);
				var sinZ = Math.sin(z);
				var rotZ = [
					[cosZ, -sinZ, 0, 0],
					[sinZ, cosZ, 0, 0],
					[0, 0, 1, 0],
					[0, 0, 0, 1]
				];
 
				this.m = this.matrixMultiply(this.m, rotZ);
			}
		}
 
		/**
		 * Pushes the current transformation onto the stack
		 */
		Space.prototype.push = function() {
			this.mStack.push(this.m);
			this.m = [
				[this.m[0][0], this.m[0][1], this.m[0][2], this.m[0][3]],
				[this.m[1][0], this.m[1][1], this.m[1][2], this.m[1][3]],
				[this.m[2][0], this.m[2][1], this.m[2][2], this.m[2][3]],
				[this.m[3][0], this.m[3][1], this.m[3][2], this.m[3][3]]
			];
		}
 
		/**
		 * Pops the end off the transformation stack
		 */
		Space.prototype.pop = function() {
			this.m = this.mStack.pop();
		}
 
		/* -------------------------------------------------------------------- */
 
		/**
		 * A 3d coordinate
		 */
		function Point(x, y, z) {
			this.x = x;
			this.y = y;
			this.z = z;
 
			// Relative to camera coordinates
			this.tx;
			this.ty;
			this.tz;
 
			// Flattened coordinates
			this.fx;
			this.fy;
		}
 
		/**
		 * A Shape is made up of polygons
		 */
		function Shape() {
			this.points = [];
			this.polygons = [];
		}
 
 
 		Shape.prototype.rotate = function(x, y, z, angle) {
			//for each point in a shape we must rotate that point.  All rotation are done about the center of an object
			
				angle = angle * Math.PI / 180.0;
				//calculate center point of shape.  This is based on an averaging of all the shapes points 
				var avgX = 0.0;
				var avgY = 0.0;
				var avgZ = 0.0;
				for (var i = 0; i< this.points.length; i++){
					avgX += this.points[i].x;
					//avgY += this.points[i].y;
					avgZ += this.points[i].z ;
				}
				avgX = avgX / this.points.length;
				//avgY = avgY / this.points.length;
				avgZ = avgZ / this.points.length;
				
				for(var i =0; i< this.points.length; i++){
					var dx = this.points[i].x - avgX;
					//var dy = this.points[i].y - avgY;
					var dz = this.points[i].z - avgZ; 
					var a = Math.atan2(dx, dz);
					var dist = Math.sqrt(dx * dx + dz * dz);
					var a2 = a+angle;
					var dx2 = Math.sin(a2) * dist;
					var dz2 = Math.cos(a2) * dist;
					
					this.points[i].x = dx2 + avgX;
					this.points[i].z = dz2 + avgZ;
				}
				//reoriginShape(this);
		}
 
 
		/**
		 * Draws the shape
		 */
		Shape.prototype.draw = function(drawlist) {
			for (var i = 0; i< this.points.length; i++) {
				space.flatten(this.points[i]);
			}
 
			for (var i = 0; i< this.polygons.length; i++) {
				var poly = this.polygons[i]; // convenience
 
				space.flatten(poly.origin);
 
				// lazy backface culling
				if (poly.normal && this.backface) {
					space.flatten(poly.normal);
 
					var originDist = Math.pow(poly.origin.tx, 2)
												 + Math.pow(poly.origin.ty, 2)
												 + Math.pow(poly.origin.tz, 2);
 
					var normalDist = Math.pow(poly.normal.tx, 2)
												 + Math.pow(poly.normal.ty, 2)
												 + Math.pow(poly.normal.tz, 2);
 
					if(originDist > normalDist) {
						drawlist.push(poly);
					}
				} else {
					drawlist.push(poly);
				}
			}
		}
 
		/**
		 * A polygon is a connection of points in the shape object. You
		 * should probably try to make them coplanar.
		 */
		function Polygon(points, normal, backface, type, color) {
			this.points = points;
			this.origin = new Point(0, 0, 0);
			for(var i = 0; i < this.points.length; i++) {
				this.origin.x += this.points[i].x;
				this.origin.y += this.points[i].y;
				this.origin.z += this.points[i].z;
			}
 
			this.origin.x /= this.points.length;
			this.origin.y /= this.points.length;
			this.origin.z /= this.points.length;
 
			if (normal) {
				this.normal = new Point(this.origin.x + normal.x,
																this.origin.y + normal.y,
																this.origin.z + normal.z);
			} else {
				this.normal = null;
			}
 
			this.backface = backface;
			this.type = type;
			this.color = color;
		}
 
		Polygon.SOLID = 0;
		Polygon.WIRE = 1;
 
		/**
		 * Draws the polygon. Assumes that the points have already been
		 * flattened.
		 */
		Polygon.prototype.draw = function() {
			ctx.beginPath();
			ctx.moveTo(this.points[0].fx, this.points[0].fy);
 
			for(var i = 0; i < this.points.length; i++) {
				ctx.lineTo(this.points[i].fx, this.points[i].fy);
			}
 
			ctx.closePath();
 
			var color = this.color;
 
			/*
			// Do lighting here
			lightvector = Math.abs(this.normal.x + this.normal.y);
			if(lightvector > 1) {
				lightvector = 1;
			}
 
			color[0] = (color[0] * lightvector).toString();
			color[1] = (color[1] * lightvector).toString();
			color[2] = (color[2] * lightvector).toString();
			*/
 
			if (color.length > 3) {
				var style = ["rgba(",
				             color[0], ",",
				             color[1], ",",
				             color[2], ",",
				             color[3], ")"].join("");
			} else {
				var style = ["rgb(",
				             color[0], ",",
				             color[1], ",",
				             color[2], ")"].join("");
			}
 
			if (this.type == Polygon.SOLID) {
				ctx.fillStyle = style;
				ctx.fill();
			} else if (this.type == Polygon.WIRE) {
				ctx.strokeStyle = style;
				ctx.stroke();
			}
		}
 
		/* -------------------------------------------------------------------- */
 
		/**
		 * Scene describes the 3D environment
		 */
		function Scene() {
			this.shapes = {};
			this.camera = new Point(0, 0, 0);
			this.cameraTarget = new Point(0, 0, 0);
			this.cameraRotation = 0;
 
			this.drawlist = [];
		}
 
		/**
		 * Draw the world
		 */
		Scene.prototype.draw = function() {
			space.push();
 
			// Camera transformation
			space.translate(
				-this.camera.x,
				-this.camera.y,
				-this.camera.z
			);
 
			// Camera rotation
			var xdiff = this.cameraTarget.x - this.camera.x;
			var ydiff = this.cameraTarget.y - this.camera.y;
			var zdiff = this.cameraTarget.z - this.camera.z;
 
			var xzdist = Math.sqrt(Math.pow(xdiff, 2) + Math.pow(zdiff, 2));
 
			var xrot = -Math.atan2(ydiff, xzdist); // up/down rotation
			var yrot =  Math.atan2(xdiff, zdiff);  // left/right rotation
 
			space.rotate(xrot, yrot, this.cameraRotation);
 
			// Drawing
			this.drawlist = [];
 
			for(var i in this.shapes) {
				this.shapes[i].draw(this.drawlist);
			}
 
			// Depth sorting (warning: this is only enough to drive this demo - feel
			// free to contribute a better system).
			this.drawlist.sort(function (poly1, poly2) {
				return poly1.origin.z - poly2.origin.z;
			});
 
			for (var i = 0; i < this.drawlist.length; i++) {
				this.drawlist[i].draw();
			}
 
			space.pop();
		}
 
		/* -------------------------------------------------------------------- */
 
		//var count = 0;
 
		function loop() {
			ctx.clearRect(0, 0, canvasWidth, canvasHeight);
			//scene.camera.x = 70*Math.sin(count);
			scene.camera.x = 0;
			scene.camera.y = 0;
			//scene.camera.z = 70*Math.cos(count);
			scene.camera.z = 220;
			//scene.cameraRotation = count / 5;
			//count += 0.02;
			scene.draw();
		}
		
		function opacityShape(shape, opacity){
			var colorHold;
			var arLen = shape.polygons.length;
			for (var i =0, len = arLen; i<len; ++i)
			{
				shape.polygons[i].color[3] = opacity; 
			}
		}
		
		var moveLeftInterval
		function moveLeft(){
			moveLeftInterval = setInterval('moveLeftDelay()', 20);
		}
		
		var moveLeftCount = 0;
		function moveLeftDelay(){
			moveLeftCount += 1;
			moveShape(scene.shapes['book'], 9, 0, 0);
			opacityShape(scene.shapes['book'],  (100-(moveLeftCount*8))/100);//100 to 60 in 5 steps
			moveShape(scene.shapes['book2'], 9, 0, 0);
			opacityShape(scene.shapes['book2'],  (60-(moveLeftCount*8))/100);//60 to 20 in 5 steps
			moveShape(scene.shapes['book3'], 9, 0, 0);
			opacityShape(scene.shapes['book3'],  (60+(moveLeftCount*8))/100);//60 to 100 in 5 steps
			moveShape(scene.shapes['book4'], 9, 0, 0);
			opacityShape(scene.shapes['book4'],  (20+(moveLeftCount*8))/100);//20 to 60 in 5 steps
			moveShape(scene.shapes['book5'], 9, 0, 0);
			opacityShape(scene.shapes['book5'],  (20-(moveLeftCount*4))/100);//20 to 0 in 5 steps
			moveShape(scene.shapes['book6'], 9, 0, 0);
			opacityShape(scene.shapes['book6'],  (0+(moveLeftCount*4))/100);//0 to 20 in 5 steps

			loop();
			if(moveLeftCount == 5){
				moveLeftCount = 0;
				clearInterval(moveLeftInterval);
				//move all shapes back to original position
				moveShape(scene.shapes['book'], -45, 0, 0);
				opacityShape(scene.shapes['book'], 1);
				moveShape(scene.shapes['book2'], -45, 0, 0);
				opacityShape(scene.shapes['book2'], 0.6);
				moveShape(scene.shapes['book3'], -45, 0, 0);
				opacityShape(scene.shapes['book3'], 0.6);
				moveShape(scene.shapes['book4'], -45, 0, 0);
				opacityShape(scene.shapes['book4'], 0.2);
				moveShape(scene.shapes['book5'], -45, 0, 0);
				opacityShape(scene.shapes['book5'], 0.2);
				moveShape(scene.shapes['book6'], -45, 0, 0);
				opacityShape(scene.shapes['book6'], 0);		
				moveF(8);
			}
		}
		  
		var PageFlip = 'HomePage'
		function moveB(speed, PageName){ 
			PageFlip = PageName;
			rotateCCW(speed);
		}
		
		var rotateCCWInterval;
		var rotateCCWSpeed = 0;
		function rotateCCW(speed){				
			rotateCCWSpeed = speed;
			rotateCCWInterval = setInterval("rotateCCWDelay(rotateCCWSpeed)", 20);
		}
		
		var rotateCCWCount = 0;
		function rotateCCWDelay(speed){
			rotateCCWCount += 1;
			scene.shapes['book'].rotate(false, true, false, -speed);
			if(rotateCCWCount == Math.abs(45/speed)){
				var hold = scene.shapes['book'].polygons[0].origin.z;
				scene.shapes['book'].polygons[0].origin.z = scene.shapes['book'].polygons[1].origin.z;
				scene.shapes['book'].polygons[1].origin.z = hold;
			}
			loop();
			if(rotateCCWCount >= Math.abs(90/speed)) {
				rotateCCWCount = 0;
				clearInterval(rotateCCWInterval);
				moveBaR(8);
			}
		}		
		
		var moveBaRSpeed = 0;
		var moveBaRInterval;	
		function moveBaR(speed){
			moveBaRSpeed = speed;
			moveBaRInterval = setInterval('moveBaRDelay(moveBaRSpeed)', 20);
		}
		
		var moveBaRCount = 0;
		function moveBaRDelay(speed){
			moveBaRCount += 1;
			moveShape(scene.shapes['book'], 0, 0, -speed);
			loop();
			
			if(moveBaRCount == Math.abs(80/speed)){
				moveBaRCount = 0;
				clearInterval(moveBaRInterval);
				moveLeft();
			}
		}
		
		var moveFSpeed = 0;
		var moveFInterval;
		function moveF(speed){
			moveFSpeed = speed;
			moveFInterval = setInterval('moveFDelay(moveFSpeed)', 20);
		}
		
		var moveFCount = 0;
		function moveFDelay(speed){
			moveFCount += 1;
			moveShape(scene.shapes['book'], 0, 0, speed);
			loop();
			
			if(moveFCount == Math.abs(80/speed)){
				moveFCount = 0;
				clearInterval(moveFInterval);
				rotateCW(9);
			}
		}
		
		var rotateCWInterval;
		var rotateCWSpeed = 0;
		function rotateCW(speed){				
			rotateCWSpeed = speed;
			rotateCWInterval = setInterval("rotateCWDelay(rotateCWSpeed)", 20);
		}
		
		var rotateCWCount = 0;
		function rotateCWDelay(speed){
			rotateCWCount += 1;
			scene.shapes['book'].rotate(false, true, false, speed);
			if(rotateCWCount == Math.abs(45/speed)){
				var hold = scene.shapes['book'].polygons[0].origin.z;
				scene.shapes['book'].polygons[0].origin.z = scene.shapes['book'].polygons[1].origin.z;
				scene.shapes['book'].polygons[1].origin.z = hold;
			}
			loop();
			if(rotateCWCount >= Math.abs(90/speed)) {
				rotateCWCount = 0;
				clearInterval(rotateCWInterval);
				showContent();
			}
		}
		
		function showContent(){
			if(PageFlip == "AttPaulFordPage"){
				document.getElementById('AttPaulFordPage').innerHTML = '<a><img src="Pages/PaulFord.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "AttWalterPaulekasPage"){
				document.getElementById('AttWalterPaulekasPage').innerHTML = '<a><img src="Pages/WalterPaulekas.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "AttScottConsoliPage"){
				document.getElementById('AttScottConsoliPage').innerHTML = '<a><img src="Pages/ScottConsoli.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "AttDavidHillPage"){
				document.getElementById('AttDavidHillPage').innerHTML = '<a><img src="Pages/DavidHill.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "AttLawrenceDvorinPage"){
				document.getElementById('AttLawrenceDvorinPage').innerHTML = '<a><img src="Pages/LawrenceDvorin.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "AttMatthewYoumansPage"){
				document.getElementById('AttMatthewYoumansPage').innerHTML = '<a><img src="Pages/MatthewYoumans.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "AttEleanorBortolanPage"){
				document.getElementById('AttEleanorBortolanPage').innerHTML = '<a><img src="Pages/EleanorBortolan.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "AttEdwardLonginottiPage"){
				document.getElementById('AttEdwardLonginottiPage').innerHTML = '<a><img src="Pages/EdwardLonginotti.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "DirectionsPage"){
				document.getElementById('DirectionsPage').innerHTML = '<a><img src="Pages/Directions.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "FirmDirectoryPage"){
				document.getElementById('FirmDirectoryPage').innerHTML = '<a><img src="Pages/FirmDirectory.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "HistoryPage"){
				document.getElementById('HistoryPage').innerHTML = '<a><img src="Pages/History.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "AttorneysPage"){
				document.getElementById('AttorneysPage').innerHTML = '<a><img src="Pages/Attorneys.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "PracticeAreasPage"){
				document.getElementById('PracticeAreasPage').innerHTML = '<a><img src="Pages/PracticeAreas.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "PraCommercialPage"){
				document.getElementById('PraCommercialPage').innerHTML = '<a><img src="Pages/Commercial.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "PraInsolvencyPage"){
				document.getElementById('PraInsolvencyPage').innerHTML = '<a><img src="Pages/Insolvency.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "PraRealEstatePage"){
				document.getElementById('PraRealEstatePage').innerHTML = '<a><img src="Pages/RealEstate.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "PraRealEstateLitigationPage"){
				document.getElementById('PraRealEstateLitigationPage').innerHTML = '<a><img src="Pages/RealEstateLitigation.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "PraCorporateAndEmploymentPage"){
				document.getElementById('PraCorporateAndEmploymentPage').innerHTML = '<a><img src="Pages/CorporateAndEmploymentLaw.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "PraLendingPage"){
				document.getElementById('PraLendingPage').innerHTML = '<a><img src="Pages/Lending.PNG" class="PageVisible" /></a>';
			}
			if(PageFlip == "PraTrustsAndEstatesPage"){
				document.getElementById('PraTrustsAndEstatesPage').innerHTML = '<a><img src="Pages/TrustsAndEstates.PNG" class="PageVisible" /></a>';
			}
			hideAllPages();
			if(PageFlip.substr(0, 3) == "Att"){
				$('#divAttorneyNavigation').show('fast');
			}
			if(PageFlip.substr(0, 3) == "Pra"){
				$('#divPracticeNavigation').show('fast');
			}
			if(PageFlip.substr(0, 3) == "Fir"){
				$('#divDirectory').show('fast');
			}
			if(PageFlip == "AttPaulFordPage"){
				hideAllVcards();
				hideAllEmails();
				$('#VCardSelection').show('fast');
				$('#vcardPFord').show('fast');
				$('#emailLinks').show('fast');
				$('#emailPFord').show('fast');
			}
			if(PageFlip == "AttWalterPaulekasPage"){
				hideAllVcards();
				hideAllEmails();
				$('#VCardSelection').show('fast');
				$('#vcardWPaulekas').show('fast');
				$('#emailLinks').show('fast');
				$('#emailWPaulekas').show('fast');
			}
			if(PageFlip == "AttScottConsoliPage"){
				hideAllVcards();
				hideAllEmails();
				$('#VCardSelection').show('fast');
				$('#vcardSConsoli').show('fast');
				$('#emailLinks').show('fast');
				$('#emailSConsoli').show('fast');
			}
			if(PageFlip == "AttDavidHillPage"){
				hideAllVcards();
				hideAllEmails();
				$('#VCardSelection').show('fast');
				$('#vcardDHill').show('fast');
				$('#emailLinks').show('fast');
				$('#emailDHill').show('fast');
			}
			if(PageFlip == "AttLawrenceDvorinPage"){
				hideAllVcards();
				hideAllEmails();
				$('#VCardSelection').show('fast');
				$('#vcardLDvorin').show('fast');
				$('#emailLinks').show('fast');
				$('#emailLDvorin').show('fast');
			}
			if(PageFlip == "AttMatthewYoumansPage"){
				hideAllVcards();
				hideAllEmails();
				$('#VCardSelection').show('fast');
				$('#vcardMYoumans').show('fast');
				$('#emailLinks').show('fast');
				$('#emailMYoumans').show('fast');
			}
			if(PageFlip == "AttEleanorBortolanPage"){
				hideAllVcards();
				hideAllEmails();
				$('#VCardSelection').show('fast');
				$('#vcardLBortolan').show('fast');
				$('#emailLinks').show('fast');
				$('#emailLBortolan').show('fast');
			}
			if(PageFlip == "AttEdwardLonginottiPage"){
				hideAllVcards();
				hideAllEmails();
				$('#VCardSelection').show('fast');
				$('#vcardELonginotti').show('fast');
				$('#emailLinks').show('fast');
				$('#emailELonginotti').show('fast');
			}
			if(PageFlip == "DirectionsPage"){
				loadMapa();
				$('#directionsMap').show('fast');
			}
			$('#divContent').show('fast');
			$('#'+PageFlip).show('fast');
			redrawAllDivs();	
		}
		
		function hideAllVcards(){
			$('#vcardPFord').hide();
			$('#vcardWPaulekas').hide();
			$('#vcardSConsoli').hide();
			$('#vcardDHill').hide();
			$('#vcardLDvorin').hide();
			$('#vcardMYoumans').hide();
			$('#vcardLBortolan').hide();
			$('#vcardELonginotti').hide();
		}
		
		function redrawAllDivs(){
			$('#HomePage').forceRedraw(true);
			$('#HistoryPage').forceRedraw(true);
			$('#AttorneysPage').forceRedraw(true);
			$('#PracticeAreasPage').forceRedraw(true);
			$('#DirectionsPage').forceRedraw(true);
			$('#FirmDirectoryPage').forceRedraw(true);
			$('#AttPaulFordPage').forceRedraw(true);
			$('#AttScottConsoliPage').forceRedraw(true);
			$('#AttWalterPaulekasPage').forceRedraw(true);
			$('#AttDavidHillPage').forceRedraw(true);
			$('#AttLawrenceDvorinPage').forceRedraw(true);
			$('#AttMatthewYoumansPage').forceRedraw(true);
			$('#AttEdwardLonginottiPage').forceRedraw(true);
			$('#AttEleanorBortolanPage').forceRedraw(true);
			$('#divAttorneyNavigation').forceRedraw(true);
			$('#PraCommercialPage').forceRedraw(true);
			$('#PraRealEstateLitigationPage').forceRedraw(true);
			$('#PraInsolvencyPage').forceRedraw(true);
			$('#PraRealEstatePage').forceRedraw(true);
			$('#PraLendingPage').forceRedraw(true);
			$('#PraCorporateAndEmploymentPage').forceRedraw(true);
			$('#PraTrustsAndEstatesPage').forceRedraw(true);
			$('#divPracticeNavigation').forceRedraw(true);
			$('#divDirectory').forceRedraw(true);
			$('#VCardSelection').forceRedraw(true);
			$('#emailLinks').forceRedraw(true);
			$('#directionsMap').forceRedraw(true);
			$('#vcardPFord').forceRedraw(true);
			$('#vcardWPaulekas').forceRedraw(true);
			$('#vcardSConsoli').forceRedraw(true);
			$('#vcardDHill').forceRedraw(true);
			$('#vcardLDvorin').forceRedraw(true);
			$('#vcardMYoumans').forceRedraw(true);
			$('#vcardLBortolan').forceRedraw(true);
			$('#vcardELonginotti').forceRedraw(true);
			$('#emailPFord').forceRedraw(true);
			$('#emailWPaulekas').forceRedraw(true);
			$('#emailSConsoli').forceRedraw(true);
			$('#emailDHill').forceRedraw(true);
			$('#emailLDvorin').forceRedraw(true);
			$('#emailMYoumans').forceRedraw(true);
			$('#emailLBortolan').forceRedraw(true);
			$('#emailELonginotti').forceRedraw(true);
		}
		
		function hideAllEmails(){
			$('#emailPFord').hide();
			$('#emailWPaulekas').hide();
			$('#emailSConsoli').hide();
			$('#emailDHill').hide();
			$('#emailLDvorin').hide();
			$('#emailMYoumans').hide();
			$('#emailLBortolan').hide();
			$('#emailELonginotti').hide();
		}
		
		function hideAllPages(){
			$('#HomePage').hide();
			$('#HistoryPage').hide();
			$('#AttorneysPage').hide();
			$('#PracticeAreasPage').hide();
			$('#DirectionsPage').hide();
			$('#FirmDirectoryPage').hide();
			$('#AttPaulFordPage').hide();
			$('#AttScottConsoliPage').hide();
			$('#AttWalterPaulekasPage').hide();
			$('#AttDavidHillPage').hide();
			$('#AttLawrenceDvorinPage').hide();
			$('#AttMatthewYoumansPage').hide();
			$('#AttEdwardLonginottiPage').hide();
			$('#AttEleanorBortolanPage').hide();
			$('#divAttorneyNavigation').hide();
			$('#PraCommercialPage').hide();
			$('#PraRealEstateLitigationPage').hide();
			$('#PraInsolvencyPage').hide();
			$('#PraRealEstatePage').hide();
			$('#PraLendingPage').hide();
			$('#PraCorporateAndEmploymentPage').hide();
			$('#PraTrustsAndEstatesPage').hide();
			$('#divPracticeNavigation').hide();
			$('#divDirectory').hide();
			$('#VCardSelection').hide();
			$('#emailLinks').hide();
			$('#directionsMap').hide();
		}
		
		function moveShape(shape, xMotion, yMotion, zMotion){
			var arpLen = shape.points.length;
			for (var j =0, plen = arpLen; j<plen; ++j)
			{
				shape.points[j].x += xMotion;
				shape.points[j].y += yMotion;
				shape.points[j].z += zMotion;
			}
		}
 
		function load() {
			// Init drawing system
			canvas = document.getElementById("canvas1");
			ctx = canvas.getContext("2d");
 
			canvasWidth = canvas.width;
			canvasHeight = canvas.height;
			halfCanvasWidth = canvasWidth * 0.5;
			halfCanvasHeight = canvasHeight * 0.5;
 
			// Init 3D components
			space = new Space();
			scene = new Scene();
 
			// Create a book shape and add it to scene
			scene.shapes['book2'] = new Shape();
			scene.shapes['book3'] = new Shape();
			scene.shapes['book4'] = new Shape();
			scene.shapes['book5'] = new Shape();
			scene.shapes['book6'] = new Shape();
			scene.shapes['book'] = new Shape();
			
			
			var p2 = scene.shapes['book2'].points; // the second book
			var p3 = scene.shapes['book3'].points; // the third book
			var p4 = scene.shapes['book4'].points; // the fourth book
			var p5 = scene.shapes['book5'].points; // the fifth book
			var p6 = scene.shapes['book6'].points; // the sixth book
			var p = scene.shapes['book'].points; // the first book
			
			p[0] = new Point(0, -30, -120); // left  bottom back
			p[1] = new Point(-10, -30, -120);  // right bottom back
			p[2] = new Point(-10, 70, -120);   // right top back
			p[3] = new Point(0, 70, -120);  // left  top back
 
			p[4] = new Point(0, -30, 20);  // left  bottom front
			p[5] = new Point(-10, -30, 20);   // right bottom front
			p[6] = new Point(-10, 70, 20);    // right top  front
			p[7] = new Point(0, 70, 20);   // left  top  front
			
			p2[0] = new Point(45, -30, -120); // left  bottom front
			p2[1] = new Point(35, -30, -120);  // right bottom front
			p2[2] = new Point(35, 70, -120);   // right top    front
			p2[3] = new Point(45, 70, -120);  // left  top    front
 
			p2[4] = new Point(45, -30, 20);  // left  bottom back
			p2[5] = new Point(35, -30, 20);   // right bottom back
			p2[6] = new Point(35, 70, 20);    // right top    back
			p2[7] = new Point(45, 70, 20);   // left  top    back
			
 
 			p3[0] = new Point(-45, -30, -120); // left  bottom front
			p3[1] = new Point(-55, -30, -120);  // right bottom front
			p3[2] = new Point(-55, 70, -120);   // right top    front
			p3[3] = new Point(-45, 70, -120);  // left  top    front
 
			p3[4] = new Point(-45, -30, 20);  // left  bottom back
			p3[5] = new Point(-55, -30, 20);   // right bottom back
			p3[6] = new Point(-55, 70, 20);    // right top    back
			p3[7] = new Point(-45, 70, 20);   // left  top    back
 
 			p4[0] = new Point(-90, -30, -120); // left  bottom front
			p4[1] = new Point(-100, -30, -120);  // right bottom front
			p4[2] = new Point(-100, 70, -120);   // right top    front
			p4[3] = new Point(-90, 70, -120);  // left  top    front
 
			p4[4] = new Point(-90, -30, 20);  // left  bottom back
			p4[5] = new Point(-100, -30, 20);   // right bottom back
			p4[6] = new Point(-100, 70, 20);    // right top    back
			p4[7] = new Point(-90, 70, 20);   // left  top    back
			
 
 			p5[0] = new Point(90, -30, -120); // left  bottom front
			p5[1] = new Point(80, -30, -120);  // right bottom front
			p5[2] = new Point(80, 70, -120);   // right top    front
			p5[3] = new Point(90, 70, -120);  // left  top    front
 
			p5[4] = new Point(90, -30, 20);  // left  bottom back
			p5[5] = new Point(80, -30, 20);   // right bottom back
			p5[6] = new Point(80, 70, 20);    // right top    back
			p5[7] = new Point(90, 70, 20);   // left  top    back
 
 
 			p6[0] = new Point(-135, -30, -120); // left  bottom front
			p6[1] = new Point(-145, -30, -120);  // right bottom front
			p6[2] = new Point(-145, 70, -120);   // right top    front
			p6[3] = new Point(-135, 70, -120);  // left  top    front
 
			p6[4] = new Point(-135, -30, 20);  // left  bottom back
			p6[5] = new Point(-145, -30, 20);   // right bottom back
			p6[6] = new Point(-145, 70, 20);    // right top    back
			p6[7] = new Point(-135, 70, 20);   // left  top    back 
			

 
			// Front
			scene.shapes['book2'].polygons.push(new Polygon(
				[ p2[4], p2[5], p2[6], p2[7] ],
				new Point(0, 0, 1),
				false,
				Polygon.SOLID,
				[0, 0, 255, 0.6]
			));
			scene.shapes['book2'].polygons[0].origin.z = 0;
 
			// Left
			scene.shapes['book2'].polygons.push(new Polygon(
				[ p2[1], p2[5], p2[6], p2[2] ],
				new Point(1, 0, 0),
				false,
				Polygon.SOLID,
				[27, 63, 139, 0.6]
			));
			scene.shapes['book2'].polygons[1].origin.z = 20;
 
 
 			// Front
			scene.shapes['book4'].polygons.push(new Polygon(
				[ p4[4], p4[5], p4[6], p4[7] ],
				new Point(0, 0, 1),
				false,
				Polygon.SOLID,
				[0, 0, 255, 0.2]
			));
 			scene.shapes['book4'].polygons[0].origin.z = 1;
 
			// Right
			scene.shapes['book4'].polygons.push(new Polygon(
				[ p4[0], p4[4], p4[7], p4[3] ],
				new Point(-1, 0, 0),
				false,
				Polygon.SOLID,
				[27, 63, 139, 0.2]
			));
 			scene.shapes['book4'].polygons[1].origin.z = 0;
 
			// Front
			scene.shapes['book3'].polygons.push(new Polygon(
				[ p3[4], p3[5], p3[6], p3[7] ],
				new Point(0, 0, 1),
				false,
				Polygon.SOLID,
				[0, 0, 255, 0.6]
			));
			scene.shapes['book3'].polygons[0].origin.z = 1;

			// Right
			scene.shapes['book3'].polygons.push(new Polygon(
				[ p3[0], p3[4], p3[7], p3[3] ],
				new Point(-1, 0, 0),
				false,
				Polygon.SOLID,
				[27, 63, 139, 0.6]
			));
 			scene.shapes['book3'].polygons[1].origin.z = 0
			 
 
 
			// Front
			scene.shapes['book5'].polygons.push(new Polygon(
				[ p5[4], p5[5], p5[6], p5[7] ],
				new Point(0, 0, 1),
				false,
				Polygon.SOLID,
				[0, 0, 255, 0.2]
			));
 			scene.shapes['book5'].polygons[0].origin.z = 1;
 
			// Left
			scene.shapes['book5'].polygons.push(new Polygon(
				[ p5[1], p5[5], p5[6], p5[2] ],
				new Point(1, 0, 0),
				false,
				Polygon.SOLID,
				[27, 63, 139, 0.2]
			));
 			scene.shapes['book5'].polygons[1].origin.z = 0;
 

			// Front
			scene.shapes['book6'].polygons.push(new Polygon(
				[ p6[4], p6[5], p6[6], p6[7] ],
				new Point(0, 0, 1),
				false,
				Polygon.SOLID,
				[0, 0, 255, 0.0]
			));
			scene.shapes['book6'].polygons[0].origin.z = 1;
 
			// Left
			scene.shapes['book6'].polygons.push(new Polygon(
				[ p6[0], p6[4], p6[7], p6[3] ],
				new Point(-1, 0, 0),
				false,
				Polygon.SOLID,
				[27, 63, 139, 0.0]
			));
			scene.shapes['book6'].polygons[1].origin.z = 0;
 
 			// Front
			scene.shapes['book'].polygons.push(new Polygon(
				[ p[4], p[5], p[6], p[7] ],
				new Point(0, 0, 1),
				false,
				Polygon.SOLID,
				[0, 0, 255, 1]
			));
			scene.shapes['book'].polygons[0].origin.z = 10;
			
			// Right
			scene.shapes['book'].polygons.push(new Polygon(
				[ p[1], p[5], p[6], p[2] ],
				new Point(1, 0, 0),
				false,
				Polygon.SOLID,
				[27, 63, 139, 1]
			));
 			scene.shapes['book'].polygons[1].origin.z = 5;
 
 			moveF(8);

 			loop()
		}
 

			$(document).ready(function () {
	  		$("img").lazyload();
	  		});
	
			function SwapPages(PageName){
				$('#divContent').hide("fast", function(){moveB(9, PageName);});
			}
	
			function loadMapa() {
				document.getElementById('directionsMap').innerHTML = '<iframe width="410" height="240" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=280+Trumbull+Street,+Hartford,+CT&amp;aq=0&amp;sll=37.0625,-95.677068&amp;sspn=51.089971,79.013672&amp;ie=UTF8&amp;hq=&amp;hnear=280+Trumbull+St,+Hartford,+Connecticut+06103&amp;ll=41.769775,-72.675762&amp;spn=0.030727,0.070381&amp;z=13&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=280+Trumbull+Street,+Hartford,+CT&amp;aq=0&amp;sll=37.0625,-95.677068&amp;sspn=51.089971,79.013672&amp;ie=UTF8&amp;hq=&amp;hnear=280+Trumbull+St,+Hartford,+Connecticut+06103&amp;ll=41.769775,-72.675762&amp;spn=0.030727,0.070381&amp;z=13" style="color:#0000FF;text-align:left">View Larger Map</a></small>';
			}
		/* -------------------------------------------------------------------- */
