/* Standard Stuff */
var flashMovie = false;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) {
    //alert(a[i]);
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Example usage: javascript:mask('etrout.com','o@kilgor','inf','')
function mask(end,middle,start,subject){
	var one ='mai';
	var two='lto:';
	var three='?Subject=';
	//start,middle,end,subject;
	var putogether= one+two+start+middle+end+three+subject;
	document.location.href=eval('"'+putogether+'"');
	window.status=putogether;
}


var oldlist='elist1';
function swapelist(newlist){
	if(newlist!=oldlist){
		document.getElementById(newlist).style.display = 'block';
		document.getElementById(oldlist).style.display = 'none';
		oldlist=newlist;
	}
}

/* Scriptaculous Stuff */

var oldnum='numdiv0';
var architectureDone = teamPicsDone = interiorPicsDone = teamTextDone = interiorTextDone = planningPicsDone = planningTextDone = false;

function newpic(lineid,picname,picwidth,picheight,lgpicwidth,lgpicheight) {
	//new Effect.SlideDown('thumbscroller');
	var dimensions = $('body').getDimensions();
	//alert("Width: "+dimensions.width+"\nHeight: "+dimensions.height);
	
	var xt = picname.substr(-4);
	if (f_clientHeight() > 750 && picwidth < 500) {
		picname = picname.substr(0, picname.length - 7) + xt;
		picwidth = lgpicwidth;
		picheight = lgpicheight;
	}
	//alert("picname: "+picname+"\npicwidth: "+picwidth+"\npicheight: "+picheight);
	//var img = new Image();
    //img.src = '/images/' + picname;
	//loaded($('mainpic'));
	
	var newnum = 'numdiv'+lineid;
	
	if(oldnum!='numdiv0' && oldnum != newnum) { new Effect.Morph(oldnum,{ style:'margin-top:8px;height:8px;background-color:#666;', duration:0.5 }); }

	if (oldnum != newnum) {
		if (oldPageType == 't' || oldPageType == 'tc') {
			swapmainpic(picname, '/images/');
			new Effect.Morph('mainpicwrap',{ style:'width:'+picwidth+'px;height:'+picheight+'px;', duration:0.5,afterFinish: function() { 
				document.getElementById('mainpic').style.width = picwidth + 'px';
				document.getElementById('mainpic').style.height = picheight + 'px';
				new Effect.Appear('mainpic',{duration:0.5});
				new Effect.Morph(newnum,{ style:'margin-top:0px;height:17px;background-color:#716C00;', duration:0.3});
			}});
			
		} else {
			new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
				swapmainpic(picname, '/images/');
				new Effect.Morph('mainpicwrap',{ style:'width:'+picwidth+'px;height:'+picheight+'px;', duration:0.5,afterFinish: function() {
					document.getElementById('mainpic').style.width = picwidth + 'px';
					document.getElementById('mainpic').style.height = picheight + 'px';
					new Effect.Appear('mainpic',{duration:0.5});
					new Effect.Morph(newnum,{ style:'margin-top:0px;height:17px;background-color:#716C00;', duration:0.3});
				}});
			}});
		}
	}
	oldnum=newnum;
}

/* Window height calculation */
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
    
function swapmainpic(picname, root) {
    document.getElementById('mainpic').style.backgroundImage = 'url(' + root + picname + ')';
}

var oldmenuid = 0;
var imageID = new Array();
	imageID["philosophy"] = 107;
	imageID["sustainability"] = 127;
	imageID["process"] = 147;
	imageID["architecture"] = 167;
	imageID["planning"] = 187;
	imageID["asset_management"] = 207;
	imageID["interior_design"] = 227;
	imageID["environmental_graphics"] = 247;
	imageID["client_list"] = 267;
	imageID["culture"] = 287;
	imageID["careers"] = 347;
	imageID["general_info"] = 367;
	imageID["directory"] = 407;	

function menuswap(menuid) {
	var offid = menuid+'_off';
	var onid = menuid+'_on';
	var onmenu = 'mn_' + menuid;
	var imgdir = "/display/zone/";
	
	switch(menuid) {
		case "approach":
			MM_preloadImages(imgdir + (imageID["philosophy"] + 1) + ".jpg", imgdir + (imageID["sustainability"] + 1) + ".jpg", imgdir + (imageID["process"] + 1) + ".jpg");
			break;
		case "services":
			MM_preloadImages(imgdir + (imageID["architecture"] + 1) + ".jpg", imgdir + (imageID["planning"] + 1) + ".jpg", imgdir + (imageID["asset_management"] + 1) + ".jpg", imgdir + (imageID["interior_design"] + 1) + ".jpg", imgdir + (imageID["graphics"] + 1) + ".jpg");
			break;
		case "portfolio":
			MM_preloadImages(imgdir + (imageID["client_list"] + 1) + ".jpg");
			break;
		case "people":
			MM_preloadImages(imgdir + (imageID["culture"] + 1) + ".jpg", imgdir + (imageID["careers"] + 1) + ".jpg");
			break;
		case "contact":
			MM_preloadImages(imgdir + (imageID["general_info"] + 1) + ".jpg", imgdir + (imageID["directory"] + 1) + ".jpg");
			break;
	}
	
	if(oldmenuid != 0){
		var oldoffid = oldmenuid+'_off';
		var oldonid = oldmenuid+'_on';
		var offmenu = 'mn_' + oldmenuid;
		new Effect.Fade(offmenu,{duration:0.2,afterFinish: function() {
			new Effect.Morph(oldoffid,{ style:'left:0px;', duration:0.5 });
			new Effect.Morph(oldonid,{ style:'left:-108px;', duration:0.5 });
			new Effect.Morph(offid,{ style:'left:108px;', duration:0.5 });
			new Effect.Morph(onid,{ style:'left:0px;', duration:0.5,afterFinish: function() {
				new Effect.Appear(onmenu,{duration:0.4});
				new Effect.BlindDown(onmenu,{duration:0.4});
			}});
		}});
	} else {
		new Effect.Morph(offid,{ style:'left:108px;', duration:0.5 });
		new Effect.Morph(onid,{ style:'left:0px;', duration:0.5,afterFinish: function() {
			new Effect.Appear(onmenu,{duration:0.4});
			new Effect.BlindDown(onmenu,{duration:0.4});
		}});
	}
	oldmenuid=menuid;
}

function menuoff(menuid) {
	var offid = menuid+'_off';
	var onid = menuid+'_on';
	var offmenu = 'mn_' + menuid;	
	new Effect.Fade(offmenu,{duration:0.2,afterFinish: function() {
		new Effect.Morph(offid,{ style:'left:0px;', duration:0.5 });
		new Effect.Morph(onid,{ style:'left:-108px;', duration:0.5});
	}});
	oldmenuid=0;
}

//function loadtrtext() {new Ajax.Updater('trtext_swapwrap','/content/thumbs_team_tx.php?directload=1', {asynchronous:true, evalScripts:true});}

var currthumb = 0, animDone = true, barLength;

function firstthumb() {
	barLength = thumbTotal * thumbWidth;
	var dimensions = $('body').getDimensions();
	var leftwidth = Math.round(.55 * dimensions.width);
	$('teamscroller').setStyle({
		'width': (thumbTotal * 5 * thumbWidth) + 'px',
		'left': leftwidth + 35 + (barLength*startOffset*(-1)) - getThumbMoveDist(thumbWidth, currthumb) + 'px'
	});
	if (staticgallery != 'team') {
		new Ajax.Updater('teamscroller','/content/thumbs_team.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function() {teamPicsDone = true;}});
		new Ajax.Updater('teamscrollertext','/content/thumbs_team_tx.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function() {teamTextDone = true;}});
	}
}

function getThumbMoveDist(width, newID, oldID) {
	if (oldID == undefined)
		oldID = 0;
	var thumbspan = (newID - oldID) * width;
	return thumbspan;
}

function gotothumb(newthumb, offset) {
	if (animDone) {
		animDone = false;
		
		if (offset == undefined)
			offset = 0;
		
		var leftwidth = $('tlcol').getDimensions().width;
		var scrollerpos = (Number(document.getElementById('teamscroller').style.left.replace(/px/i, '')));
		
		var currthumbtxid='thumbtx'+(currthumb);
		var newthumbtxid='thumbtx'+newthumb;
		var currthumbid='thumb'+(currthumb);
		var newthumbid='thumb'+newthumb;
		
		if (currthumb == newthumb) {
			new Effect.Appear(newthumbid,{duration:0.3, afterFinish: function() {currthumb=newthumb;}});
			$(newthumbtxid).setStyle({display: 'inline'});
			$('trtext').setStyle({
				marginTop: '20px',
				paddingLeft: '50px'
			});
			new Effect.Appear('trtext',{duration: 0.3, afterFinish: function() {animDone = true;}});
		} else {
			// Fade the currently selected photograph
			new Effect.Fade(currthumbid,{duration:0.2, afterFinish: function() {
				if (offset != 0)
					document.getElementById('teamscroller').style.left = scrollerpos + (barLength * offset);
				// Slide the bar over
				new Effect.Morph('teamscroller', {style: 'left: '+(scrollerpos - getThumbMoveDist(thumbWidth, newthumb, currthumb))+';', duration: 0.4, transition: Effect.Transitions.sinoidal});
			}});
			new Effect.Fade('trtext', {duration:0.2, afterFinish: function() {
				$(currthumbtxid).setStyle({display: 'none'});
				$(newthumbtxid).setStyle({display: 'inline'});
				new Effect.Appear(newthumbid,{delay: 0.4, duration:0.3, afterFinish: function() {
					currthumb=newthumb;
					new Effect.Appear('trtext', {duration:0.3, afterFinish: function() {animDone = true;}});
				}});
			}});
		}
		oldgallery = currentgallery;
	}
}

function nextthumb() {
	var newthumb = currthumb + 1;
	if (newthumb >= thumbTotal)
		gotothumb(newthumb - thumbTotal, 1);
	else
		gotothumb(newthumb);
}

// interior thumb list
var intcurrthumb = 0, intanimdone = true, intbarLength;

function intfirstthumb() {
	intbarLength = intthumbTotal * intthumbWidth;
	var dimensions = $('body').getDimensions();
	var leftwidth = Math.round(.55 * dimensions.width);
	$('interiorscroller').setStyle({
		'width': (intthumbTotal * 5 * intthumbWidth) + 'px',
		'left': leftwidth + 35 + (intbarLength*startOffset*(-1)) - getThumbMoveDist(intthumbWidth, intcurrthumb) + 'px'
	});
	if (staticgallery != 'interiors') {
		new Ajax.Updater('interiorscroller','/content/thumbs_interior.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function() {interiorPicsDone = true;}});
		new Ajax.Updater('interiorscrollertext','/content/thumbs_interior_tx.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function() {interiorTextDone = true;}});
	}
}

function intgotothumb(newthumb, offset, catID) {
	if (intanimdone) {
		intanimdone = false;
		
		if (offset == undefined)
			offset = 0;
		
		var leftwidth = $('tlcol').getDimensions().width;
		var scrollerpos = (Number(document.getElementById('interiorscroller').style.left.replace(/px/i, '')));
		
		var currthumbtxid='intthumbtx'+(intcurrthumb);
		var newthumbtxid='intthumbtx'+newthumb;
		var currthumbid='intthumb'+(intcurrthumb);
		var newthumbid='intthumb'+newthumb;
		
		if (intcurrthumb == newthumb && !projectopen) {
			if (oldgallery == 'interiors') {
				projectopen = true;
				newproject(catID);
			} else {
				if (catID == undefined)
					catID = 45;
				new Effect.Appear(newthumbid,{duration:0.3, afterFinish: function() {intcurrthumb=newthumb;}});
				$(newthumbtxid).setStyle({display: 'inline'});
				$('trtext').setStyle({
					marginTop: '20px',
					paddingLeft: '50px'
				});
				new Effect.Appear('trtext',{duration: 0.3, afterFinish: function() {intanimdone = true;}});
			}
		} else {
			// Fade the currently selected photograph
			new Effect.Fade(currthumbid,{duration:0.2, afterFinish: function() {
				if (offset != 0)
					document.getElementById('interiorscroller').style.left = scrollerpos + (intbarLength * offset);
				// Slide the bar over
				new Effect.Morph('interiorscroller', {style: 'left: '+(scrollerpos - getThumbMoveDist(intthumbWidth, newthumb, intcurrthumb))+';', duration: 0.4, transition: Effect.Transitions.sinoidal});
			}});
			new Effect.Fade('trtext', {duration:0.2, afterFinish: function() {
				$(currthumbtxid).setStyle({display: 'none'});
				$(newthumbtxid).setStyle({display: 'inline'});
				new Effect.Appear(newthumbid,{delay: 0.4, duration:0.3, afterFinish: function() {
					intcurrthumb=newthumb;
					new Effect.Appear('trtext', {duration:0.2, afterFinish: function() {intanimdone = true;}});
				}});
			}});
		}
		new Ajax.Request('/content/build_project.php?catid='+catID+'&editor=10&firstimg=1', {
			asynchronous: true,
			evalJS: true,
			onSuccess: function(transport) {
				eval(transport.responseText);
			}
		});
		oldgallery = currentgallery;
	}
}

function intnextthumb() {
	var newthumb = intcurrthumb + 1;
	if (newthumb >= intthumbTotal)
		intgotothumb(newthumb - intthumbTotal, 1);
	else
		intgotothumb(newthumb);
}

// planning thumb list
var plncurrthumb = 0, plnanimdone = true, plnbarLength;

function plnfirstthumb() {
	plnbarLength = plnthumbTotal * plnthumbWidth;
	var dimensions = $('body').getDimensions();
	var leftwidth = Math.round(.55 * dimensions.width);
	$('planningscroller').setStyle({
		'width': (plnthumbTotal * 5 * plnthumbWidth) + 'px',
		'left': leftwidth + 35 + (plnbarLength*startOffset*(-1)) - getThumbMoveDist(plnthumbWidth, plncurrthumb) + 'px'
	});
	if (staticgallery != 'planning') {
		new Ajax.Updater('planningscroller','/content/thumbs_planning.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function() {planningPicsDone = true;}});
		new Ajax.Updater('planningscrollertext','/content/thumbs_planning_tx.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function() {planningTextDone = true;}});
	}
}

function plngotothumb(newthumb, offset, catID) {
	if (plnanimdone) {
		plnanimdone = false;
		
		if (offset == undefined)
			offset = 0;
		
		var leftwidth = $('tlcol').getDimensions().width;
		var scrollerpos = (Number(document.getElementById('planningscroller').style.left.replace(/px/i, '')));
		
		var currthumbtxid='plnthumbtx'+(plncurrthumb);
		var newthumbtxid='plnthumbtx'+newthumb;
		var currthumbid='plnthumb'+(plncurrthumb);
		var newthumbid='plnthumb'+newthumb;
		
		if (plncurrthumb == newthumb && !projectopen) {
			if (oldgallery == 'planning') {
				projectopen = true;
				newproject(catID);
			} else {
				if (catID == undefined)
					catID = 45;
				new Effect.Appear(newthumbid,{duration:0.3, afterFinish: function() {plncurrthumb=newthumb;}});
				$(newthumbtxid).setStyle({display: 'inline'});
				$('trtext').setStyle({
					marginTop: '20px',
					paddingLeft: '50px'
				});
				new Effect.Appear('trtext',{duration: 0.3, afterFinish: function() {plnanimdone = true;}});
			}
		} else {
			// Fade the currently selected photograph
			new Effect.Fade(currthumbid,{duration:0.2, afterFinish: function() {
				if (offset != 0)
					document.getElementById('planningscroller').style.left = scrollerpos + (plnbarLength * offset);
				// Slide the bar over
				new Effect.Morph('planningscroller', {style: 'left: '+(scrollerpos - getThumbMoveDist(plnthumbWidth, newthumb, plncurrthumb))+';', duration: 0.4, transition: Effect.Transitions.sinoidal});
			}});
			new Effect.Fade('trtext', {duration:0.2, afterFinish: function() {
				$(currthumbtxid).setStyle({display: 'none'});
				$(newthumbtxid).setStyle({display: 'inline'});
				new Effect.Appear(newthumbid,{delay: 0.4, duration:0.3, afterFinish: function() {
					plncurrthumb=newthumb;
					new Effect.Appear('trtext', {duration:0.2, afterFinish: function() {plnanimdone = true;}});
				}});
			}});
		}
		new Ajax.Request('/content/build_project.php?catid='+catID+'&editor=12&firstimg=1', {
			asynchronous: true,
			evalJS: true,
			onSuccess: function(transport) {
				eval(transport.responseText);
			}
		});
		oldgallery = currentgallery;
	}
}

function plnnextthumb() {
	var newthumb = plncurrthumb + 1;
	if (newthumb >= plnthumbTotal)
		plngotothumb(newthumb - plnthumbTotal, 1);
	else
		plngotothumb(newthumb);
}

function slidetab(tabid,leftpos,rightpos) {
	var currleft=document.getElementById(tabid).style.left;
	currleft=parseInt(currleft);

	if(currleft<500){
	new Effect.Morph(tabid,{ style:'left:'+rightpos+'px;', duration:0.4 });	
	}else{
	new Effect.Morph(tabid,{ style:'left:'+leftpos+'px;', duration:0.4 });
	}
}

var oldPageType = '', currentgallery = '', oldgallery = '', infoChange = false, piclinkid;
	
function loadpage(contentfile, newPageType) {
	//alert("old: " + oldPageType + " new: " + newPageType);
	var dimensions = $('body').getDimensions();
	var leftwidth = Math.round(.45 * dimensions.width);
	
	if (newPageType == 'h') {
		new Effect.Morph('trcol', {style: 'height: 1px', delay: 0.5, duration: 1.0});
	} else {
		new Effect.Morph('trcol', {style: 'height: 200px', delay: 0.5, duration: 1.0});
	}
	if ($('mainpicfooterwrap').getStyle('height') == '1px' && newPageType != 'h') {
		new Effect.Parallel([
			new Effect.Morph('mainpicfooterwrap', {sync: true, style: 'height: 20px'}),
			new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 19) + 'px'})
		], {duration: 0.3});
	}
	
	if (newPageType == 'i' || newPageType == 'h') {
		oldgallery = '';
	} else {
		currentgallery = contentfile;
	}
	
	if (staticpage == 'i') {
		staticpage = '';
		new Effect.Fade('staticimage', {duration:0.4});
	}
	
	if (f_clientHeight() < 750)
		new Effect.Fade('copyright');
		
	if ($('thumbreturn').getStyle('marginTop') == '0px') {
		if (projectopen)
			new Effect.Morph('thumbreturn', {style: 'margin-top: -20px', delay: 1.0, duration: 0.3});
		else
			new Effect.Morph('thumbreturn', {style: 'margin-top: -20px', duration: 0.3});
	}
	
	/* TEAM/INTERIORS GALLERY PAGE TRANSITIONS */
	if (oldPageType == newPageType && newPageType == 't') {
		//alert(currentgallery + " " + oldgallery);
		if (currentgallery != oldgallery) {
			if (oldgallery == 'team') {
				if (currentgallery == 'interiors') {
					document.getElementById('interiorscroller').style.left = ((leftwidth + 35 + (intbarLength*startOffset*(-1))) - getThumbMoveDist(intthumbWidth, intcurrthumb));
					new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
						$('thumbtx'+currthumb).setStyle({display: 'none'});
					}});
					new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
					new Effect.Morph('teamscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function(){
						new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
						new Effect.Morph('interiorscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {intgotothumb(intcurrthumb);}});
					}});
				} else if (currentgallery == 'planning') {
					document.getElementById('planningscroller').style.left = ((leftwidth + 35 + (plnbarLength*startOffset*(-1))) - getThumbMoveDist(plnthumbWidth, plncurrthumb));
					new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
						$('thumbtx'+currthumb).setStyle({display: 'none'});
					}});
					new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
					new Effect.Morph('teamscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function(){
						new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
						new Effect.Morph('planningscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {plngotothumb(plncurrthumb);}});
					}});
				}
			} else if (oldgallery == 'interiors') {
				if (currentgallery == 'team') {
					if (projectopen) {
						new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
							$('intbodytx'+intcurrthumb).setStyle({display: 'none'});
							$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
						}});
						new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
							new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px; height: 1px; background-color: #eee', duration:0.5, afterFinish: function() {
								document.getElementById('teamscroller').style.left = ((leftwidth + 35 + (barLength*startOffset*(-1))) - getThumbMoveDist(thumbWidth, currthumb));
								new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
								new Effect.Morph('teamscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {gotothumb(currthumb);}});
							}});
						}});
						new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
						new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
						projectopen = false;
					} else {
						document.getElementById('teamscroller').style.left = ((leftwidth + 35 + (barLength*startOffset*(-1))) - getThumbMoveDist(thumbWidth, currthumb));
						new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
							$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
						}});
						new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
						new Effect.Morph('interiorscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
							new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
							new Effect.Morph('teamscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {gotothumb(currthumb);}});
						}});
					}
				} else if (currentgallery == 'planning') {
					if (projectopen) {
						new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
							$('intbodytx'+intcurrthumb).setStyle({display: 'none'});
							$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
						}});
						new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
							new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px; height: 1px; background-color: #eee', duration:0.5, afterFinish: function() {
								document.getElementById('planningscroller').style.left = ((leftwidth + 35 + (plnbarLength*startOffset*(-1))) - getThumbMoveDist(plnthumbWidth, plncurrthumb));
								new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
								new Effect.Morph('planningscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {plngotothumb(plncurrthumb);}});
							}});
						}});
						new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
						new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
						projectopen = false;
					} else {
						document.getElementById('planningscroller').style.left = ((leftwidth + 35 + (plnbarLength*startOffset*(-1))) - getThumbMoveDist(plnthumbWidth, plncurrthumb));
						new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
							$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
						}});
						new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
						new Effect.Morph('interiorscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
							new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
							new Effect.Morph('planningscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {plngotothumb(plncurrthumb);}});
						}});
					}
				}
			} else if (oldgallery == 'planning') {
				if (currentgallery == 'team') {
					if (projectopen) {
						new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
							$('plnbodytx'+plncurrthumb).setStyle({display: 'none'});
							$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
						}});
						new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
							new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px; height: 1px; background-color: #eee', duration:0.5, afterFinish: function() {
								document.getElementById('teamscroller').style.left = ((leftwidth + 35 + (barLength*startOffset*(-1))) - getThumbMoveDist(thumbWidth, currthumb));
								new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
								new Effect.Morph('teamscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {gotothumb(currthumb);}});
							}});
						}});
						new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
						new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
						projectopen = false;
					} else {
						document.getElementById('teamscroller').style.left = ((leftwidth + 35 + (barLength*startOffset*(-1))) - getThumbMoveDist(thumbWidth, currthumb));
						new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
							$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
						}});
						new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
						new Effect.Morph('planningscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
							new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
							new Effect.Morph('teamscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {gotothumb(currthumb);}});
						}});
					}
				} else if (currentgallery == 'interiors') {
					if (projectopen) {
						new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
							$('plnbodytx'+plncurrthumb).setStyle({display: 'none'});
							$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
						}});
						new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
							new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px; height: 1px; background-color: #eee', duration:0.5, afterFinish: function() {
								document.getElementById('interiorscroller').style.left = ((leftwidth + 35 + (intbarLength*startOffset*(-1))) - getThumbMoveDist(intthumbWidth, intcurrthumb));
								new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
								new Effect.Morph('interiorscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {intgotothumb(intcurrthumb);}});
							}});
						}});
						new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
						new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
						projectopen = false;
					} else {
						document.getElementById('interiorscroller').style.left = ((leftwidth + 35 + (intbarLength*startOffset*(-1))) - getThumbMoveDist(intthumbWidth, intcurrthumb));
						new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
							$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
						}});
						new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
						new Effect.Morph('planningscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
							new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
							new Effect.Morph('interiorscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {intgotothumb(intcurrthumb);}});
						}});
					}
				}
			}
		} else {
			if (projectopen && oldgallery == 'interiors') {
				closeproject(leftwidth);
				new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
				new Effect.Parallel([
					new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px'}),
					new Effect.Morph('interiorscrollerwrap', {sync: true, style: 'height: 175px'})
					], {delay: 0.5, duration: 0.5, afterFinish: function() {
						projectopen = false;
				}});
			} else if (projectopen && oldgallery == 'planning') {
				closeproject(leftwidth);
				new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
				new Effect.Parallel([
					new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px'}),
					new Effect.Morph('planningscrollerwrap', {sync: true, style: 'height: 175px'})
					], {delay: 0.5, duration: 0.5, afterFinish: function() {
						projectopen = false;
				}});
			}
		}
	}
	else if (oldPageType == 'tc' && newPageType == 't') {
		if (projectopen) {
			oldnum='numdiv0'
			new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
			new Effect.Fade('trtext', {duration:0.4, afterFinish: function() {
				$('tc'+currtab+'bodytx'+(currthumblist[currtab])).setStyle({display: 'none'});
				$('tc'+currtab+'thumbtx'+(currthumblist[currtab])).setStyle({display: 'none'});
				$('trtext').setStyle({
					marginTop: '20px',
					paddingLeft: '50px'
				});
			}});
			new Effect.Fade('mainpic',{duration:0.5, afterFinish: function() {
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px; height: 1px; background-color: #eee', duration:0.5, afterFinish: function() {
					if (currentgallery == 'team') {
						document.getElementById('teamscroller').style.left = ((leftwidth + 35 + (barLength*startOffset*(-1))) - getThumbMoveDist(thumbWidth, currthumb));
						new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
						new Effect.Morph('cgallerywrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
							new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
							new Effect.Morph('teamscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {gotothumb(currthumb);}});
						}});
					} else if (currentgallery == 'planning') {
						document.getElementById('planningscroller').style.left = ((leftwidth + 35 + (plnbarLength*startOffset*(-1))) - getThumbMoveDist(plnthumbWidth, plncurrthumb));
						new Effect.Parallel([
							new Effect.Morph('mainpicwrap', {sync: true, style:'width: ' + (leftwidth-1) + 'px;'}),
							new Effect.Morph('cgallerywrap', {sync: true, style: 'height: 0px'})
						], {duration: 0.5, afterFinish: function() {
								new Effect.Parallel([
									new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px'}),
									new Effect.Morph('planningscrollerwrap', {sync: true, style: 'height: 175px'})
									], {duration: 0.5, afterFinish: function() {plngotothumb(plncurrthumb);}}
								);
							}
						});
					} else if (currentgallery == 'interiors') {
						document.getElementById('interiorscroller').style.left = ((leftwidth + 35 + (intbarLength*startOffset*(-1))) - getThumbMoveDist(intthumbWidth, intcurrthumb));
						new Effect.Parallel([
							new Effect.Morph('mainpicwrap', {sync: true, style:'width: ' + (leftwidth-1) + 'px;'}),
							new Effect.Morph('cgallerywrap', {sync: true, style: 'height: 0px'})
						], {duration: 0.5, afterFinish: function() {
								new Effect.Parallel([
									new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px'}),
									new Effect.Morph('interiorscrollerwrap', {sync: true, style: 'height: 175px'})
									], {duration: 0.5, afterFinish: function() {intgotothumb(intcurrthumb);}}
								);
							}
						});
					}
				}});
			}});
			new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
			projectopen = false;
		} else {
			if (currentgallery == 'team') {
				document.getElementById('teamscroller').style.left = ((leftwidth + 35 + (barLength*startOffset*(-1))) - getThumbMoveDist(thumbWidth, currthumb));
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('tc'+currtab+'thumbtx'+(currthumblist[currtab])).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('cgallerywrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
					new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
					new Effect.Morph('teamscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() { gotothumb(currthumb); }});
				}});
			} else if (currentgallery == 'planning') {
				document.getElementById('planningscroller').style.left = ((leftwidth + 35 + (plnbarLength*startOffset*(-1))) - getThumbMoveDist(plnthumbWidth, plncurrthumb));
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('tc'+currtab+'thumbtx'+(currthumblist[currtab])).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('cgallerywrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
					new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
					new Effect.Morph('planningscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() { plngotothumb(plncurrthumb); }});
				}});
			} else if (currentgallery == 'interiors') {
				document.getElementById('interiorscroller').style.left = ((leftwidth + 35 + (intbarLength*startOffset*(-1))) - getThumbMoveDist(intthumbWidth, intcurrthumb));
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('tc'+currtab+'thumbtx'+(currthumblist[currtab])).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('cgallerywrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
					new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
					new Effect.Morph('interiorscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() { intgotothumb(intcurrthumb); }});
				}});
			}
		}
	}
	else if (oldPageType == 'i' && newPageType == 't') {
		new Effect.Morph('piccaptionwrap', {style: 'margin-top: -20px', duration:0.3});
		if (currentgallery == 'team') {
			document.getElementById('teamscroller').style.left = ((leftwidth + 35 + (barLength*startOffset*(-1))) - getThumbMoveDist(thumbWidth, currthumb));
			new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
				$('infopagetext').setStyle({display: 'none'});
			}});
			new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
				new Effect.Morph('mainpicwrap', { style: 'height: 1px; background-color: #eee', duration:0.5});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
				new Effect.Morph('teamscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {gotothumb(currthumb);}});
			}});
		} else if (currentgallery == 'planning') {
			document.getElementById('planningscroller').style.left = ((leftwidth + 35 + (plnbarLength*startOffset*(-1))) - getThumbMoveDist(plnthumbWidth, plncurrthumb));
			new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
				$('infopagetext').setStyle({display: 'none'});
			}});
			new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
				new Effect.Morph('mainpicwrap', { style: 'height: 1px; background-color: #eee', duration:0.5});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
				new Effect.Morph('planningscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {plngotothumb(plncurrthumb);}});
			}});
		} else if (currentgallery == 'interiors') {
			document.getElementById('interiorscroller').style.left = ((leftwidth + 35 + (intbarLength*startOffset*(-1))) - getThumbMoveDist(intthumbWidth, intcurrthumb));
			new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
				$('infopagetext').setStyle({display: 'none'});
			}});
			new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
				new Effect.Morph('mainpicwrap', { style: 'height: 1px; background-color: #eee', duration:0.5});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
				new Effect.Morph('interiorscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {intgotothumb(intcurrthumb);}});
			}});
		}
	}
	else if (oldPageType == 'h' && newPageType == 't') {
		new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:1.0, afterFinish: function() {
			if (currentgallery == 'team') {
				document.getElementById('teamscroller').style.left = ((leftwidth + 35 + (barLength*startOffset*(-1))) - getThumbMoveDist(thumbWidth, currthumb));
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
				new Effect.Morph('teamscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {gotothumb(currthumb);}});
			} else if (currentgallery == 'planning') {
				document.getElementById('planningscroller').style.left = ((leftwidth + 35 + (plnbarLength*startOffset*(-1))) - getThumbMoveDist(plnthumbWidth, plncurrthumb));
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
				new Effect.Morph('planningscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {plngotothumb(plncurrthumb);}});
			} else if (currentgallery == 'interiors') {
				document.getElementById('interiorscroller').style.left = ((leftwidth + 35 + (intbarLength*startOffset*(-1))) - getThumbMoveDist(intthumbWidth, intcurrthumb));
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
				new Effect.Morph('interiorscrollerwrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {intgotothumb(intcurrthumb);}});
			}
		}});
		if (flashMovie) {
			new Effect.Parallel([
			new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + parseInt($('intropic').getStyle('height'))) + 'px'}),
			new Effect.Morph('intropicwrap', {sync: true, style: 'height: 1px'})
				], {duration: 1.0, afterFinish: function() {
					$('intropicwrap').setStyle({visibility: 'hidden'});
					flashMovie.Rewind();
				}}
			);
		}
	}
	
	/* INFO PAGE TRANSITIONS */
	else if (oldPageType == newPageType && newPageType == 'i') {
		new Effect.Morph('piccaptionwrap', {style: 'margin-top: -20px', duration: 0.5});
		new Effect.Fade('mainpic',{duration:0.4});
		new Effect.Fade('trtext',{duration:0.4,afterFinish: function() {
			new Ajax.Updater('infopagetext','/content/' + contentfile + '.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function(){
				newPicZone(contentfile);
			}});
		}});
	}
	else if (oldPageType == 't' && newPageType == 'i') {
		if (projectopen) {
			new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
			new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
				$('intbodytx'+intcurrthumb).setStyle({display: 'none'});
				$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
				$('plnbodytx'+plncurrthumb).setStyle({display: 'none'});
				$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
			}});
			new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
				new Ajax.Updater('infopagetext','/content/' + contentfile + '.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function(){
					newPicZone(contentfile);
				}});
			}});
			new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
			projectopen = false;
		} else {
			if (currentgallery == 'team') {
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('thumbtx'+currthumb).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('teamscrollerwrap', {style: 'height: 0px', duration:0.5});
				new Effect.Morph('mainpicwrap', { style: 'background-color: #ccc', duration:0.5});
				new Ajax.Updater('infopagetext','/content/' + contentfile + '.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function(){
					newPicZone(contentfile);
				}});
			} else if (currentgallery == 'planning') {
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('planningscrollerwrap', {style: 'height: 0px', duration:0.5});
				new Effect.Morph('mainpicwrap', { style: 'background-color: #ccc', duration:0.5});
				new Ajax.Updater('infopagetext','/content/' + contentfile + '.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function(){
					newPicZone(contentfile);
				}});
			} else if (currentgallery == 'interiors') {
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('interiorscrollerwrap', {style: 'height: 0px', duration:0.5});
				new Effect.Morph('mainpicwrap', { style: 'background-color: #ccc', duration:0.5});
				new Ajax.Updater('infopagetext','/content/' + contentfile + '.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function(){
					newPicZone(contentfile);
				}});
			}
		}
	}
	else if (oldPageType == 'tc' && newPageType == 'i') {
		if (projectopen) {
			new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
			new Effect.Fade('trtext', {duration:0.4, afterFinish: function() {
				$('tc'+currtab+'bodytx'+(currthumblist[currtab])).setStyle({display: 'none'});
				$('tc'+currtab+'thumbtx'+(currthumblist[currtab])).setStyle({display: 'none'});
			}});
			new Effect.Fade('mainpic',{duration:0.4,afterFinish: function() {
				new Ajax.Updater('infopagetext','/content/' + contentfile + '.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function(){
					newPicZone(contentfile);
				}});
			}});
			new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
			projectopen = false;
		} else {
			new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
				$('tc'+currtab+'thumbtx'+(currthumblist[currtab])).setStyle({display: 'none'});
				new Ajax.Updater('infopagetext','/content/' + contentfile + '.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function(){
					newPicZone(contentfile);
				}});
			}});
			new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
			new Effect.Morph('cgallerywrap', {style: 'height: 0px', duration:0.5});
			new Effect.Morph('mainpicwrap', { style: 'background-color: #ccc', duration:0.5});
		}
	}
	else if (oldPageType == 'h' && newPageType == 'i') {
		$('mainpicwrap').setStyle({backgroundColor: '#ccc'});
		new Ajax.Updater('infopagetext','/content/' + contentfile + '.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function(){
			newPicZone(contentfile);
		}});
		if (flashMovie) {
			new Effect.Parallel([
				new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + parseInt($('intropic').getStyle('height'))) + 'px'}),
				new Effect.Morph('intropicwrap', {sync: true, style: 'height: 1px'})
				], {duration: 1.0, afterFinish: function() {
					$('intropicwrap').setStyle({visibility: 'hidden'});
					flashMovie.Rewind();
			}});
		}
	}
	
	/* ARCHITECTURE GALLERY PAGE TRANSITIONS */
	else if (oldPageType == newPageType && newPageType == 'tc') {
		if (projectopen) {
			closeproject(leftwidth);
			new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
			new Effect.Parallel([
				new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px'}),
				new Effect.Morph('cgallerywrap', {sync: true, style: 'height: 175px'})
				], {delay: 1.0, duration: 0.5, afterFinish: function() {
					gototcthumb(currthumblist[currtab]);
					projectopen = false;
			}});
		}
	}
	else if (oldPageType == 'i' && newPageType == 'tc') {
		new Effect.Morph('piccaptionwrap', {style: 'margin-top: -20px', duration:0.3});
		for (i = 0; i < tabs.length; i++)	{
			document.getElementById('tcscroll'+i).style.left = ((leftwidth + (categoryBarLength[i]*startOffset*(-1))) - (i * tabwidth) - getThumbMoveDist(categoryThumbWidth, (currthumblist[i])) + 10);
		}
		new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
			$('infopagetext').setStyle({display: 'none'});
		}});
		new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
			new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
			new Effect.Morph('mainpicwrap', { style: 'height: 1px; background-color: #eee', duration:0.5});
			new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
			new Effect.Morph('cgallerywrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {gototcthumb(currthumblist[currtab]);}});
		}});
	}
	else if (oldPageType == 't' && newPageType == 'tc') {
		if (projectopen) {
			new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
				$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
				$('intbodytx'+intcurrthumb).setStyle({display: 'none'});
				$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
				$('plnbodytx'+plncurrthumb).setStyle({display: 'none'});
			}});
			new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px; height: 1px; background-color: #eee', duration:0.5, afterFinish: function() {
					for (i = 0; i < tabs.length; i++)
							document.getElementById('tcscroll'+i).style.left = ((leftwidth + (categoryBarLength[i]*startOffset*(-1))) - (i * tabwidth) - getThumbMoveDist(categoryThumbWidth, (currthumblist[i])) + 10);
					new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
					new Effect.Morph('interiorscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function(){
						new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
						new Effect.Morph('cgallerywrap', {style: 'height: 175px', duration:0.5, afterFinish: function() { gototcthumb(currthumblist[currtab]); }});
					}});
				}});
				new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
			}});
			new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
			projectopen = false;
		} else {
			if (oldgallery == 'team') {
				for (i = 0; i < tabs.length; i++)
					document.getElementById('tcscroll'+i).style.left = ((leftwidth + (categoryBarLength[i]*startOffset*(-1))) - (i * tabwidth) - getThumbMoveDist(categoryThumbWidth, (currthumblist[i])) + 10);
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('thumbtx'+currthumb).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('teamscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
					new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
					new Effect.Morph('cgallerywrap', {style: 'height: 175px', duration:0.5, afterFinish: function() { gototcthumb(currthumblist[currtab]); }});
				}});
			} else if (oldgallery == 'planning') {
				for (i = 0; i < tabs.length; i++)
					document.getElementById('tcscroll'+i).style.left = ((leftwidth + (categoryBarLength[i]*startOffset*(-1))) - (i * tabwidth) - getThumbMoveDist(categoryThumbWidth, (currthumblist[i])) + 10);
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
				}});
				new Effect.Parallel([
					new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px'}),
					new Effect.Morph('planningscrollerwrap', {style: 'height: 0px', duration:0.5})
					], {duration: 0.5, afterFinish: function() {
						new Effect.Parallel([
							new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px'}),
							new Effect.Morph('cgallerywrap', {sync: true, style: 'height: 175px'})
							], {duration:0.5, afterFinish: function() {gototcthumb(currthumblist[currtab]);}}
						);
					}
				});
			} else if (oldgallery == 'interiors') {
				for (i = 0; i < tabs.length; i++)
					document.getElementById('tcscroll'+i).style.left = ((leftwidth + (categoryBarLength[i]*startOffset*(-1))) - (i * tabwidth) - getThumbMoveDist(categoryThumbWidth, (currthumblist[i])) + 10);
				new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
				}});
				new Effect.Parallel([
					new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px'}),
					new Effect.Morph('interiorscrollerwrap', {style: 'height: 0px', duration:0.5})
					], {duration: 0.5, afterFinish: function() {
						new Effect.Parallel([
							new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px'}),
							new Effect.Morph('cgallerywrap', {sync: true, style: 'height: 175px'})
							], {duration:0.5, afterFinish: function() {gototcthumb(currthumblist[currtab]);}}
						);
					}
				});
			}
		}
	}
	else if (oldPageType == 'h' && newPageType == 'tc') {
		new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:1.0, afterFinish: function() {
			for (i = 0; i < tabs.length; i++)
				document.getElementById('tcscroll'+i).style.left = ((leftwidth + (categoryBarLength[i]*startOffset*(-1))) - (i * tabwidth) - getThumbMoveDist(categoryThumbWidth, (currthumblist[i])) + 10);
			new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) - 175) + 'px', duration:0.5});
			new Effect.Morph('cgallerywrap', {style: 'height: 175px', duration:0.5, afterFinish: function() {gototcthumb(currthumblist[currtab]);}});
		}});
		if (flashMovie) {
			new Effect.Parallel([
				new Effect.Morph('pagetable', {sync: true, style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + parseInt($('intropic').getStyle('height'))) + 'px'}),
				new Effect.Morph('intropicwrap', {sync: true, style: 'height: 1px'})
				], {duration: 1.0, afterFinish: function() {
					$('intropicwrap').setStyle({visibility: 'hidden'});
					flashMovie.Rewind();				
				}}
			);
		}
	}
	
	/* HOMEPAGE TRANSITIONS */
	else if (oldPageType == 'i' && newPageType == 'h') {
		new Effect.Morph('piccaptionwrap', {style: 'margin-top: -20px', duration:0.3});
		new Effect.Morph('mainpicfooterwrap', {style: 'height: 1px', duration: 0.3});
		new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
			$('infopagetext').setStyle({display: 'none'});
		}});
		new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
			new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px;', duration:0.5});
			new Effect.Morph('mainpicwrap', { style: 'height: 1px; background-color: #eee', duration:0.5});
			playFlash();
		}});
	}
	
	else if (oldPageType == 't' && newPageType == 'h') {
		new Effect.Morph('mainpicfooterwrap', {style: 'height: 1px', duration: 0.3});
		if (projectopen) {
			new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
			new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
				$('intbodytx'+intcurrthumb).setStyle({display: 'none'});
				$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
				$('plnbodytx'+plncurrthumb).setStyle({display: 'none'});
				$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
			}});
			new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
				new Effect.Morph('mainpicwrap', { style: 'height: 1px; background-color: #eee', duration:0.5});
				playFlash();
			}});
			new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
			projectopen = false;
		} else {
			if (parseInt($('teamscrollerwrap').getStyle('height'))) {
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('thumbtx'+currthumb).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('teamscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
					playFlash();
				}});
			} else if (parseInt($('planningscrollerwrap').getStyle('height'))) {
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('planningscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
					playFlash();
				}});
			} else {
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
				}});
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
				new Effect.Morph('interiorscrollerwrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
					playFlash();
				}});
			}
		}
	}
	else if (oldPageType == 'tc' && newPageType == 'h') {
		new Effect.Morph('mainpicfooterwrap', {style: 'height: 1px', duration: 0.3});
		if (projectopen) {
			new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
			new Effect.Fade('trtext', {duration:0.4, afterFinish: function() {
				$('tc'+currtab+'bodytx'+(currthumblist[currtab])).setStyle({display: 'none'});
				$('tc'+currtab+'thumbtx'+(currthumblist[currtab])).setStyle({display: 'none'});
				$('trtext').setStyle({
					marginTop: '20px',
					paddingLeft: '50px'
				});
			}});
			new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
				new Effect.Morph('mainpicwrap', { style: 'height: 1px; background-color: #eee', duration:0.5});
				playFlash();
			}});
			new Effect.Appear(piclinkid, {delay: 0.5, duration: 0.3});
			projectopen = false;
		} else {
			new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
				$('tc'+currtab+'thumbtx'+(currthumblist[currtab])).setStyle({display: 'none'});
			}});
			new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', duration:0.5});
			new Effect.Morph('cgallerywrap', {style: 'height: 0px', duration:0.5, afterFinish: function() {
				playFlash();
			}});
			new Effect.Morph('mainpicwrap', { style: 'background-color: #ccc', duration:0.5});
		}
	}
	oldPageType = newPageType;
}

/*function fadecontent(contentfile, pageType) {
	//new Effect.Fade('trtext',{duration:0.8,afterFinish: function() {
		if (pageType == 'i') {
			if ($('piccaptionwrap').getStyle('display') != 'none') {
				new Effect.Morph('piccaptionwrap', {style: 'margin-top: -20px', duration: 0.5, afterFinish: function() {
					new Ajax.Updater('piccaption','/content/' + contentfile + '.php?directload=1&fetchcaption=1', {asynchronous:true, evalScripts:true, onComplete: function() {
						// if page is going from an info page to an info page, fade the info panel
						new Effect.Morph('piccaptionwrap', {style: 'margin-top: 0px', {duration: 0.5});
					}});
				}});
			} else {
				new Ajax.Updater('piccaption','/content/' + contentfile + '.php?directload=1&fetchcaption=1', {asynchronous:true, evalScripts:true, onComplete: function() {
					// if page is going from an info page to an info page, fade the info panel
					new Effect.Morph('piccaptionwrap', {style: 'margin-top: 0px', duration: 0.5});
				}});
			}
		}
		if (pageType == 't') {
			document.getElementById('infopagetext').style.display = 'none';
		}
		else
			new Ajax.Updater('infopagetext','/content/' + contentfile + '.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function(){new Effect.Appear('trtext', {duration: 0.4});}});	
	//}});
}*/

function newPicZone(contentfile) {
	var dimensions = $('body').getDimensions();
	var picname = imageID[contentfile];
	//alert("Width: "+dimensions.width+"\nHeight: "+dimensions.height);
	
	if (f_clientHeight() > 750) {
		picname = (picname + 1) + ".jpg";
		picwidth = 523;
		picheight = 475;
	}
	else {
		picname = picname + ".jpg";
		picwidth = 440;
		picheight = 325;
	}
	//alert("picname: "+picname+"\npicwidth: "+picwidth+"\npicheight: "+picheight);
	if (oldPageType == 't' || oldPageType == 'tc' || contentfile == 'home') {
		swapmainpic(picname, '/display/zone/');
		new Effect.Morph('mainpicwrap',{ style:'width:'+picwidth+'px;height:'+picheight+'px;', duration:0.5,afterFinish: function() { 
			var rightwidth = dimensions.width - parseInt($('mainpicwrap').getStyle('width'));
			var newleft = (rightwidth/2) - (424/2) + 'px';
			if (contentfile != 'directory')
				$('trtext').setStyle({marginTop: '100px', paddingLeft: newleft});
			else
				$('trtext').setStyle({marginTop: '40px', paddingLeft: newleft});
			document.getElementById('mainpic').style.width = picwidth + 'px';
			new Ajax.Updater('piccaption','/content/' + contentfile + '.php?directload=1&fetchcaption=1', {asynchronous:true, evalScripts:true, onComplete: function() {
				new Effect.Appear('mainpic',{duration:0.5});
				new Effect.Appear('trtext', {duration: 0.4});
				new Effect.Morph('piccaptionwrap', {style: 'margin-top: 0px', duration: 0.5});
			}});
			//document.getElementById('mainpic').style.height = picheight + 'px';
		}});
	} else {
		new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
			swapmainpic(picname, '/display/zone/');
			new Effect.Morph('mainpicwrap',{ style:'width:'+picwidth+'px;height:'+picheight+'px;', duration:0.5,afterFinish: function() {
				//alert(dimensions.width+" "+f_clientWidth());
				var rightwidth = dimensions.width - parseInt($('mainpicwrap').getStyle('width'));
				var newleft = (rightwidth/2) - (424/2) + 'px';
				if (contentfile != 'directory') {
					if (f_clientHeight() < 750)
						$('trtext').setStyle({marginTop: '50px', paddingLeft: newleft});
					else
						$('trtext').setStyle({marginTop: '100px', paddingLeft: newleft});
				} else {
					if (f_clientHeight() < 750)
						$('trtext').setStyle({marginTop: '20px', paddingLeft: newleft});
					else
						$('trtext').setStyle({marginTop: '40px', paddingLeft: newleft});
				}
				document.getElementById('mainpic').style.width = picwidth + 'px';
				document.getElementById('mainpic').style.height = picheight + 'px';
				new Ajax.Updater('piccaption','/content/' + contentfile + '.php?directload=1&fetchcaption=1', {asynchronous:true, evalScripts:true, onComplete: function() {
					$('infopagetext').setStyle({display: 'inline'});
					new Effect.Appear('mainpic',{duration:0.5});
					new Effect.Appear('trtext', {duration: 0.4});
					new Effect.Morph('piccaptionwrap', {style: 'margin-top: 0px', duration: 0.5});
				}});
			}});
		}});
	}
}

var tabs = [], tabwidth, currtab = 0, currthumblist = [], runOnce = false, tabwidth, categoryBarLength = [], topAccordion;
function loadAccordions() {
	var windowwidth = $('body').getDimensions().width;
	if (staticgallery != 'architecture') {
		new Ajax.Updater($('horizontal_container'),'/content/thumbs_arch.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function() {
		tabs = $$('div.horizontal_accordion_content');
		currtab = tabs.length - 1;
		
		tabwidth = 25;
		var tabpanewidth = windowwidth - (tabs.length * tabwidth) - tabs.length + 5;
		if (isie)
			tabpanewidth -= 24;
					
		topAccordion = new accordion('horizontal_container', {
			classNames : {
				toggle : 'horizontal_accordion_toggle',
				toggleActive : 'horizontal_accordion_toggle_active',
				content : 'horizontal_accordion_content'
			},
			defaultSize : {
				width : tabpanewidth
			},
			direction : 'horizontal'
		});
		
		if (isie) {
			var nexts = $$('div#cgallerywrap  div.nextthumb');
			var max = nexts.length - 1;
			for (i = 0; i < nexts.length; i++) {
				nexts[i].setStyle({'left': (windowwidth - 93 - (25 * max))+'px'});
			}
		}
		
		firsttcthumb();
		
		// Open last one
		topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[currtab]);
		}});
	} else {
		tabs = $$('div.horizontal_accordion_content');
		currtab = tabs.length - 1;
		
		tabwidth = 25;
		var tabpanewidth = windowwidth - (tabs.length * tabwidth) - tabs.length + 5;
		if (isie)
			tabpanewidth -= 24;
		
		topAccordion = new accordion('horizontal_container', {
			classNames : {
				toggle : 'horizontal_accordion_toggle',
				toggleActive : 'horizontal_accordion_toggle_active',
				content : 'horizontal_accordion_content'
			},
			defaultSize : {
				width : tabpanewidth
			},
			direction : 'horizontal'
		});
		
		if (isie) {
			var nexts = $$('div#cgallerywrap  div.nextthumb');
			var max = nexts.length - 1;
			for (i = 0; i < nexts.length; i++) {
				nexts[i].setStyle({'left': (windowwidth - 93 - (25 * max))+'px'});
			}
		}
		
		firsttcthumb();
		
		// Open last one
		topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[currtab]);
	}
}

function firsttcthumb() {
	var leftwidth = Math.round(.55 * $('body').getDimensions().width);
	for (i = 0; i < tabs.length; i++) {	
		categoryBarLength[i] = categoryThumbTotal[i] * categoryThumbWidth;
		document.getElementById('tcscroll' + i).style.width = (categoryBarLength[i] * 5) + 'px';
		if (staticgallery == 'architecture')
			document.getElementById('tcscroll'+i).style.left = ((leftwidth + (categoryBarLength[i]*startOffset*(-1))) - (i * tabwidth) - getThumbMoveDist(categoryThumbWidth, (currthumblist[i])) + 10);
	}
	if (staticgallery != 'architecture')
		new Ajax.Updater('tctext_swap','/content/thumbs_arch_tx.php?directload=1', {asynchronous:true, evalScripts:true, onComplete: function() {architectureDone = true;}});
}

function gototcthumb(newthumb, offset, catID) {
	if (animDone) {
		animDone = false;
		
		if (offset == undefined)
			offset = 0;
		
		var leftwidth = $('tlcol').getDimensions().width;
		var scrollerpos = (Number(document.getElementById('tcscroll' + currtab).style.left.replace(/px/i, '')));
		
		var currthumbtxid='tc'+currtab+'thumbtx'+(currthumblist[currtab]);
		var newthumbtxid='tc'+currtab+'thumbtx'+newthumb;
		var currthumbid='tc'+currtab+'thumb'+(currthumblist[currtab]);
		var newthumbid='tc'+currtab+'thumb'+newthumb;
		//alert(newthumbid + ", " + offset);
		if (currthumblist[currtab] == newthumb) {
			if (oldgallery == 'architecture' && !projectopen) {
				projectopen = true;
				newproject(catID);
			} else {
				if (catID == undefined)
					catID = 41;
				new Effect.Appear(newthumbid,{duration:0.3, afterFinish: function() {currthumblist[currtab]=newthumb;}});
				$(newthumbtxid).setStyle({display: 'inline'});
				$('trtext').setStyle({
					marginTop: '20px',
					paddingLeft: '50px'
				});
				new Effect.Appear('trtext',{duration:0.3, afterFinish: function() {animDone = true;}});
			}
		} else {
			// Fade the currently selected photograph
			new Effect.Fade(currthumbid,{duration:0.2, afterFinish: function() {
				if (offset != 0)
					document.getElementById('tcscroll' + currtab).style.left = scrollerpos + (categoryBarLength[currtab] * offset);
				// Slide the bar over
				//alert(getThumbMoveDist(categoryThumbWidth, newthumb, currthumblist[currtab]));
				new Effect.Morph('tcscroll' + currtab, {style: 'left: '+(scrollerpos - getThumbMoveDist(categoryThumbWidth, newthumb, currthumblist[currtab]))+';', duration: 0.4, transition: Effect.Transitions.sinoidal});
			}});
			// Fade the selected photograph text
			new Effect.Fade('trtext', {duration:0.2, afterFinish: function() {
				$(currthumbtxid).setStyle({display: 'none'});
				$(newthumbtxid).setStyle({display: 'inline'});
				new Effect.Appear(newthumbid,{delay: 0.4, duration:0.3, afterFinish: function() {
					currthumblist[currtab]=newthumb;
					new Effect.Appear('trtext', {duration:0.3, afterFinish: function() {animDone = true;}});
				}});
			}});
		}
		new Ajax.Request('/content/build_project.php?catid='+catID+'&editor=9&firstimg=1', {
			asynchronous: true,
			evalJS: true,
			onSuccess: function(transport) {
				eval(transport.responseText);
			}
		});
		oldgallery = currentgallery;
	}
}

function tctabchange(newthumb) {
	var leftwidth = $('tlcol').getDimensions().width;
	var scrollerpos = (Number(document.getElementById('tcscroll' + currtab).style.left.replace(/px/i, '')));
	
	var currthumbtxid='tc'+currtab+'thumbtx'+(currthumblist[currtab]);
	var newthumbtxid='tc'+currtab+'thumbtx'+newthumb;
	var currthumbid='tc'+currtab+'thumb'+(currthumblist[currtab]);
	var newthumbid='tc'+currtab+'thumb'+newthumb;
	
	new Effect.Appear(newthumbid,{duration:0.3, afterFinish: function() {currthumblist[currtab]=newthumb;}});
	new Effect.Appear(newthumbtxid,{delay: 0.2, duration:0.3});
}

function nexttcthumb() {
	var newthumb = currthumblist[currtab] + 1;
	if (newthumb >= categoryThumbTotal[currtab])
		gototcthumb(0, 1);
	else
		gototcthumb(newthumb);
}

function resizeAccordions() {
	var windowwidth = $('body').getDimensions().width;
	if (isie) {
		if (parseInt($('teamscrollerwrap').getStyle('height')) || parseInt($('interiorscrollerwrap').getStyle('height')) || parseInt($('cgallerywrap').getStyle('height'))) {
			pagetable.style.setExpression("height", "document.body.clientHeight - 11 - 175");
		} else {
			pagetable.style.setExpression("height", "document.body.clientHeight - 11 - parseInt($('intropicwrap').getStyle('height'))");
		}
		document.recalc(true);
		var nexts = $$('div#cgallerywrap  div.nextthumb');
		var max = nexts.length - 1;
		for (i = 0; i < nexts.length; i++) {
			nexts[i].setStyle({'left': (windowwidth - 93 - (25 * max))+'px'});
		}
	} else {
		if (parseInt($('teamscrollerwrap').getStyle('height')) || parseInt($('interiorscrollerwrap').getStyle('height')) || parseInt($('cgallerywrap').getStyle('height'))) {
			$('pagetable').setStyle({'height': (document.body.clientHeight - 11 - 175) + 'px'});
		} else {
			$('pagetable').setStyle({'height': (document.body.clientHeight - 11 - parseInt($('intropicwrap').getStyle('height'))) + 'px'});
		}
	}
	if (topAccordion != undefined) {
		var tabpanewidth = windowwidth - (tabs.length * tabwidth) - tabs.length;
		
		var oldwidth = parseInt($$('#horizontal_container .horizontal_accordion_content')[currtab].getStyle('width'));
		var newwidth = windowwidth - (tabwidth * tabs.length)
		if (isie)
			newwidth -= 24;
		$$('#horizontal_container .horizontal_accordion_content')[currtab].setStyle({
			'width': newwidth + 'px'
		});
		topAccordion.options.defaultSize.width = newwidth;
		
		if (oldPageType == 'tc' && !projectopen) {
			var leftwidth = Math.round(.55 * windowwidth);
			document.getElementById('mainpicwrap').style.width = (leftwidth-1);
			for (i = 0; i < tabs.length; i++) {
				document.getElementById('tcscroll'+i).style.left = ((leftwidth + (categoryBarLength[i]*startOffset*(-1))) - (i * tabwidth) - getThumbMoveDist(categoryThumbWidth, (currthumblist[i])) + 10);
			}
		}
	}
	if (projectopen || oldPageType == 'i') {
		var rightwidth = $('body').getDimensions().width - parseInt($('mainpicwrap').getStyle('width'));
		var newleft = (rightwidth/2) - (424/2) + 'px';
		$('trcol').setStyle({left: newleft});
	}
}

var oldproject = 'project0', projectopen = false, currentcatID;

function newproject(catID) {
	var editor, gallery;
	currentcatID = catID;
	oldproject = 'project0';
	
	$('body').setStyle({cursor: 'progress'});
	
	if (oldPageType == 'tc') {
		gallery = "cgallerywrap";
		editor = 9;
		piclinkid = "tc" + currtab + "plink" + (currthumblist[currtab]);
		loadingid = "tc" + currtab + "loading" + (currthumblist[currtab]);
		
		new Effect.Fade(piclinkid, {duration: 0.2, afterFinish: function() {new Effect.Appear(loadingid, {duration: 0.3});}});
		new Ajax.Updater('picnavwrap','/content/build_project.php?catid='+catID+'&editor='+editor+'&category='+(currtab+1), {asynchronous:true, evalScripts:true, onComplete: function() {
			new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', delay: 0.5, duration:0.5});
			new Effect.Morph('picnavwrap', {style: 'margin-top: 0px', delay: 1.0, duration:0.5, afterFinish: function() {
				animDone = true;
			}});
			new Effect.Morph(gallery, {style: 'height: 0px', delay: 0.5, duration:0.5});
			new Effect.BlindDown('tc'+currtab+'bodytx'+currthumblist[currtab], {delay: 0.5, duration:0.5});
			new Effect.Morph('thumbreturn', {style: 'margin-top: 0px', delay: 1.5, duration: 0.4});
			$('body').setStyle({cursor: 'auto'});
			new Effect.Fade(loadingid, {duration: 0.3});
		}});
	} else {
		if (currentgallery == 'interiors') {
			gallery = "interiorscrollerwrap"
			editor = 10;
			piclinkid = "plink" + intcurrthumb;
			loadingid = "loading" + intcurrthumb;
	
			new Effect.Fade(piclinkid, {duration: 0.2, afterFinish: function() {new Effect.Appear(loadingid, {duration: 0.3});}});
			new Ajax.Updater('picnavwrap','/content/build_project.php?catid='+catID+'&editor='+editor, {asynchronous:true, evalScripts:true, onComplete: function() {
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', delay: 0.5, duration:0.5});
				new Effect.Morph('picnavwrap', {style: 'margin-top: 0px', delay: 1.0, duration:0.5, afterFinish: function() {
					intanimdone = true;
				}});
				new Effect.Morph(gallery, {style: 'height: 0px', delay: 0.5, duration:0.5});
				new Effect.BlindDown('intbodytx'+intcurrthumb, {delay: 0.5, duration:0.5});
				new Effect.Morph('thumbreturn', {style: 'margin-top: 0px', delay: 1.5, duration: 0.4});
				$('body').setStyle({cursor: 'auto'});
				new Effect.Fade(loadingid, {duration: 0.3});
			}});
		} else if (currentgallery == 'planning') {
			gallery = "planningscrollerwrap"
			editor = 12;
			piclinkid = "plnplink" + plncurrthumb;
			loadingid = "plnloading" + plncurrthumb;
	
			new Effect.Fade(piclinkid, {duration: 0.2, afterFinish: function() {new Effect.Appear(loadingid, {duration: 0.3});}});
			new Ajax.Updater('picnavwrap','/content/build_project.php?catid='+catID+'&editor='+editor, {asynchronous:true, evalScripts:true, onComplete: function() {
				new Effect.Morph('pagetable', { style: 'height: ' + (parseInt($('pagetable').getStyle('height')) + 175) + 'px', delay: 0.5, duration:0.5});
				new Effect.Morph('picnavwrap', {style: 'margin-top: 0px', delay: 1.0, duration:0.5, afterFinish: function() {
					plnanimdone = true;
				}});
				new Effect.Morph(gallery, {style: 'height: 0px', delay: 0.5, duration:0.5});
				new Effect.BlindDown('plnbodytx'+plncurrthumb, {delay: 0.5, duration:0.5});
				new Effect.Morph('thumbreturn', {style: 'margin-top: 0px', delay: 1.5, duration: 0.4});
				$('body').setStyle({cursor: 'auto'});
				new Effect.Fade(loadingid, {duration: 0.3});
			}});
		}
	}
}

function projectpic(lineid, picname, lgpicname, picwidth, picheight, lgpicwidth, lgpicheight) {
	var gallery, textcontainer;
	var dimensions = $('body').getDimensions();
	//alert("Width: "+dimensions.width+"\nHeight: "+dimensions.height);
	
	if (f_clientHeight() > 750 && picwidth < 500) {
		picname = lgpicname;
		picwidth = lgpicwidth;
		picheight = lgpicheight;
	}
	
	var rightwidth = dimensions.width - picwidth;
	var gallerytextwidth = 424;
	var newleft = (rightwidth/2) - (gallerytextwidth/2) + "px";
	
	var directory = picname.substr(0, picname.lastIndexOf("/") + 1);
	picname = picname.substr(picname.lastIndexOf("/") + 1);
	//alert("picname: "+picname+"\npicwidth: "+picwidth+"\npicheight: "+picheight+"\ndirectory: "+directory);
	
	var newproject = 'project'+lineid;
	//alert("old: " + oldproject + "\nnew: "+newproject);
	
	if(oldproject!='project0' && oldproject != newproject) { new Effect.Morph(oldproject,{ style:'margin-top:8px;height:8px;background-color:#666;', duration:0.5 }); }

	if (oldproject != newproject) {
		new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
			swapmainpic(picname, directory);
			new Effect.Morph('trtext', {style: {marginTop: '100px', paddingLeft: newleft}, duration: 0.5});
			if (isie)
				new Effect.Morph('mainpicfooterwrap', {style: {width: picwidth+'px'}, duration: 0.5});
			new Effect.Morph('mainpicwrap',{ style:'width:'+picwidth+'px; height:'+picheight+'px; background-color: #ccc', duration:0.5, afterFinish: function() {
				document.getElementById('mainpic').style.width = picwidth + 'px';
				document.getElementById('mainpic').style.height = picheight + 'px';
				new Effect.Appear('mainpic',{duration:0.5});
				new Effect.Morph(newproject,{ style:'margin-top:0px;height:17px;background-color:#716C00;', duration:0.3 });
				}});
		}});
	}
	
	oldproject=newproject;
}

function closeproject(leftwidth) {
	if (currentgallery == 'architecture')
		new Effect.BlindUp('tc'+currtab+'bodytx'+currthumblist[currtab], {duration:0.5});
	else if (currentgallery == 'interiors')
		new Effect.BlindUp('intbodytx'+intcurrthumb, {duration:0.5});
	else if (currentgallery == 'planning')
		new Effect.BlindUp('plnbodytx'+plncurrthumb, {duration:0.5});
	
	new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
		new Effect.Morph('mainpicwrap',{ style:'width: ' + (leftwidth-1) + 'px; height: 1px; background-color: #eee', duration:0.5});
		new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
		//new Effect.Morph('mainpicfooterwrap', {style: {width: '393px'}, delay: 0.5, duration: 0.5}); // does not appear to be needed
		new Effect.Morph('trtext', {
			style: {
				marginTop: '20px',
				paddingLeft: '50px'
			},
			duration: 0.5
		});
	}});
}

function nextproject(catID) {
	var editor, gallery, newthumb, newthumbtx, oldpiclinkid = piclinkid;
	oldproject = 'project0';
	
	$('body').setStyle({cursor: 'progress'});
			
	new Effect.Morph('picnavwrap', {style: 'margin-top: -20px', duration:0.5});
	new Effect.Fade('mainpic',{duration:0.5,afterFinish: function() {
		if (currentgallery == 'interiors') {
			gallery = "interiorscrollerwrap";
			editor = 10;
			var scrollerpos = (Number(document.getElementById('interiorscroller').style.left.replace(/px/i, '')));
			var loadingid = "loading" + intcurrthumb;
			
			new Effect.Appear(loadingid, {duration: 0.3});
			document.getElementById('intthumb'+intcurrthumb).style.display = 'none';
			new Ajax.Updater('picnavwrap','/content/build_project.php?catid='+catID+'&editor='+editor, {asynchronous:true, evalScripts:true, onComplete: function() {
				$('body').setStyle({cursor: 'auto'});
				new Effect.Morph('picnavwrap', {style: 'margin-top: 0px', delay: 1.0, duration:0.5});
				new Effect.Morph(gallery, {style: 'height: 0px', delay: 0.5, duration:0.5});
				new Effect.Fade(loadingid, {duration: 0.3});
				
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('intbodytx'+intcurrthumb).setStyle({display: 'none'});
					$('intthumbtx'+intcurrthumb).setStyle({display: 'none'});
					
					$(oldpiclinkid).setStyle({display: 'inline'});
					
					if (intcurrthumb + 1 == intthumbTotal) {
						intcurrthumb = 0;
						document.getElementById('interiorscroller').style.left = (scrollerpos + ((intthumbTotal - 1) * intthumbWidth)) + "px";
					} else {
						intcurrthumb++;
						document.getElementById('interiorscroller').style.left = (scrollerpos - intthumbWidth) + "px";
					}
					var newthumbtx='intthumbtx'+intcurrthumb;
					var newbodytx='intbodytx'+intcurrthumb;
					var newthumb='intthumb'+intcurrthumb;
					
					document.getElementById(newthumb).style.display = 'inline';
					$(newthumbtx).setStyle({display: 'inline'});
					$(newbodytx).setStyle({display: 'inline'});
					new Effect.BlindDown(newbodytx, {duration:0.1});
					new Effect.Appear('trtext',{delay: 0.1, duration:0.5});
					piclinkid = "plink" + intcurrthumb;
					$(piclinkid).setStyle({display: 'none'});
				}});
			}});
		} else if (currentgallery == 'planning') {
			gallery = "planningscrollerwrap";
			editor = 12;
			var scrollerpos = (Number(document.getElementById('planningscroller').style.left.replace(/px/i, '')));
			var loadingid = "plnloading" + plncurrthumb;
			
			new Effect.Appear(loadingid, {duration: 0.3});
			document.getElementById('plnthumb'+plncurrthumb).style.display = 'none';
			new Ajax.Updater('picnavwrap','/content/build_project.php?catid='+catID+'&editor='+editor, {asynchronous:true, evalScripts:true, onComplete: function() {
				$('body').setStyle({cursor: 'auto'});
				new Effect.Morph('picnavwrap', {style: 'margin-top: 0px', delay: 1.0, duration:0.5});
				new Effect.Morph(gallery, {style: 'height: 0px', delay: 0.5, duration:0.5});
				new Effect.Fade(loadingid, {duration: 0.3});
				
				new Effect.Fade('trtext',{duration:0.4, afterFinish: function() {
					$('plnbodytx'+plncurrthumb).setStyle({display: 'none'});
					$('plnthumbtx'+plncurrthumb).setStyle({display: 'none'});
					
					$(oldpiclinkid).setStyle({display: 'inline'});
					if (plncurrthumb + 1 == plnthumbTotal) {
						plncurrthumb = 0;
						$('planningscroller').setStyle({left: (scrollerpos + ((plnthumbTotal - 1) * plnthumbWidth)) + "px"});
					} else {
						plncurrthumb++;
						document.getElementById('planningscroller').style.left = (scrollerpos - plnthumbWidth) + "px";
					}
					var newthumbtx='plnthumbtx'+plncurrthumb;
					var newbodytx='plnbodytx'+plncurrthumb;
					var newthumb='plnthumb'+plncurrthumb;
					
					document.getElementById(newthumb).style.display = 'inline';
					$(newthumbtx).setStyle({display: 'inline'});
					$(newbodytx).setStyle({display: 'inline'});
					new Effect.BlindDown(newbodytx, {duration:0.1});
					new Effect.Appear('trtext',{delay: 0.1, duration:0.5});
					piclinkid = "plnplink" + plncurrthumb;
					$(piclinkid).setStyle({display: 'none'});
				}});
			}});
		} else if (currentgallery == 'architecture') {
			gallery = "cgallerywrap";
			editor = 9;
			var scrollerpos = (Number(document.getElementById('tcscroll' + currtab).style.left.replace(/px/i, '')));
			var loadingid = "tc" + currtab + "loading" + (currthumblist[currtab]);
			
			new Effect.Appear(loadingid, {duration: 0.3});
			
			document.getElementById('tc'+currtab+'thumb'+(currthumblist[currtab])).style.display = 'none';
			new Ajax.Updater('picnavwrap','/content/build_project.php?catid='+catID+'&editor='+editor+'&category='+(currtab+1), {asynchronous:true, evalScripts:true, onComplete: function() {
				$('body').setStyle({cursor: 'auto'});
				new Effect.Morph('picnavwrap', {style: 'margin-top: 0px', delay: 1.0, duration:0.5});
				new Effect.Morph(gallery, {style: 'height: 0px', delay: 0.5, duration:0.5});
				new Effect.Fade(loadingid, {duration: 0.3});
				
				new Effect.Fade('trtext', {duration:0.4, afterFinish: function() {
					$('tc'+currtab+'bodytx'+(currthumblist[currtab])).setStyle({display: 'none'});
					$('tc'+currtab+'thumbtx'+(currthumblist[currtab])).setStyle({display: 'none'});
					$(oldpiclinkid).setStyle({display: 'inline'});
					
					if (currthumblist[currtab] + 1 == categoryThumbTotal[currtab]) {
						currthumblist[currtab] = 0;
						document.getElementById('tcscroll' + currtab).style.left = (scrollerpos + ((categoryThumbTotal[currtab] - 1) * categoryThumbWidth)) + "px";
					} else {
						currthumblist[currtab]++;
						document.getElementById('tcscroll' + currtab).style.left = (scrollerpos - categoryThumbWidth) + "px";
					}
					
					var newthumbtx='tc'+currtab+'thumbtx'+currthumblist[currtab];
					var newbodytx='tc'+currtab+'bodytx'+currthumblist[currtab];
					var newthumb='tc'+currtab+'thumb'+currthumblist[currtab];
					
					document.getElementById(newthumb).style.display = 'inline';
					$(newthumbtx).setStyle({display: 'inline'});
					$(newbodytx).setStyle({display: 'inline'});
					new Effect.BlindDown(newbodytx, {duration:0.1});					
					new Effect.Appear('trtext',{duration:0.5});
					piclinkid = "tc" + currtab + "plink" + (currthumblist[currtab]);
					$(piclinkid).setStyle({display: 'none'});
				}});
			}});
		}
	}});
}

function viewphotos(catID) {
	if (!projectopen) {
		projectopen=true;
		newproject(catID);
	}
}

function playFlash(mydelay)
{
	if (flashMovie) {
		if (mydelay == undefined)
			mydelay = 0;
		$('intropicwrap').setStyle({visibility: 'visible'});
		$('intropic').setStyle({height: homeDivHeight()+'px'});
		flashMovie.Play();
		new Effect.Parallel([
			new Effect.Morph('intropicwrap', {sync: true, style: 'height: '+homeDivHeight()+'px'}),
			new Effect.Morph('pagetable', {sync: true, style: 'height: '+(parseInt($('pagetable').getStyle('height')) - homeDivHeight())+'px'})
			], {delay: mydelay, duration: 1.6}
		);
	}
}

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName] || false;
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName] || false; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName) || false;
  }
}

function homeDivHeight() {
	var height = document.body.clientHeight - 11 - 251 - 30;
	if (height > 420)
		height = 420;
	else if (height < 300)
		height = 300;
	return height;
}