// bizmile common js functions... 
// questions: gregh@webpipeline.com
// 

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function displayErrorMessage(where,what) {
    if (where == "alert") {
        alert(what);
    } else {
        $(where).html(what).show();
    }
}

function showProps(x) {
    msg='';
    for (var i in x) { msg += i + '\t'}   
    alert(msg);
}

function nonEmpty(s) { return (s.trim() != ""); }

// courtesy of http://stackoverflow.com/questions/46155/validate-email-address-in-javascript

function validEmailAddress(email) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ 
    return (email.match(re) != null);
}

// alternate
//function checkEmail() {
//  var email = document.getElementById('emailaddress');
//  var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
//  if (!filter.test(email.value)) {
//    alert('Please provide a valid email address');
//    email.focus
//    return false;
//  }
//}

