    // A utility function that returns true if a string contains only 
    // whitespace characters.
    function isblank(s) {
        for(var i = 0; i < s.length; i++) {
            var c = s.charAt(i);
            if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
        } 
        return true;
    }

    // This is the function that performs form verification. It is invoked
    // from the onsubmit event handler. The handler should return whatever
    // value this function returns.
    function verify(f) {

        var msg;
        var empty_fields = "";
        var errors = "";
        var secondMsg = "";
        var thirdMsg = "";
        var inquiryErrmsg = "";

        // Loop through the elements of the form, looking for all 
        // elements that have a "mandatory" property defined.
        // Then, check for fields that are empty and make a list of them.
        // Put together error messages for fields that are wrong.
        for(var i = 0; i < f.length; i++) {
            var e = f.elements[i];
            
            if (e.mandatory) {
                // first check if the field is empty and line add to the error msg 
                if ((e.value == null) || (e.value == "") || isblank(e.value)) {
                    //edited by Kostya to display error msg in countries native language
                    //empty_fields += "\n          " + e.name.replace(/^p/, "") + " - " + f.elements[i-1].value;
                    empty_fields += "\n          - " + f.elements[i-1].value;
                    continue;
                }
            }
        }
           
        for(var i = 0; i < f.length; i++) {
            var e = f.elements[i];
            var name = e.name;
            if(e.name == "inquirytype"){
                if(e.value == "Select one"){
                    inquiryErrmsg = "- Please select an inquiry type"; 
                }
            }
        }

        for(var i = 0; i < f.length; i++) {
            var e = f.elements[i];
            var name = e.name;
            var subSection = name.substring(9,0);    
            //if(subSection == ("pquestion")){
                if(e.value == "Select One" && e.mandatory){
                    thirdMsg += "- Please Select an option from the list\n";
                }
            //}
        }

        for(var i = 0; i < f.length; i++) {
            var e = f.elements[i];
            if(e.name == "pemail"){
                if((e.value.indexOf(".") == -1) || (e.value.indexOf("@") == -1)){
                    //secondMsg = "- Incorrect Email Format";
                    secondMsg = "- " + f.emptyEmailMessage.value;
                }
            } 
        }

        // Now, if there were any errors, display the messages, and
        // return false to prevent the form from being submitted. 
        // Otherwise return true.
        if (!empty_fields && !errors && secondMsg == "" && thirdMsg == "" && inquiryErrmsg == "") return true;

        msg = f.formNotSubmittedMessage.value + "\n";    
  
        if(secondMsg != "")
            msg += "\n" + secondMsg + "\n";

        if(inquiryErrmsg != "")    
            msg += "\n" + inquiryErrmsg + "\n";

        if(thirdMsg != "")
            msg += "\n" + thirdMsg + "\n";

        if(empty_fields)
            msg += "\n- " + f.emptyFieldsFollowingMessage.value + empty_fields + "\n";

        if (errors) msg += "\n";

        msg += errors;
        alert(msg);
        return false;
    }
