var browser="unknown";
var ver=navigator.appVersion.charAt(0);
if ((navigator.appName=="Netscape" && ver==4) || document.layers) browser="n";// ns4
if (document.all) browser="e";      // ie4+
if ((document.getElementById)&&(browser!="e")) browser="m";// ns6 etc
var css=(ver==4 || ver==5 || ver==6)?true:false;
var pj=(browser!="e");

function rightclick(e)
{
	var m="Copyright 1993-2007 K J Lewis";
	if (navigator.appName=='Netscape' && e.which==3) {alert(m);return false;}
	else if (navigator.appName=='Microsoft Internet Explorer' && event.button==2) {alert(m);return false;}
	return true;
}
document.onmousedown=rightclick;
function swap0(im, im2)
{
	var s = document.images[im].src;
	if (s.indexOf("0.jpg")>-1 || s.indexOf("walls0")>-1 || s.indexOf("lowres")>-1) document.images[im].src=im2;
}
function lo2hi(im, im2){if (document.images[im].src.indexOf("lowres")>-1) document.images[im].src=im2;}
function swap(im, im2) {document.images[im].src=im2;}
function progressive(i, im1, im2, w, h, a, b)
{
	if (!pj) document.write("<img src='" + im1 + "' width=" + w + " height=" + h + " onLoad='lo2hi(\"" + i + "\", \"" + im2 + "\")' alt='" + a + "' border=" + b + ">");
	else document.write("<img src='" + im2 + "' width=" + w + " height=" + h + " alt='" + a + "' border=" + b + ">");
}
function preloadjpegs(im, n){
	for (i=0; i<n; i++)
	{
		var new_img=new Image();
		new_img.src=im+i+".jpg";
	}
}
function loaded(i) {return document.images[i].complete;}
function visitorsbook()
{
	if (document.forms[0].name.value==""||document.forms[0].comment.value==""||document.forms[0].town.value=="")
		{alert("Please fill in all 3 fields");return false;}
	return confirm("Thank you for your feedback.\nIt will be added to the visitors book when the site is next updated.");
}
function W(wall, exhib)
{
	var path0=parent.frames[0].location.href;
	var slash=path0.lastIndexOf("/");
	var path1=path0.substring(0, slash);
	var html=path0.substring(slash+1, path0.length)
	slash=path1.lastIndexOf("/");
	var dir=path1.substring(slash+1, path1.length);
	var e=false;
	if (dir=="foyer"||dir=="ordering"||dir=="search"||dir=="misc"||dir=="info") path=path1.substring(0, slash+1);
	else
	{
		e=true;
		var path2=path1.substring(0, slash);
		slash=path2.lastIndexOf("/");
		path=path2.substring(0, slash+1);
	}
	var new_url;
	if ((e && exhib!="") || (!e && exhib==""))//only change middle frame
	{
		if (e) new_url=path + exhib + "/w/" + wall + ".html";
		else new_url=path + "foyer/foyer.html";
		parent.frames[0].location=new_url;
	}
	else
	{
		if (exhib=="") new_url=path + "foyer/foyer.html";
		else new_url=path + exhib + "/w/" + wall + ".html";
		parent.frames[0].location=new_url;
	}
}
function hide(fr,id)
{
	var a = style(1, id);
	a.visibility = "hidden";
}	
function footer(x,y,dir)
{
	frames();
	hide(2,"up");hide(2,"down");hide(2,"left");hide(2,"right");
	if (dir=="") return;
	var px=50*(x-1) + 14;
	var py=50*(y-1) + 12;
	if (x>3) px+=8;
	var a = style(1, dir);
	if (browser=="n" || browser=="e") {a.left = px; a.top = py;}
	else {a.left = px + "px"; a.top = py + "px";}
	a.visibility = "visible";
}
function style(fr, id)
{
	var obj;
	if (browser=="n") obj = parent.frames[fr].document.layers[id];
	else if (browser=="e") obj = parent.frames[fr].document.all[id].style;
	else obj = parent.frames[fr].document.getElementById(id).style;
	return obj;
}
function D(name)
{
	if (browser!="n") document.forms[0].wallname.value=name;
	else if(document.layers['wallname']) document.layers['wallname'].document.forms[0].wallname.value=name;
}
function C()
{
	if (browser!="n") document.forms[0].wallname.value="";
	else if (document.layers['wallname']) document.layers['wallname'].document.forms[0].wallname.value="";
}
function copyright()
{
	copyrightwin=window.open('copyright.html','copyright','width=380,height=240,scrollbars=0,resizable=0,toolbar=0,status=0,menubar=0,dependent=0');
	copyrightwin.focus();
}
function mess(m) {parent.window.status=m;}
function detail(n)
{
	document.write("<img src=\"../../im/magnify.gif\" width=46 height=64 title='move mouse over &#10;painting to &#10;find details' onMouseOver='mess(\"A number of details of this painting are present. Move mouse over painting to reveal them.\");return true;' onMouseOut='mess(\"\")'>");
	document.write("<br><b>" + n + " detail" + (n>1?"s":"") + "<br>available</b>");
}
function frames()
{
	var path = parent.location.href;
	var slash = path.lastIndexOf("/");
	var html = path.substring(slash+1, path.length);
	if (parent.frames.length==2 || (html=="search.html" && parent.parent.frames.length==2)) return true;
	var slash2 = path.substring(0, slash).lastIndexOf("/");
	var dir = path.substring(slash2+1, slash);
	var dots=(dir=="w"||dir=="p"||dir=="html")?"../../":"../";
	var url;
	if (html=="search.html"||html=="search1.html"||html=="search2.html"||html=="search3.html")
	{
		url = "search/search.html";
	}
	else
	{
		url = escape(self.location);
	}
	top.location.href = dots + "gallery.html?" + url;
	return false;
}
