var menu0 = new Array("Cellina","Custom","Evo","Executive");
var link0 = new Array("cellina.html","custom.html","evo.html","executive.html");
var menu = new Array(menu0);
var link = new Array(link0);
var lastsubmenu = "submenu"+0;

function submenu(what){
	var newText = new String();
	var submenu="submenu"+what;
	var el = document.getElementById(lastsubmenu);
	var pagelink = "../pages/";
	
	if(window.location.pathname.search("index.html")>0){
		pagelink = "./pages/";
	}
	
	if(what==99){
		
		if(el){
			el.parentNode.removeChild(el);
		}
	}
	else{
		if(!el){
			var parent = "Psubmenu"+what;
			var newUL = document.createElement('ul');
			newUL.setAttribute('id',submenu);
			for (var i=0; i<menu[what].length; i++){	
				newText+="<li>"+"<a href='"+pagelink+link[0][i]+"'>"+menu[what][i]+"</a></li>";
			}
			document.getElementById(parent).appendChild(newUL);
			lastsubmenu="submenu"+what;
			document.getElementById(submenu).innerHTML=newText;
		}
		else{
			el.parentNode.removeChild(el);
		}
	}
	
}

function changeLink(LinkItem,tcolour){
	LinkItem.style.color=tcolour;
}

function closewindow()
{
window.close()
}


var what = 1;
var many = 1;

function sethowmany(pics){
	many = pics;
	createmailto();
}

function newimage(picaddy,which){
	switch (which)
	{
	case 0:
		what--;
		if(what<1){
			what=many;
		}		
		
		break	
	case 1:
		what++;
		if(what>many){
		what=1;
		}		
		
		break
	case 2:
		break
	 }

	var picname = picaddy +  what + ".png";
	document.getElementById("imagespot").src = picname;
	createmailto();
}

function largeimage(pageaddy){
leftval = (screen.availWidth / 2) - (630 / 2 );
topval= (screen.availHeight / 2) - (500 / 2 );
imagepreview=window.open (pageaddy, "ImagePreview", "height=500, width=630, left="+leftval+", top="+topval+", scrollbars=no");
imagepreview.focus();
}

function setstartpic(){
	what=window.opener.what;
}

function createmailto(){
	var protocol = window.location.protocol;
	var path = window.location.pathname;
	var separator = (protocol == "file:" && path.indexOf("/", 1) == -1 ? "\\" : "/");
	var path = window.location.pathname;
	var file = path.substring(path.lastIndexOf(separator) + 1);

	// fill in your email addy below in b,c,d and e. eg. email@somewhere.com
	// this just hides it from spam bots

	a="mailto:";
	b="sales";						//email
	c="@";							//@
	d="ergotrend";						//somewhere
	e=".com";						//.com
	f="?subject=Request information for ";
	g=file;
	h=" picture No."+what;

	if(document.getElementById("emailspot")){
		document.getElementById("emailspot").href = a+b+c+d+e+f+g+h;
	}
}