function checkChangepwdForm(){
	var oldpass = document.changepwd.oldpasswd.value;
	var newpass = document.changepwd.newpasswd.value;
	var confirmpass = document.changepwd.confirmpwd.value;
	if (oldpass==''){
		alert('Please enter the old password!');
		document.changepwd.oldpasswd.focus();
		return false;
	}
	if (newpass.length < 6){
		alert('The new password is too short!');
		document.changepwd.newpasswd.focus();
		return false;
	}
	if (newpass==''){
		alert('Please enter the new password!');
		document.changepwd.newpasswd.focus();
		return false;
	}
	if (confirmpass==''){
		alert('Please confirm the new password!');
		document.changepwd.confirmpwd.focus();
		return false;
	}
	if (newpass!=confirmpass){
		alert('Incorrect confirmed password. Try again!');
		document.changepwd.confirmpwd.focus();
		return false;
	}
	
	return true;
}

function confirm_delete(szURL){
	if (confirm('Are you sure you wish to delete this information?')){
		window.location.href = szURL;
	}
}

function IsNumeric(strString){
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;

	if (strString.length == 0) return false;

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			blnResult = false;
		}
	}
	return blnResult;
}


function check_lp_form(){
	var mystr = document.lp_form.str.value;
	var myyear = document.lp_form.year.value
	if (mystr==''){
		alert('Please enter the name!');
		document.lp_form.str.focus();
		return false;
	}
	if (myyear==''){
		alert('Please enter the year!');
		document.lp_form.year.focus();
		return false;
	}
	if (!IsNumeric(myyear)){
		alert('Please enter the valid year!');
		document.lp_form.year.focus();
		return false;
	}
	if (myyear.length!=4){
		alert('Please enter the valid year!');
		document.lp_form.year.focus();
		return false;
	}
	return true;
}

function check_malalamiko_form(){
	var from_date = document.malalamiko.from_date.value;
	var to_date = document.malalamiko.to_date.value
	if (from_date==''){
		alert('Tafadhali weka tarehe ya kuanzia!');
		document.malalamiko.from_date.focus();
		return false;
	}
	if (to_date==''){
		alert('Tafadhali weka tarehe ya kumalizia!');
		document.malalamiko.to_date.focus();
		return false;
	}
	if (to_date < from_date){
		alert('Tarehe ya kumalizia lazima iwe kubwa kuliko tarehe ya kuanzia!');
		document.malalamiko.to_date.focus();
		return false;
	}
	return true;
}