// Copyright 2005 Go2map
function PopWin(a,b,c,d,e)	//(container,windowZIndex,shadowZIndex,width,height)
{
	this.createWindow(b);
	this.createContentArea();
	this.createCloseButton();
	a.appendChild(this.windowDiv);
	if(!d) d=50;
	if(!e) e=40;
	this.setSize(d,e);
	this.hide()
	
};
PopWin.prototype.createWindow=function(a)	//(zIndex)
{
	var b,c,d,e,f,g;
	b=this.window={};
	c=b.title=Layer.createDiv(1,1,1,16,3);
	//c.style.backgroundColor="#FDDE5F";
	//c.style.color="#FFFFFF";
	c.style.backgroundImage="url(images/dec_04.jpg)";
	d=b.body=Layer.createDiv(18,1,1,1,3);
	//d.style.backgroundColor="#FFE4E4";
	e=this.windowDiv=Layer.createDiv(0,0,1,1,a);
	e.onmousedown=this.onMouseDown;
	e.onclick=this.onMouseDown;
	e.style.backgroundColor="#e2f3ff";
	f=this.shadowDiv=Layer.createDiv(3,3,1,1,1);
	f.style.backgroundColor="#000";
	f.style.filter="alpha(opacity=50)";
	_setStyle(f,"noprint");
	g=this.backDiv=Layer.createDiv(0,0,1,1,2);
	g.style.backgroundColor="#FFFFFF";
	g.style.border="#ffffff 1px solid";
	e.appendChild(c);
	e.appendChild(d);
	e.appendChild(f);
	e.appendChild(g);
};
PopWin.prototype.createContentArea=function()
{
	var a,b;
	a=this.contentArea=Layer.createDiv(18,1,1,1,3);
	_setCursor(a,"auto"); 
	a.onmousedown=this.onMouseDown;
	a.style.backgroundColor="#e2f3ff";
	this.windowDiv.appendChild(a);
	a=this.offscreenContainer=Layer.createDiv(-screen.height,-screen.width,screen.width,screen.height);
	a.style.visibility="hidden";
	document.body.appendChild(a);
	a=this.offscreenArea=Layer.createDiv(18,1,null,null,3);
	_setCursor(a,"auto");
	a.onmousedown=this.onMouseDown;
	this.offscreenContainer.appendChild(this.offscreenArea);
	b=this.caption=Layer.createDiv(1,1,null,16,3);
	b.style.fontFamily="Arial"
	b.style.fontSize="11px"
	b.style.overflow="hidden";
	b.style.whiteSpace="nowrap";
	b.style.padding="2px";
	b.style.fontWeight="bold";
	b.style.color="#ffffff";
	_setStyle(b,"PopWinCaption");
	this.windowDiv.appendChild(b);
};
PopWin.prototype.createCloseButton=function()
{
	var b,c,d;
	c=this;
	b=c.closeButton=Layer.createDiv(2,1,12,12,3);
	b.style.color="#000";
	//b.style.fontFamily="webdings";
	b.style.fontWeight="bolder";
	b.style.fontSize="17px";
	b.innerHTML="<p><img src='images/x1.gif'></p>";
	_setCursor(b,"pointer");
	b.onmousedown=c.eventHandler("onCloseMouseDown");
	b.onclick=c.eventHandler("onCloseMouseDown");
	b.onmouseover=function(){this.style.color="#f00"};
	b.onmouseout=function(){this.style.color="#000"};
	c.windowDiv.appendChild(b)
};
PopWin.prototype.setContentSize=function(a,b)
{   //alert("csz")
	this.setSize(a+2,b+20)
};
PopWin.prototype.setSize=function(a,b)
{   //alert("sz")
	a=this.width=Math.max(a,50);
	b=this.height=Math.max(b,40);
	var c,d;
	c=this.window;
	d=c.title.style;
	d.width=a-2+"px";
	d=c.body.style;
	d.width=a-2+"px";
	d.height=(b-20)+"px";
	c=this.closeButton;
	d=this.width-parseInt(c.style.width)-4;
	c.style.left=d+"px";
	//c.style.top="5px";
	this.caption.style.width=(d-8)+"px"
	c=this.windowDiv;
	c.width=a+"px";
	c.height=b+"px";
	c=this.backDiv;
	c.style.width=a+"px";
	c.style.height=b+"px";
	c=this.shadowDiv;
	c.style.width=a+"px";
	c.style.height=b+"px";
};
PopWin.prototype.getOffsetLeft=function()
{
	return this.windowDiv.offsetLeft
};
PopWin.prototype.getOffsetTop=function()
{
	return this.windowDiv.offsetTop
};
PopWin.prototype.hide=function()
{
	this.windowDiv.style.display="none";
};
PopWin.prototype.show=function()
{
	this.windowDiv.style.display="";
	this.windowDiv.style.visibility="visible";
	this.contentArea.style.visibility="visible"
};
PopWin.prototype.isVisible=function()
{
	return this.windowDiv.style.display!="none"
};
PopWin.prototype.positionAt=function(a,b,c,d,e)	//(x,y,iconClass,viewSize,screenPerCent)
{
	var f,g,h,i,j,k,l;
	f=this.windowDiv;
	g=Math.round(d.width*e.x);
	h=Math.round(d.height*e.y);
	if(g>this.width&&d.width-g<this.width)
	{
		this.left=a-Math.min(38,c.pointCoord.x)-this.width;
	}
	else
	{
		this.left=a+Math.min(38,c.width-c.pointCoord.x);
	}
	if(h>this.height&&d.height-h<this.height)
	{
		this.top=b+Math.min(38,c.height-c.pointCoord.y)-this.height;
	}
	else
	{
		this.top=b-Math.min(38,c.pointCoord.y);
	}
	this.windowDiv.style.left=this.left+"px";
	this.windowDiv.style.top=this.top+"px";
};
PopWin.prototype.prepareOffscreen=function(a)
{
	if(this.windowDiv.style.display=="none")
	{
		this.windowDiv.style.display="";
		this.windowDiv.style.visibility="hidden";
		this.contentArea.style.visibility="hidden";
		this.offscreenArea.style.visibility="hidden"
	}
	if(a)
	{
		this.offscreenContainer.style.width=_pixel(a)
	}

};
PopWin.prototype.clearOffscreenArea=function()
{
	_clearAllChildNodes(this.offscreenArea)
};
PopWin.prototype.flipOffscreenAndSize=function()
{
	var a=Math.max(this.offscreenArea.offsetWidth,50);
	var b=Math.max(this.offscreenArea.offsetHeight,40);
	this.flipOffscreenArea(a,b);
	this.setContentSize(a,b)
};
PopWin.prototype.sizeToContent=function()
{
	this.setContentSize(Math.max(this.contentArea.offsetWidth,50),this.contentArea.offsetHeight)
};
PopWin.prototype.flipOffscreenArea=function(a,b)
{
	this.offscreenContainer.removeChild(this.offscreenArea);
	this.windowDiv.removeChild(this.contentArea);
	var c=this.offscreenArea;
	this.offscreenArea=this.contentArea;
	this.contentArea=c;
	this.offscreenContainer.appendChild(this.offscreenArea);
	this.windowDiv.appendChild(this.contentArea);
	if(a&&b)
	{
		this.contentArea.style.width=_pixel(a);
		this.contentArea.style.height=_pixel(b)
	}
	this.offscreenArea.style.width="50px";
	this.offscreenArea.style.height="40px";
	this.contentArea.style.visibility="visible";
	this.clearOffscreenArea()
};
PopWin.prototype.onMouseDown=function(a)
{
	_stopEvent(a);
};
PopWin.prototype.onCloseMouseDown=function(a)
{
	_stopEvent(a);
	this.setTimeout(function(){Event.trigger(this,"closeclick")},300)
};
PopWin.prototype.getTotalHeightAboveGround=function()
{
	return this.height;
};
PopWin.prototype.getTotalWidth=function()
{
	return this.width;
};