/*

JS files needed:
	- StdLibrary.js
	
Usage:
	var curbrw = new CurrentBrowser();
	switch ( curbrw.GetBrowser().ID )
	{
		case curbrw.INTERNET_EXPLORER:
		{
			//DO something
			break;
		}
		
		case curbrw.FIREFOX:
		{
			//DO something
			break;
		}
		
		case curbrw.OPERA:
		{
			//DO something
			break;
		}
		
		default:
			break;
	}


*/


// Ust to create an object
function BrowserInfo(ID, key, name)
{
	this.ID			= ID;
	this.key		= key;
	this.name		= name;
	//this.version	= version;
}

// Return tru if the curent browser is denoted by the 'key', false otherwize
function CheckIt_CurrentBrowser(key)
{
	if ( false == __CheckString(key) || this.detect.indexOf(key) < 0 )
	{
		return false;
	}

	return true;
}

// Return the references of the current browser
function GetBrowser_CurrentBrowser()
{
	return this.browser;
}

// Used to create an object with information of the current browser
function CurrentBrowser()
{
	this.detect					= navigator.userAgent.toLowerCase();
	this.value					= 0;
	this.UNKNOWN				= ++this.value;
	this.KONQUEROR				= ++this.value;
	this.SAFARI					= ++this.value;
	this.OMNIWEB				= ++this.value;
	this.OPERA					= ++this.value;
	this.FIREFOX				= ++this.value;
	this.WEBTV					= ++this.value;
	this.ICAB					= ++this.value;
	this.INTERNET_EXPLORER		= ++this.value;
	this.NETSCAPE_NAVIGATOR		= ++this.value;
	
	this.browser				= new BrowserInfo(this.UNKNOWN, 'unknown', 'Unknown');
	this.CheckIt				= CheckIt_CurrentBrowser;
	this.GetBrowser				= GetBrowser_CurrentBrowser;
	

	this.browser.ID = this.UNKNOWN;
	this.browser.key = 'unknown';
	this.browser.name = 'Unknown';
	this.browser.version = '0';
	
	if ( this.CheckIt('konqueror') )
	{
		this.browser.ID			= this.KONQUEROR;
		this.browser.key		= 'konqueror';
		this.browser.name		= 'Konqueror';
	}
	else if ( this.CheckIt('safari') )
	{
		this.browser.ID			= this.SAFARI;
		this.browser.key		= 'safari';
		this.browser.name		= 'Safari';
	}
	else if ( this.CheckIt('omniweb') )
	{
		this.browser.ID			= this.OMNIWEB;
		this.browser.key		= 'omniweb';
		this.browser.name		= 'OmniWeb';
	}
	else if ( this.CheckIt('opera') )
	{
		this.browser.ID			= this.OPERA;
		this.browser.key		= 'opera';
		this.browser.name		= 'Opera';
	}
	else if ( this.CheckIt('firefox') )
	{
		this.browser.ID			= this.FIREFOX;
		this.browser.key		= 'firefox';
		this.browser.name		= 'FireFox';
	}
	else if ( this.CheckIt('webtv') )
	{
		this.browser.ID			= this.WEBTV;
		this.browser.key		= 'webtv';
		this.browser.name		= 'WebTV';
	}
	else if ( this.CheckIt('icab') )
	{
		this.browser.ID			= this.ICAB;
		this.browser.key		= 'icab';
		this.browser.name		= 'iCab';
	}
	else if ( this.CheckIt('msie') )
	{
		this.browser.ID			= this.INTERNET_EXPLORER;
		this.browser.key		= 'msie';
		this.browser.name		= 'Internet Explorer';
	}
	else if ( !this.CheckIt('compatible') )
	{
		this.browser.ID			= this.NETSCAPE_NAVIGATOR;
		this.browser.key		= 'compatible';
		this.browser.name		= 'Netscape Navigator';
		//version					= detect.charAt(8);
	}
}
