var arrLinks = new Array("how.html;How we work","about.html;About us","gallery.html;Gallery","faq.html;FAQ & links","contact.html;Contact us","default.html;Home");

var sub = '1';

function getMenu() {
var strLinks = "";
var ubound = arrLinks.length;
document.getElementById("menu").style.paddingRight = "0px";
    if ((getPageName() == "") || (getPageName() == "default.html"))
    {
         ubound = arrLinks.length -1;
         //document.getElementById("menu").style.paddingRight = "5%";
    }  

	for (i=0;i<ubound;i++) {
		if ((arrLinks[i].split(";")[0]) == getPageName()) 
		{
			strLinks += arrLinks[i].split(";")[1] + " | ";
			document.title += " - " + arrLinks[i].split(";")[1];
		}
		else
		{
			strLinks += "<a href='" + arrLinks[i].split(";")[0] +"'>" + arrLinks[i].split(";")[1] + "</a> | ";
		}
	}
	strLinks = strLinks.substring(0,strLinks.length-2);
	document.getElementById("menu").innerHTML = strLinks;
	document.getElementById("header").innerHTML = "<a href='./'><img src='images/logo.gif' width='500' height='76'></a>"
	document.getElementById("footer").innerHTML = "Cutting 'Edge: sustainable greenwood timberframes | <a href='mailto:cuttingedgeframes@gmail.com'>cuttingedgeframes@gmail.com</a> | 01749 860202 | <a href='privacy.html'>privacy policy</a> | <a href='disclaimer.html'>disclaimer</a>"
	}

function getPageName() {
var loc = document.location + "";
var arrLoc = loc.split("\/");
	return arrLoc[arrLoc.length-1];
}

function showIt(arg) {
var strSrc = arg.src;
var arrSrc = strSrc.split('\/');
var strFileName = arrSrc[arrSrc.length-1];
var strFileDir = "images/";
var newImg = new Image();

	if (strFileName.substring(0,3) == "tn_") 
	{
		newImg.src = strFileDir + strFileName.substring(3,strFileName.length);
		strTitle = "Click to shrink";
	}
	else
	{
		newImg.src = strFileDir + "tn_" + strFileName;
		strTitle = "Click to enlarge";
	}
document.images[arg.id].src = newImg.src;
document.images[arg.id].title = strTitle;
}

function showLarge(arg) {
var strSrc = arg.src;
var arrSrc = strSrc.split('\/');
var strFileName = arrSrc[arrSrc.length-1];
var newImg = new Image();
	if (document.getElementById("imgLarge").style.display == 'none')
	{
		// show image
		newImg.src = "images/" + strFileName.substring(3,strFileName.length);
		document.images["placeholder"].src = newImg.src;
		document.getElementById("imgLarge").style.display = "block";
	}
	else
	{
		arrExisting = document.images["placeholder"].src.split("\/");
		strExisting = arrExisting[arrSrc.length-1];
		if (strExisting != strFileName.substring(3,strFileName.length))
		{
			// show different image
			newImg.src = "images/" + strFileName.substring(3,strFileName.length);
			document.images["placeholder"].src = newImg.src;
			document.getElementById("imgLarge").style.display = "block";

		}
		else
		{
			// hide image
			newImg.src = null;
			hideIt();
		}
	}

}

function hideIt() 
{
	document.getElementById("imgLarge").style.display = "none";
	document.images["placeholder"].src = null;
}

var strImages = "";

function getImages() {
	if (arrImages.length > 0) {
	for (i=0;i<arrImages.length;i++)
	{
		strImages += "<a href=\"javascript:showImage('" + i + "');\" ><img src='images/tn_"+ arrImages[i] + "' width='120'></a><br/>";
	}
	document.getElementById("right").innerHTML = strImages;
	document.images.mainImage.src = "images/" + arrImages[0];
	}
}

function showImage(arg) {
	var imgNew = new Image();
	imgNew.src = "images/" + arrImages[arg];
	document.images.mainImage.src = imgNew.src;
}

function getPart(arg,part) {
	if (arg.length > 0) {
  	var chrIndex = arg.indexOf("-");
  	var strOut = "";	
  	return arg.substring(0,chrIndex);
	}
}