//<![CDATA[

/**
 * Copyright (C) 2006 Rustam Bogubaev
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

function Browser(){
	var IS_FIREFOX = (/firefox/gi).test(navigator.userAgent);
	var IS_OPERA   = (/opera/gi).test(navigator.userAgent);
	var IS_MSIE    = (/microsoft/gi).test(navigator.appName);
	
	// get screen width
	this.getScreenWidth = function(){
		return screen.width;
	}

	// get screen height
	this.getScreenHeight = function(){
		return screen.height;
	}
	
	// get window inner width
	this.getWindowInnerWidth = function(minWidth) {
		var windowInnerWidth = 0;
	
		if (IS_FIREFOX) {
			windowInnerWidth = document.documentElement.clientWidth;
		} else if (IS_OPERA) {
			windowInnerWidth = document.body.clientWidth;
		} else if (IS_MSIE) {
			windowInnerWidth = document.documentElement.clientWidth;
		} else {
			return minWidth;
		}
		
		if (windowInnerWidth < minWidth){
			windowInnerWidth = minWidth;
		}
		
		return windowInnerWidth;
	}

	// get window inner height
	this.getWindowInnerHeight = function(minHeight) {
		var windowInnerHeight = 0;
	
		if (IS_FIREFOX) {
			windowInnerHeight = document.documentElement.clientHeight;
			return document.documentElement.clientHeight;
		} else if (IS_OPERA) {
			windowInnerHeight = document.body.clientHeight;
		} else if (IS_MSIE) {
			windowInnerHeight = document.documentElement.clientHeight;
		} else {
			return minHeight;
		}
		
		if (windowInnerHeight < minHeight){
			windowInnerHeight = minHeight;
		}
		
		return windowInnerHeight;
	}
	
	// get window X position
	this.getWindowPositionX = function(){
		return (IS_OPERAs || IS_MSIE) ? window.screenLeft : window.screenX;
	}

	// get window Y position
	this.getWindowPositionY = function(){
		return (IS_OPERA  || IS_MSIE) ? window.screenTop : window.screenY;
	}
}

//]]>
