function browserType() {
	this.isIE = document.all ? true : false;
	this.isIE4 = (document.all && !document.getElementById) ? true : false;
	this.isIE5 = (document.all && document.getElementById) ? true : false;

	this.isDOM = document.getElementById ? true : false;

	this.isNN4 = document.layers ? true : false;
	this.isNN6 = (document.getElementById && !document.all) ? true : false;
	this.isNN7 = (navigator.userAgent.indexOf("rv:1")) && (navigator.userAgent.indexOf("Netscape/7")) ? true : false;
	this.isNN = this.isNN4 || this.isNN6
	
	this.isMac = (navigator.appVersion.indexOf("Mac") != -1);

	this.scrollTop = getScrollTop;
	this.scrollLeft = getScrollLeft;

	this.objectExists = objectExists;
	this.setProp = setProp;
	this.closeWindow = closeWindow;
	
	this.getRealTop = getRealTop;
	this.getRealLeft = getRealLeft;
	
	this.getWindowTop = getWindowTop;
	this.getWindowLeft = getWindowLeft;

	this.htmlEncode = htmlEncode;
	this.jsEscape = jsEscape;
		
	this.URLEnc = URLEnc;
	
	//* definitions
	this.GetWidth = function() {
	  var myWidth = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
		} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
		}
		return myWidth;
	}
	this.GetHeight = function() {
		var myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myHeight = document.body.clientHeight;
		}
		return myHeight;
	}

	function getScrollTop() {
		return this.isIE ? document.body.scrollTop : window.pageYOffset;
	}
	function getScrollLeft() {
		return this.isIE ? document.body.scrollLeft : window.pageXOffset;
	}

	function objectExists(divID) {
		if (this.isDOM) {
			return document.getElementById(divID) ? true : false;
		} else if (this.isIE4) {
			return document.all[divID] ? true : false;
		} else if (this.isNN4) {
			return document.layers[divID] ? true : false;
		}
	}
	
	//bNoShowAlert -- no alert on referencing to wrong item
	function setProp(divID, propStr, valueStr, bNoShowAlert) {
		var objRef;
		if (typeof(divID) == "object") {
			objRef = divID
		} else {
			if (this.isDOM) {
				objRef = document.getElementById(divID);
			} else if (this.isIE4) {
				objRef = document.all[divID];
			} else if (this.isNN4) {
				objRef = document.layers[divID];
			}
		}
		
		if (!objRef) {
			if (bNoShowAlert!=1){
				alert(strNoSetProp + divID);
			}
			return;
		}
		
		switch (propStr.toLowerCase()) {
			case "innerhtml":
				if (this.isNN4) {
					objRef.document.open();
					objRef.document.write(valueStr);
					objRef.document.close();
				} else {
					objRef.innerHTML = valueStr;
				}
				break;
			case "left":
			case "top":
			case "visibility":
				if (!this.isNN4) propStr = "style." + propStr;
				eval("objRef." + propStr + " = '" + valueStr + "'");
				break;
			default:
				eval("objRef." + propStr + " = '" + valueStr + "'");
		}
	}	

	function closeWindow(winRef) {
		winRef.close();
	}

	function getRealTop(el) {
		if (this.isIE) {
	    var yPos = el.offsetTop;
	    var tempEl = el.offsetParent;
	    while (tempEl != null) {
	        yPos += tempEl.offsetTop;
	        tempEl = tempEl.offsetParent;
	    }
	    return yPos;
		} else {
			return el.y;
		}
	}

	function getRealLeft(el) {
		if (this.isIE) {
	    var xPos = el.offsetLeft;
	    var tempEl = el.offsetParent;
	    while (tempEl != null) {
	        xPos += tempEl.offsetLeft;
	        tempEl = tempEl.offsetParent;
	    }
	    return xPos;
		} else {
			return el.x
		}
	}

	function getWindowTop() {
		if (this.isIE) {
			return top.window.screenTop;
		} else {
			return top.window.screenY;
		}
	}
	function getWindowLeft() {
		if (this.isIE) {
			return top.window.screenLeft;
		} else {
			return top.window.screenX;
		}
	}	
	
	function htmlEncode(arg) {
		var myArg = "";
		myArg = arg.replace("&", "&amp;");
		
		return myArg;
	}

	this.rndEndURL = function (strURL) {
		if (strURL.indexOf("?") != -1) {
			return strURL + "&NoC=" + Math.random();
		} else {
			return strURL + "?NoC=" + Math.random();
		}
	}
	//* this should be used when building strings such as:
	//*			htmlStr += "<span onclick=\"vlsiObj.removeUserAnswer('" + _b.jsEscape(buffer) + "');\" class='vlsiWordHighlight'>" + buffer + "</span>";
	function jsEscape(arg) {
		//* this has to be the FIRST ONE
		arg = arg.replace(/\\/g, "\\\\");
		arg = arg.replace(/'/g, "\\'");
		arg = arg.replace(/`/g, "\\`");
		arg = arg.replace(/"/g, "\\\"");
		return arg;
	}
	
	function URLEnc(str) {
		var returnStr = "";
		if (typeof(encodeURIComponent ) == "undefined") {
			returnStr = Utf8UrlEncode(str);
//			alert("Utf8UrlEncode: " + str + " : " + returnStr)
		} else {
			returnStr = encodeURIComponent (str);
//			alert("encodeURI: " + str + " : " + returnStr)
		}	
		return returnStr;
	}

	function Utf8UrlEncode(originaltext) {
		var SAFECHARS = "0123456789" +					// Numeric
						"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetci
						"abcdefghijklmnopqrstuvwxyz" +
						"-_.!~*'()";					// RFC2396 Mark characters
		var HEX = "0123456789ABCDEF";
	
		var encoded = "";
		for (var i = 0; i < originaltext.length; i++ ) {
			var ch = originaltext.charAt(i);
		    if (ch == " ") {
			    encoded += "+";	// x-www-urlencoded, rather than %20
			} else if (SAFECHARS.indexOf(ch) != -1) {
			    encoded += ch;
			} else {
			    var charCode = ch.charCodeAt(0);
				if (charCode > 127) {
	
					// all chars in range 127 to 2047 => 2byte
					if((charCode > 127) && ( charCode < 2048)) {
						encoded += '%' + ((charCode >> 6)|192).toString(16);
						encoded += '%' + ((charCode & 63)|128).toString(16);
					}
					// all chars in range 2048 to 66536 => 3byte
					else {
						encoded += '%' + ((charCode >> 12)|224).toString(16);
						encoded += '%' + (((charCode >> 6)&63)|128).toString(16);
						encoded += '%' + ((charCode & 63)|128).toString(16);
					}
	
				} else {
					encoded += "%";
					encoded += HEX.charAt((charCode >> 4) & 0xF);
					encoded += HEX.charAt(charCode & 0xF);
				}
			}
		} // for
		
		return encoded;
	}	
	
	return this;
}

var _b = new browserType();

if (! _b.isIE) {
  HTMLElement.prototype.__defineGetter__("innerText", 
              function () { return(this.textContent); });
  HTMLElement.prototype.__defineSetter__("innerText", 
              function (txt) { this.textContent = txt; });
}
//************************************
//* SOME COMMON FUNCTIONS
//************************************

//* 1st param should be something like this: "Size of %1 cannot be greather than %2 characters"
//* the rest of parameters is what will be substitued
//* Example: getContentParam("Size of %1 cannot be greather than %2 characters", "Customer Name", 50)
//* will return "Size of Customer Name cannot be greather than 50 characters"
function getContentParam() {
	if (arguments.length < 1) {
		alert("Nothing is passed in!");
		return null;
	}

	var returnStr = arguments[0];
	if (arguments.length < 2) {
		return returnStr;
	}
	
	//* I start with 1 b/c the [0] is the string we need to replace in
	for (var i = 1; i < arguments.length; i++) {
		returnStr = returnStr.replace("%" + i, arguments[i]);
	}

	return returnStr;
}



