function MM_validateForm() { //v4.0 to validate email field
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) {test=args[i+2];val=document.getElementById(args[i]);
      if (val) {nm=val.name;if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) {p=val.indexOf('@');q=val.indexOf('.',p);
          if (p<1 || p==(val.length-1) || q<1 || q==(val.length-1) || q==(val.length-2))
              errors+='The '+nm+' field must contain a valid e-mail address.\n';
        } else if (test!='R') {num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) {p=test.indexOf(':');
            min=test.substring(8,p);max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      }}} else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n';}
    }if (errors) {alert(errors);return false;} else {return checkRegister();}
    //document.MM_returnValue = (errors == '');
}}

function checkRegister(){
	if(document.getElementById('email').value==""){
		alert('Please review the supplied email entry!');
		return false;
		}

	//if(document.getElementById('password').value==0){
	//	alert('Please enter a password!');
	//	return false;
	//	}
        if(document.getElementById('password').value.length < 5){
        alert('Please choose a password with minimum of 5 characters');
        return false;
        }
	if(document.getElementById('surname').value=="" || document.getElementById('othernames').value==""){
		alert('Please enter your lastname and othernames!');
		return false;
		}				
	if(document.getElementById('address').value==""){
		alert('Please enter your contact address!');
		return false;
		}
	if(document.getElementById('addressstate').value==0){
		alert('Please select your state!');
		return false;
		}		
	if(document.getElementById('sex').value==0){
		alert('Please select your Sex!');
		return false;
		}
        if(document.getElementById('dob').value.length > 10 || document.getElementById('dob').value.length < 8){
        alert('Please enter a valid date in the format YYYY-MM-DD');
        document.getElementById('dob').focus();
        return false;
        }
        if(document.getElementById('phone').value.length != 11){
		alert('Please enter a valid 11-digit telephone number!');
		return false;
		}
	if(document.getElementById('LRName').value==""){
		alert('Please enter your Liberty Reserve Account Name!');
		return false;
		}
      	if(document.getElementById('LRNo').value==""){
		alert('Please enter your Liberty Reserve Account Number!');
		return false;
		}

/*	if(document.getElementById('banker').value==""){
		alert('Please enter your banker\'s name!');
		return false;
		}
	if(document.getElementById('acName').value==""){
		alert('Please enter your Bank account name in the space provided!');
		return false;
		}
	if(document.getElementById('acNo').value==""){
		alert('Please enter your Bank account number in the space provided!');
		return false;
		}
	if(document.getElementById('photoId').value==""){
		alert('Please select your preferred form of identification!');
		return false;
		}
  */
	if(document.getElementById('photoId').value!="0" && document.getElementById('photoFilename').value==""){
		alert('Please select a scanned copy of Photo ID for upload!');
		return false;
		}
	if(document.getElementById('password').value!=document.getElementById('repassword').value){
		alert('Please confirm passwords!');
		document.getElementById('password').value="";
		document.getElementById('repassword').value="";
		document.getElementById('password').focus();
		return false;
		}		
	document.getElementById('checked').value="true";
	return true;
}

function checkAccountMod(){
    if(document.getElementById('banker').value=="0" || document.getElementById('acNo').value=="" || document.getElementById('acName').value==""){
        alert('Please Fill in all required field!');
        return false;
    }
    else {return true;}

/*    if (confirm("You will not be able to perform any transaction until we have verified your account modification! Continue anyway?")){
    document.getElementById('accountchecked').value="true";
    return true;
	}
    return false;
*/
}


function checkIdentityMod(){
    //if photoFilename is set
    if((document.getElementById('photoFilename').name=="photoFilename") && (document.getElementById('photoFilename').value=="0" || document.getElementById('photoFilename').value=="")){
	alert('Please select the Photo ID file for upload!');
	return false;
	}
    if(document.getElementById('utilityFilename').name=="utilityFilename" && document.getElementById('utilityFilename').value==""){
	alert('Please select the Bank statement image file for upload!');
	return false;
	}
    if (confirm("You will not be able to perform any transaction until account changes have been verified! Continue anyway?")){
    document.getElementById('accountchecked').value="true";
    return true;
	}
    return false;
}

function checkLogin(){
		if(document.getElementById('loginusername').value==""){
		alert('Please enter your email to login!');
		return false;
		}
		 if(document.getElementById('loginpassword').value==""){
		 alert('Please enter your password to login!');
		return false;
		}
	document.getElementById('loginchecked').value="true";
	return true;
}

function checkForgot(){
		if(document.getElementById('forgotusername').value==""){
		alert('Please enter the email address you supplied when registering on iGN!');
		return false;
		}
	return true;
}


function checkPReset(){
	if(document.getElementById('fPassword').value=="" || document.getElementById('nPassword').value=="" || document.getElementById('rPassword').value==""){
		alert('All three password fields are required!');
		return false;
		}
	if(document.getElementById('nPassword').value != document.getElementById('rPassword').value){
		alert("New password fields don't match");
		return false;
		}
        if(document.getElementById('nPassword').value.length < 5){
        alert('Please choose a password with minimum of 5 characters');
        return false;
        }
	document.getElementById('passwordresetchecked').value="true";
	return true;

	}
	
function checkLRForm(){
	if(document.getElementById('LRName').value=="" || document.getElementById('LRNo').value==""){
		alert('All fields in the Liberty Reserve Form are required!');
                return false;
            }
        if (confirm("You will not be able to perform any transaction until new account information has been verified! Continue anyway?")){
            document.getElementById('LRchecked').value="true";
            return true;
		}
	return false;
}

function checkOKForm(){
	if(document.getElementById('OKName').value=="" || document.getElementById('OKNo').value==""){
		alert('All fields in the OKPAY Form are required!');
		return false;
		}
        /*if (confirm("You will not be able to perform any transaction until new account information has been verified! Continue anyway?")){
            document.getElementById('OKchecked').value="true";
            return true;
		}*/
	else {return true;}
}

function checkFunding(){
if (document.getElementById('centamount').value > 99 || document.getElementById('centamount').value < 0 || document.getElementById('dollaramount').value < 20 || document.getElementById('dollaramount').value > 10000){
		alert('Please specify funding amount within the range: $20.00 - $10,000.00!');
		return false;
	}
document.getElementById('fundChecked').value="true";
return true;
}

function checkWithdrawal(){
if (document.getElementById('centamount').value > 99 || document.getElementById('centamount').value < 0 || document.getElementById('dollaramount').value < 20 || document.getElementById('dollaramount').value > 10000){
		alert('Please specify withdrawal amount within the range: $20.00 - $10,000.00!');
		return false;
	}
document.getElementById('withdrawalChecked').value="true";
return true;
}

function confirmCancel(){
	if (confirm("Are you sure you want to ABORT this transaction?")){
		return true;
		}
	return false;
	}

 function checkCurrencyForm(){
	if(document.getElementById('buyDollar').value=="" || document.getElementById('sellDollar').value=="" || document.getElementById('sellNaira').value=="" || document.getElementById('sellNaira').value==""){
		alert('All fields in the Currency Exchange Form are required!');
		return false;
		}
	document.getElementById('OKchecked').value="true";
	return true;
}
