// validate Case number input before submitting form
// 2005-06-13 Ken Shipman - created
function ValidateCaseNumber()
{
	var txt = trimString(document.getElementById("txtCaseNo").value);
	var ErrMsg = 'You must enter a valid Case number to check status.'
	var BadInput = false;
	
//	alert('Validate: ' + txt);
	if ( txt.length < 9 )
	{
//		alert('txt.length < 9');
		BadInput = true;
	}
	else if ( txt.length > 12 )
	{
//		alert('txt.length > 12');
		BadInput = true;
	}
	else	// length is OK, so validate that the complete input is a number
	{
		var results, re;                     
		re = /\d{9,12}/;
		results = txt.match(re);        
		if ( results == null )
		{	// no match at all
//			alert('results == null');
			BadInput = true;
		}
		else if ( results[0].length != txt.length )
		{	// partial match because the match isn't identical to the input.
//			alert('results.length != txt.length\n' + results.length.toString() + ' != ' + txt.length.toString() + '\n' + results + ' != ' + txt );
			BadInput = true;
		}
	}
	if ( BadInput )
	{	// we've found an error
		alert( ErrMsg );
		document.getElementById("txtCaseNo").focus();
		return;			
	}

//	alert('submitting request');
    document.CaseNumberInput.submit();
        
}

// used by index.html to make sure focus is given to the input box.
function index_onload()
{
	document.getElementById("txtCaseNo").focus();
}

