	function clearField(strFieldName, strString) {
		if (strFieldName.value == strString) {
			strFieldName.value = "";
		}
	}


	function fillField(strFieldName, strString) {
		if (strFieldName.value == "") {
			strFieldName.value = strString;
		}
	}


	function openWindow(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=1,status=1,resizable=1,Width='+ o_width +',Height='+ o_height +',left='+ o_left +',top='+ o_top +',screenX='+ o_left +',screenY='+ o_top +'');
	}


	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
	is = new BrowserCheck ();

	function BrowserCheck() 
	{
		this.win=(navigator.platform=="Win32")?1:0;
		this.mac=(navigator.platform=="MacPPC")?1:0;
		this.ver=navigator.appVersion;
		this.ua=navigator.userAgent;
		this.dom=document.getElementById?1:0;
		this.ie5=(this.ver.indexOf("MSIE 5")!=-1 && this.dom)?1:0;
		this.ie6=(this.ver.indexOf("MSIE 6")!=-1 && this.dom)?1:0;
		this.ie4=(document.all && !this.dom)?1:0;
		this.ie=(this.ie5 || this.ie4 || this.ie6);
		this.ns7=(this.ua.indexOf('Netscape/7')!=-1)?1:0;
		this.ns6=(this.dom && parseInt(this.ver)>=5)?1:0;
		this.ns4=(document.layers && !this.dom)?1:0;
		this.ns=(this.ns4 || this.ns6 || this.ns7);
		this.op=(this.ua.indexOf('Opera')!=-1)?1:0;
		this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.ns7);
		this.bx=(this.ie5 || this.ns6 || this.ie6 || this.ns7);
	}


	// 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 (/[\w-\.]+@([\w\-_]+\.)*[a-z]{2}[a-z]?[a-z]?/gi))
					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;
	}


