var d=document;

if (self != top) top.location = self.location;

// Insert chosen movie into div (there's also an insertMovie2 function in the home page)
function insertMovie(movie,id) {
	mbc="#cccccc"; // Movie background colour
	var obj=document.getElementById(id);
	str=movies[movie][3] + "<br>";
    str+="<embed src='" + movies[movie][0] + "' width='" + movies[movie][1] + "' height='" + movies[movie][2] + "' bgcolor='" + mbc + "' controller='true' autoplay='true' kioskmode='true' pluginspage='http://www.apple.com/quicktime/download/'></embed>";
    obj.innerHTML=str;
	}


// Write movie holder div
function doMovie(movie,id) {
	str1='<a href="javascript:insertMovie(0,\'' + id + '\')" onmouseout="MM_swapImgRestore();" onmouseover="MM_swapImage(\'play_button\',\'\',\'../images/play_button/play_button_f2.jpg\',1);">';
	str2=' border="0" alt="" title="Click to play movie" galleryimg="no" /></a></td>';
	d.write('<br><br><div id=' + id + '>');
	d.write(movies[movie][3]); // Write movie label
	d.write('<br><table border="0" cellpadding="0" cellspacing="0" width="640"><tr><td>' + str1 + '<img name="play_button" src="../images/play_button/play_button.jpg" width="165" height="163"' + str2 + '<td>' + str1 + '<img src="../images/play_button/tr.jpg" width="475" height="163"' + str2 + '</tr><tr><td colspan="2">' + str1 + '<img src="../images/play_button/bott.jpg" width="640" height="333"' + str2 + '</tr></table></div>');
	}


// Write piccies
function doPiccies() {
	gapstr="";
	for (pic = 0; pic < pics.length; pic++) {
		title = (pics[pic][4]) ? pics[pic][4] : pics[pic][3];
		if (pics[pic][5]) {
			// big image exists, so include link to big image in new window function
			str=gapstr + pics[pic][3] + '&nbsp;&nbsp;<span class="small">(click for a big version in a new window)</span><br><a href="javascript:loadBigPic(\'' + pic + '\',\'gl3\')"><img src="' + gfx_path + pics[pic][0] + '" border="0" width="' + pics[pic][1] + '" height="' + pics[pic][2] + '" alt="' + title + '" title="' + title + '" galleryimg="no"></a><br>';
			} else {
			// no big image so use standard piccy template
			str=gapstr + pics[pic][3] + '<br><img src="' + gfx_path + pics[pic][0] + '" border="0" width="' + pics[pic][1] + '" height="' + pics[pic][2] + '" alt="' + title + '" title="' + title + '" galleryimg="no"><br>';
			}
		d.write(str);
		gapstr="<br><br>";
		}
	}


// Write thumbnail piccy with drop shadow round it
// (extra r.gif & b.gif put in front to force Firefox to load them asap (doesn't load/display background shadows until end otherwise))
function makeShadows(pic,flag,rows,rowspan,colspan) {
	title = (pics[pic][4]) ? pics[pic][4] : pics[pic][3]; // Use short title if available
	if (flag.indexOf("start") >= 0) d.write("<table border='0' cellpadding='0' cellspacing='0' align='right'><tr><td rowspan='" + rows + "'><img src='../images/spacer.gif' width='5' height='1' border='0' alt='' title=''></td>");
	if (flag.indexOf("strt2") >= 0) d.write("<table border='0' cellpadding='0' cellspacing='0'><tr>");
	if (flag.indexOf("newrow") >= 0) d.write("</tr><tr>");
	d.write("<td rowspan='" + rowspan + "' colspan='" + colspan + "'><table border='0' cellpadding='0' cellspacing='0'><tr><td rowspan='2'  bgcolor='#ffffff'><img src='../images/spacer.gif' width='5' height='1'></td><td bgcolor='#ffffff'><img src='../images/spacer.gif' width='1' height='5'></td><td rowspan='2'  class='shadr vtat'><img src='../images/sh/tr.gif' width='15' height='15'><br><img src='../images/sh/r.gif' width='15' height='8'></td></tr><tr><td><a href=\"javascript:loadBigPic('" + pic + "')\"><img src='" + gfx_path + pics[pic][0] + "' width='" + pics[pic][1] + "' height='" + pics[pic][2] + "' alt ='" + title +"' title='" + title +"' border='0'></a></td></tr><tr><td colspan='2' class='shadb htal'><img src='../images/sh/bl.gif' width='15' height='15'><img src='../images/sh/b.gif' width='8' height='15'></td><td><img src='../images/sh/br.gif' width='15' height='15'></td></tr></table></td>");
	if (flag.indexOf("end") >= 0) d.write("</tr></table>");
	}


// Open gfx_loader 3 or 4 in new presized window & pass number of big piccy to display
function loadBigPic(num,type) {
	x=800;
	y=600;
	getWinDims();
	// if (screen.height) y=screen.height-80; // Change y to monitor height (-80 for Safari in Windo$e)
	// if (y > 1200) y=1200; // Limit height
	// x=screen.availWidth;
	// y=screen.availHeight;
	// alert(screen.availWidth + "  " + screen.availHeight);



options="resizable=yes,scrollbars=yes,toolbar=no,directories=no,status=yes,location=no,menubar=yes";
	if (x>799) options+=",width=" + x;
	if (y>599) options+=",height=" + y;

	gl=(type == "gl3") ? "3" : "4"; // Use correct gfx_loader
	filename="../gfx_loader" + gl + ".htm?gfx=" + num;

	newWindow2=window.open(filename,"piccy", options);
	newWindow2.focus();
	}

function getWinDims() {
	// Get inner dimensions of current window
	// (in IE 'offsetHeight' will sometimes give FULL length of page contents)
	// (Must be called *after* <body> tag has been rendered)

	// If browser supports window.innerWidth (Safari, Firefox, NS6)
	if (window.innerWidth) {
		x=window.innerWidth;
		if (window.innerHeight) y=window.innerHeight;
		}
	// If browser supports document.all (IE 4+)
	if (document.all) {
		if (document.body.clientWidth) x=document.body.clientWidth;
		if (document.body.clientHeight) y=document.body.clientHeight;
		}
	}


// Detects the capabilities of the browser
function browserSniffer() {
	isNav=false;
	isMoz=false;
	isIE=false;
	isOP=false;
	
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) isOP=true;	// Opera
	else if (document.all) isIE=true;								// Internet Explorer
	else if (document.layers) isNav=true;							// Netscape Communicator
	else if (!document.all && document.getElementById) isMoz=true;	// Mozila (eg Netscape 6 upwards)
	else isIE=true;													// Hopefully will not get here
	}

function checkIfNumber(x) {
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(x)) return true;
	else return false;
	}

function mailEncoder(){var i,j,x,y,x=
"x=\"783d223279723637783d36315c223636306133676e6636656c34372e7863363c693936" +
"3b3031363d696436287232326f6663353b276433273d3636793b35365c5c5c223237623338" +
"36303330326233313639326333323232326533383231363536663234376333393663363237" +
"39363737313665326434343764326536353435366533643632323537633533366236663635" +
"37343665325c5c5c2266363d7833363530657933327d3b333529293233322c373769283263" +
"7274363573623664757334642e7833342b2737332527363528653661706136326373363565" +
"6e3733753d37662b7933627b293635323d37652b6932663b683633745c2236653b7932353d" +
"273637273b3631666f363072283733693d3763303b3635693c3664782e36306c6534636e67" +
"3635746836643b6932352b3d363737303631297b3630666f3733722837636a3d36354d6136" +
"64746836302e6d3463696e3635287836642e6c3632656e326367743564682c3335692b3663" +
"37303634293b37392d2d36346a3e37323d6932633b2935637b7936392b3d3631782e366463" +
"6834646172323541743430286a3332293b33357d7d3235793b223b6a3d6576616c28782e63" +
"6861724174283029293b783d782e7375627374722831293b793d27273b666f7228693d303b" +
"693c782e6c656e6774683b692b3d34297b792b3d782e73756273747228692c32293b7d666f" +
"7228693d323b693c782e6c656e6774683b692b3d34297b792b3d782e73756273747228692c" +
"32293b7d793d792e737562737472286a293b\";y='';for(i=0;i<x.length;i+=2){y+=un" +
"escape('%'+x.substr(i,2));}y";
while(x=eval(x));}


// Image swap script for rollovers

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
