var nW,nH,oH,oW;
function zoomToggle(iWideSmall,iHighSmall,iWideLarge,iHighLarge,whichImage){
oW=whichImage.style.width;oH=whichImage.style.height;
  if((oW==iWideLarge)||(oH==iHighLarge)){
	  whichImage.style.zIndex=parseInt(whichImage.style.zIndex) - 1;
    nW=iWideSmall;
  	nH=iHighSmall;
  } else {
	  whichImage.style.zIndex=parseInt(whichImage.style.zIndex) - 1;
    nW=iWideLarge;
	  nH=iHighLarge;
  }
  whichImage.style.width=nW;
	whichImage.style.height=nH;
}
function changeZOrder(obj) {
  var object=document.getElementById(obj);
  if (object.style.zIndex == 2) { 
	  object.style.zIndex = 1; 
	}
  else { 
	  object.style.zIndex = 2; 
	} 
}

var newwindow;
function popitup(url , title, width, height) {
if (newwindow && !newwindow.closed)
{ newwindow.focus(); newwindow.document.clear() }
else
{ newwindow=window.open('','','width='+width+',height='+height+',resizable=no,scrollbars=no,toolbar=no,status=no') }
newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body marginheight=\"0\" marginwidth=\"0\">');
newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');
newwindow.document.writeln('<\/body> <\/html>');
newwindow.document.close();
}

function Images(nameArray, captions, objectName, name, minW, minH, maxW, maxH) {
	this.images=nameArray;
	this.sName=name;
	this.sCaption = captions;
	this.sObjectName = objectName;
	this.minW = minW;
	this.minH = minH;
	this.maxW = maxW;
	this.maxH = maxH;
	this.clicked = 0;
	this.imgObject = new Image();
	this.preloadObject = new Image();
	this.preloadObject.src="images/imageLoading.jpg";
}
Images.prototype.numImages = function () {
	return this.images.length;
}
//Images.prototype.hideAll = function () {
function HideAll () {
	for (var i=0; i<this.images.length; i++) {
		var temp = document.getElementById(i);
		temp.setAttribyte('style', 'visibility: hidden');
	}
}
Images.prototype.Show = function (boxName) { //alert(this.maxW);
	document.write("<table width='"+this.minW+"' cellspacing='3' cellpadding='0' style='border: 0px'>");
	document.write("<tr><td valign='top' align='left'>");

document.write("<div id='"+this.sName+"' style=\"position:relative; z-index: 1; width:"+this.minW+";height:"+this.minH+"\"><div style=\"position:absolute\">");
document.write("<table width='100%' border=0 cellspacing=2 cellpadding=0>");
document.write("<tr><td colspan='"+this.images.length+"'>");
document.write("<img style='border: solid #000000 1px' width='"+this.minW+"' height='"+this.minH+"' id='" + boxName + "Container' src='" + this.images[0] + "' onclick=\"changeZOrder('"+this.sName+"'); zoomToggle('"+this.minW+"px','"+this.minH+"px','"+this.maxW+"px','"+this.maxH+"px',this);\" onMouseOver=\"this.style.cursor='hand'; this.style.cursor='pointer';\">");
document.write("</td></tr><tr>");
for (i=0; i<this.images.length; i++) {
		document.write("<td id='"+boxName+"clickingBox"+i+"' style='border: solid #000000 1px; background-color: #CAFFF9;' align='center' onMouseOver=\"if ("+boxName+".GetClicked() != "+i+") {this.style.cursor='hand'; this.style.cursor='pointer'; this.style.backgroundColor='#EEEEEE'};\" onMouseOut=\"if ("+boxName+".GetClicked() != "+i+") {this.style.backgroundColor='#CAFFF9'} else this.style.backgroundColor='#EEEEEE'\" onClick=\"if ("+boxName+".GetClicked() != "+i+") {"+boxName+".SetClicked('"+boxName+"',"+i+");" + boxName + ".ShowIt('" + boxName + "', '" + i + "');}\">");
		   
		document.write("<font style='font-family: verdana, arial; font-size: 8px'>" + this.sCaption[i] + "</font></td>");
	}
	document.write("</tr>");
	
document.write("<tr><td colspan='"+this.images.length+"' style='text-align: center; border: solid #000000 1px; background-color: #3C8ABB;'>");
document.write("<font style='color: #FFFFFF; font-family: verdana, arial; font-size: 10px'>Use the buttons above to swap images.<br>Click on the image to make it larger/smaller.</font>");	
document.write("</td></tr>");
	
	document.write("</table></div></div></td></tr></table>");
//	document.write("</tr>");


}
Images.prototype.SetClicked = function (boxName, number) {
  var cellClicked = document.getElementById(boxName+'clickingBox' + number);
  var cellOld = document.getElementById(boxName+'clickingBox' + this.clicked);
  cellClicked.style.backgroundColor = '#EEEEEE';
  cellOld.style.backgroundColor = '#CAFFF9';
  this.clicked = number;
}
Images.prototype.GetClicked = function () {
  return this.clicked;
}
Images.prototype.ShowIt = function (boxName, id) {
	var temp = document.getElementById(boxName + 'Container');
	temp.src=this.preloadObject.src;
//  this.imgObject = new Image();
    this.imgObject.onload = imageLoadHandler;
	this.imgObject.src = this.images[id];
	//if (this.checkPreloadStatus())
	  temp.src = this.imgObject.src;
}

function imageLoadHandler (evt) {
//  setTimeout('', 10000);
}
Images.prototype.checkPreloadStatus = function () {
  if (this.imgObject.complete)
	  return true;
	else {
	  setTimeout(this.checkPreloadStatus(), 10000);
	}
}

Images.prototype.Reset = function () {
  var temp = document.getElementById(this.sObjectName+'Container');
  temp.src = this.images[0];
}

function UpdateContent(whichOne, number) {
//var el = document.getElementById('container');
//el.style.backgroundColor = whichOne.style.backgroundColor;
//el.style.borderBottom = 'solid red 2px';
imgBox1.Reset();imgBox2.Reset();imgBox3.Reset();imgBox4.Reset();
for (var i=1; i<6; i++) {
  var cel = document.getElementById('cell'+i);
  var con = document.getElementById('content'+i);
	if (i == number) {
	  con.style.display='block';
	  cel.style.backgroundColor = '#FFE96D';
	  cel.style.borderBottom='0px';
	}
	else {
	  con.style.display='none';
	  cel.style.backgroundColor = '#CAFFF9';
	  cel.style.borderBottom='solid #000000 1px';
	}
}
//whichOne.style.borderBottom = '0px';
}
/*var newwindow;
function popitup(url , title, width, height) {
if (newwindow && !newwindow.closed)
{ newwindow.focus(); newwindow.document.clear() }
else
{ newwindow=window.open('','','width='+width+',height='+height+',resizable=no,scrollbars=no,toolbar=no,status=no') }
newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body marginheight=\"0\" marginwidth=\"0\">');
newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');
newwindow.document.writeln('<\/body> <\/html>');
newwindow.document.close();
}

function Images(nameArray, name) {
	this.images=nameArray;
	this.sName=name;
}
Images.prototype.numImages = function () {
	return this.images.length;
}
//Images.prototype.hideAll = function () {
function HideAll () {
	for (var i=0; i<this.images.length; i++) {
		var temp = document.getElementById(i);
		temp.setAttribyte('style', 'visibility: hidden');
	}
}
Images.prototype.Show = function (boxName) {
	document.write("<table width='200' cellspacing='1' cellpadding='1' border='1'>");
	document.write("<tr><td colspan='" + this.images.length + "'>");
//onClick=\"popitup('" + this.images[0] + "','View Image', '250', '188');\" 
document.write("<img id='" + boxName + "Container' src='" + this.images[0] + "' onMouseOver=\"this.style.cursor='hand'; this.style.cursor='pointer';\">");

	document.write("</td></tr><tr>");
	for (i=0; i<this.images.length; i++) {
		document.write("<td align='center' onMouseOver=\"this.style.cursor='hand'; this.style.cursor='pointer'; this.style.backgroundColor='gray'\" onMouseOut=\"this.style.backgroundColor='white'\" onClick=\"" + boxName + ".ShowIt('" + boxName + "', '" + i + "');\">");
		document.write("<font size='1px'>" + (i+1) + "</font></td>");
	}
	document.write("</tr></table>");
}
Images.prototype.ShowIt = function (boxName, id) {
//alert(name + id);
	
	var temp = document.getElementById(boxName + 'Container');
	temp.src=this.images[id];
}*/
