<!--
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];}}
}

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_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];}}
}
//-->


/*
var btnDisabled = 'Right mouse button disabled. Sorry.' 

if (document.layers) 
	{document.captureEvents(Event.MOUSEDOWN)}
document.onmousedown=enlargePic;
*/
function enlargePic(e)
{
	if(!isValidButton(e)) return;
	var obj = window.event.srcElement

	if(obj.src) // make sure the click happened over an image
		openPic(getPath(obj.src), isPortrait(obj.id))
}


function isValidButton(e)
{
	if(navigator.appName != 'Microsoft Internet Explorer') {							
		if (e.which == 3) { 
			alert(btnDisabled);
			return false;
		}
//		alert('Sorry. Function currently available only for Internet Explorer');
		return false;
	}
	if (event.button == 2) {
		alert(btnDisabled);
		return false;
	}
	return true;
}



function getPath(someValue){
	//	gets the path based on 			/NUMBERS.jpg
	var pattern = /\/\d*\.jpg$/
//	return 'image' + pattern.exec(someValue);
	return 'large' + pattern.exec(someValue);
}	


function getNumber(someValue){
	//	Get a number out without converting it to an integer data type (i.e., via parseInt())
	var pattern = /\d+/
	return pattern.exec(someValue);
}


function isPortrait(someValue){
	//	A regexp check (used with value from img id, which includes "_p" if portrait)
	var pattern = /_p/
	return pattern.test(someValue)
}


function isOffSite(someValue){
//	Determines whether or not the images are stored in another location (i.e. on tripod)
/*	ORIGINAL RIGHT HERE
	var galleryCount = 10
	for(var i = 8; i <= galleryCount; i++)
	{
		var theGallery = 'Gallery' + i
		if(someValue.indexOf(theGallery) > -1)	// was originally 0; might have to change it back
			return true;
	}
	return false;						TO HERE */
	return false;	
}


function getOffSiteImage(theImage, theLocation) {
	//	Reconstructs the src for the image to an off-site location
	var patternStaging = /http:\/\/ggb7n01\//	//regular expressions for replace function
	var patternLive = /http:\/\/glscott\.net/
	var patternIndex = /index\.html/
			
	if(patternStaging.test(theLocation))
		theLocation = theLocation.replace(patternStaging, urlOffSite);
	else
		theLocation = theLocation.replace(patternLive, urlOffSite);
	
	theLocation = theLocation.replace(patternIndex, '');
	return theLocation + theImage
}


function openPic(path, isPortrait, caption){
	var theTitle = ''
	if(isPortrait) 
		OpenImageWin(path, 480, 640, caption, theTitle, isPortrait);
	else 
		OpenImageWin(path, 640, 480, caption, theTitle,  isPortrait);
}


function OpenImageWin(Picture, intWidth, intHeight, Caption, Title, isPortrait) {	
	if(!Title)	{
		if(document.title != '')
			Title= document.title
		else
			Title='kingary.net'
	}
		
	if(Caption=='--Sony')
		Caption = ''
	var blnScroll = 0;

	if(isOffSite(window.location.href))
		Picture = getOffSiteImage(Picture, window.location.href)
	// aligning the picture window in the screen
	if(isPortrait) {
		var intLeft = 150; var intTop = 1
	}else{
		var intLeft = 57; var intTop = 37
	}
		
	if (navigator.appName == "Microsoft Internet Explorer")  
	{
		objWin = window.open("", "", "left="+ intLeft + ",top=" + intTop + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + blnScroll + ",resizable=yes,copyhistory=no,width=" + intWidth + ",height=" + intHeight);
		with(objWin.document)
		{
			clear(); open();
			writeln('<html><head><title>' + Title + '</title><link rel="stylesheet" type="text/css" href="/assets/css/pic.css"><style>Img{cursor:hand;}</style></head><body bgcolor="#A7A77C" onBlur="window.close();">' + wrapLayer('<img id="theImage" src="' + Picture + '">') + '</body></html>')
			close();
		}
	}

	if(navigator.appName == "Netscape")  
	{
		intWidth+=100;
		intHeight+=150;

		objWin = window.open("", "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + blnScroll + ",resizable=yes,width=20,height=20");
		objWin.moveTo(5,5)
		with(objWin.document)
		{
			clear();
	    		open();
			writeln('<html><head><title>' + Caption + '</title><style>Img{cursor:hand;}</style></head><body bgcolor="#A7A77C"><img src="' + Picture + '"><p><b><font color=white>' + Caption + '</font></p></body></html>');
			close();
		}
		objWin.resizeTo(intWidth,intHeight)
	}
}


function writeLayer() {
	return '<div class="UploadMessage" id="layMess" onClick="window.close()">If the image fails to appear it means that the large version has not yet been uploaded.</div>'
}

function wrapLayer(imageHTML) {
	return '<div class="PictureLayer" id="layPic" onClick="window.close();">' + imageHTML + '</div>'
}
