<!--
// Copyright information must stay intact
// FormCheck v1.10
// Copyright NavSurf.com 2002, all rights reserved
// Creative Solutions for JavaScript navigation menus, scrollers and web widgets
// Affordable Services in JavaScript consulting, customization and trouble-shooting
// Visit NavSurf.com at http://navsurf.com
function formCheck(formobj,frmName){
	// name of mandatory fields
    if (frmName == 'donations' ){
        var fieldRequired = Array("deceased", "realname", "address", "phone", "email", "charity", "message", "imgverify");
    	var fieldDescription = Array("Deceased Name", "Your Name", "Your Mailing Address", "Your Phone", "Your Email Address", "Name of Charity", "Your Message to the Family", "Enter image verification");
    }else{
        var fieldRequired = Array("deceased", "realname", "address", "phone", "email", "message", "imgverify");
    	var fieldDescription = Array("Deceased Name", "Your Name",  "Your Mailing Address", "Your Phone", "Your Email Address", "Your Message to the Family", "Enter image verification");
    }
        // field description to appear in the dialog box
        
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	var l_Msg = alertMsg.length;

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			if (obj.type == null){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				continue;
			}


			switch(obj.type){

			case "checkbox":

				 if (!obj.checked){
				 	alertMsg += " - " + fieldDescription[i] + "\n";
				 }
				 break;
			case "select-one":
				if (obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
            case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
    		case "text":
                if (obj.name == "email") {
                    if (obj.value == "" || obj.value == null){
                        alertMsg += " - " + fieldDescription[i] + "\n";
                    } else {
                        var AtPos = obj.value.indexOf("@");
                        var StopPos = obj.value.indexOf(".");
                        //if ((obj.value.indexOf(".") = -1) || (obj.value.indexOf("@") = -1)){
                        //    alertMsg += " - " + fieldDescription[i] + " is invalid\n";
                        //}
                        if (AtPos == -1 || StopPos == -1) {
                            alertMsg += " - " + fieldDescription[i] + " is invalid\n";
                        }

                        //if (StopPos < AtPos) {
                        //    alertMsg += " - " + fieldDescription[i] + " is invalid\n";
                        //}

                        if (StopPos - AtPos == 1) {
                            alertMsg += " - " + fieldDescription[i] + " is invalid\n";
                        }
                    }
                }
                if (obj.name == "deceased"){
                    if (obj.value == "" || obj.value == null){
                        alertMsg += " - " + fieldDescription[i] + "\n";
                    }
                }
                if (obj.name == "realname"){
                    if (obj.value == "" || obj.value == null){
                        alertMsg += " - " + fieldDescription[i] + "\n";
                    }
                }
                if (obj.name == "phone"){
                    if (obj.value == "" || obj.value == null){
                        alertMsg += " - " + fieldDescription[i] + "\n";
                    }
                }
                if (frmName == 'donations'){
                  if (obj.name == "charity"){
                      if (obj.value == "" || obj.value == null){
                          alertMsg += " - " + fieldDescription[i] + "\n";
                      }
                  }
                }
                if (obj.name == "imgverify"){
                    if (obj.value == "" || obj.value == null){
                        alertMsg += " - " + fieldDescription[i] + "\n";
                    }
                }
                break;


		case "textarea":
               if (obj.name == "address"){
    				if (obj.value == "" || obj.value == null){
    					alertMsg += " - " + fieldDescription[i] + "\n";
    				}
               }
               if (obj.name == "message"){
        	       if (obj.value == "" || obj.value == null){
        		       alertMsg += " - " + fieldDescription[i] + "\n";
        		   }
               }
			   break;
			default:
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}
// -->
