<!--hide this script from non-javascript-enabled browsers
var _imageWindow;
_imageWindow=null;
var d=null;
//image should be an image in /images/ directory
// and x and y should be its size
function DisplayImage(image,x,y, description)
{
	var msg="";
	msg+="<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"
	msg+="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \n";
    msg+="\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
	msg+="<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">\n";
	msg+="<head>";
	msg+="<title>"+description+"</title>";
	msg+="<link rel=\"stylesheet\" href=\"theme.css\" type=\"text/css\" />";
	msg+="</head>";
	msg+="<body class=\"popupimage\"><div>";
	// display the image
	msg+="<img class=\"userimage\" src=\""+image+"\" alt=\""+description+"\" width=\""+x+"\" height=\""+y+"\" />";
	// add the description under the title
	msg+="<br />";
	msg+="<h2>"+description+"</h2>";
	// have a close button
	msg+="<form action=\"\"><div>";
	msg+="<input type=\"button\" class=\"button\" value=\"Close\" onclick=\"javascript:window.close();\" />";
	msg+="</div></form></div>";
	msg+="</body>";
	msg+="</html>";	
	return msg;
}
// use href="javascript:imagepopup('img.jpg','858','523','image of donegal');
function imagepopup(image,x,y, description) 
{
	// window sizes slight bigger than the image to display
	var xwin=x+50;
	var ywin=y+120;
	var msg;
	if(_imageWindow!=null)
	{
		_imageWindow.close();
		_imageWindow=null;
	}
    
	_imageWindow=window.open("","_figWindow","resizable,toolbar=no,scrollbars=yes,width="+xwin+",height="+ywin);
	d=_imageWindow.document;
	msg = DisplayImage(image, x, y, description);
	d.write(msg);
	
    _imageWindow.opener = top;
}
// for a filmstrip thumbnail in a link when clicked put the href into the placeholder and the title into the description
function showImage (linkobj, placeholderId, descriptionId, newWidth, newHeight) 
{ 
	if (document.getElementById && linkobj) 
	{ 
		var placeholder=document.getElementById(placeholderId);
		var descriptionElement=document.getElementById(descriptionId);	
		var newTitle=null;
		if (linkobj.title) 
		{ 
			newTitle = linkobj.title; 
		} 
		else if(linkobj.childNodes)
		{ 
			newTitle = linkobj.childNodes[0].nodeValue; 
		} 

		if(placeholder)
		{
			placeholder.src = linkobj.href; 
			placeholder.width=newWidth;
			placeholder.height=newHeight;
			if(placeholder.title && newTitle)
			{
				if(placeholder.alt)
				{
					placeholder.alt=newTitle;
				}
				placeholder.title=newTitle;
			}
		}
		if(descriptionElement && descriptionElement.childNodes)
		{
			if (newTitle) 
			{ 
				descriptionElement.childNodes[0].nodeValue = newTitle; 
			} 
		}
		return false; 
	} 
	else 
	{ 
		return true; 
	} 
}
// storybook code
var imageCount = 0;
var maxImages=0;
var deftext;
var ImageInfoArray;
var srcDir="/classified/";
var theNext=1;
var thePrev=-1;
var imgElementId;
var txtElementId;
var hrefId;
var imgElement= null;
var txtElement = null;
var hrefElement = null;
function ImageInfo(file, description,height,width, popupURL, popupHeight, popupWidth) 
{
	this.file=file;
	this.description=description;
	this.height=height;
	this.width=width;
	this.popupURL=popupURL;
	this.popupWidth=popupWidth;
	this.popupHeight=popupHeight;
}

function InitialiseStoryBook(infoArray, theTextElementId, theImageElementId, theHrefId)
{
	ImageInfoArray=infoArray;
	txtElementId=theTextElementId;
	imgElementId=theImageElementId;
	maxImages=infoArray.length;
	imageCount=0;
	hrefId=theHrefId;
}

function getimage(direction) 
{
	if ((direction == theNext) && (imageCount <maxImages-1)) {
		imageCount ++;
	}
	else if((direction == thePrev) && (imageCount > 0)) {
		imageCount --;
	}
	else if((direction == theNext) && (imageCount == maxImages-1)){
		imageCount = 0;
	}
	else if((direction == thePrev) && (imageCount == 0)){
		imageCount = maxImages-1;
	}
	// just retrieve the image element the first time.
	if(document.getElementById  && !imgElement)
	{
		imgElement=document.getElementById(imgElementId);
		txtElement=document.getElementById(txtElementId);
		hrefElement=document.getElementById(hrefId);
	}
	if(imgElement)
	{
		imgElement.src= srcDir + ImageInfoArray[imageCount].file;
		imgElement.width=ImageInfoArray[imageCount].width;
		imgElement.height=ImageInfoArray[imageCount].height;
		imgElement.alt=ImageInfoArray[imageCount].description;
		imgElement.title=ImageInfoArray[imageCount].description;
	}
	if(txtElement)
	{
		txtElement.innerHTML = ImageInfoArray[imageCount].description;
	}
	if(hrefElement)
	{
		hrefElement.href=ImageInfoArray[imageCount].popupURL;

		var newURL=ImageInfoArray[imageCount].popupURL;
		var baseURL=location.href.substring(0,location.href.lastIndexOf('/')+1);
		var popupHeight=ImageInfoArray[imageCount].popupHeight;
		var popupWidth=ImageInfoArray[imageCount].popupWidth;
		var description=ImageInfoArray[imageCount].description;
		// we need to also pass the new sizes and the title
		if(newURL!="" && newURL!="#")
		{
			hrefElement.onclick=function(){
				GB_showCenter(description,baseURL+newURL,popupHeight,popupWidth);
				return false;
				};
		}
		else
		{
			hrefElement.onclick="";
		}
	}
}
function getnextimage()
{
	getimage(theNext);
}
function getprevimage()
{
	getimage(thePrev);
}
// -->