// Sample usage:


var browser = new BrowserInfo();
//alert(browser.nameCode + " *** " + browser.platform + " *** " +  "***" + browser.version + "***" + browser.screenWidth  + "*** " + browser.screenHeight + "***" + browser.windowWidth  + "*** " + browser.windowHeight );


function BrowserInfo(){

	// Full browser info (unparsed)
	this.agent = navigator.userAgent.toLowerCase();
	
	 // browser name (Possibilities: ie, op, ff, ns, nn, sf)
  	if ( (document.all) && (document.getElementById) ){ // IE (4+), Opera (7+)
		this.nameCode = (this.agent.lastIndexOf("opera") != -1) ? "op" : "ie"; 
	}else if( (!document.all) && (document.getElementById) ){ // FireFox (1+),  Netscape (6+), Safari 1.2+
		if(this.agent.lastIndexOf("firefox") != -1){
			this.nameCode = "ff";
		}else if (this.agent.lastIndexOf("safari")!=-1){  // Safari (1.2+)
			this.nameCode = "sf" 
		}else{
			this.nameCode = "ns";
		}
	}else if (document.layers){ // Netscape Navigator 4
    	this.nameCode = "nn";
	}else{
		this.nameCode = "unknown";
	}
	
	
	// browser app version (if (ie4+ or op7+), then will return >= 4.0, if (ff1+ or ns6+), then will return >=5.0)
    this.version = navigator.appVersion.substring(0,4);
	
	// get platform name
    if ( (this.agent.indexOf("win")!=-1) || (this.agent.indexOf("32bit")!=-1) ){
     this.platform = "win";
    }else if( (navigator.appVersion.indexOf("Mac")!=-1) || (this.agent.indexOf("mac")!=-1) ){
     this.platform = "mac";
    }else{ 
 	 this.platform = "other";
    }
	
	// others
	this.codename = navigator.appCodeName;
    this.javaEnabled = navigator.javaEnabled();
    this.screenWidth = screen.width;
    this.screenHeight = screen.height;
	//this.windowWidth = (this.nameCode=="ie") ? document.documentElement.clientWidth : window.innerWidth;
	//this.windowHeight = (this.nameCode=="ie")? document.documentElement.clientHeight : window.innerHeight;
	this.windowWidth = document.documentElement.clientWidth;
	this.windowHeight = document.documentElement.clientHeight;
}; // BrowserInfo
