/**
 * This file is a part of Javascript ToolKit
 * 
 * Javascript ToolKit is a cross-browser javascript/DOM framework 
 * used to build rich web-based client interfaces with basic controls 
 * (dialog, button, imageButton, ...), complex controls 
 * (htmlEditor, colorChooser, grid, ...) and RPC components.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * 
 * Copyright (C) 2005 Frédéric LECOINTRE <frederic.lecointre@burnweb.net>
 *
 * $Id: jtkBrowser.js,v 1.1 2005/04/07 07:57:48 gabriel_ Exp $ 
 */
/**
 * Modified from original file by Frédéric LECOINTRE  2007/08
 */

/** 
 * @class jtkBrowser
 * @package core
 * @version 1.0.0 $Date: 2005/04/07 07:57:48 $ $Revision: 1.1 $
 * @author Frédéric LECOINTRE<frederic.lecointre@burnweb.net>
 * 
 */
jtkBrowser = function (){

	this.type = null;
	this.version = null;		
	this._chkNavigator();
	
}//end function

/**
 * 
 * @return boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.isIe = function() {
	return ( this.type == "msie" );
}//end function


/**
 * 
 * @return boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.isGecko = function() {
	return ( this.type == "gecko" );
}//end function


/**
 * 
 * @return boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.isFirefox = function(){ 
	return ( this.type == "firefox" );
}//end function

/**
 * 
 * @return boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.isNetscape = function() {
	return ( this.type == "netscape" );
}//end function


/**
 * 
 * @return  boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.isOpera = function() {
	return ( this.type == "opera" );
}//end function

/**
 * 
 * @return boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.isKonqueror = function() {
	return ( this.type == "konqueror" );
}//end function

/**
 * 
 * @return  boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.isSafari = function(){ 
	return ( this.type == "safari" );
}//end function

/**
 * 
 * @return  boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.isDom = function() {
	return (document.createElement && document.appendChild && document.getElementsByTagName);
}//end function

/**
 * 
 * @return  boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.isSupported = function() {
	var retval = false;
	
	if(this.isIe()){
		retval = true
	}//end if
	else if(this.isGecko()){
		retval = true
	}//end if
	else if(this.isFirefox()){
		retval = true
	}//end if
	else if(this.isNetscape()){
		retval = true
	}//end if
	return retval;
}//end function

/**
 * 
 * @return  boolean
 * @since 1.0.0
 */
jtkBrowser.prototype.getString = function() {
	return this.agent;
}//end function

/**
 * 
 * @return  void
 * @since 1.0.0
 */
jtkBrowser.prototype._chkNavigator = function() {

	this.agent 	= navigator.userAgent.toLowerCase();
	this.appName = navigator.appName.toLowerCase();
	var version = navigator.appVersion;
	
	if( this.agent.indexOf("msie") != -1  && this.agent.indexOf("opera") == -1 && this.agent.indexOf("webtv") == -1 ){
	
		var reg = /MSIE ([0-9]\.?[0-9]?)/i;
		reg.exec(version);
		
		this.type 		= "msie";
		this.version 	= parseFloat(RegExp.$1);
		
	}//end if
	else if ( this.agent.indexOf("opera") != -1 ) {
	
		this.type 		= "opera";
		this.version 	= parseInt( this.agent.substr ( this.agent.indexOf("opera") +6, 1 ) );
		
	}//end elseif
	else if ( this.agent.indexOf("konqueror") != -1 ) {
	
		this.type 		= "konqueror";
		this.version 	= parseInt(version);

	}//end elseif
	else if ( this.agent.indexOf("safari") != -1 ) {
	
		this.type 		= "safari";
		this.version 	= parseInt(version);

	}//end elseif
	else if ( this.agent.indexOf("firefox") != -1 ) {
	
		this.type 		= "firefox";
		this.version 	= parseInt(version);
		
	}//end elseif
	else if ( this.agent.indexOf("gecko") != -1 ) {
	
		this.type 		= "gecko";
		this.version 	= parseInt(version);
		
	}//end elseif
	else if ( this.agent.indexOf("opera") == -1 && this.agent.indexOf("safari") == -1 && this.appName == "netscape" ) {
	
		this.type 		= "netscape";
		this.version 	= parseInt(version);
		
	}//end elseif
	else {
	
		this.type 		= null;
		this.version 	= null;
		
	}//end else
	
}//end function


