	function clearField(strFieldName, strString) {
		if (strFieldName.value == strString) {
			strFieldName.value = "";
		}
	}


	function fillField(strFieldName, strString) {
		if (strFieldName.value == "") {
			strFieldName.value = strString;
		}
	}

	function openWindow(sUrl, sName, iWidth, iHeight, bResizable, bScrollbars, bStatus) { 
	        var iLeft = parseInt((screen.availWidth/2)-(iWidth/2)); 
	        var iTop = parseInt((screen.availHeight/2)-(iHeight/2)); 
	        var iRandom = Math.floor(Math.random()*99); 
	        
	        var oWindow = window.open (sUrl, sName + iRandom, 'toolbar=0,location=0,menubar=0,directories=0,scrollbars='+ bScrollbars +',status='+ bStatus +',resizable='+ bResizable +',Width='+ iWidth +',Height='+ iHeight +',left='+ iLeft +',top='+ iTop +',screenX='+ iLeft +',screenY='+ iTop +'');
	
	        oWindow.focus(); 
	} 

	function openStaticWindow(o_url, o_name, o_width, o_height) {
		var o_left = (screen.availWidth/2)-(o_width/2);
		var o_top = (screen.availHeight/2)-(o_height/2);
		window.open (o_url, o_name, 'toolbar=0,location=0,menubar=0,directories=0,scrollbars=0,status=0,resizable=0,Width='+ o_width +',Height='+ o_height +',left='+ o_left +',top='+ o_top +',screenX='+ o_left +',screenY='+ o_top +'');
	}


	// automatically create the "is" object
	var is = new BrowserCheck ();


	// BrowserCheck Object // 19990326
	// provides most commonly needed browser checking variables
	function BrowserCheck() 
	{
		var b = navigator.appName
		if (b == "Netscape")
			this.b = "ns";
		else if (b == "Microsoft Internet Explorer")
			this.b = "ie";
		else
			this.b = b;
		this.v = parseInt (navigator.appVersion);
		
		this.ns = (this.b=="ns" && this.v>=4);
		this.ns4 = (this.b=="ns" && this.v==4);
		this.ns5 = (this.b=="ns" && this.v==5);
		this.ie = (this.b=="ie" && this.v>=4);
		this.ie4 = (navigator.userAgent.indexOf ('MSIE 4') > 0);
		this.ie5 = (navigator.userAgent.indexOf ('MSIE 5') > 0);
		this.pc = (navigator.platform.indexOf ("Win")!=-1) ? true : false;
		this.mac = (navigator.platform.indexOf ("Mac")!=-1) ? true : false;
		
		if (this.ie) 
			this.ver = parseFloat (navigator.userAgent.substring (navigator.userAgent.indexOf ("MSIE") + 5, navigator.userAgent.indexOf ("MSIE") + 8));
		else
			this.ver = parseFloat(navigator.appVersion);
		
		if (this.ie5)
			this.v = 5;
		this.min = (this.ns  ||  this.ie);
	}


	// Creates the object
	// Add: formname = new FormHandler ("formName","layerName")
	function FormHandler (formName, layername) 
	{
		this.obj = eval("document." + formName);
		
		this.fieldname = new Array ();
		this.errormessage = new Array ()
		this.fieldtype = new Array ();
		this.minlength = new Array ();
		
		this.add = FormHandlerAdd;
		this.check = FormHandlerCheck;
		this.error = FormHandlerError;
		
		this.TEXT     = "text";
		this.NUMBER   = "number";
		this.EMAIL    = "email";
		this.CHECKBOX = "checkbox";
		this.SELECT   = "select";
		this.PASSWORD = "password";
	}


	// Add a field
	// Add: formname.add("fieldname","error message", minlength, fieldtype)
	function FormHandlerAdd (fieldname, errormessage, minlength, fieldtype) 
	{
		current = this.fieldname.length;
		this.fieldname[current] = fieldname;
		this.errormessage[current] = errormessage;
		
		if (typeof (fieldtype) != 'undefined')
			this.fieldtype[current] = fieldtype;
		else
			this.fieldtype[current] = FormHandler.TEXT;
		
		if (typeof (minlength) != 'undefined') 
			this.minlength[current] = minlength;
		else 
			this.minlength[current] = 0;
	}


	// Check all fields
	// Add: onsubmit="return objectName.check()" in the form-element
	function FormHandlerCheck() 
	{
		for (var i = 0; i < this.fieldname.length; ++i) 
		{
			currentField = eval ("this.obj." + this.fieldname[i]);
			
			if (currentField.value != null)
				currentFieldLC = currentField.value.toLowerCase ();
				
			if (this.fieldtype[i] == this.TEXT)
			{
				if (currentField.value.length < this.minlength[i])
					return this.error (i);
			}
			else if (this.fieldtype[i] == this.NUMBER)
			{
				if (currentField.value.length < this.minlength[i])
					return this.error (i);
				if (currentField.value.match (/[\d\,\.\-]+/) != currentField.value)
					return this.error (i);
			}
			else if (this.fieldtype[i] == this.EMAIL)
			{
				if (currentField.value.length < this.minlength[i])
					return this.error (i)
				if (currentFieldLC != currentFieldLC.match (/^.+\@[A-Za-z0-9][A-Za-z0-9\-]+\..+[A-Za-z]$/))
					return this.error (i);
			}
			else if (this.fieldtype[i] == this.CHECKBOX)
			{
				if (!currentField.checked)
					return this.error(i);
			}
			else if (this.fieldtype[i] == this.SELECT)
			{
				if (currentField.options[currentField.selectedIndex].value == -1)
					return this.error (i);
			}
			else if (this.fieldtype[i] == this.PASSWORD)
			{
				passwordField = eval ("this.obj." + this.fieldname[i] + "2");
				
				if (currentField.value.length < this.minlength[i]
					||  currentField.value != passwordField.value)
				{
					return this.error (i);
				}
			}
			
		}
		return true
	}

	// Create alertbox on error
	function FormHandlerError(id) 
	{
		alert (this.errormessage[id]);
		currentField = eval("this.obj." + this.fieldname[id]);
		currentField.focus ();
		return false;
	}

	function urlMenu(that) {
		theURL = that.options[that.selectedIndex].value; 
	
		if (theURL) {
			window.location = theURL;
		}
	}

	function toggleDiv(divid) {
		targetDiv = document.getElementById(divid);
		if (targetDiv.style.display != "block") {
			targetDiv.style.display = "block";
		} else {
			targetDiv.style.display = "none";
		}
	}
	function replaceAll( str, from, to ) {
	    var idx = str.indexOf( from );
		
	    while ( idx > -1 ) {
	        str = str.replace( from, to ); 
	        idx = str.indexOf( from );
	    }
		
	    return str;
	}
	function fUnEscape(sVar){
		return unescape(replaceAll(sVar, '+', ' '));
	}
	function addNote(iID, sItem, sNext, sOldNote) {
		var sNote = prompt('Add note for: '+ sItem, fUnEscape(sOldNote));
		if (sNote) {
			document.location = 'addNote_resp.asp?function=addNote&id='+ iID +'&note='+ escape(sNote) +'&next='+ sNext;
		}
	}
	function addNoteOBS(iID, sItem, sNext, sOldNote) {
		var sNote = prompt('Remember to update first!\n Add note for '+ sItem, '');
		if (sNote) {
			document.location = 'addNote_resp.asp?function=addNote&id='+ iID +'&note='+ escape(sNote) +'&next='+ sNext;
		}
	}
	function updatePic(eID,s){
		var el = document.getElementById(eID);
		el.src = '/images/upload/'+ s;
	}
	function confBig(el){
		var s = el.value;
		if(s > 9){
			alert('Are you sure you wanted to add '+ s +'?');
		}
	}
	function gE(e){
		return document.getElementById(e);
	}
	function fConfirm(s,u){
		if(confirm(s)){
			document.location = u;
		}
	}
	
