// depends on common.js: QQ
QQ.Browser = function(){

  return {
  	// return innerWidth or innerHeight of the browser window, parameter: 0 is width, 1 is height
  	getInnerSize: function (parameter){
			var width;
			var height;
			if(typeof(window.innerWidth) == 'number'){
			  width = window.innerWidth;
			  height = window.innerHeight;
			}else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			  width = document.documentElement.clientWidth;
			  height = document.documentElement.clientHeight;
			}
			if (parameter == 0) return width;
			  return height;
		},
		getScrollPosition: function (parameter){
			if (parameter == "x"){
			  if (window.pageXOffset !== undefined) return window.pageXOffset;
			  if (document.documentElement !== undefined) return document.documentElement.scrollLeft;
			  return document.body.scrollLeft;
			}else{
			  if (window.pageYOffset !== undefined) return window.pageYOffset;
			  if (document.documentElement !== undefined) return document.documentElement.scrollTop;
			  return document.body.scrollTop;
			}
		},
		getAgent: function(){
			if (navigator.userAgent.indexOf('Opera') != -1) return 'Opera';
			if (navigator.userAgent.indexOf('MSIE') != -1) return 'IE';
			if (navigator.userAgent.indexOf('Firefox') != -1) return 'Firefox';
			if (navigator.userAgent.indexOf('Safari') != -1) return 'Safari';
		},
		isOpera: function(){
			if (this.getAgent() === 'Opera') return true;
			return false;
		},
		isIE: function(){
			if (this.getAgent() === 'IE') return true;
			return false;
		},
		isFF: function(){
			if (this.getAgent() === 'Firefox') return true;
			return false;
		},
		isSafari: function (){
			if (this.getAgent() === 'Safari') return true;
			return false;
		},
		xMouse: function (e){
			return this.getMousePosition(e).x;
		},
		yMouse: function (e){
			return this.getMousePosition(e).y;
		},
		getMousePosition: function(e){
			var Position = {};
			
			if (!e) var e = window.event;
			if (e.pageX || e.pageY){
				Position.x = e.pageX;
				Position.y = e.pageY;
			}else if (e.clientX || e.clientY){
				Position.x = e.clientX;
				Position.y = e.clientY;
				if (this.isIE()){
					Position.x += document.body.scrollLeft;
					Position.y += document.body.scrollTop;
				}
			}
			
			return Position;
		}
  };
}();
