
 function updateTips(t) {
    tips.css("color", "red");
    tips.text(t).effect("highlight", {}, 1500);
 }

 function checkLength(o, n, min, max) {
    if (o.val().length > max || o.val().length < min) {
       o.addClass('ui-state-error');
       //updateTips("Length of " + n + " must be between " + min + " and " + max + ".");
       updateTips("Please enter " + n);
       return false;
    } else {
       return true;
    }
 }

 function checkRegexp(o, regexp, n) {
    if (!(regexp.test(o.val()))) {
       o.addClass('ui-state-error');
       updateTips(n);
       return false;
    } else {
       return true;
    }
 }
 
function displayDIV(whichID, showFlag, optDisplay)
{
	var dv = document.getElementById(whichID);
	
	if(dv != null)
	{
		if(showFlag == 0)
		{
			dv.style.display = "none";
			return false;
		}
		else
		{
			dv.style.display = (optDisplay == null ? "" : optDisplay);
			return true;
		}
	}
	else
	{
		return false;
	}
}

function trim(what) {
    var aa = what;

    // Trim Leading Spaces
    while (aa.charAt(0) == ' ') {
        aa = aa.substring(1, aa.length);
    }

    // Trim Trailing Spaces
    while (aa.charAt(aa.length - 1) == ' ') {
        aa = aa.substring(0, aa.length - 1);
    }

    return aa;
}

function validEmail(email) {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
        return (true);
    }

    return (false);
}