/* Browser Detection Script */
browserVars = new browserVarsObj();
if(!browserVars.type.getById) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = new Function('e', 'browserVars.updateMouse(e)');

function browserDetect()
{
this.getById = document.getElementById?true:false;
this.layers = document.layers?true:false;
this.ns4 = ((this.layers) && (!this.getById));
this.ns6 = ((navigator.userAgent.indexOf('Netscape6') != -1) && (this.getById));
this.moz = ((navigator.appName.indexOf('Netscape') != -1) && (this.getById) && (!this.ns6));
this.ie  = ((!this.layers) && (this.getById) && (!(this.ns6 || this.moz)));
this.opera = window.opera?true:false;
}


function browserVarsObj()
{
this.updateMouse = browserVarsObjUpdateMouse;
this.updateVars = browserVarsObjUpdateVars;

this.mouseX = 0;
this.mouseY = 0;

this.type = new browserDetect();
this.width = 0;
this.height = 0
this.screenWidth = screen.width;
this.screenHeight = screen.height;
this.scrollWidth = 0;
this.scrollHeight = 0;
this.scrollLeft = 0;
this.scrollTop = 0;
this.updateVars();
}

function browserVarsObjUpdateMouse(e)
{
if(!this.type.ie)
{
this.mouseX = e.pageX;
this.mouseY = e.pageY;
}
else
{
this.mouseX = window.event.clientX + this.scrollLeft;
this.mouseY = window.event.clientY + this.scrollTop;
}
}
function f_clientWidth() {
return f_filterResults (
window.innerWidth ? window.innerWidth : 0,
document.documentElement ? document.documentElement.clientWidth : 0,
document.body ? document.body.clientWidth : 0
);
}
function f_clientHeight() {
return f_filterResults (
window.innerHeight ? window.innerHeight : 0,
document.documentElement ? document.documentElement.clientHeight : 0,
document.body ? document.body.clientHeight : 0
);
}
function f_scrollLeft() {
return f_filterResults (
window.pageXOffset ? window.pageXOffset : 0,
document.documentElement ? document.documentElement.scrollLeft : 0,
document.body ? document.body.scrollLeft : 0
);
}
function f_scrollTop() {
return f_filterResults (
window.pageYOffset ? window.pageYOffset : 0,
document.documentElement ? document.documentElement.scrollTop : 0,
document.body ? document.body.scrollTop : 0
);
}
function f_scrollWidth() {
return f_filterResults (
document.width ? document.width : 0,
document.documentElement ? document.documentElement.scrollWidth : 0,
document.body ? document.body.scrollWidth : 0
);
}
function f_scrollHeight() {
return f_filterResults (
document.height ? document.height : 0,
document.documentElement ? document.documentElement.scrollHeight : 0,
document.body ? document.body.scrollHeight : 0
);
}
function f_filterResults(n_win, n_docel, n_body) {
var n_result = n_win ? n_win : 0;
if (n_docel && (!n_result || (n_result > n_docel)))
n_result = n_docel;
return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function browserVarsObjUpdateVars()
{
this.width = f_clientWidth();
this.height = f_clientHeight();
this.scrollWidth = f_scrollWidth();
this.scrollHeight = f_scrollHeight();
this.scrollLeft = f_scrollLeft();
this.scrollTop = f_scrollTop();
}

function fitPopupToContent() {
	var width = 0, height = 0;
	
	var obj = document.getElementById('container');
	if (typeof(obj.offsetLeft) == 'number' && typeof(obj.offsetTop) == 'number') {
		width += obj.offsetLeft;
		height += obj.offsetTop;
	}
	
	if (typeof(window.innerWidth) == 'number' ) {
		//Non IE
		height += window.innerHeight;
		width += window.innerWidth;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ) {
		//IE6+ in standarts compliant mode
		height += document.documentElement.clientHeight;
		width += document.documentElement.clientWidth;
	} else if ( document.body && (document.body.clientWidth || document.body.clientHeight) ) {
		//IE 4 compatible
		height += document.body.clientHeight;
		width += document.body.clientWidth;
	}		 

	if (width > 0 && height > 0 ) { 
		window.resizeTo(width+20, height+100);
	}
}
