
function checkform(objForm) {

	if (navigator.userAgent.match(/Opera (\S+)/)) {
		var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]);
	}
	if (!document.getElementById||operaVersion<7) return;

	for (var m=0; m < objForm.elements.length; m++) {
		if (objForm.elements[m].className.indexOf('VALIDATE')!=-1){
			elemToTest=objForm.elements[m].className;
			if (elemToTest.match(/VALIDATE (\S+)/)) {
				elemType = elemToTest.match(/VALIDATE (\S+)/)[1]
				if (elemType == 'ValidateTEXT') {
					obj = eval("objForm." + objForm.elements[m].name);
					if (isFilled(obj) == false) {
						alert("Please check the the form is complete.");
						obj.focus();
						return false;
					}
				}

				if (elemType == 'ValidateEMAIL') {
					obj = eval("objForm." + objForm.elements[m].name);
					if (isEmail(obj) == false) {
						alert("Please check that you have entered a valid email address.");
						obj.focus();
						return false;
					}
				}
				
				if (elemType == 'ValidateSELECT') {
					obj = eval("objForm." + objForm.elements[m].name);
					if (obj.selectedIndex == 0) {
						alert("Please check the the form is complete.");
						obj.focus();
						return false;
					}
				}
				
				if (elemType == 'ValidateEXPIRE') {
					obj = eval("objForm." + objForm.elements[m].name);
					dtThen = new Date(objForm.card_expiry_year.value, objForm.card_expiry_month.value-1, objForm.card_expiry_day.value);
					dtNow = new Date();
					if (dtThen <= dtNow) {
						alert("Please enter a valid date.");
						obj.focus();
						return false;
					}
				}
			}

		}
	}
	return true;
}


function checkForm(objForm) {

	ary1 = new Array();
	ary2 = new Array();

	for (var n=0; n < objForm.length; n++) {
		if (objForm.elements[n].accept) {
			ary1[n] = objForm.elements[n].id;
			ary2[n] = objForm.elements[n].accept;
		}
	}

	for (var i=0;i < ary1.length; i++) {

		if (ary2[i] == 'text') {
			obj = eval("objForm." + ary1[i]);
			if (isFilled(obj) == false) {
				alert("Please check the the form is complete.");
				obj.select();
				return false;
			}
		}

		if (ary2[i] == 'email') {
			obj = eval("objForm." + ary1[i]);
			if (isEmail(obj) == false) {
				alert("Please check that you have entered a valid email address.");
				obj.select();
				return false;
			}
		}

		if (ary2[i] == 'select') {
			obj = eval("objForm." + ary1[i]);
			if (isFilled(obj) == false) {
				alert("Please check that you have made a selection.");
				obj.focus();
				return false;
			}
		}

	}
	return true;
}


//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\

function isEmail(elm) {
	if (elm.value.indexOf("@") + "" != "-1" && elm.value.indexOf(".") + "" != "-1" && elm.value != "")
		return true;
	else return false;
}

function isFilled(elm) {
	if (elm.value == "" || elm.value == null)
		return false;
	else return true;
}


//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\

function checkRadio(obj) {
	var bCheck = false;
	for(i=0; i<obj.length; i++) {
		if (obj[i].checked) {
			bCheck = true;
		}
	}
	if (bCheck == false) {
		alert ("Please Choose One");
		return false;
	}
	return true;
}


function autoCap(elm) {
	if (!elm.autoCapped){
		var words = elm.value.split(" ");
		var caps = "";
		for(var i=0; i<words.length; i++) {
			var word = words[i];
			tmp = word.substring(0, 1);
			tmp = tmp.toUpperCase();
			word = tmp +word.substring(1, word.length).toLowerCase();
			caps = caps +" " +word;
	   }
		elm.value = caps.substring(1, caps.length);
		elm.autoCapped = true
	}
}


function confirmDup(elm1, elm2, message) {
	if (elm1.value !== elm2.value) {
		alert (message);
		elm1.select();
		return false;
	}
	return true; 
}




	function srchBoxFoc()
	{
		if (event.srcElement.style.color == '#735137')
		{
			event.srcElement.value = '';
			event.srcElement.style.color = 'black';
		}
	}
	function srchBoxBlu()
	{
		if (event.srcElement.value == '')
		{
			event.srcElement.value = 'Keyword Search';
			event.srcElement.style.color = '#735137';
		}
	}
	
	function runSearch() {
		if (srchBox.style.color == '#735137' || srchBox.value == '')
		{
			alert('Please enter some keywords to search for.')
		}
		else
		{
			window.open('/search.asp?search='+escape(srchBox.value),'_self')
		}
	}
