
var andrewtlawrence = function() {

return {

		setFlash1: function() {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="500" bgcolor="#000000" >\n');
		document.write('<param name="movie" value="portfolio_images/illustration2.swf" />\n');
		document.write('<param name="quality" value="high" />\n');
		document.write('<param name="bgcolor" value="#000000" />\n');
		document.write('<embed type="application/x-shockwave-flash" src="portfolio_images/illustration2.swf" width="800" height="500" bgcolor="#000000" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
		document.write('</object>\n');
		},
		
		setFlash2: function() {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="500" bgcolor="#000000">\n');
		document.write('<param name="movie" value="portfolio_images/illustration4.swf" />\n');
		document.write('<param name="quality" value="high" />\n');
		document.write('<param name="bgcolor" value="#000000" />\n');
		document.write('<embed type="application/x-shockwave-flash" src="portfolio_images/illustration4.swf" width="800" height="500" bgcolor="#000000" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
		document.write('</object>\n');
		},
		
		setFlash3: function() {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="500" bgcolor="#000000">\n');
		document.write('<param name="movie" value="portfolio_images/illustration7.swf" />\n');
		document.write('<param name="quality" value="high" />\n');
		document.write('<param name="bgcolor" value="#000000" />\n');
		document.write('<embed type="application/x-shockwave-flash" src="portfolio_images/illustration7.swf" width="800" height="500" bgcolor="#000000" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
		document.write('</object>\n');
		},
			
		setSlides: function() {
		document.getElementById('interactive').onmouseover = function() { andrewtlawrence.scrollThumbs(1); };
		document.getElementById('print').onmouseover = function() { andrewtlawrence.scrollThumbs(1); };
		document.getElementById('photography').onmouseover = function() { andrewtlawrence.scrollThumbs(1); };
		document.getElementById('illustration').onmouseover = function() { andrewtlawrence.scrollThumbs(1); };
		},
		
		pgnum: 1,
		
		scrollThumbs: function() {
		if (andrewtlawrence.pgnum == 2) {
		scrollTarget = document.getElementById(currport+"_2");
		} else {
		scrollTarget = document.getElementById(currport);
		}
		document.onmousemove = andrewtlawrence.onMouseMove;
		},
		
		onMouseMove: function(e) {
		var posX = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY) { posX = e.pageX; }
		else if (e.clientX || e.clientY) { posX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; }
		var targetWidth = scrollTarget.offsetWidth;
		if ( andrewtlawrence.pgnum == 1 ) {	
		var targetLeft = document.getElementById('container').offsetLeft + 40;
		} else {
		var targetLeft = document.getElementById('container').offsetLeft + 100;
		}
		var newLeft = ( posX - targetLeft ) - 50;		
		if ( andrewtlawrence.pgnum == 1 ) {
		var scrollLeft = ( -1 * ( newLeft/500 * ( targetWidth - 600 ) ) );
		scrollTarget.style.left = scrollLeft+"px";
		if ( scrollLeft < ( -1 * ( targetWidth - 550 ) ) ) { scrollTarget.style.left = ( -1 * ( targetWidth - 550 ) )+"px"; }
		} else {
		var scrollLeft = ( -1 * ( newLeft/696 * ( targetWidth - 796 ) ) );
		scrollTarget.style.left = scrollLeft+"px";
		if ( scrollLeft < ( -1 * ( targetWidth - 746 ) ) ) { scrollTarget.style.left = ( -1 * ( targetWidth - 746 ) )+"px"; }
		}
		if ( scrollLeft > 42 ) { scrollTarget.style.left = "42px"; }
		},
		
		stopScroll: function() {
		document.onmousemove = function () { return false; };
		},

		thumbOver: function(thumb,currnum,port) {
		currport=port;
		slidenum=currnum;
		if (this.pgnum==2) {
		var slideDiv = document.getElementById(currport+"_2");
		} else {
		var slideDiv = document.getElementById(currport);
		}
		var thumbDiv = document.getElementById(thumb);
		var thumbLeft = thumbDiv.offsetLeft;
		var thumbWidth = thumbDiv.offsetWidth;
		var thumbTop = thumbDiv.offsetTop;
		var thumbOverDiv = ( document.getElementById('thumbover') ) ? document.getElementById('thumbover') : document.createElement('div');
		thumbOverDiv.id = "thumbover";
		thumbOverDiv.style.textAlign = "center";
		thumbOverDiv.style.left = (thumbLeft-2)+"px";
		thumbOverDiv.style.top = thumbTop+"px";
		thumbOverDiv.style.position = "absolute";
		thumbOverDiv.style.height = "92px";
		thumbOverDiv.style.width = (thumbWidth-4)+"px";
		thumbOverDiv.style.border = "4px solid #cccccc";
		slideDiv.appendChild(thumbOverDiv);
		},
		
		preloadImgs: function() {
		switch(currport) { case "interactive": var total = "17";break;case "print": var total = "15";break;case "photography":var total = "9";break; }
		for ( i=1; i<=total; i++ ) {
		var loadImg = document.getElementById(currport+""+i);
		loadImg.src = "portfolio_images/"+currport+""+i+".jpg";
		}
		if ( currport == "illustration" ) {
		var loadImg = document.getElementById(currport+"1");
		loadImg.src = "portfolio_images/"+currport+"1.gif";
		var loadImg = document.getElementById(currport+"2");
		loadImg.src = "portfolio_images/"+currport+"2.jpg";
		var loadImg = document.getElementById(currport+"5");
		loadImg.src = "portfolio_images/"+currport+"5.jpg";
		var loadImg = document.getElementById(currport+"6");
		loadImg.src = "portfolio_images/"+currport+"6.png";
		var loadImg = document.getElementById(currport+"8");
		loadImg.src = "portfolio_images/"+currport+"8.jpg";
		}
		},
		
		startPortfolio: function() {
		saveslidenum = slidenum;
		andrewtlawrence.pgnum = 2;
		document.onmousemove = function () { return false; };
		andrewtlawrence.preloadImgs();
		document.getElementById('print_2').style.left = "-598px";
		document.getElementById('interactive_2').style.left = "-678px";
		document.getElementById('photography_2').style.left = "-50px";
		document.getElementById('illustration_2').style.left = "-20px";
		document.getElementById('design').style.display = "none";
		document.getElementById('development').style.display = "none";
		document.getElementById("imgloader").style.display = "block";
		document.getElementById(currport+"_2_Container").style.display = "block";
		var slide = currport+""+slidenum;
		currSlide = document.getElementById(slide);
		currSlide.style.marginLeft = "auto";
		currSlide.style.marginRight = "auto";
		currSlide.style.width = "auto";
		currSlide.style.height = "auto";
		currSlide.style.display = "block";
		document.getElementById('portfolio').style.display = "block";
		document.getElementById('closeicon').style.display = "block";
		document.getElementById('nextslide').style.display = "block";
		document.getElementById('previousslide').style.display = "block";
		document.getElementById("loading").style.display = "block";
		if ( currport == "illustration" ) {
		if ( ( slidenum == "2" ) || ( slidenum == "4" ) || ( slidenum == "7" ) ) { 
		currSlide.src = "images/spacer.gif";
		return;
		} else {
		switch(slidenum) { case 1:currSlide.src = "portfolio_images/"+currport+""+slidenum+".gif";break;case 6:currSlide.src = "portfolio_images/"+currport+""+slidenum+".png";break;default:currSlide.src = "portfolio_images/"+currport+""+slidenum+".jpg";break; }
		}
		} else {
		currSlide.src = "portfolio_images/"+currport+""+slidenum+".jpg";
		}
		},
		
		showSlide: function() {
		saveslidenum = slidenum;
		currSlide.style.display = "none";
		if ( typeof(int) != "undefined" ) { clearInterval(int); }
		if ( typeof(newSlide) != "undefined" ) { newSlide.style.display = "none"; }
		var slide = currport+""+slidenum;
		newSlide = document.getElementById(slide);
		newSlide.style.marginLeft = "auto";
		newSlide.style.marginRight = "auto";
		newSlide.style.width = "auto";
		newSlide.style.height = "auto";
		newSlide.style.display = "block";
		if ( currport == "illustration" ) {
		if ( ( slidenum == "2" ) || ( slidenum == "4" ) || ( slidenum == "7" ) ) { 
		newSlide.src = "images/spacer.gif";
		return;
		} else {
		switch(slidenum) { case 1:newSlide.src = "portfolio_images/"+slide+".gif";break;case 6:newSlide.src = "portfolio_images/"+slide+".png";break;default:newSlide.src = "portfolio_images/"+slide+".jpg";break; }
		}
		} else {
		newSlide.src = "portfolio_images/"+slide+".jpg";
		}
		newSlide.style.filter = "alpha(opacity=0)";
		newSlide.style.opacity = ".0";
		transnum = 1;
		int = setInterval("andrewtlawrence.fadeImageIn()",20);
		},
		
		closePortfolio: function() {
		andrewtlawrence.pgnum = 1;
		currSlide.style.display = "none";
		document.getElementById('print').style.left = "-498px";
		document.getElementById('interactive').style.left = "-578px";
		document.getElementById('photography').style.left = "-50px";
		document.getElementById('illustration').style.left = "-20px";
		document.getElementById('development').style.display = "block";
		document.getElementById('design').style.display = "block";
		document.getElementById('portfolio').style.display = "none";
		document.getElementById('closeicon').style.display = "none";
		document.getElementById('nextslide').style.display = "none";
		document.getElementById('previousslide').style.display = "none";
		document.getElementById("illustration2").style.display = "none";
		document.getElementById("illustration4").style.display = "none";
		document.getElementById("illustration7").style.display = "none";
		document.getElementById("loading").style.display = "none";
		if ( typeof(newSlide) != "undefined" ) { newSlide.style.display = "none"; }
		document.getElementById(currport+"_2_Container").style.display = "none";
		},
		
		nextSlide: function() {
		if ( typeof(int) != "undefined" ) { clearInterval(int); }
		var slideDiv = document.getElementById(currport);
		var slides = slideDiv.getElementsByTagName("img");
		var total = ( currport == "illustration" ) ? "8" : slides.length;
		slideImage = document.getElementById(currport+""+saveslidenum);
		if ( saveslidenum < total ) { saveslidenum++; } else { saveslidenum = 1; }
		if (saveslidenum == '1') {
		document.getElementById(currport+""+total).style.display = "none";
		} else {
		slideImage.style.display = "none";
		}
		newSlide = document.getElementById(currport+""+saveslidenum);
		newSlide.style.marginLeft = "auto";
		newSlide.style.marginRight = "auto";
		newSlide.style.width = "auto";
		newSlide.style.height = "auto";
		
		if ( currport == "illustration" ) {
		switch(saveslidenum) { case 1:newSlide.src = "portfolio_images/"+currport+""+saveslidenum+".gif";break;case 6:newSlide.src = "portfolio_images/"+currport+""+saveslidenum+".png";break;default:newSlide.src = "portfolio_images/"+currport+""+saveslidenum+".jpg";break; }
		} else {
		newSlide.src = "portfolio_images/"+currport+""+saveslidenum+".jpg";
		}
		newSlide.style.filter = "alpha(opacity=0)";
		newSlide.style.opacity = ".0";
		newSlide.style.display = "block";
		transnum = 1;
		int = setInterval("andrewtlawrence.fadeImageIn()",20);
		},
		
	 	previousSlide: function() {
		if ( typeof(int) != "undefined" ) { clearInterval(int); }
		var slideDiv = document.getElementById(currport);
		var slides = slideDiv.getElementsByTagName("img");
		var total = ( currport == "illustration" ) ? "8" : slides.length;
		slideImage = document.getElementById(currport+""+saveslidenum);
		if ( saveslidenum > 1 ) { saveslidenum = saveslidenum - 1; } else { saveslidenum = total; }
		globalThumb = currport+"thumb"+saveslidenum;
		if (saveslidenum == total) {
		document.getElementById(currport+"1").style.display = "none";
		} else {
		slideImage.style.display = "none";
		}
		newSlide = document.getElementById(currport+""+saveslidenum);
		newSlide.style.marginLeft = "auto";
		newSlide.style.marginRight = "auto";
		newSlide.style.width = "auto";
		newSlide.style.height = "auto";
		if ( currport == "illustration" ) {
		switch(saveslidenum) { case 1:newSlide.src = "portfolio_images/"+currport+""+saveslidenum+".gif";break;case 6:newSlide.src = "portfolio_images/"+currport+""+saveslidenum+".png";break;default:newSlide.src = "portfolio_images/"+currport+""+saveslidenum+".jpg";break; }
		} else {
		newSlide.src = "portfolio_images/"+currport+""+saveslidenum+".jpg";
		}
		newSlide.style.filter = "alpha(opacity=0)";
		newSlide.style.opacity = ".0";
		newSlide.style.display = "block";
		transnum = 1;
		int = setInterval("andrewtlawrence.fadeImageIn()",20);
		},
		
		fadeImageIn: function() {
		if (transnum >= 9) {
		clearInterval(int);
		newSlide.style.filter = "alpha(opacity=100)";
		newSlide.style.opacity = "1.0";
		transnum = 1;
		} else {
		transnum2 = (Math.round(transnum * 100) / 100) * 10;
		newSlide.style.filter = "alpha(opacity="+transnum2+")";
		newSlide.style.opacity = "."+transnum+"";
		transnum = transnum + .5;
		}
		}

};

}();



