//
// Global bugImagePop management -- BIP (Bugimus Image Popup)
//

bugBase.prototype.attachBIP = function() {
	this.BIPnum = 0
	this.BIPobj = new Array()
}
window.bugimus.attachBIP()

//
// Local bugImagePop functionality
//

// Define button object
function imagePop() {
	this.objname = "window.bugimus.BIPobj[" + window.bugimus.BIPnum + "]"
	this.winName = "BIP"+window.bugimus.BIPnum
	window.bugimus.BIPobj[window.bugimus.BIPnum++] = this
	this.winTitle = ""	
	this.winMargin = "0px"	
	this.winPadding = "0px"	
	this.chromeFound = false
	this.padWidth = 0
	this.padHeight = 0
	this.bgImage = ""	
	this.bgColor = "#ffffff"	
}

imagePop.prototype.setTitle = function(title) {
	this.winTitle = title
}

imagePop.prototype.setMargin = function(margin) {
	this.winMargin = margin + "px"
}

imagePop.prototype.setBackgroundImage = function(image) {
	this.bgImage = image
}

imagePop.prototype.setBackgroundColor = function(c) {
	this.bgColor = c
}

imagePop.prototype.showPic = function(imgName) {
	this.w = window.open('.',this.winName,'toolbar=no,location=no,locationbar=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=200,height=200')
	if(!this.w) return true
	with(this.w.document) {
		write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" )
		write( "<html><head>" )
		write( "<title>"+this.winTitle+"</title>" )
		write( "<script language=\"JavaScript\">\n")
		write( "self.focus()\n")
		write( "function autoSize() {\n")
		write( "if(!window.opener."+this.objname+".chromeFound) {\n")
		write( "if(window.opener.window.bugimus.IE5) {\n")
		write( "bw=document.documentElement.clientWidth\n")
		write( "bh=document.documentElement.clientHeight\n")
		write( "top.window.resizeTo(bw,bh)\n")
		write( "} else if(window.opener.window.bugimus.NN4) {\n")
		write( "bw=window.innerWidth\n")
		write( "bh=window.innerHeight\n")
		write( "top.window.resizeTo(200,200)\n")
		write( "} else {\n")
		write( "bw=window.outerWidth\n")
		write( "bh=window.outerHeight\n")
		write( "}\n")
		write( "if(window.opener.window.bugimus.IE5) {\n")
		write( "aw=document.documentElement.clientWidth\n")
		write( "ah=document.documentElement.clientHeight\n")
		write( "} else {\n")
		write( "aw=window.innerWidth\n")
		write( "ah=window.innerHeight\n")
		write( "}\n")
		write( "window.opener."+this.objname+".padWidth=bw-aw\n")
		write( "window.opener."+this.objname+".padHeight=bh-ah\n")
		write( "window.opener."+this.objname+".chromeFound=true\n")
		write( "}\n")
		write( "ww=window.opener."+this.objname+".padWidth+"+parseInt(this.winMargin)*2+"\n")
		write( "wh=window.opener."+this.objname+".padHeight+"+parseInt(this.winMargin)*2+"\n")
		write( "top.window.resizeTo( document.images[0].width+ww, document.images[0].height+wh)\n")
		write( "self.focus()\n")
		write( "}\n</scr")
		write( "ipt>\n")
		write( "</head>\n" )
		if(bugimus.NN4)
			write( "<body marginwidth="+this.winMargin+" marginheight="+this.winMargin+" background=\""+this.bgImage+"\" bgcolor=\""+this.bgColor+"\" onLoad=" )
		else
			write( "<body style=\"overflow: hidden; margin:"+this.winMargin+"; padding:"+this.winPadding+"; background-color:"+this.bgColor+"; background-image : url("+this.bgImage+");\" onLoad=" )
		write( "\"javascript:autoSize();\">" )
		write( "<img src=\""+imgName+"\" />" )
		write( "</body></html>" )
		close()
	}
}


