//**********************************************************************
// Show/hide infoline.
function fnShow(id)
{
	document.getElementById( id ).style.display = "block";
}
function fnHide(id)
{
	document.getElementById( id ).style.display = "none";
}
//**********************************************************************
var sFrameSrc = 'empty.html';
function setFrameSrc(sSrc)
{
	sFrameSrc = sSrc;
}
function openFrame(id)
{
	window.open(sFrameSrc, "_blank");;
}
//**********************************************************************
// Resize content
function BOTForceSize( minWidth, minHeight )
{
	this.cnt	= "page";
	this.minW	= minWidth;
	this.minH	= minHeight;
	this.cursize= '';
	var o		= this;
	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		this.setWindowEvent( 'onload', this, this.onLoadDivIE );
		this.setWindowEvent( 'onresize', this, this.onResizeDivIE );
	}
	else
	{
		this.setWindowEvent( 'onload', this, this.onLoadDiv );
		this.setWindowEvent( 'onresize', this, this.onResizeDiv );
	}
}

BOTForceSize.prototype = {
	setWindowEvent: function( eventName, scope, func )
	{
		window[ eventName ] = function(){ func.call( scope ); };
	},
	clearWindowEvent: function(eventName)
	{
		window[ eventName ] = null;
	},
	getWinSize: function()
	{
		var winW = this.minW
		var winH = this.minH;
		if( typeof( window.innerWidth ) == 'number' )
		{
			//Non-IE
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ))
		{
			//IE 6+ in 'standards compliant mode'
			winW = document.documentElement.clientWidth;
			winH = document.documentElement.clientHeight;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		{
			//IE 4 compatible
			winW = document.body.clientWidth;
			winH = document.body.clientHeight;
		  }
		return {width: winW, height: winH };
	},
	setSize: function(iWidth, iHeight)
	{
		// Update sizes.
		document.getElementById( this.cnt ).style.width	 = (iWidth -  40) + "px";
		document.getElementById( this.cnt ).style.height = (iHeight - 40) + "px";
		
		// Resize rFrame.
		document.getElementById("rframe").style.width	= (iWidth - 337) + "px";
		document.getElementById("rframe").style.height	= (iHeight - 110) + "px";

		// Update frame size.
		document.getElementById("content").style.width	= (iWidth - 313) + "px";
	},
	// **************************************************
	// !IE
	onLoadDiv: function()
	{
		this.setSize(this.minW, this.minH);
		this.onResizeDiv();
	},
	onResizeDiv: function()
	{
		var winSize  = this.getWinSize();
		var w = (winSize.width  < this.minW) ? (this.minW) : winSize.width;
		var h = (winSize.height < this.minH) ? (this.minH) : winSize.height;
		// Check scrollbars.
		if (w == this.minW) h = Math.max(h-20, this.minH);
		if (h == this.minH) w = Math.max(w-20, this.minW)
		this.setSize(w, h);
	},

	// **************************************************
	// IE
	onLoadDivIE: function()
	{
		this.setSize(this.minW, this.minH);
		this.onResizeDiv();
	},
	
	onResizeDivIE: function()
	{
		var winSize  = this.getWinSize();
		if (this.cursize == (winSize.width+''+winSize.height)) return;
		var w = (winSize.width  < this.minW) ? (this.minW) : winSize.width;
		var h = (winSize.height < this.minH) ? (this.minH) : winSize.height;
		// Check scrollbars.
		if (w == this.minW) h = Math.max(h-20, this.minH);
		if (h == this.minH) w = Math.max(w-20, this.minW)
		document.body.scroll = ( w > this.minW && h > this.minH )? "no" : "auto";
		// Check IE6.
		if (navigator.userAgent.indexOf("MSIE 6.0") !=-1) h -= 10;
		// Disable event.
		this.clearWindowEvent('onresize');
		this.setSize(w, h);
		var nSize	= this.getWinSize();
		this.cursize= (nSize.width+''+nSize.height);
		// Debug.
		/*
			var dtNow	= new Date();
			window.status = 'Window size: old[' + winSize.width +':'+winSize.height +'] new[' + nSize.width +':'+nSize.height+'] tStamp:'+dtNow.getTime() + ' Scroll:' + document.body.scroll;
		*/
		// Enable event.
		this.setWindowEvent('onresize', this, this.onResizeDivIE );
	}
}