cms.browser =
{
    OPERA : 1,
    MSIE : 2,
    FIREFOX : 3,
	SAFARI : 4,
    UNKNOWN : 5,
	
	browser : undefined,

	getBrowserId : function()
	{
		if (/Safari/i.test(navigator.userAgent))
		{
			return this.SAFARI;
		}
        switch(navigator.appName)
        {
            case 'Microsoft Internet Explorer': return this.MSIE;
            case 'Netscape': return this.FIREFOX;
            case 'Opera': return this.OPERA;
        }
		return this.UNKNOWN;
	},

    getBrowser : function()
    {
		if (!this.browser)
		{
			this.browser = this.getBrowserId();
		}
        return this.browser;
    },
    
    isBrowser : function(browser)
    {
        return this.getBrowser() == browser;
    },
    
    isIE : function()
    {
        return this.isBrowser(this.MSIE);
    },

    isOpera : function()
    {
        return this.isBrowser(this.OPERA);
    },
    
    isFirefox : function()
    {
        return this.isBrowser(this.FIREFOX);
    },
	
	isSafari : function()
	{
		return this.isBrowser(this.SAFARI);
	},
	
	getCursorX : function(event)
	{		
		if (event.x)
		{
			return event.x; 
		}
		return event.pageX; 
	},

	getCursorY : function(event)
	{
		if (event.y)
		{
			return event.y; 
		}
		return event.pageY; 
	},
	
	getOffsetLeft : function(element)
	{
		return parseInt(element.x)? element.x : this.getOffset(element, "Left");
	},
	
	getOffsetTop : function(element)
	{
		return parseInt(element.y)? element.y : this.getOffset(element, "Top");
	},
	
	getOffset : function(element, suffix)
	{
		var position = 0;
		while (element != null)
		{
			position += element["offset" + suffix]; 
			element = element.offsetParent;
		}
		return position;
	},

	clearSelection : function()
	{
		if (this.isIE())
		{
			document.selection.empty() ;
		}
		else if (window.getSelection)
		{
			var selection = window.getSelection();
			if(selection && selection.removeAllRanges)
			{
				selection.removeAllRanges() ;
			}
		}
	}
}