// ------------------------------------------------------------------------------------------------

/*
 File $Workfile: jfgallery.js $ 
 $Archive: /IMatch/scripts/WebGallery/jfgallery/jfgallery.js $ 
 Last changed by $Author: Jürgen Failenschmid $ 
 Last modified   $Modtime: 9/06/03 12:22a $ 
 Last checked in $Date: 9/06/03 12:23a $ 
 $Revision: 4 $ 
*/

// If condition is true, create a link for trueImage with given width/height, otherwise just reference the falseImage 
// trueAlternate, falseAlternate are alternative representations of the corresponding images
// linkoptions are added to the <a> tag
function button(condition, trueImage, falseImage, width, height, link, trueAlternate, falseAlternate, linkoptions ) {
	if (condition) {
		document.write('<td align="center"><a href="')
		document.write(link)
		document.write('" "')
		document.write(linkoptions)
		document.write('"><img class="ms-button" border="0" src="')
		document.write(trueImage)
		document.write('" align="absmiddle" width="')
		document.write(width)
		document.write('" height="')
		document.write(height)
		document.write('" alt="')
		document.write(trueAlternate)
		document.write('"></a></td>')
	}
	else {
		document.write('<td align="center">')
		document.write('<img border="0" src="')
		document.write(falseImage)
		document.write('" align="absmiddle" width="')
		document.write(width)
		document.write('" height="')
		document.write(height)
		document.write('" alt="')
		document.write(falseAlternate)
		document.write('"></td>')
	}
}

// ------------------------------------------------------------------------------------------------

// Create a popup window to rate and comment on an image
//
// Usage:	RatemeWindow(rateWhat,rateID,PopupWidth,PopupHeight,[rateTitle])
// Where:	rateWhat specify what is being rated (quoted 'image' or 'gallery' in any case) 
//		rateID is the quoted ('') relative or absolute url of the image file
//		PopupWidth and PopupWidth specify the image size in pixels
// 		rateTitle is the quoted ('') text to use as the window's title [optional, def=rateID]
//
// Author:	dom@thoth.org 2004-08-05 (revised 2005-04-25)
//
// Do not remove this notice.

function RatemeWindow(rateWhat, galleryID, rateID, initWidth, initHeight, initTitle) {

	var rateTitle = initTitle;
	var imageWidth = initWidth;
	var imageHeight = initHeight;
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	var rateWhat = rateWhat.toLowerCase()

	switch (rateWhat) {
		case "image":
			rateLabel = "Image"
			break
		case "gallery":
			rateLabel = "Gallery"
			break
		default:
			rateLabel = "Item"
	}
		
	if (!rateTitle) {var rateTitle = "&nbsp;";}

	if ((imageWidth + 30 > screenWidth) || (imageHeight + 60 > screenHeight)) {
		if (imageWidth + 20 > screenWidth - 80) {var imageWidth = screenWidth - 80;}
		else {var imageWidth = imageWidth + 20;}
		if (imageHeight + 20 > screenHeight - 110) {var imageHeight = screenHeight - 110;}
		else {var imageHeight = imageHeight + 20;}
		var optScroll = "scrollbars=yes,resizable=yes";
	}
	else {
		var imageWidth = imageWidth;
	    	var imageHeight = imageHeight;
		var optScroll = "scrollbars=yes,resizable=yes";
	}

	var initX = (screenWidth-imageWidth)/2;
	var initY = (screenHeight-imageHeight)/2 - 10;
	var optWin = optScroll+",width="+imageWidth+",height="+imageHeight+",screenX="+initX+",screenY="+initY+",left="+initX+",top="+initY;

	imageWin = window.open('about:blank', "Image", optWin);
	with (imageWin.document) {

		writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
		writeln('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">');
		writeln('<head>');
		writeln('	<title>Kingston Green Fair Gallery: Comment on '+rateLabel+' '+rateID+'</title>');
		writeln('	<link rel="stylesheet" href="/assets/style/main.css" type="text/css" media="all" />');
		writeln('	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />');
		writeln('	<meta name="author" content="Dominic Search" />');
		writeln('	<meta name="date" content="20 August 2004" />');
		writeln('</head>');
		writeln('<body>');
		writeln('<div id="HeaderSpace" class="HeaderSpace">');
		writeln('	<div id="LogoImagePopup" class="LogoImagePopup">');
		writeln('		<a href="/index.html" style="border:0;"><img src="/assets/images/h2.gif" width="600" height="70" alt="Kingston Green Fair" align="middle" /></a>');
		writeln('	</div>');
		writeln('</div>');
		writeln('<div id="ContentSpace" class="ContentSpace">');
		writeln('	<div id="PopupPane" class="PopupPane">');
		writeln('		<h2>Comment on This '+rateLabel+'</h2>');
		writeln('		<p>Tell us what you think about our photographs. The personal information you supply will never be made public, nor will it be given to any other organisation or person.</p>');
		writeln('		<form action="/cgi-bin/formmail.pl" method="post">');
		writeln('			<input type="hidden" name="recipient" value="rateme-rx@kingstongreenfair.org.uk" />');
		writeln('			<input type="hidden" name="email" value="rateme-tx@kingstongreenfair.org.uk" />');
		writeln('			<input type="hidden" name="subject" value="Website Picture Comment" />');
		writeln('			<input type="hidden" name="redirect" value="/assets/misc/ratethanks.html" />');
		writeln('			<input type="hidden" name="Rate-Type" value="'+rateLabel+'" />');
		writeln('			<input type="hidden" name="Gallery-ID" value="'+galleryID+'" />');
		writeln('			<input type="hidden" name="Rate-ID" value="'+rateID+'" />');
		writeln('			<input type="hidden" name="Rate-Title" value="'+rateTitle+'" />');
		writeln('			<div class="FSMargin">');
		writeln('				<div class="FormLabel">');
		writeln('					<label for="Imagename">ID:</label>');
		writeln('				</div><div class="FormInput" id="Imagename">');
		writeln('					<b>'+rateID+'</b>');
		writeln('				</div>');
		writeln('				<div class="FormLabel">');
		writeln('					<label for="rateTitle">Title:</label>');
		writeln('				</div><div class="FormInput" id="rateTitle">');
		writeln('					<b>'+rateTitle+'</b>');
		writeln('				</div>');
		writeln('				<br />');
		writeln('				<div class="FormLabel">');
		writeln('					<label for="Realname">Your Name:</label>');
		writeln('				</div><div class="FormInput">');
		writeln('					<input type="text" name="Realname" id="Realname" size="50"></input>');
		writeln('				</div>');
		writeln('				<div class="FormLabel">');
		writeln('					<label for="My-email">Your Email:</label>');
		writeln('				</div><div class="FormInput">');
		writeln('					<input type="text" name="My-Email" id="My-email" size="50"></input>');
		writeln('				</div>');
		writeln('				<div class="FormLabel">');
		writeln('					<label for="My-comments">Comments:</label>');
		writeln('				</div><div class="FormInput">');
		writeln('					<textarea name="My-Comments" id="My-comments" cols="37" rows="3"></textarea>');
		writeln('				</div>');
		writeln('				<div class="FormLabel">');
		writeln('					<label for="My-Rating">Rating:</label>');
		writeln('				</div><div class="FormInput">');
		writeln('					<select name="My-rating" id="My-rating">');
		writeln('						<option>- choose -</option>');
		writeln('						<option>1</option>');
		writeln('						<option>2</option>');
		writeln('						<option>3</option>');
		writeln('						<option>4</option>');
		writeln('						<option>5</option>');
		writeln('					</select>');
		writeln('					&nbsp; (1 = poor. 5 = excellent.)');
		writeln('				</div>');
		writeln('				<br /><div class="FormLabel">&nbsp;</div>');
		writeln('				<div class="FormInput">');
		writeln('					<input type="submit" value="Send Form" name="submit"></input>');
		writeln('					<input type="reset" value="Clear Form" name="reset"></input>');
		writeln('				</div>');
		writeln('			</div>');
		writeln('		</form>');
		writeln('	</div>');
		writeln('</div>');
		writeln('</body></html>');

		close();		
	}
	
	void imageWin.focus( );
}

// ------------------------------------------------------------------------------------------------
