// Routine for popup windows with title, size and background colour parameter (5 parameters)

var newwindow;
var wheight = 0, wwidth = 0;

function popitup5(url, title, iwidth, iheight, colour) {
var pwidth, pheight;


if ( !newwindow || newwindow.closed ) {
	pwidth=iwidth+30;
	pheight=iheight+30;
	newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10,status=1 ');
	wheight=iheight;
	wwidth=iwidth;
}
 
if (wheight!=iheight || wwidth!=iwidth ) {
	pwidth=iwidth+30;
	pheight=iheight+90;
	if (version.substring(0,1)>3) { 	// check browser v4+ supporting JavaScript 1.2	
		newwindow.resizeTo(pwidth, pheight);
	}
	wheight=iheight;
	wwidth=iwidth;
}

newwindow.document.clear();
newwindow.focus();
newwindow.document.writeln('<html> <head> <title>' + title + ' <\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
newwindow.document.writeln('<img src=' + url + '  title=\"' + title + '\"   alt=\"' + title + '\" >');
newwindow.document.writeln('<\/center> <\/body> <\/html>');
newwindow.document.close();
newwindow.focus();
}

//Routines used specifically for popup feedback form windows

var fbwindow
function fbpopitup(url) {
if (fbwindow && !fbwindow.closed) 
	{ fbwindow.location.href = url; fbwindow.focus(); } 
else 
	{ fbwindow=window.open(url,'fhtmlname','width=600,height=650,resizable=1,scrollbars=0,top=0,left=10'); }
}

//Routines to tidy up popup windows when page is left

function tidy() {tidy5() }
function tidy5() {
tidyh();
fbtidy();
}

function tidyh() {
if (newwindow && !newwindow.closed) { newwindow.close(); }
}

function fbtidy(){
if (fbwindow && !fbwindow.closed) {fbwindow.close(); } }	

//routines to simulate functions used on older pages. 

function popitup(url) { popitup5(url , 'Digital Image 384x288', 384, 288, 'white') }
function ppopitup(url) { popitup5(url , 'Photographic Image 800x600',800, 600, 'white') }

function vpopitup(url) { popitup5(url , 'Digital Image 288x384', 288,384, 'white') }
function pvpopitup(url) { popitup5(url , 'Photographic Image 267x400', 267, 400, 'white') }


//Routines for cookies used to remember if user has broadband

/* Call function as setCookie("cookiename" , cookievalue, lifetime, cookiepath)
with the lifetime required in days, -1 to delete a cookie or zero
for a temporary cookie. The Cookie Path is optional.*/

function setCookie(cookie_name, cookie_value, cookie_life, cookie_path) {
  var today = new Date()
  var expiry = new Date(today.getTime() + cookie_life * 24*60*60*1000)
  if (cookie_value != null && cookie_value != ""){
    var cookie_string =cookie_name + "=" + escape(cookie_value)
    if(cookie_life){ cookie_string += "; expires=" + expiry.toGMTString()}
    if(cookie_path){ cookie_string += "; path=" + cookie_path}
	document.cookie = cookie_string
  }
} // Based on JavaScript provided by Peter Curtis at http://www.pcurtis.com/popup.htm -->

/* Call function as getCookie("cookiename") It returns the value of a cookie
if set or null. Beware of potential ambiguities in names of cookies -
getCookie is simple and will match the end of a string so xyname 
will also be matched by yname and ame. */
 
function getCookie(name) {
  var index = document.cookie.indexOf(name + "=")
  if (index == -1) { return null}
  index = document.cookie.indexOf("=", index) + 1
  var end_string = document.cookie.indexOf(";", index)
  if (end_string == -1) { end_string = document.cookie.length }
  return unescape(document.cookie.substring(index, end_string))
} // Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->

// Function to toggle flag for broadband users

function toggle(){
		if (getCookie('broadband') != "true") {
			setCookie('broadband',"true",0,"/");
			}
		else  {
			setCookie('broadband',"false",0,"/");
			}
		}

// Functions called for vertical and horizontal popups of two different sizes (image files end in i.jpg for icon, w.jpg for small image (400*300) and b.jpg for large images (600x450)

	function popitup2v(url,title) {
		if ( getCookie('broadband') == "true") {url=url+'b.jpg';popitup5(url , title, 450, 600, 'white') }
		else {url=url+'w.jpg'; popitup5( url , title, 300, 400, 'white') }	}

	function popitup2h(url,title) { 
		if ( getCookie('broadband') == "true") {url=url+'b.jpg';popitup5(url , title, 600, 450, 'white') }
		else { url=url+'w.jpg'; popitup5( url, title, 400, 300, 'white')
 		}}

	function popitup2g(url) {
		if ( getCookie('broadband') == "true") {url=url+'b.jpg';popitup5(url , title, 450, 600, 'white') }
		else {url=url+'w.jpg'; popitup5( url , title, 300, 400, 'white') }	}

/*
Functions to put in the HTML to provide simplified calls for vertical and horizontal popups with a doubleClick event handler calling toggle() so that large popups can be displayed if user has broadband
*/

	function hpop(image, title, alignment) {
		document.write('<IMG src= \"' +image + 'i.jpg\" alt=\"' + title + '\"  title=\"' + title + '\"    width = 160 height = 120 border = 0 align=\"' + alignment + '\" hspace = 10 vspace = 10 onDblClick=\"toggle()\"  onClick=\"popitup2h(\' '+ image+'\' ,\' ' + title+ '  \' )\" <\/IMG>') }

	function vpop(image, title, alignment) {
		document.write('<IMG src= \"' +image + 'i.jpg\" alt=\"' + title + '\"  title=\"' + title + '\"     width = 120 height = 160 border = 0 align=\"' + alignment + '\" hspace = 10 vspace = 10 onDblClick=\"toggle()\"  onClick=\"popitup2v(\''+ image+ '\' ,\' ' + title+ '  \' )\" <\/IMG>') }

<!-- ;

//Last Updated 10th August 2005
