function Browser() {
	
	// Variables con scope local
	this.place = 0;
	this.thestring = '';
	this.Name = '';
	this.Version = '';
	this.OS = '';
	this.UpdateURL = '';
	// URL por defecto adonde dirigirse si no permite popups.
	this.NoPopUpURL = '';
	
	// Heredadas de QObject
	this.classname = 'Browser';
	this.classversion = [0,9,1];

	this.DHTML = function() {
		if (document.getElementById || document.all || document.layers) {
			return true;
		} else {
			return false;
		}
	};
	
	this.DOM = function() {
		if (document.getElementById && document.createElement) {
			return true;
		} else {
			return false;
		}
	};
	
	this.BasicDOM = function () {
		if (document.getElementById) {
			return true;
		} else {
			return false;
		}
	};
	
	this.Cookies = function () {
		var tmpcookie = new Date();
		var chkcookie = (tmpcookie.getTime() + '');
		document.cookie = "chkcookie=" + chkcookie + "; path=/";
		if (document.cookie.indexOf(chkcookie,0) < 0) {
			return false;
		} else {
		  	return true;
		}
	};
	
	this.Java = function () {
		if (navigator.javaEnabled() || navigator.javaEnabled) {
			return true;
		}
	};

	this.cUserAgent = navigator.userAgent.toLowerCase();
	
	/**
	 * Carga la clase con los datos del navegador
	 */
	this.Fill = function() {

		if (this.Check('konqueror')) {
			this.Name = "Konqueror";
			this.OS = "Linux";
		} else if (this.Check('safari')) { 
			this.Name = "Safari";
			this.UpdateURL = "http://www.safari.com";
		} else if (this.Check('omniweb')) {
			this.Name = "OmniWeb";
			this.UpdateURL = "http://www.omniweb.com";
		} else if (this.Check('opera')) {
			this.Name = "Opera";
			this.UpdateURL = "http://www.opera.com";
		} else if (this.Check('webtv')) {
			this.Name = "WebTV";
			this.UpdateURL = "http://www.webtv.com";
		} else if (this.Check('icab')) { 
			this.Name = "iCab";
			this.UpdateURL = "http://www.icab.com";
		} else if (this.Check('msie')) {
			this.Name = "Internet Explorer"
			this.UpdateURL = "http://download.microsoft.com";
		} else if (this.Check('firefox')) {
			this.Name = "Mozilla Firefox"
			this.UpdateURL = "http://www.getfirefox.com";
			this.Version = this.cUserAgent.substr(this.place + this.thestring.length);			
		} else if (!this.Check('compatible')) {
			this.Name = "Netscape Navigator"
			this.Version = this.cUserAgent.charAt(8);
			this.UpdateURL = "http://www.netscape.com";
		}	
		else this.Name = "Desconocido";
		
		if (!this.Version) this.Version = this.cUserAgent.charAt(this.place + this.thestring.length);
		
		if (!this.OS)
		{
			if (this.Check('linux')) this.OS = "Linux";
			else if (this.Check('x11')) this.OS = "Unix";
			else if (this.Check('mac')) this.OS = "Mac"
			else if (this.Check('win')) this.OS = "Windows"
			else this.OS = "Desconocido";
		}
		
	};
	
	/**
	 * Busca la posici?n de una cadena en el userAgent.
	 */
	this.Check = function(string) {
		this.place = this.cUserAgent.indexOf(string) + 1;
		this.thestring = string;
		return this.place;	
	},
	
	/**
	 * Abre una ventana con la informaci?n del navegador
	 * Si no puede, hace un alert.
	 */
	this.About = function() {
		var wAbout = window.open('', 'wAbout', 'directories=no, scrollbars=no, width=350, height=200, top=200, left=200');
		if (wAbout) {
			var cDoc = '<html><head><title>Su navegador</title>';
			cDoc += '<style type="text/css">BODY { font-size: 12px; font-family: Tahoma, sans-serif;</style></head>';
			cDoc += '<body>';
			cDoc += '<b>Caracter&iacute;sticas de su navegador</b><br /><br />';
			cDoc += 'Sistema Operativo: <b>'+this.OS+'</b><br />';	
			cDoc += 'Navegador: <b>'+this.Name+'</b><br />';
			cDoc += 'Versi&oacute;n: <b>'+this.Version+'</b><br />';
			cDoc += 'Soporta DHTML: <b>'+(this.DHTML() ? '<font color="green">S&iacute;</font>' : '<font color="red">No</font>')+'</b><br />';
			cDoc += 'Soporta W3C DOM: <b>'+(this.DOM() ? '<font color="green">S&iacute;</font>' : '<font color="red">No</font>')+'</b><br />';
			if (!this.DOM()) {
				cDoc += 'Soporta W3C DOM B&aacute;sico: <b>'+(this.BasicDOM() ? '<font color="green">Habilitado</font>' : '<font color="red">Deshabilitado</font>')+'</b><br />';
			}
			cDoc += 'Permite Cookies: <b>'+(this.Cookies() ? '<font color="green">S&iacute;</font>' : '<font color="red">No</font>')+'</b><br />';
			cDoc += 'Permite Java: <b>'+(this.Java() ? '<font color="green">S&iacute;</font>' : '<font color="red">No</font>')+'</b><br />';
			cDoc += 'Ventanas emergentes (PopUps): <font color="green"><b>Permitidas</b></font><br />';
			if (!(this.DOM() && this.DHTML())) {
			cDoc += 'Se recomienda que actualice su navegador. <br />Haga click aqu? para saber porqu?.';				
			}
			cDoc += '<br /><em>'+this.GetVersion()+'</em>';
			cDoc += '</body></html>';
			wAbout.document.write(cDoc);	
		} else {
			var cAlert = 'Caracteristicas de su navegador\r\n\r\n';
			cAlert += 'Sistema Operativo: '+this.OS+'\r\n';	
			cAlert += 'Navegador: '+this.Name+'\r\n';
			cAlert += 'Version: '+this.Version+'\r\n';
			cAlert += 'Soporta DHTML: '+(this.DHTML() ? 'Si' : 'No')+'\r\n';
			cAlert += 'Soporta W3C DOM: '+(this.DOM() ? 'Si' : 'No')+'\r\n';
			if (!this.DOM()) {
				cAlert += 'Soporta W3C DOM Basico: '+(this.BasicDOM() ? 'Si' : 'No')+'\r\n';
			}
			cAlert += 'Permite Cookies: '+(this.Cookies() ? 'Si' : 'No')+'\r\n';
			cAlert += 'Permite Java: '+(this.Java() ? 'Si' : 'No')+'\r\n';
			cAlert += 'Ventanas emergentes (PopUps): No permitidas';
			alert(cAlert);
		}
	}
}

Extend(Browser, QObject);
var oBrowser = new Browser;
oBrowser.Fill();
