function PictureRotateImage( display, drilldown )
{
	this.DisplayImage = display;
	this.DrillDownImage = drilldown;
}
function PictureRotate()
{
	this.Images = new Array();
	this.clientID = "";
	this.basePath = "";
	this.noImage = "";
	this.presentImage = 0;
	return this;
}
PictureRotate.prototype.SetBasePath = function( bp )
{
	if( bp == "/" ) bp = "";
	if( bp.length > 1 )
		if( bp.charAt( bp.length -1 ) == '/' ) bp = bp.substring(0, bp.length-1);
		
	this.basePath = bp;
}
PictureRotate.prototype.addimage = function( displayImage, drilldownImage )
{
	var newOne = new PictureRotateImage( this.basePath + displayImage, this.basePath + drilldownImage );
	this.Images.push( newOne );	
}
PictureRotate.prototype.render = function()
{
	if( this.Images.length < 1 )
	{
		var newOne = new PictureRotateImage( this.basePath + this.noImage, "");
		this.Images.push( newOne );
	}

	baseimage = this.Images[0].DisplayImage;
	document.write("<table width='144' cellspacing=0 cellpadding=2 border=0><tr><td colspan=3>")
	document.write("<a href=\"javascript:pr_click('" + this.clientID + "');\">");
	document.write("<img style='border:1px solid #edede6;' onmouseover=\"pr_mouseover('" + this.clientID + "')\" onmouseout=\"pr_mouseout('" + this.clientID + "')\" ID='" + this.clientID + "_img' src='" + baseimage + "' alt='' border='0'/>");
	document.write("</a>");
	document.write("</td></tr>");
	document.write("<tr>");
	document.write("<td><a href=\"javascript:pr_previous('" + this.clientID + "');\"><img src='" + this.basePath + this.leftArrow + "' alt='' border='0'/></a></td>");
	document.write("<td width='84' align=\"center\"><div style='font-size:8pt;' id='" + this.clientID + "_captiondiv'>");
	document.write("" + (this.presentImage+1) + "/" + (this.Images.length));
	document.write("</div></td>");
	document.write("<td align='right'><a href=\"javascript:pr_next('" + this.clientID + "');\"><img src='" + this.basePath + this.rightArrow + "' alt='' border='0'/></a></td>");
	document.write("</tr></table>");
}
PictureRotate.prototype.next = function()
{
	this.presentImage++;
	if( this.presentImage > (this.Images.length-1)) this.presentImage = 0;
	
	var imgobj = document.getElementById(this.clientID + "_img");
	imgobj.src = this.Images[this.presentImage].DisplayImage;	
	
	var divobj = document.getElementById( this.clientID + "_captiondiv");
	divobj.innerHTML = "" + (this.presentImage+1) + "/" + (this.Images.length);
}
PictureRotate.prototype.previous = function()
{
	this.presentImage--;
	if( this.presentImage < 0 ) 
		this.presentImage = (this.Images.length-1);
	
	var imgobj = document.getElementById(this.clientID + "_img");
	imgobj.src = this.Images[this.presentImage].DisplayImage;	

	var divobj = document.getElementById( this.clientID + "_captiondiv");
	divobj.innerHTML = "" + (this.presentImage+1) + "/" + (this.Images.length);
}
PictureRotate.prototype.click = function()
{
	var simage = this.Images[this.presentImage].DrillDownImage;
	if( simage == "" ) return;
	var w = window.open( this.basePath + "/template/items/viewimage.aspx?image=" + simage, "imgviewer", "width=347,height=257,toolbar=no", true );
	if( w.focus != null ) w.focus();
}
PictureRotate.prototype.setStatus = function( caption )
{
	var simage = this.Images[this.presentImage].DrillDownImage;
	var divobj = document.getElementById( this.clientID + "_captiondiv");
	if( simage == "" ) divobj.innerHTML = "No images";
	else
		divobj.innerHTML = caption;
}
PictureRotate.prototype.restoreStatus = function()
{
	var divobj = document.getElementById( this.clientID + "_captiondiv");
	divobj.innerHTML = "" + (this.presentImage+1) + "/" + (this.Images.length);
}
function pr_previous( objID )
{
	var probj = eval( objID );
	if( probj != null ) probj.previous();
}
function pr_next( objID )
{
	var probj = eval( objID );
	if( probj != null ) probj.next();
}
function pr_click( objID )
{
	var probj = eval( objID );
	if( probj != null ) probj.click();
}
function pr_mouseover( objID )
{
	var probj = eval( objID );
	probj.setStatus("Click to Enlarge");
}
function pr_mouseout( objID )
{
	var probj = eval( objID );
	probj.restoreStatus();
}

