/*
Copyright (c) 2001, 2002 by Martin Tsachev. All rights reserved.
mailto:shaggy@members.evolt.org
http://members.evolt.org/shaggy/

This software is OSI Certified Open Source Software.

Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the conditions available at
http://www.opensource.org/licenses/bsd-license.html
are met.
*/

// generic validation functions
function validateString(str, warning, min, max) {
	if (!min) {
		min = 1;
	}
	if (!max) {
		max = 65535;
	}

	if (!str.value || str.value.length < min || str.value.length > max) {
		alert(unescape(warning));
		str.focus();
		str.select();
		return false;
	}

	return true;
}


function validateEmail(email) {
	if (!email.value) {
		return true;
	}

	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if ( !re_mail.test(email.value) ) {
		alert('Incorrect email address');
		email.focus();
		email.select();
		return false;
	}

	return true;
}

function validateMatch(var1, var2, msg) {
	if (var1.value != var2.value) {
		alert(unescape(msg));
		var1.focus();
		var1.select();
		return false;
	}

	return true;
}


// site specific validation functions
