//------------------------------------------------------------------------------
// The source code and other contents of this file are owned by DuoKomp
// company and you are not allowed to use, modify, distribute or make them
// subject to any other action of yours unless you obtain an explicit DuoKomp's
// consent to do so.
//------------------------------------------------------------------------------
// If you need to contact us for any reason, visit www.duokomp.eu.
//-----------------------------------------------------------------------------
var imagePopupObj = null;

function ImagePopup ()
{
	this.path = "";
	this.width = 0;
	this.height = 0;
	this.border = 0;
	this.bordercolor = "white"
	
	var objref = null;
	var imgref = null;
	
	this.resize = function ()
	{
		var screen = new Geom_Rectangle();
		var pict = new Geom_Rectangle();
		this.getRectangles(screen, pict);
		objref.styles.width = screen.getDiffWidth()+"px";
		objref.styles.height = screen.getDiffHeight()+"px";
		imgref.styles.left = pict.left;
		imgref.styles.top = pict.top;
	}
	
	this.getRectangles = function (screen, pict)
	{
		screen.getBodyInnerRect();
		pict.right = this.width - 1;
		pict.bottom = this.height - 1;
		pict.centerIntoRectangle(screen);
	}
	
	this.show = function ()
	{
		if (this.width <= 0 || this.height <= 0 || this.path == "") return false;
		
		imagePopupObj = this;
		
		var screen = new Geom_Rectangle();
		var pict = new Geom_Rectangle();
		this.getRectangles(screen, pict);
		var totalheight = screen.getDiffHeight();
		var totalwidth = screen.getDiffWidth();
		var id = "_ImagePopupObject1"
		var innerHTML = "<div style='background-color:gray;opacity:0.8;filter:alpha(opacity=80);width:"+totalwidth+"px;height:"+totalheight+"px;position:absolute;left:0px;top:0px' onClick='javascript:imagePopupObj.close()' id='"+id+"'></div>";
		var newdiv = document.createElement("ipd");
		newdiv.innerHTML = innerHTML;
		newdiv = document.body.appendChild(newdiv);
		innerHTML = "<img src='"+this.path+"' style='position:absolute;left:"+(pict.left)+"px;top:"+(pict.top)+"px;border-style:solid;border-color:"+this.bordercolor+";border-width:"+this.border+"px;width:"+this.width+"px;height:"+this.height+"' onClick='javascript:imagePopupObj.close()'/>";
		var newimg = document.createElement("ip");
		newimg.innerHTML = innerHTML;
		newdiv.appendChild(newimg);
		objref = newdiv;
		imgref = newimg;
		return true;
	}
	
	this.close = function ()
	{
		document.body.removeChild(objref);
	}
}

function DoImagePopup (path, width, height, border, bordercolor)
{
	var obj = new ImagePopup();
	obj.path = path;
	obj.width = width;
	obj.height = height;
	obj.border = border;
	obj.bordercolor = bordercolor;
	obj.show();
}
