<!--

	
function keyup(evt, str)
{
	if (!isIE)
		str.value = str.value.toUpperCase();	
}

App = {};

App.getAjaxCmd = function(url, service, cBack)
{
	AjaxUpdater.Get(url, service, cBack);
}

App.postAjaxCmd = function(url, service, JSONstr, cBack)
{
	AjaxUpdater.Post(url, service, JSONstr, cBack);
}

App.responseNotReady = function()
{
	return ((Ajax.checkReadyState('loading') != 'OK') ? true : false);
		
}

App.fldidx   = 0;

App.setFocus = function(fld)
{
//	JS.dbg('fld = ' + fld);

//	document.queryform1.elements[fld].focus();
	document.forms[0].elements[fld].focus();
}

/*			
App.incFocus = function()
{
	this.setFocus(++App.fldidx);

	if (App.fldid >= App.stopfld)
		App.fldidx = App.startfld;
		
//	JS.dbg('fldidx = ' + App.fldidx + '  startfld = ' + App.startfld + '  stopfld = ' + App.stopfld);
}
			
App.Blur = function(fld)
{
	document.queryform1.elements[fld].blur();
}
*/

var submit  = 0;
		
function dbg(msg)
{
	document.getElementById("error").innerHTML = msg;
}

App.validate_email = function(field)
{
	with (field)
	{
		apos = value.indexOf("@");
		dotpos = value.lastIndexOf(".");
		
		if ((apos < 1) || (dotpos - apos) < 2)
		{
			alert('\'' + value + '\' is not a valid email address');
			
			return (false);
		}
	}
		
	return (true);
}

App.validate = function(field, alerttxt)
{
	with (field)
	{
		if ((value == null) || (value == ""))
		{
			alert(alerttxt);
			return (false);
		}
	}
		
	if (field.name == 'enquiry')
	{
		if (field.value.indexOf('http') >= 0)
		{
			alert('invalid text in field');
			return (false);
		}
	}	
	
	return (true);
}

App.Submit = function(frm, frm_type)
{
	if (submit != 0)
		return (false);

	with (frm)
	{		
		if (!this.validate(name, 'Name field is empty'))
			return (false);

		if (!this.validate(email, 'Email field is empty'))
			return (false);
		else if (!this.validate_email(email))
			return (false);

		if (!this.validate(enquiry, 'Question field is empty'))
			return (false);
	}

	submit = 1;
	frm.submit();
	return (true);
}

App.Reset = function (frm)
{
//	frm.uin.value = '';
}

App.name_fld = function(evt, kc)
{
	if (Kbd.isalpha(kc))
	{
		if (isIE)
			evt.keyCode = toupper(kc);
		
		return (true);
	}
		
	if (Kbd.isspace(kc))
		return (true);
		
	if ((kc == 45) || (kc == 39))
		return (true);
		
	return (false);
}

App.phone_fld = function(evt, kc)
{
	if (Kbd.isdigit(kc))
		return (true);
		
	if (Kbd.isspace(kc))
		return (true);
		
	if ((kc == 43) || (kc == 40) || (kc == 41) || (kc == 45))
		return (true);
		
	return (false);
}

App.email_fld = function(evt, kc)
{
	if (Kbd.isalnum(kc) == true)
	{
		if (isIE)
			evt.keyCode = tolower(kc);
			
		return (true);
	}
		
	if ((kc != 64) && (kc != 95) && (kc != 46))
		return (false);
	
	return (true);	
}

App.query_fld = function(evt, kc)
{
	if (Kbd.isalpha(kc))
	{
		if (isIE)
			evt.keyCode = toupper(kc);
		
		return (true);
	}
		
	if (Kbd.isspace(kc))
		return (true);
		
	if ((kc == 45) || (kc == 39))
		return (true);
		
	return (false);
}

App.text_fld = function(evt, kc, cse)
{
	return (true);
}

App.kbdinput = function(evt, keyCode, fldtype, cse)
{
	var v = false;

	if (fldtype == 'NAME')
		v = this.name_fld(evt, keyCode);
	else if (fldtype == 'PHONE')
		v = this.phone_fld(keyCode);
	else if (fldtype == 'EMAIL')
		v = this.email_fld(evt, keyCode);
	else if (fldtype == 'TEXT')
		v = this.text_fld(evt, keyCode);
	
	if (isIE)
	{
		if (v == false)
			evt.keyCode = 0;
	}
	
	return (v);
}

App.init = function()
{
	this.fldidx   = 0;
}

function App_init()
{
	application = App;
	
	application.init();
}

new App_init();

//-->

