/*	DETECT.JS
	Responsaveis: Anderson Cesconeto (4902) / Luciano Ribas (4901)
	Ultima Atualizacao: 20/03/2000
*/
function push(item)
{
	this[this.length] = item;
	return this.length;
}
Array.prototype.push = push;
function split(separador)
{
	var retorno= new Array;
	var temp= new String("");
	if( this.length == 0) return null;
	for( var i=0; i < this.length; i++) {
		var ch= this.substring(i,i+1);
		if( ch == separador) {
			retorno.push(temp);
			temp= "";
		}else{
			temp+= ch;
		}
	}
	retorno.push(temp);
	return retorno;
}
String.prototype.split = split;
function trim(){
	var retVal = "";
	var start = 0;
	while ((start < this.length) && (this.charAt(start) == ' ')) {
	++start;
	}
	var end = this.length;
	while ((end > 0) && (this.charAt(end - 1) == ' ')) {
	--end;
	}
	retVal = this.substring(start, end);
	return retVal;
}
String.prototype.trim = trim;
function Browser() {
	var ua=navigator.userAgent;
	this.name = "Unknown";
	this.platform = "Unknown";
	this.version = "";
	this.majorver = "";
	this.minorver = "";
	uaLen = ua.length;
	var preparens = new String("");
	var parenthesized = new String("");
	i = ua.indexOf("(");
	if (i >= 0)
	{
		preparens = ua.substring(0,i).trim();
		parenthesized = ua.substring(i+1, uaLen);
		j = parenthesized.indexOf(")");
		if (j >= 0)
			parenthesized = parenthesized.substring(0, j);
	}else
		preparens = ua;
	var browVer = preparens;
	var s= new String(parenthesized);
	var tokens= new Array;
	tokens= s.split(";");
	var token = "";
	for (var i=0; i < tokens.length; i++) {
		token = tokens[i].trim();
	  	if (token == "compatible"){
		}
		else if (token.indexOf("MSIE") >= 0) {
			browVer = token;
		}else if (token.indexOf("Opera") >= 0) {
			browVer = token;
		}
		//plataforma: testamos para X11, SunOS, Win, Mac, PPC
		else if ((token.indexOf("X11") >= 0) || (token.indexOf("SunOS") >= 0) || (token.indexOf("Linux") >= 0)) {
			this.platform = "Unix";
		}else if (token.indexOf("Win") >= 0) {
			this.platform = token;
		}else if ((token.indexOf("Mac") >= 0) || (token.indexOf("PPC") >= 0)) {
			this.platform = token;
		}
	}
	var msieIndex = browVer.indexOf("MSIE");
	if (msieIndex >= 0) {
		browVer = browVer.substring(msieIndex, browVer.length);
	}
	var leftover = "";
	if (browVer.substring(0, "Mozilla".length) == "Mozilla") {
		this.name = "Netscape";
		leftover = browVer.substring("Mozilla".length+1, browVer.length);
	}
	else if (browVer.substring(0, "Lynx".length) == "Lynx") {
		this.name = "Lynx";
		leftover = browVer.substring("Lynx".length+1, browVer.length);
	}
	else if (browVer.substring(0, "MSIE".length) == "MSIE") {
		this.name = "IE";
		leftover = browVer.substring("MSIE".length+1, browVer.length);
	}
	else if (browVer.substring(0, "Microsoft Internet Explorer".length) == "Microsoft Internet Explorer") {
		this.name = "IE"
		leftover = browVer.substring("Microsoft Internet Explorer".length+1,
		browVer.length);
	}
	else if (browVer.substring(0, "Opera".length) == "Opera") {
		this.name = "Opera"
		leftover = browVer.substring("Opera".length+1, browVer.length);
	}
	leftover = leftover.trim();
	//tentamos pegar a versao fora do leftover
	i = leftover.indexOf(" ");
	if (i >= 0)
		this.version = leftover.substring(0, i);
	else
		this.version = leftover;
	j = this.version.indexOf(".");
	if (j >= 0) {
		this.majorver = this.version.substring(0,j);
		this.minorver = this.version.substring(j+1, this.version.length);
	}else {
		this.majorver = this.version;
	}
}//Fim de Browser
