
function validate(element)
{try
{element=element||window.event;element=element.target||element.srcElement;var id=element.id+"_error";var request=newXMLHttpRequest();request.onreadystatechange=getReadyStateHandler(request,function(xmlDocument)
{var messages=xmlDocument.getElementsByTagName("message");var message=(messages.length>0?messages[0].childNodes[0].nodeValue:"");document.getElementById(id).innerHTML=message;});var url=element.path+"?app="+element.application+"&name="+element.property+"&value="+encodeURIComponent(element.value)+"&portal="+element.portal+"&desktop="+element.desktop;if(element.type=="password")
{url="https://"+window.location.host+url;}
var xmlDocument=getValidatorXMLDocument(element.form);request.open("POST",url,true);request.send(xmlDocument);}catch(ex)
{}}
function getValidatorXMLDocument(form)
{var elements=form.elements;var xmlDocument=newXMLDocument("bean");var i;for(i=0;i<elements.length;i++)
{var formElement=elements[i];if(formElement.type=="checkbox"||formElement.type=="radio")
{if(formElement.checked)
{addXMLPropertyElements(xmlDocument,formElement.property,formElement.value);}}
else if(formElement.type!="button"&&formElement.type!="password"&&formElement.type!="reset"&&formElement.type!="submit")
{addXMLPropertyElements(xmlDocument,formElement.property,formElement.value);}}
return xmlDocument;}
function addXMLPropertyElements(xmlDocument,name,value)
{if(name&&value)
{name=getFormBeanPropertyName(name);var nameElement=xmlDocument.createElement(name);var valueElement=xmlDocument.createTextNode(value);nameElement.appendChild(valueElement)
xmlDocument.documentElement.appendChild(nameElement);}}
function getFormBeanPropertyName(name)
{if(name&&name.length>0)
{name=name.substring(0,1).toLowerCase()+name.substring(1);}
return name;}