// JavaScript Document

	function returnDirectory(){
		var dirs=window.location.href.split('/'),
		cdir=dirs[dirs.length-2];
		return cdir;
	}
	
	function returnDocument() {
        var file_name = document.location.href;
        var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
        return file_name.substring(file_name.lastIndexOf("/")+1, end);
    } 
	function setlink(){
		var file=returnDocument();
		var pref="faq_";
		file = pref+file;
		return file;
	}
	function backswitch(){
		//alert("TESTING");
		var doc = new Array("about","portfolio","services","client","map","links","contact");
		for(var i = 0; i<doc.length; i++){
			if(returnDocument().match(doc[i]+".html") != null || returnDocument().match(doc[i]+".php") != null){
				var x = document.getElementById(doc[i]);
				//alert("IN HERE "+doc[i]);
				//alert("url(images/nav/"+doc[i]+"_btn_over.gif) \nurl(images/nav/about_btn_over.gif)")
				x.style.backgroundImage = "url(images/nav/"+doc[i]+"_btn_over.gif)"
			}
		}
	}
	function linkme(){
		var files = Array("bamboo.html","rapid_loc.html","engwood.html");
		var files2 = Array("faq_bamboo.html","faq_rapid_loc.html","faq_engwood.html");
		if("faq_gen.html" == returnDocument()){
				document.write("<a href='../beta/js/faq.html' id='thelink'>View Main FAQ Page</a>");
			}
		for(var i = 0; i<files.length; i++){
			if(files[i] == returnDocument()){ 
				document.write("<a href='../beta/js/"+setlink()+"' id='thelink'>View The Product Faq</a>");
			}
			else if(files2[i] == returnDocument()){
				var filelink=strip(files2[i]);
				document.write("<a href='../beta/js/"+filelink+"' id='thelink'>View The Product Page</a>");
			}			
		}
	}
	function strip(str){
		var f = str.replace(".html","");
		return f;		
	}
	
	function load()
	{
		window.status="Page is loaded";
		alert("loaded")
	}


   function hidediv(thediv) {
		if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(thediv).style.display= 'none'
		}
		else {
			if (document.layers) { // Netscape 4
			document.thediv.display= 'none'
			}
			else { // IE 4
			document.all.thediv.style.display= 'none'
			}
		}
	}
	function showdiv(thediv) {
		if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(thediv).style.display = 'inline';
		}
		else {
			if (document.layers) { // Netscape 4
			document.thediv.display = 'inline';
			}
			else { // IE 4
			document.all.thediv.style.display = 'inline';
			}
		}
	}
	
	function showHide(show,hide){
			showdiv(show);
			hidediv(hide);
	}
	
	function getElementHeight(Elem) {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
			xPos = elem.offsetHeight;
		return xPos;
}

function setElementHeight(Elem,height) {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
			elem.style.height = height;
			alert("HEIGHT IS "+height);
			var xpos = getElementHeight(Elem);
			alert("XPOS IS "+xpos);
		return xpos;
}

function getElementWidth(Elem) {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
			xPos = elem.offsetWidth;
		return xPos;
}

function setEqualHeight(){
	var left = getElementHeight("nav");
	var right = getElementHeight("main");
	alert("Nav is "+left+"\nMain is "+right);
	if(left > right){
		alert("Main is less");
		right=setElementHeight("main",left);
	}
	else if(left < right){
		alert("Nav is less");
		left=setElementHeight("nav",right);
	}
	alert("Nav is "+left+"\nMain is "+right);
}


function setme(){
	//alert("HERE");
	var files = new Array("consulting","architecture","green","ucc","survey","featured","project_plum","project_conway","project_wilkinsburg","project_matr");
	var doc = strip(returnDocument());
	//alert(doc);
	var i = 0;
	var id;
	while(i < files.length +1){
		if(files[i] == doc){
			id = i;
			//alert(i);
			break;
		}
		i++;		
	}
	id+=1;
	if(id < 7){
		
		var x = document.getElementById("sub"+(id));
		x.style.backgroundColor = "#FFFFFF";
		switch(id){
			case 1:
				showHide('cwhite','c');
				break;
			case 2:
				showHide('awhite','a');
				break;
			case 3:
				showHide('gwhite','g');
				break;
			case 4:
				showHide('uwhite','u');
				break;
			case 5:
				showHide('swhite','s');
				break;
			case 6:
				showHide('fwhite','f');
				break;
		}
	}
	else {
		if(id < doc.length+1){
			var y = document.getElementById('sub6');
			y.style.backgroundColor = "#FFFFFF";
			showHide('fwhite','f');
		}		
	}
	
}


function link_switch(id){
if(returnDocument() == id){
	document.write("<span class='green'>");}
else{
	document.write("<span class='white'>");
}
}

