function getHeader() {
	document.write('<object type="application/x-shockwave-flash" data="flash/intro.swf" width="920" height="170" style="position: absolute; left: 0; top: 0;z-index: 1;">\n');
  document.write('<param name="movie" value="flash/intro.swf" />');
  document.write('<param name="bgcolor" value="#1e1e1e"/>');
  document.write('<param name="wmode" value="transparent"/>');
  document.write('</object>\n');
}

var testimonial = null;
var testimonialShell = null;
var loading = null;
var myClose = null;
var opacity = 0;
var textOpacity = 0;
var originalHeight = 0;
function getTestimonial(which) {
	var pageTop = 0;
	if (window.pageYOffset) {
    pageTop = window.pageYOffset;
	} else {
  	pageTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
  }
	testimonial = document.getElementById('testimonialText');
	testimonialShell = document.getElementById('testimonialShell');
	loading = document.getElementById('loading');
	myClose = document.getElementById('closeWindow');
	opacity = 0;
	textOpacity = 0;
	loading.style.display="block";
	testimonial.style.opacity=opacity;
	testimonial.style.filter='alpha(opacity='+opacity+')';
	testimonialShell.style.opacity=opacity;
	testimonialShell.style.filter='alpha(opacity='+opacity+')';
	if(originalHeight!=0) {
		testimonialShell.style.height = originalHeight+"px";
	}
	myClose.style.opacity=opacity;
	myClose.style.filter='alpha(opacity='+opacity+')';
	document.getElementById('testimonialContent').style.display="block";
	document.getElementById('testimonialContent').style.top=pageTop+"px";
	fadeIn();
	var client = new HttpClient();
	client.isAsync = true;
	
	client.callback = function(result) {
		showResult(result);
	}
	
	client.makeRequest('../content/testimonials/'+which+'.inc',null);
}

var fadeId=0;
function fadeIn() {
	if(fadeId!=0) {
		clearTimeout(fadeId);
	}
	if(opacity<100) {
		opacity+=5;
		testimonialShell.style.opacity = opacity/100;
		testimonialShell.style.filter='alpha(opacity='+opacity+')';
		myClose.style.opacity=opacity;
		myClose.style.filter='alpha(opacity='+opacity+')';
		fadeId = setTimeout('fadeIn()',5);
	} else {
		fadeId=0;
	}
}
var textHeight = 0;
var shellHeight = 0;
function showResult(result) {
	testimonial.innerHTML = result;
	textHeight = testimonial.offsetHeight;
	shellHeight = testimonialShell.offsetHeight;
	if(originalHeight==0) {
		originalHeight = shellHeight;
	}
	expandId = setTimeout('expand()',500);
}

var expandId = 0;
function expand() {
	if(expandId!=0) {
		clearTimeout(expandId);
	}
	if(testimonialShell.offsetHeight<textHeight) {
		shellHeight+=5;
		testimonialShell.style.height = shellHeight+"px";
		expandId = setTimeout('expand()',10);
	}	else {
		expandId=0;
		fadeText();
	}
}

function fadeText() {
	if(fadeId!=0) {
		clearTimeout(fadeId);
	} else {
		loading.style.display="none";
	}
	if(textOpacity<100) {
		textOpacity+=5;
		testimonial.style.opacity = textOpacity/100;
		testimonial.style.filter='alpha(opacity='+textOpacity+')';
		fadeId = setTimeout('fadeText()',15);
	} else {
		fadeId = 0;
	}
}
function closeWindow() {
	document.getElementById('testimonialContent').style.display="none";
	document.getElementById('testimonialText').innerHTML="Loading...";
}

var phases = new Array('planning','course','qc','needs','moisture','reserves','eifs','defects','monitoring');
var selected = 'planning';
function showPhase(which) {
	for(var i=0;i<phases.length;i++) {
		if(phases[i]!=which) {
			if(document.getElementById(phases[i])) {
				document.getElementById(phases[i]).style.display="none";
				document.getElementById(phases[i]+'Heading').style.color="#777";
			}
		} else {
			selected = which;
			document.getElementById(phases[i]).style.display="block";
			document.getElementById(phases[i]+'Heading').style.color="#fff";
		}
	}
	
	if(which=="course") {
		startSlideshow('course','../',0);
		document.getElementById('caption').innerHTML = 'An Example of a Course of Construction Sequence';
	}else if (which=="planning") {
		startSlideshow('planning','../',0);
		document.getElementById('caption').innerHTML = 'Planning Stages';
	}else if(which=="qc") {
		startSlideshow('qc','../',0);
			document.getElementById('caption').innerHTML = 'Cost and Quality Control';
	}
}

function showColor(which,color) {
	if(selected!=which) {
		document.getElementById(which+'Heading').style.color=color;
	}
}

var projectOpacity = 0;
function getProject(which,pre) {
	document.getElementById('projectThumbs').style.opacity = 0;
	document.getElementById('projectThumbs').style.filter = "alpha(opacity=0)";
	projectOpacity = 0;
	
	var client = new HttpClient();
	client.isAsync = true;
	
	client.callback = function(result) {
		document.getElementById('projectThumbs').innerHTML=result;
		Slimbox.scanPage();
		fadeProjects();
	}
	
	client.makeRequest(pre+'content/projects/'+which+'.php?pre='+pre,null);
}

var projId = 0;
function fadeProjects() {
	if(projId!=0) {
		clearTimeout(projId);
	}
	
	if(projectOpacity<100) {
		projectOpacity += 5;
		document.getElementById('projectThumbs').style.opacity = projectOpacity/100;
		document.getElementById('projectThumbs').style.filter = "alpha(opacity="+projectOpacity+")";
		projId = setTimeout('fadeProjects()',15);		
	} else {
		projId = 0;
		projectOpacity = 100;
	}
}

