function limitOptions(oSel, maxSelections)
{
    var x=0;
    var option;
    var count = 0;


    while (option = oSel.options[x++])
    {
        if (option.selected)
        {
            count++;

            if (count > maxSelections)
            {
                option.selected = false;
            }
        }

    }

    if (count > maxSelections)
    {
        alert("Only select a maximum of " + maxSelections);
    }

}
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}