/*
**    File: fw_info.js
**    Created by: Zolotarev Anton (http://sourceforge.net/projects/ajaxos)
**
**    License Information:
**    -------------------------------------------------------------------------
**    Copyright (C) 2005 Zolotarev Anton
**
**    This program is free software; you can redistribute it and/or modify it
**    under the terms of the GNU General Public License as published by the
**    Free Software Foundation; either version 2 of the License, or (at your
**    option) any later version.
**    
**    This program 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
**    General Public License for more details.
**    
**    You should have received a copy of the GNU General Public License along
**    with this program; if not, write to the Free Software Foundation, Inc.,
**    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

if(!fw.info)
fw.info = function(){
    var out = {};
    for(var i in fw.info) out[i] = (typeof fw.info[i]);
    out['version'] = "v0.10";
    return out;
}

fw.info._count = 0;
fw.info.counter = function(pref){
    if(!pref) pref = "COUNT";
    return (pref + "_" + this._count++);
}

fw.info._browser = function(){
	var agt = navigator.userAgent.toLowerCase();
	this.version = parseFloat(navigator.appVersion);
	this.isIE = (agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1);
	this.isIE4up = this.isIE && (this.version >= 4);
	if(this.isIE){
		if(this.isIE4up){
			if(agt.indexOf("msie 6") != -1) this.version = 6;
			else if (agt.indexOf("msie 5.5") != -1) this.version = 5.5;
			else if (agt.indexOf("msie 5") != -1) this.version = 5;
		}else this.version = 3;
	}
	this.isIE5up = this.isIE && (this.version >= 5);
	this.isIE5_5up = this.isIE && (this.version >= 5.5);
	this.isIE6up = this.isIE && (this.version >= 6);
	this.isNN = (agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1) &&
		(agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1) &&
		(agt.indexOf('webtv') == -1) && (agt.indexOf('hotjava') == -1);
	this.isNN4up = this.isNN && (this.version >= 4);
	this.isNN6up = this.isNN && (this.version >= 5);
	this.isOnline = true;
	if(this.isIE4up) this.isOnline = navigator.onLine;
	this.name = "Unknown";
	if(this.isIE) this.name = "Internet Explorer";
	else if(agt.indexOf("netscape6/") != -1){
		this.name = "Netscape";
		this.version = parseFloat(agt.substr(agt.indexOf("netscape6/") + 10));
		if(!this.version) this.version = 6;
	}else if(agt.indexOf('gecko') != -1) this.name = "Mozilla";
	else if (this.isNN) this.name = "Netscape Navigator";
	else if (agt.indexOf("aol") != -1){
		this.name = "AOL Browser";
		if(this.version < 4) this.version = 3;
	} else if(agt.indexOf("opera") != -1){
		this.isOp = true;
		this.name = "Opera";
		this.version = parseFloat(agt.substr(agt.indexOf("opera") + 6));
	} else if(agt.indexOf("webtv") != -1) this.name = "WebTV";
	else if((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)) this.name = "AOL TV Navigator";
	else if (agt.indexOf("hotjava") != -1) this.name = "HotJava";
	this.fullName = this.name + ' ' + this.version;
	if(this.version == Math.floor(this.version)) this.fullName += '.0';
}

fw.info.browser = new fw.info._browser();

fw.info.closeHndl = function(hndl){
	if(fw.data.isType(hndl, fw.io._type)) return fw.io.close(hndl);
	if(fw.data.isType(hndl, fw.timer._type)) return fw.timer.close(hndl);
	if(fw.data.isType(hndl, fw.debug._type)) return fw.debug.close(hndl);
	
	return fw.data.error(2);
}

fw.info();