//
// Javascript functions to identify OS, Browser Type and Version
//
// dependencies: dreamFuncs.js
//
//  
browserNames = new Array("Safari", "Opera", "MSIE", "Mozilla");

osNames = new Array("Win", "Linux", "FreeBSD", "Macintosh", "PPC", "AIX", "IRIX", "SunOS",
              "OSF1", "OpenBSD", "Mac_Power", "Solaris", "OS/2", "HP-UX", "NetBSD",
              "BSD/OS");
osCategoryNames = new Array("Win", "Linux", "BSD", "Mac", "Unix", "Unix", "Unix", "Unix",
              "Unix", "Unix", "Mac", "Unix", "OS/2", "Unix", "Unix",
              "Unix");

function getBrowserInfo() { 
	// identify OS
	this.userAgent=navigator.userAgent; 

	this.os = "unknown";
	this.osCategory = "unknown";
	for(index = 0; index < osNames.length; index++) {
		if(this.userAgent.indexOf(osNames[index])>-1) { 
			this.os=osNames[index]; 
			this.osCategory=osCategoryNames[index]; 
			break;
		}
	}
	this.platform = navigator.platform ? navigator.platform : "unknown"; 
	this.cpuClass = navigator.cpuClass ? navigator.cpuClass : "unknown"; 
	
	this.hasDOM=document.getElementById?1:0; 

	this.appName=navigator.appName; 
	this.appVersion=navigator.appVersion; 
	this.appMinorVersion=navigator.appMinorVersion; 

	this.browserName="unknown"; 
	this.browserVersion=-1;
	this.browserLanguage = navigator.language ? navigator.language : navigator.browserLanguage; 
	 
	for(index = 0; index < browserNames.length; index++) {
		if(this.userAgent.indexOf(browserNames[index])>-1) { 
			this.browserName=browserNames[index]; 
			break;
		}
	}
	
	versionIndex = this.userAgent.indexOf(this.browserName); 
	this.browserVersion=parseInt(this.userAgent.indexOf(this.browserName, 
								 versionIndex+this.browserName.length+1)); 

	this.isBrowser=(this.browserName == "Opera" || 	this.browserName == "MSIE" || this.browserName == "Mozilla"); 

	this.cookiesEnabled = (navigator.cookiesEnabled == true ? 1 : 0); 
	if (this.cookiesEnabled == 0){
		document.cookie="cookiesEnabled=null*; path=/; expires=Wed, 1 Jan 2020 00:00:00 GMT";
		this.cookiesEnabled=(document.cookie.indexOf("cookiesEnabled=")!=-1)?1:0;
	};

	return this; 
} 

function getDocumentInfo() 
{ 
	this.documentTitle = (self.document.title.substr(0,16) != self.location.href.substr(0,16) ? self.document.title : "untitled"); 
	this.documentURL = self.location.href; 
	this.documentCookie = document.cookie; 
	this.lastModified = document.lastModified; 

	this.httpReferrer = document.referrer;
	if((this.httpReferrer=="undefined")||(this.httpReferrer=="")) {
	    this.httpReferrer="bookmark";
	}
	this.httpReferrer = this.httpReferrer; 

	this.date = new Date(); 
	this.timezone = date.getTimezoneOffset() * -1 / 60; 
	
	return this; 
} 
