var Image1, Image2;

function BuildImageTag() {
	var display = true;
	var x, w, h, t;

	if (queryString('x') != 'false') {
		x = queryString('x');
	} else {
		display = false;
	}

	if (queryString('w') != 'false') {
		w = queryString('w');
	} else {
		display = false;
	}

	if (queryString('h') != 'false') {
		h = queryString('h');
	} else {
		display = false;
	}
	
	if (queryString('t') != 'false') {
		t = queryString('t');
	} else {
		t = '';
	}

	if (display == true) {
		Image1 = new Image(w,h)
		Image1.src = 'images/source/' + x + 'x.jpg'

		Image2 = new Image(w,h)
		Image2.src = 'images/gallery/' + x + '.jpg'

		document.write("<div class='galleryheader'>&quot;" + unescape(t) + "&quot;</div>");
//		document.write("<a href='PhotoViewer.htm?x=" + x + "&w=" + w + "&h=" + h + "' onMouseOver='SwapOut()' onMouseOut='SwapBack()'>");
		document.write("<img name='imageflip' src='images/gallery/" + x + ".jpg' width='" + w + "' height='" + h + "' border='0'>");
//		document.write("</a>");		
	} else {
		document.write("<div class='err'>Unable to load photograph</a>");
	}
}

function SwapOut() {
document.imageflip.src = Image2.src; return true;
}

function SwapBack() {
document.imageflip.src = Image1.src; return true;
}

function OpenWindow(x, w, h, t) {
	viewer = window.open('PhotoViewer.htm?x=' + x +'&w=' + w + '&h=' + h + '&t=' + escape(t),'viewer','width=800,height=700,toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function OpenWedWindow(x, w, h, t) {
	viewer = window.open('PhotoViewOnly.htm?x=' + x +'&w=' + w + '&h=' + h + '&t=' + escape(t),'viewer','width=800,height=700,toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}

function configurePaypal() {
	var t;
		
	if (queryString('t') != 'false') {
		t = queryString('t');
	} else {
		t = 'undefined';
	}
	
	document.forms[0].item_name.value = t;
}

function queryString(key) {
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

var message = "Property of Dick Pratt Photography";
function processClick(e) 
{
  if (document.all) {
    if (event.button == 2) {
		    alert(message);
				return false;
				}
		}

if (document.layers) {
    if (e.which == 3) {
		    alert(message);
				return false;
				}
		}
}

if (document.layers) {
	 document.captureEvents(Event.MOUSEDOWN);
}

document.onmousedown = processClick;

