<!--
function FIND(item) {
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function IntlToUpprCs(frmObj) {
	var index; var tmpStr; var  tmpChar; var  preString; var  postString; var  strlen;
	tmpStr = frmObj.value.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {
			if (index == 0)  {
				tmpChar = tmpStr.substring(0,1).toUpperCase();
				postString = tmpStr.substring(1,strLen);
				tmpStr = tmpChar + postString;
			} else {
				tmpChar = tmpStr.substring(index, index+1);
				if (tmpChar == " " && index < (strLen-1))  {
					tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
					preString = tmpStr.substring(0, index+1);
					postString = tmpStr.substring(index+2,strLen);
					tmpStr = preString + tmpChar + postString;
		    		}
			}
	   }
	}
	frmObj.value = tmpStr;
}

function toUpprCs(frmObj){
	frmObj.value = frmObj.value.toUpperCase();
}

function pstCdeCntry(frmObj,lyr,pstCde,frm){
	if(frmObj.value != '1'){
		getPage(lyr);
		page.display='block';
	}else{
		// is uk
		if(pstCde.value != ''){
			// if postcode avaialble get address
			frm.action = location.href;
			frm.submit();
		}
	}
}

// un-disable box dependent on value
function chckTtl(frmObj,undisVal,objAlt){
	if(frmObj.value==undisVal){
		dt = FIND(objAlt);
		dt.disabled=false;
	}
}

// clear box if val is
function clrIf(frmObj,clrVal){
	if(frmObj.value==clrVal) frmObj.value='';
}

// change status of disabled or not on form element
function frm_dsbl(obj,valchck,val){
	dt = FIND(obj);
	vl = FIND(valchck);
	if(vl.value==val){
		dt.disabled=false;
	}else{
		dt.value='';
		dt.disabled=true;
	}
}


// make sailor double check they do want auto entry.
function confirmAutoEntry(obj){
	dt = FIND(obj);
	if(dt.checked==true){
		var cnf = confirm('If you wish to enable Automatic Entry click OK below. \nBy enabling Automatic Entry you are commiting to pay the entry fee in full, even if you do not attend the championship. PLEASE BE ABSOLUTELY SURE BEFORE CLICKING OK.\n\nIf you do not wish to use Automatic Entry click Cancel below.');
	if(!cnf)
		dt.checked=false;
	}
}






//=============================================
//=============================================

// form validation



function vldtEml(emx){
	// return true if valid email address in emx/
	rtrn = true;
	var ema = emx.indexOf('@');
	var emb = emx.indexOf('.');
	if (ema < 1 || emb < 1) rtrn = false;
	return rtrn;
}

function vldtNtZr(emx){
	// return true if length of emx is not 0
	rtrn = true;
	if(emx == '0') rtrn = false;
	return rtrn;
}

function vldtLngthNtLss(emx,n){
	// return true if length of emx is not less than n
	rtrn = true;
	if(emx.length < n) rtrn = false;
	return rtrn;
}

function vldtLngthNtMr(emx,n){
	// return true if length of emx is not more than n
	rtrn = true;
	if(emx.length > n) rtrn = false;
	return rtrn;
}

function vldtLngthNtEq(emx,n){
	// return true if length of emx is not equal than n
	rtrn = true;
	if(emx.length == n) rtrn = false;
	return rtrn;
}

function vldtLngthEq(emx,n){
	// return true if length of emx is equal than n
	rtrn = true;
	if(emx.length != n) rtrn = false;
	return rtrn;
}

function vldtEq(emx,emy){
	// return true if object equal each other
	rtrn = true;
	if(emx != emy) rtrn = false;
	return rtrn;
}

function vldtNtEml(emx){
	// return true if object equal each other
	rtrn = true;
	var ema = emx.indexOf('@');
	if (ema > 0) rtrn = false;
	return rtrn;
}

function validate(frmNme,objs,nmes,vld,errIntl){
		// frmNme is the name of form for addressing
		// objs array of form object names
		// nmes = literal names for form objects
		// vld array of validation checks
		// errIntl = Initial error message
		
		var errors = '';
		
		// loop through objects
		for(i = 0; i < objs.length; i++){
			// find out if validating
			if(vld[i]){
				if(vld[i] == 'E'){
					// validate is email address
					tstVal = eval('document.'+frmNme+'.'+objs[i]+'.value');
					if(!vldtEml(tstVal)) errors += 'Please provide a valid Email address.\n';
				} else if(vld[i] =='NE'){
					// validate not an email
					tstVal = eval('document.'+frmNme+'.'+objs[i]+'.value');//alert(tstVal);
					if(!vldtNtEml(tstVal)) errors += nmes[i]+' must be a valid telephone number.\n';
				} else if(vld[i] =='R'){
					// validate feild required
					tstVal = eval('document.'+frmNme+'.'+objs[i]+'.value');//alert(tstVal);
					if(!vldtLngthNtLss(tstVal,1)) errors += nmes[i]+' is required.\n';//alert(vldtLngthNtLss(tstVal,1));
				} else if(vld[i] =='EQ'){
					// validate feild equal to next feild
					tstVal = eval('document.'+frmNme+'.'+objs[i]+'.value');//alert(tstVal);
					// increment counter
					i++;
					nxtVal = eval('document.'+frmNme+'.'+objs[i]+'.value');
					if(!vldtEq(tstVal,nxtVal)) errors += nmes[(i-1)]+' must be the same as '+nmes[i]+'.\n';
				} else if(vld[i] =='SR'){
					// validate select box value required
					tstVal = eval('document.'+frmNme+'.'+objs[i]+'.value');//alert(tstVal);
					if(!vldtNtZr(tstVal)) errors += 'Please make a selection from '+nmes[i]+'.\n';//alert(vldtLngthNtLss(tstVal,1));
				} else if(vld[i] =='C'){
					// validate select box value required
					tstVal = eval('document.'+frmNme+'.'+objs[i]+'.checked');//alert(tstVal);
					if(!(tstVal)) errors += nmes[i]+' is required.\n';//alert(vldtLngthNtLss(tstVal,1));
				}
				
			}
		}
		
		// check if any errors occured
		if(errors){
			alert(errIntl+"\n\n"+errors);
			
		}
		document.returnVal =  (errors == '');
}


//-->