/*

	JavaScript Document

	July 02, 2007

	TimmyLI

	DIABC

	photo_gallery.js

*/



//EVENT CAPTURE

function requiresEventCapture()

{

	var exp = /netscape/ig;

	return ((exp.test(navigator.appName)==true) && (parseInt(navigator.appVersion.substr(0,3)) <= 4))

}

if(requiresEventCapture()){alert();window.captureEvents("Event.CLICK");}







//PREVIEW PICTURE

var gsPhotographer = "Barb Roy";

var gsEmail = "GrandmaScuba@Hotmail.com";

var gsWeb = "www.BarbRoyPhotography.com";

var gsTitle = "No Title";

var gsArea = "Dive Area";

var gsLocation = "British Columbia";

var hndWinPreview = null;



function Preview(oAlink, sTitle, sPhotographer, sEmail, sWeb)

{

	/*

		<a href="javascript:void(0)" onclick="return Preview(this)><img/></a>

		

		Thumbnail pictures use this function to preview it's higher quality picture version.

		This function creates a new popup window then writes the necessary code into that 

		window. 

		

		The calling webpage is expected to embed the following local variables:

			sArea = 'Area webpage is covering i.e. Port Hardy'

			sLocation = 'Location Area is located i.e. Northern Vancouver Island, BC'

			

		1st argument is manditory (A tag object)

		2nd arg is recommended and describes the picture being previewed

		3rd-5th args are optional, if not included global variables are used

	*/

	

	//Init

	sTitle = (sTitle)? sTitle : gsTitle;

	sEmail = (sEmail)? sEmail : gsEmail;

	sWeb = (sWeb)? sWeb : gsWeb;

	sPhotographer = (sPhotographer)? sPhotographer : gsPhotographer;

	var sArea = (sArea)? sArea : gsArea;

	var sLoc = (sLoc)? sLoc : gsLocation;

	

	//Build preview image

	var sSrc = oAlink.firstChild.src;

	var regx = /(\.jpg){1}$/i;

	sSrc = sSrc.replace(regx,"1.jpg");

	var sImg = "<img src='" + sSrc + "' alt='" + sTitle +"'/>";

	

	//Build photographer info

	if(sPhotographer.length>0)sPhotographer="<h5>Photographer <strong>" + sPhotographer + "</strong></h5>";

	var sLinks = "";

	if(sEmail.length>0)sLinks="<a href='mailto:" + sEmail + "?subject=DIABC Website Picture: " + sArea + " " + sLoc + " on " + sSrc + "'>" + sEmail + "</a><br/><br/>";

	if(sWeb.length>0)sLinks+="<a id='aWeb' target='_blank' href='http://" + sWeb + "'>" + sWeb + "</a>";

	//sLinks += "<hr/><br/><a href='javascript:void window.close();'>Close</a>";

		

	//Build header info

	var sHeader = "<h3>" + sArea +"</h3>";

	sHeader += "<p id='pLocation'>" + sLoc + "</p>";

	sHeader += "<p id='pTitle'>" + sTitle + "</p><hr/>";

		

	//Build layout table

	var sTable = "<table id='tblPhotoPreview' cellpadding='0' cellspacing='0' align='center'>";

	sTable += "<tr align='center'><td>" + sHeader + "</td></tr>";

	sTable += "<tr align='center' class='trContent'><td>";

	sTable += sImg + sPhotographer + sLinks + "</td></tr>";

	sTable += "<tr><td id='tdCopyright'><hr/><img src='../../img/main/footer_logo_picpreview.gif' width='29' height='15' align='left' alt='DIABC Logo.' style='margin-right:5px;'/> <strong>Copyright © 2007</strong> Dive Industry Association of British Columbia. All Rights Reserved.</td></tr></table>";

		

	//Build webpage

	var sHead = "<html><head><title>" + sArea + ": " + sTitle + "</title><link href='photo_preview.css' type='text/css' rel='stylesheet'/></head>";

	var sFoot = "</body></html>";

	var sHtml = sHead + sTable + sFoot;

	

	//Display webpage

	var sArgs = "scrollbars=yes,top=1,left=1,screenx=1,screeny=1,resizeable=yes,status=no,toolbar=no,menubar=no,location=no,height=700";

	if(!hndWinPreview || hndWinPreview.closed)hndWinPreview = window.open("","preview",sArgs);

	var doc = hndWinPreview.document;

	doc.open();

	doc.write(sHtml);

	doc.close();

	hndWinPreview.focus();

	

	//Cancel link execution

	return false;

}