/***********************************************************
**	Object: 	Browser
**	Purpose:	To allow the programmer to access information about
**				the browser, computer, operating system that the user is using
**
**	Created:	?	?
**	Revised:	Matt Finholt - 7/17/01
**
**
**
************************************************************/


function browserObj()
	{
	//init all descriptive variables 
	this.name = "";
	this.isNav = false;
	this.isNS6 = false;
	this.isIE = false;
	this.isOpera = false;
	this.isJava = false;
	this.isCookie = false;
	this.isWin = false;
	this.isMac = false;
	//this.isFlash = false;
	//this.isRealPlayer = false;
	this.version = 0;
	this.width = 0;
	this.height = 0;
	//this.platform = null;
	
	
	// convert all characters to lowercase
    var agt = navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();
	//get version info
	this.version = parseFloat(appVer);
	this.name = navigator.appName;
	
	//check if Internet Explorer
	this.isIE = appVer.indexOf('msie');
	if (this.isIE !=-1) 
		{	
		this.version = parseFloat(appVer.substring(this.isIE+5,appVer.indexOf(';',this.isIE)));	
		this.isIE = true;
		}
	else	{	this.isIE = false;	}
		
	//check if Netscape 6
	this.isNS6 = agt.indexOf('netscape6');
    if (this.isNS6 !=-1) 
		{	
		this.version = parseFloat(agt.substring(this.isNS6+10));
		this.isNS6 = true;
		}
	else	{	this.isNS6 = false;	}
		//is_major = parseInt(is_minor)
		
	//check if browser is a navigator or opera
	this.isNav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
				    && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1));					
	this.isOpera = (agt.indexOf("opera") != -1);
	
	//check for java capability
	this.isJava = (navigator.javaEnabled());
	
	//check for cookies - init to "true" cuz IE nedds it to be
	document.cookie = "cookies=true";
	this.isCookie = (document.cookie) ? "true" : "false";
	
	//check for OS
	this.isWin = ((agt.indexOf("win")!=-1)||(agt.indexOf("16bit")!=-1));
	this.isMac  = (agt.indexOf("mac")!=-1);
	
	//get screen resolution
	this.height = screen.height;
	this.width = screen.width;	
	
	
	this.meetsReq = function(params)
		{
		var returnString = "";
		var parameters = new Array;
		
		parameters = params.split(";");
		
		for (i=0; i<parameters.length; i++)
			{
			var tempArray = null;				 //reset the temporary string
			tempArray = parameters[i].split(":"); //parse out string
			
			//execute if there is a number to be parsed...
			if((tempArray[0] == "version") || (tempArray[0] == "width") || (tempArray[0] == "height"))
				{
				if((tempArray[1].indexOf('=')!=-1) || (tempArray[1].indexOf('<')!=-1) || (tempArray[1].indexOf('>')!=-1))
					{
					var op = tempArray[1].substring(0,1);
					tempArray[1] = tempArray[1].slice(1, tempArray[1].length);
					tempArray[1] = parseFloat(tempArray[1]);
					switch(op)
						{
						case '=':
							if(eval("this." + tempArray[0]) != tempArray[1])
								{	returnString += ";" + tempArray[0] + ":false";	}
							break;
						case '<':
							if(eval("this." + tempArray[0]) > tempArray[1])
								{	returnString += ";" + tempArray[0] + ":false";	}
							break;
						case '>':
							if(eval("this." + tempArray[0]) < tempArray[1])
								{	returnString += ";" + tempArray[0] + ":false";	}
							break;
						}//end switch				
					}//end if
				else
					{
					alert("If you are comparing numbers, you must add either a '=', '<', or an '>' operator to the left of the number.\n\n ex: '..version:>5;..'");
					}
				}//end if
				
			//if the value doesnt have to be parsed do this
			else	
				{
				if((eval("this." + tempArray[0]) != eval(tempArray[1]))) //check for equality
						{	
						returnString += "; " + tempArray[0] + ":false";	
						}					
				}//end else				
			}//end for loop
			
		//cut off first comma if there are any
		if(returnString != "")
			{
			returnString = returnString.slice(1, returnString.length);
			}//end if 
		
		return returnString;
		}//end function
	}//end object
	
	//create standard browser object...
TheBrowser = new browserObj();


