function validFirstName(str){
	re = /^[a-zA-Z \-]{1,50}$/;
	if(str == ''){
		return false;
	} else if(str.length > 50){
		return false;
	} else if(re.test(str)){
		return true;
	} else {
		return false;
	}
}

function validLastName(str){
	re = /^[a-zA-Z \-]{1,50}$/;
	if(str == ''){
		return false;
	} else if(str.length > 50){
		return false;
	} else if(re.test(str)){
		return true;
	} else {
		return false;
	}
}

function validEmail(str){
	if(str == ''){
		return false;
	} else if(str.length > 50){
		return false;
	} else if(
		(str.length < 3) || (str.length > 50) ||
		(str.charAt(0) == '@') || (str.charAt(str.length - 1) == '@') ||
		(str.charAt(0) == '.') || (str.charAt(str.length - 1) == '.') ||
		(str.indexOf('.') == -1) || (str.indexOf('@') == -1) ||
		(str.indexOf('@') != str.lastIndexOf('@')) ||
		(str.indexOf(' ') > 0) || (str.indexOf('?') > 0) || (str.indexOf('..') > 0)
	){
		return false;
	} else {
		return true;
	}
}

function validateIns(f){
	var tag1 = '';
	var kwt = document.getElementById('kwt').value;
	if(kwt){
		tag1 = '&kwt=' + kwt;
	}

	if(!validFirstName(f.first_name.value)){
		alert('Please enter your first name.');
		f.first_name.focus();
		return false;
	} else if(!validLastName(f.last_name.value)){
		alert('Please enter your last name.');
		f.last_name.focus();
		return false;
	} else if(!validEmail(f.Email.value)){
		alert('Please enter your valid email.');
		f.Email.focus();
		return false;
	} else {
		lnk = '/app/step1of2.php?first_name=' + f.first_name.value + '&last_name=' + f.last_name.value + '&Email=' + f.Email.value + tag1;
		document.location = lnk;
		return false;
	}
}
