var browser = {
	userAgent:navigator.userAgent,
	os:"",
	longOS:"",
	win:false,
	mac:false,
	linux:false,
	name:"",
	version:"",
	getOS:function() {
		var er = /\(.*\)/;
        var toSplit = er.exec(this.userAgent);
        toSplit = toSplit.toString().replace(/\(|\)/g ,"");
        var infos = toSplit.split(";");
        this.longOS = infos[2];
        if(this.userAgent.indexOf("Windows") > 0) {
        	this.win = true;
        	this.os = "Windows";
		}
        if(this.userAgent.indexOf("Mac OS X") > 0) {
        	this.mac = true;
        	this.os = "Mac OS X";
		}
        if(this.userAgent.indexOf("Linux") > 0) {
        	this.linux = true;
        	this.os = "Linux";
		}
    },
    getName:function() {
    	var indexOf;
        if(this.userAgent.indexOf("Firefox") >= 0 ) {
        	indexOf = this.userAgent.indexOf("Firefox");
            var tmpStr = this.userAgent.substring(indexOf);
            tmpStr = tmpStr.split("/");
            this.name = tmpStr[0];
            this.version = tmpStr[1];
        }
        if(this.userAgent.indexOf("MSIE") >= 0 ) {
        	indexOf = this.userAgent.indexOf("MSIE");
            var tmpStr = this.userAgent.substring(indexOf);
            var indexOf2 = tmpStr.indexOf(";");
            tmpStr = tmpStr.substring(0,indexOf2);
            tmpStr = tmpStr.split(" ");
            this.name = "IE";
            this.version = tmpStr[1];
        }
        if(this.userAgent.indexOf("Opera") >= 0 ) {
        	indexOf = this.userAgent.indexOf("Opera");
            var tmpStr = this.userAgent.substring(indexOf);
            var indexOf2 = tmpStr.indexOf(" ");
            tmpStr = tmpStr.substring(0,indexOf2);
            tmpStr = tmpStr.split("/");
            this.name = tmpStr[0];
            this.version = tmpStr[1];
        }
    },
    start:function() {
    	this.getOS();
    	this.getName();
	}
}

/*
Algumas Strings Testadas:

Mozilla/5.0 (Windows	; U		; Windows NT 5.2; en-US	; rv:1.8.1.6		) Gecko/20070725 Firefox/2.0.0.6
Mozilla/5.0 (Macintosh	; U		; Intel Mac OS X; en-US	; rv:1.8.1.6		) Gecko/20070725 Firefox/2.0.0.6
Mozilla/4.0 (compatible	; MSIE 6.0	; Windows NT 5.2; SV1	; .NET CLR 1.1.4322	)
Opera/9.20 (Windows NT 5.2; U; en)

*/

browser.start();

