function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function checkform()
{
	if (document.mainform.file.value == '' && !document.mainform.royalmail.checked) {
		alert('You must enter the file name of a photo on your system or check the box saying you will send a photo in the post.');
		document.mainform.file.focus();
		return false;
	}
	else if (document.mainform.physchar.value == '') {
		alert('Please enter some physical characteristics.');
		document.mainform.physchar.focus();
		return false;
	}
	else if (document.mainform.perschar.value == '') {
		alert('Please enter some personal characteristics.');
		document.mainform.perschar.focus();
		return false;
	}
	else if (document.mainform.file.value != '' && Right(document.mainform.file.value, 3) != 'jpg' && Right(document.mainform.file.value, 4) != 'jpeg' && Right(document.mainform.file.value, 3) != 'gif' && Right(document.mainform.file.value, 3) != 'png') {
		alert('Please enter an image in either the jpg, gif or png format.');
		document.mainform.file.focus();
		return false;
	}
	return true;
}
