function showPress(image, disp){
	if(disp){
		Element.setOpacity('press-border', 0);
		$('press').style.visibility = 'visible';
		new Effect.Appear('press-border');
		showDiv('loading', true);
		if(!/Safari/.test(navigator.userAgent)){
			ipPress = new ImagePreloader(['./images/press/'+image], onPreloadPress);
		}
		else{
			onPreloadPress();
		}
		scroll(0,0);
	}
	else{
		$('press-border').style.visibility = 'hidden';
		$('press').style.visibility = 'hidden';
		$('press-border').innerHTML = '';
		if(!/MSIE/.test(navigator.userAgent)){
			$('main-html').style.overflow = 'hidden';
		}
		else{
			$('press').style.height = 'auto';
		}
		showClose(false);
		scroll(0,0);
	}
}
function prepPage(pos, disp){
	if(pos==1){
		$('middle-middle').innerHTML = '';
		$('middle-middle-padding-top').innerHTML = '';
	}
	else{
		$('middle-middle-main').innerHTML = '';		
	}
	showDiv('loading', true);
}
function onPreloadSite(aImages){
	ajaxLoad(0);
}
function onPreloadSlide(){
	this.curimg = Math.floor(Math.random()*(galleryarray.length-1));
	this.slideImages = rotateimages;	
	showDiv('loading', false);
	$('slideshow').style.paddingTop='102px';
	Element.setOpacity('slideshow', 0);
	$('slideshow').setAttribute('src', galleryarray[this.curimg]);
	new Effect.Appear('slideshow');
	LasSlideShow = new PeriodicalExecuter(this.slideImages, 5);
}
function rotateimages(){
	new Effect.Fade('slideshow');
	if(this.curimg < galleryarray.length-1){
		this.curimg = this.curimg+1;
	}else{
		this.curimg = 0;
	}
	setTimeout("$('slideshow').setAttribute('src', '"+galleryarray[this.curimg]+"');new Effect.Appear('slideshow');", 1000);	
}
function onPreloadFace(aImage){}
function onPreloadPress(aImage){
	$('press-border').style.visibility = 'visible';
	if(aImage[0].height<window.innerHeight){		
		$('press').style.height = '100%';
	}
	else{
		if(!/MSIE/.test(navigator.userAgent)){
			$('main-html').style.overflow = 'auto';
		}
		$('press').style.height = (aImage[0].height)+'px';	
	}
	$('press-border').innerHTML = "<img src='"+aImage[0].src+"'/>";
	new Effect.Appear('press-border');
	showDiv('loading', false);
}
function showClose(show){
	if(show){
		showDiv("close", show);
		if(/MSIE/.test(navigator.userAgent)){
			$("close").style.top = document.body.parentElement.scrollTop + "px";
		}
		else{
			$("close").style.top = window.pageYOffset + "px";
		}
		$("close").style.left = "438px";
	}
	else{
		showDiv("close", show);
	}
}
function menuItemChange(p, q){
	if(q==0){
		$('menuitem-'+p).style.backgroundImage="url(images/nav-menu/nav_"+p+"_rollover.gif)";
	}else{
		$('menuitem-'+p).style.backgroundImage="url(images/nav-menu/nav_"+p+".gif)";
	}
}
function faceChange(p, q){
	if(q==0){
		Element.setOpacity(p+'-img', 0);
		$(p+'-img').setAttribute("src", "./pages/studio/"+p+"/head-rollover.jpg");
		new Effect.Opacity(p+'-img', {duration:0.3, from:0.0, to:1.0});
	}else{
		$(p+'-img').setAttribute("src", "./pages/studio/"+p+"/head.jpg");
	}
}
function showFaceInfo(p){
	faceChange(p, 0);
	ajaxLoadPersonInfo(p, 110);
}
function scrollPageUp(id, start, end){
	if(end<=start){
		clearTimeout(scrollMe);
		$(id).style.top=end+"px";
	}
	else{
		$(id).style.top=start+"px";
		scrollMe=setTimeout("scrollPageUp('"+id+"',"+(start+5)+","+end+")",1);
	}
}
function scrollPageDown(id, start, end){
	if(start<=(end+195)){
		clearTimeout(scrollMe);
		if((start*1)>20){
			$(id).style.top=(end+195)+"px";
		}
	}
	else{
		$(id).style.top=start+"px";
		scrollMe=setTimeout("scrollPageDown('"+id+"',"+(start-5)+","+end+")",1);
	}
}
function growHeight(id, start, end){
	if(start < end){
		if(end<=start || end<=(start+5)){
			clearTimeout(t);
			$(id).style.height=end+"px";
		}
		else{
			$(id).style.height=start+"px";
			t=setTimeout("growHeight('"+id+"',"+(start+5)+","+end+")",1);
		}
	}
	else{
		if(start<=end || end>=(start-5)){
			clearTimeout(t);
			$(id).style.height=end+"px";
		}
		else{
			$(id).style.height=start+"px";
			t=setTimeout("growHeight('"+id+"',"+(start-5)+","+end+")",1);
		}
	}
}
function showDiv(id, p){
	if(p){
		$(id).style.visibility = "visible";
	}
	else{
		$(id).style.visibility = "hidden";
	}
}
function showMenu(id, ht, otherId) {
	var broken = otherId.split(";");
    if(($(id).style.height.substring(0,($(id).style.height.length-2))*1)<(ht-1)){
		growHeight(id, 14, ht);
		for(var b=0; b<=broken.length-2; b++){
			if(trimString(broken[b]+"-body") != id){
				id2 = trimString(broken[b]+"-body");
				if(($(id2).style.height.substring(0,($(id2).style.height.length-2))*1)!=14){
					$(trimString(broken[b]+"-body")).style.height="14px";
				}
			}
		}
	}
	else{
		growHeight(id, ht, 14);
	}	
}
//Functions to change photos in a project
function changePhoto(image, kind, tag, sty, id){
	Element.setOpacity('slideshow', 0);
	showDiv('loading', true);
	if(!/Safari/.test(navigator.userAgent)){
		ipPhoto = new ImagePreloader([image], onPreloadPhoto);
	}
	else{
		onPreloadPhoto();
	}
	photoname=tag;
	ajaxLoadInfo(id,sty,90);
}
function onPreloadPhoto(aImage){
	showDiv('loading', false);
	if(aImage[0].height>300){
		$('slideshow').style.padding='0 0 0 0';
	}
	else{
		$('slideshow').style.padding='102px 0 0 0';	
	}
	$('slideshow').setAttribute('src', aImage[0].src);
	Effect.Appear('slideshow');
}
function showInfo(id, sty, otherId){
	var broken = otherId.split(";");
	showDiv("loading", true);
	for(var b=0; b<=broken.length-2; b++){
		if(trimString(broken[b]+"-info") == trimString(id+"-info")){
			showDiv(trimString(broken[b]+"-info"), true);
			$(trimString(broken[b]+"-info")).style.height = "auto";
		}
		else{
			showDiv(trimString(broken[b]+"-info"), false);		
			$(trimString(broken[b]+"-info")).style.height = "0";
			ajaxLoadInfo(id, sty, 60);
		}
	}
	$("middle-middle-padding-top").innerHTML = "<span style=\"display: block;width: 16px;height: 15px;border: none;padding: 0;margin: 0;background-image:url(images/nav-menu/nav_arrow.gif);cursor: pointer;\" id='menuitem-arrow' onclick=\"revelMenu('"+trimString(id)+"-info')\" onmouseover=\"menuItemChange('arrow', 0)\" onmouseout=\"menuItemChange('arrow', 1)\" ></span>";
	$("info-menu").style.height = "0";
	showDiv("info-menu", false);
	if(/MSIE/.test(navigator.userAgent)){
		$("info-panel").style.height = "239px";
		$("info-panel").style.maxHeight = "239px";
	}
	else{
		$("info-panel").style.height = "auto";		
	}
	$("info-panel").style.visibility = "visible";
	if(Element.getHeight('scroll-info-panel')<250 || /MSIE/.test(navigator.userAgent)){
		$('scrollbar').style.visibility="hidden";
	}
	else{
		$('scrollbar').style.visibility="visible";
	}
}
function revelMenu(currentID){
	$('middle-middle-padding-top').innerHTML = "<img alt='PROJECT TYPES' src='./images/work-logo.jpg' />";
	$('scroll-info-panel').style.top = '0';
	showDiv('scrollbar', false);
	showDiv('info-panel', false);
	showDiv(currentID, false);
	showDiv('info-menu', true);
	$('info-panel').style.height = '0';
	$('info-menu').style.height = 'auto';
	$('slideshow').setAttribute('src', './images/backgrounds/1px-white.gif');
	$('middle-top').innerHTML = '';
	$('right-middle').innerHTML = '';
}
function trimString(string) {
	var tstring = '';
	string = '' + string;
	splitstring = string.split(' ');
	for(i = 0; i < splitstring.length; i++)
		tstring += splitstring[i];
	return tstring.toLowerCase();
}
