function BrowserInfo()
{
}

BrowserInfo.isOP = (document.all && document.getElementById && window.opera ) ? true : false;
BrowserInfo.isCSS = (document.body && document.body.style) ? true : false;
BrowserInfo.isW3C = (BrowserInfo.isCSS && document.getElementById) ? true : false;
BrowserInfo.isIE4 = (BrowserInfo.isCSS && document.all) ? true : false;
BrowserInfo.isNN4 = (document.layers) ? true : false;
BrowserInfo.isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
BrowserInfo.isIE = ((document.all)&&(!BrowserInfo.isOP)) ? true : false;
BrowserInfo.ie50 = BrowserInfo.isIE && navigator.appVersion.indexOf("MSIE 5.0")>=0;
BrowserInfo.ie55 = BrowserInfo.isIE && navigator.appVersion.indexOf("MSIE 5.5")>=0;
BrowserInfo.ie60 = BrowserInfo.isIE && navigator.appVersion.indexOf("MSIE 6.0")>=0;
BrowserInfo.isKonqueror = ((navigator.appVersion.indexOf("Konqueror") >= 0)||(navigator.appVersion.indexOf("Safari") >= 0)) ? true : false; 
BrowserInfo.isSafari = (navigator.appVersion.indexOf("Safari") >= 0) ? true : false; 
BrowserInfo.isMozilla = ((navigator.userAgent.indexOf("Gecko") >= 0)&&(!BrowserInfo.isKonqueror)) ? true : false; 

function BrowserUtil()
{
}

BrowserUtil.attachEventListener = function(target, event, pointer)
{
	if(target)
	{
		if(target.attachEvent)
		{//IE
			target.attachEvent('on' + event, pointer);
		}
		else
		{
			if(event == 'mousewheel')
				event = 'DOMMouseScroll';
			target.addEventListener(event, pointer, false);
		}
		return pointer;
	}
	return null;
}

BrowserUtil.detachEventListener = function(target, event, pointer)
{
	if(target)
	{
		try
		{
			if(target.attachEvent)
			{//IE
				target.detachEvent('on' + event, pointer);
			}
			else
			{
				if(event == 'mousewheel')
					event = 'DOMMouseScroll';
				target.removeEventListener(event, pointer, false);
			}
		}
		catch(ex)
		{
		}
	}
	return null;
}

//Eseménybol adja vissza a page koordinátákat
BrowserUtil.getPageEventCoords = function(evt) {
    var coords = new Point(0, 0);
    if (evt.pageX) {
        coords.x = evt.pageX;
        coords.y = evt.pageY;
    } 
	else if(evt.clientX)
	{
        coords.x = evt.clientX + document.body.scrollLeft - document.body.clientLeft;
        coords.y = evt.clientY + document.body.scrollTop - document.body.clientTop;
        if (document.body.parentElement && document.body.parentElement.clientLeft)
		{
            var bodParent = document.body.parentElement;
            coords.x += bodParent.scrollLeft - bodParent.clientLeft;
            coords.y += bodParent.scrollTop - bodParent.clientTop;
        }
    }
    return coords;
}

//Visszaadja egy nem pozicionált obijektum koordinátáit
BrowserUtil.getElementPosition = function(oElement)
{
	function getNextAncestor(oElement)
	{
		var actualStyle;
		if( window.getComputedStyle )
			actualStyle = getComputedStyle(oElement,null).position;
		else if( oElement.currentStyle )
			actualStyle = oElement.currentStyle.position;
		else
			actualStyle = oElement.style.position;
		if( actualStyle == 'absolute' || actualStyle == 'fixed' )
			return oElement.offsetParent;
		return oElement.parentNode;
	}
	
	if( typeof( oElement.offsetParent ) != 'undefined' )
	{
		var originalElement = oElement;
		for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent )
		{
			posX += oElement.offsetLeft;
			posY += oElement.offsetTop;
		}
		if( !originalElement.parentNode || !originalElement.style || typeof( originalElement.scrollTop ) == 'undefined' )
		{
			return new Point(posX, posY);
		}
		/*oElement = getNextAncestor(originalElement);
		while( oElement && oElement != document.body && oElement != document.documentElement )
		{
			posX -= oElement.scrollLeft;
			posY -= oElement.scrollTop;
			oElement = getNextAncestor(oElement);
		}*/
		return new Point(posX, posY);
	}
	else
	{
		return new Point(oElement.x, oElement.y);
	}
}
/*BrowserUtil.getElementPosition = function(obj) {
    var offsetTrail = obj;
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return new Point(parseInt(offsetLeft), parseInt(offsetTop));
}*/


//Visszaadja az obijektum x koorinátáját
BrowserUtil.getObjectLeft = function(obj)
{
    var result = 0;
    if (document.defaultView)
	{
        var style = document.defaultView;
		if(style != null)
		{
        	var cssDecl = style.getComputedStyle(obj, "");
			if(cssDecl != null)
			{
        		result = cssDecl.getPropertyValue("left");
			}
		}
    }
	else if (obj.currentStyle)
	{
        result = obj.currentStyle.left;
    }
	else if (obj.style)
	{
        result = obj.style.left;
    } else if (isNN4) {
        result = obj.left;
    }
	result = parseInt(result);
	if(result == Number.NaN)
		result = 0;
    return parseInt(result);
}
   
//Visszaadja az obijektum y koorinátáját
BrowserUtil.getObjectTop = function(obj)  {
    var result = 0;
    if (document.defaultView)
	{
        var style = document.defaultView;
		if(style != null)
		{
        	var cssDecl = style.getComputedStyle(obj, "");
			if(cssDecl != null)
			{
        		result = cssDecl.getPropertyValue("top");
			}
		}
    }
	else if (obj.currentStyle)
	{
        result = obj.currentStyle.top;
    }
	else if (obj.style)
	{
        result = obj.style.top;
    }
	else if (isNN4)
	{
        result = obj.top;
    }
	result = parseInt(result);
	if(result == Number.NaN)
		result = 0;
    return parseInt(result);
}

//Visszaadja az obijektum szélességét
BrowserUtil.getObjectWidth = function(obj)
{
    var result = 0;
    if (obj.offsetWidth)
	{
        result = obj.offsetWidth;
    }
	else if (obj.clip && obj.clip.width)
	{
        result = obj.clip.width;
    }
	else if (obj.style && obj.style.pixelWidth)
	{
        result = obj.style.pixelWidth;
    }
    return parseInt(result);
}
   
//Visszaadja az obijektum magasságát
BrowserUtil.getObjectHeight = function(obj)
{
    var result = 0;
    if (obj.offsetHeight)
	{
        result = obj.offsetHeight;
    }
	else if (obj.clip && obj.clip.height)
	{
        result = obj.clip.height;
    }
	else if (obj.style && obj.style.pixelHeight)
	{
        result = obj.style.pixelHeight;
    }
    return parseInt(result);
}
   
//Visszaadja az ablak szélességét
BrowserUtil.getInsideWindowWidth = function( )
{
    if (window.innerWidth)
	{
        return window.innerWidth;
    }
	else if (BrowserInfo.isIE6CSS)
	{
        // measure the html element's clientWidth
        return document.body.parentElement.clientWidth;
    }
	else if (document.body && document.body.clientWidth)
	{
        return document.body.clientWidth;
    }
    return 0;
}
   
//Visszaadja az ablak magasságát
BrowserUtil.getInsideWindowHeight = function()
{
    if (window.innerHeight)
	{
        return window.innerHeight;
    }
	else if (BrowserInfo.isIE6CSS)
	{
        return document.body.parentElement.clientHeight;
    }
	else if (document.body && document.body.clientHeight)
	{
        return document.body.clientHeight;
    }
    return 0;
}

BrowserUtil.isParentOf = function(ParentElement, ChildElement)
{
	var TempElement = ChildElement;
	var bResult = false;
	while(TempElement.parentNode)
	{
		if(TempElement == ParentElement)
		{
			bResult = true;
			break;
		}
		
		TempElement = TempElement.parentNode;
		if(typeof TempElement.tagName == 'undefined')
			return false;
		if(TempElement.tagName.toLowerCase() == 'body')
			break;
	}
	return bResult;
}

/*BrowserUtil.parseURL = function (uri)
{
	if (typeof uri == 'undefined')
	{
		uri = location.href;
	}
	else if (uri[0] == '/')
	{
		uri = location.host + uri;
	}
	//var url = uri.match(/^([^:]*:\/\/)?([^:]*:[^@]*@)?([^\/:]*\.[^\/:]*)?(:[^\/]*)?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i);
	var url = uri.match(/^([^:]*:\/\/)?([^:]*:[^@]*@)?([^\/:\?]*\.[^\/:\?]*)?(:[^\/]*)?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i);
	delete url.input;
	url.protocol = ((url[1])?url[1]:'http://').split('://')[0];
	url.user = (url[2])?url[2].split(':')[0]:undefined;
	url.password = (url[2])?url[2].split(':')[1].split('@')[0]:undefined;
	url.host = (url[3])?url[3]:location.host;
	url.hostname = url.host;
	url.port = (url[4])?((isNaN(parseInt(url[4].split(':')[1])))?80:parseInt(url[4].split(':')[1])):80;
	url.path = (url[5])?url[5]:'/';
	url.pathname = url.path;
	url.search = (url[6])?url[6].split('?')[1]:undefined;
	url.query = url.search;
	url.fragment = (url[7])?url[7].split('#')[1]:undefined;
	url.hash = url.fragment;
	url.href = ''
		+ url.protocol + '://'
		+ ((url.user)?url.user+':'+url.password+'@':'')
		+ url.host
		+ ((url.port != 80)?':'+url.port:'')
		+ url.path
		+ ((url.search)?'?'+url.search:'')
		+ ((url.fragment)?'#'+url.fragment:'');
	return url;
}*/

BrowserUtil.parseURL = function (str)
{
	var	o   = {
				strictMode: false,
				key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
				q:   {
					name:   "queryKey",
					parser: /(?:^|&)([^&=]*)=?([^&]*)/g
				},
				parser: {
					strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
					loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
				}
			},
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

BrowserUtil.createURL = function(uri)
{
	var strResult = "";
	
	return strResult;
}
