
errortemplates={'base':{'clienterror':"These problems were found:\n\n%%e%%\n\nPlease make corrections and re-submit.",'clientheader':"<h2>Corrections Required</h2><p><strong>Your entries could not be accepted</strong> because we found these errors:</p>\n<ul>\n",'clienterroritem':" <li>%%e%%</li>\n",'clientfooter':"</ul>\n<p>Please make corrections and re-submit.</p>\n",'required':"%%f%% is required.",'minlength':"%%f%% must be at least %%min%% characters long.",'maxlength':"%%f%% must be at most %%max%% characters long.",'minmaxlength':"%%f%% must be between %%min%% and %%max%% characters long.",'minvalue':"%%f%% must be %%min%% or more.",'maxvalue':"%%f%% must be %%max%% or less.",'minmaxvalue':"%%f%% must be between %%min%% and %%max%%.",'invalidalpha':"%%f%% must contain only letters.",'invalidalphanumeric':"%%f%% must contain only letters, numbers, and spaces.",'invalidalphaspace':"%%f%% must contain only letters and spaces.",'invalidcolor':"%%f%% must be a valid HTML color.",'notwebsafe':"%%f%% must be a web-safe color.",'invalidcardtype':"%%f%% must be an accepted credit card type.",'invalidcardnum':"%%f%% must be a valid credit card number.",'invalidcvv2':"%%f%% must be a valid card verification code.",'invaliddate':"%%f%% must be a valid date.",'needpastdate':"%%f%% must be a date in the past.",'needfuturedate':"%%f%% must be a date in the future.",'needdatebefore':"%%f%% must be a date before %%min%%.",'needdateafter':"%%f%% must be a date after %%min%%.",'minage':"You must be at least %%min%% years old.",'maxage':"You must be no more than %%min%% years old.",'invalidemail':"%%f%% must be a valid email address.",'invalidemaildomain':"%%min%% is an external address and is not allowed.",'invalidemailnodomain':"%%min%% is a complete email address (including domain name); a domain name is not allowed.",'invalidemailitem':"%%min%% is not properly-formatted email address. Use &#8220;name&#8221; <address@domain>",'invalidemailaddress':"%%min%% is not a valid email address.",'unmatchedquote':"%%f%% does not have a matching quote.",'unmatchedparenthesis':"%%f%% does not have a matching parenthesis.",'unmatchedbracket':"%%f%% does not have a matching angle bracket.",'unmatchedcolon':"%%f%% has a group (marked with a colon) but no semicolon.",'invalidbackslash':"%%f%% contains a backslash (\) at the end of an address.",'doubleaddress':"%%min%% needs a comma after it to separate it from the next address.",'invalidhtml':"%%f%% must be validly-formatted HTML.",'notinteger':"%%f%% must be a whole number.",'invalidip':"%%f%% must be a valid IP address.",'invalidiprange':"%%f%% must be a valid IP address range.",'invaliddomainname':"%%f%% must be a valid domain name.",'invalidhostname':"%%f%% must be a valid hostname.",'invalidtld':"%%f%% must be in an accepted top-level domain.",'unknowndomainname':"%%f%% must be a previously-registered domain name.",'unknownhostname':"%%f%% must be an existing hostname.",'badrdnshostname':"%%f%% must have matching forward and reverse DNS.",'nolocalip':"%%f%% must be an externally-routable IP address.",'nosubdomain':"%%f%% must have at least %%min%% parts but no more than %%max%% parts for this top-level domain.",'domainminparts':"%%f%% must have at least %%min%% parts.",'domainmaxparts':"%%f%% must have no more than %%max%% parts.",'domainparts':"%%f%% must have at least %%min%% parts but no more than %%max%% parts.",'invalidlist':"%%min%% is not a valid value for %%f%%.",'invalidinvertedlist':"%%min%% is not a valid value for %%f%%.",'invalidmultiplelist':"%%min%% is not a valid value for %%f%%.",'invalidname':"%%f%% must contain only letters and spaces.",'notnumeric':"%%f%% must be a number.",'notprecise':"%%f%% must be a multiple of %%min%%.",'invalidpassword':"%%f%% must be a valid password.",'invalidphone':"%%f%% must be a valid phone number (with area code).",'invalidssn':"%%f%% must be a valid Social Security Number or Taxpayer Identification Number.",'invalidurl':"%%f%% must be a valid web address.",'invalidusername':"%%f%% must be a valid username.",'invaliddateorder':"%%f%% must be before %%min%%.",'invaliddatebetween':"%%f%% must be between %%min%% and %%max%%.",'depends':"%%f%% cannot be accepted because %%min%% has errors.",'mingroup':"You must provide at least %%min%% of %%f%%.",'maxgroup':"You must provide no more than %%max%% of %%f%%.",'minmaxgroup':"You must provide at least %%min%% and no more than %%max%% of %%f%%.",'exactgroup':"You must provide %%min%% of %%f%%.",'requiredby':"%%min%% requires %%f%%.",'match':"%%f%% and %%min%% must match.",'nomatch':"%%f%% and %%min%% must not match.",'invalidorder':"%%f%% must be less than %%min%%.",'invalidbetween':"%%f%% must be between %%min%% and %%max%%."}};errorpopupvisible=false;errorpopupisabove=false;errorpopupissecondary=false;function errorpopup_focus(f,ff)
{if(errorpopupvisible)
errorpopup_blur();if(lastvalidatedform!=f)
return;if(errorfields[ff]==null||errorfields[ff]<='')
return;var fo=document.forms[f][ff];if(fo.type==null)
fo=fo[fo.length-1];var o=window.top.document.getElementById('formerrorpopup');var o1=window.top.document.getElementById('formerrorpopupbelow');var o2=window.top.document.getElementById('formerrorpopupbelowtext');var ifr=window.top.document.getElementById('formerrorpopupbelowshim');if(errorpopupissecondary)
{o1=window.top.document.getElementById('formerrorpopupabove');o2=window.top.document.getElementById('formerrorpopupabovetext');ifr=window.top.document.getElementById('formerrorpopupaboveshim');errorpopupisabove=true;}
else
errorpopupisabove=false;var w=Math.min(200,fo.offsetParent.offsetWidth-fo.offsetLeft);var h=fo.offsetHeight;var a=getrelativepos(fo,o);var wo=window;while(wo!=window.top)
{var b=getrelativepos(wo.frameElement,wo.parent.document.body);a[0]+=b[0];a[1]+=b[1];wo=wo.parent;}
o.style.left=a[0]+"px";if(!errorpopupisabove)
o.style.top=(a[1]+h)+"px";else
o.style.top=(a[1]-o1.offsetHeight)+"px";o1.style.display="block";el=errorfields[ff].substr(0,errorfields[ff].length-1);o2.innerHTML=el.replace(/\|/g,'<br />');if(errorpopupisabove)
o.style.top=(a[1]-o1.offsetHeight)+"px";var h2=o2.offsetHeight;ifr.style.width=(o1.offsetWidth)+'px';ifr.style.height=(h2)+'px';ifr.style.display='block';}
function errorpopup_blur()
{window.top.document.getElementById('formerrorpopupabove').style.display='none';window.top.document.getElementById('formerrorpopupbelow').style.display='none';window.top.document.getElementById('formerrorpopupaboveshim').style.display='none';window.top.document.getElementById('formerrorpopupbelowshim').style.display='none';errorpopupvisible=false;errorpopupissecondary=false;}
function divshow(o)
{if(o!=null&&o.id==null)
o=document.getElementById(o);if(o==null)
return;if(arguments.length>1&&arguments[1]!=null)
arguments[1].cancelBubble=true;o.style.display=(arguments.length>2)?arguments[2]:'block';if(arguments.length>1&&arguments[1]!=null)
arguments[1].cancelBubble=true;return false;}
function divhide(o)
{if(o!=null&&o.id==null)
o=document.getElementById(o);if(o==null)
return;if(arguments.length>1&&arguments[1]!=null)
arguments[1].cancelBubble=true;o.style.display='none';if(arguments.length>1&&arguments[1]!=null)
arguments[1].cancelBubble=true;return false;}
function divtoggle(o)
{if(o!=null&&o.id==null)
o=document.getElementById(o);if(o==null)
return;if(arguments.length>1&&arguments[1]!=null)
arguments[1].cancelBubble=true;o.style.display=(o.style.display=='none')?((arguments.length>2)?arguments[2]:'block'):'none';if(arguments.length>1&&arguments[1]!=null)
arguments[1].cancelBubble=true;return false;}
function classset(o,c)
{if(o!=null&&o.id==null)
o=document.getElementById(o);if(o==null)
return;o.className=c;return false;}
function classadd(o,c)
{if(o!=null&&o.id==null)
o=document.getElementById(o);if(o==null)
return;var ca=o.className.split(/ +/);var i;for(i=0;i<ca.length;i++)
if(ca[i]==c)
return;ca[i]=c;o.className=ca.join(' ');return false;}
function classsub(o,c)
{if(o!=null&&o.id==null)
o=document.getElementById(o);if(o==null)
return;var ca=o.className.split(/ +/);var i;for(i=0;i<ca.length;i++)
if(ca[i]==c)
{ca.splice(i,1);i--;}
o.className=ca.join(' ');return false;}
function classswap(o,c,n)
{if(o!=null&&o.id==null)
o=document.getElementById(o);if(o==null)
return;var ca=o.className.split(/ +/);var i;for(i=0;i<ca.length;i++)
if(ca[i]==c)
ca[i]=n;o.className=ca.join(' ');return false;}
function classtoggle(o,c,n)
{if(o!=null&&o.id==null)
o=document.getElementById(o);if(o==null)
return;var ca=o.className.split(/ +/);var i;for(i=0;i<ca.length;i++)
if(ca[i]==c)
ca[i]=n;else if(ca[i]==n)
ca[i]=c;o.className=ca.join(' ');return false;}
function relocate(u)
{var f=(arguments.length>1)?arguments[1]:window.top;var t=(arguments.length>2)?arguments[2]:'_self';if(f!=null&&f.id==null&&f.name==null)
f=window.top.frames[f];var r=f.document.forms['relocator'];if(r==null)
return false;r.action=u;r.target=t;relocatedo(r);return false;}
function relocatedo(r)
{var s=r.action.indexOf('?');if(s>=0)
{var p=r.action.substr(s+1);var pa=p.split(/[&;]/);var pd;var i;var h='';for(i=0;i<pa.length;i++)
{pd=pa[i].split('=',2);h=h+'<input type="hidden" name="'+pd[0]+'" value="" />';}
r.innerHTML=h;for(i=0;i<pa.length;i++)
{pd=pa[i].split('=',2);r.elements[pd[0]].value=decodeURIComponent(pd[1]);}}
r.submit();}
function framename(f)
{var n=new Array();while(typeof(f)=='object'&&f!=null&&f.name!=null&&f.name>'')
{n.unshift(f.name);if(f.parent==f)
f=null
else
f=f.parent;}
return n.join('.');}
function framefind(f)
{if(typeof(f)=='object')
return f;var p=f.split(/\./);var i=0;var o=window;var t;if(p[0]>'')
for(i=0;i<p.length&&o&&o.document;i++)
{t=o.document.getElementById(p[i]);if(t.contentWindow)
o=t.contentWindow;else
o=t.contentDocument;}
return o;}
function objectfind(f)
{if(typeof(f)=='object')
return f;var p=f.split(/\./);var i=0;var o=window;var t;for(i=0;i<p.length-1&&o&&o.document;i++)
{t=o.document.getElementById(p[i]);if(t.contentWindow)
o=t.contentWindow;else
o=t.contentDocument;}
if(!o||!o.document)
return null;o=o.document.getElementById(p[p.length-1]);return o;}
function frameprint(f)
{var o=framefind(f);if(o.print)
{o.focus();o.print();}
else
{var po='<OBJECT ID="printtrigger" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';o.document.body.insertAdjacentHTML('beforeEnd',po);printtrigger.ExecWB(6,arguments.length>1?arguments[1]:2);printtrigger.outerHTML="";}}
function getrelativepos(o,r)
{a=new Array(o.offsetLeft,o.offsetTop);while(o.offsetParent!=null)
{o=o.offsetParent;a[0]+=o.offsetLeft;a[1]+=o.offsetTop;}
while(r.offsetParent!=null)
{r=r.offsetParent;a[0]-=r.offsetLeft;a[1]-=r.offsetTop;}
return a;}
alertopencount=0;alertclass='';alertvalue='';alertvaluestack=new Array();alertresult=-1;alertflashtimer=null;alertflashcount=0;alertwindowscroll=null;alertbodyscroll=null;alertbodyresize=null;alertpreclosehandlers=new Array();alertreserve=0;alertreserveopencount=0;function alertopen(m,c,v,bl,bt)
{if(alertopencount<=alertreserve)
alertopencount=alertreserve+1;else
alertopencount++;var ba=new Array();for(var i=3;i<arguments.length;i++)
ba[i-3]=arguments[i];return alertopenid(alertopencount,m,c,v,ba);}
function alertopenreserve(an,m,c,v)
{alertreserveopencount=an;alertopencount=an;var ba=new Array();return alertopenid(an,m,c,v,ba);}
function alertopenid(an,m,c,v,ba)
{var fo=document.body;var so=document.documentElement;var o=document.getElementById('alert'+an);var o1=document.getElementById('alertpopup'+an);var o2=document.getElementById('alertpopuptext'+an);var o3=document.getElementById('alertpopupbuttons'+an);var ifr=document.getElementById('alertshim'+an);var bo=document.getElementById('alertbutton');var b=bo.innerHTML;var bd='';var i=0;if(an>alertreserve)
for(i=2;i<=ba.length;i+=2)
{bd=bd+b.replace(/alert_button_id /g,'alert_button_id'+(i/2)).replace(/alert_button_label /g,ba[i-2]).replace(/alert_button_handler /g,'alertclose('+(i/2)+',\''+ba[i-1].replace(/\'/g,'\\\'')+'\'); return false;');}
alertclass=c;if(c>'')
classadd(o,c);alertvalue=v;alertvaluestack[an-1]=v;alertpreclosehandlers=new Array();ifr.style.width=document.body.offsetWidth+'px';ifr.style.height=document.body.offsetHeight+'px';ifr.style.display='block';o1.style.display="block";if(an>alertreserve)
{o2.innerHTML=m;o3.innerHTML=bd;}
var w=so.scrollLeft+Math.round((so.clientWidth-o.offsetWidth)/2);var h=so.scrollTop+Math.round((so.clientHeight-o1.offsetHeight)/2);o.style.left=w+"px";o.style.top=h+"px";if((alertopencount==alertreserve+1&&alertreserveopencount==0)||(alertopencount<=alertreserve&&alertreserveopencount>0))
{alertwindowscroll=window.onscroll;window.onscroll=alertscroll2;alertbodyscroll=document.body.onscroll;document.body.onscroll=alertscroll;alertbodyresize=document.body.onresize;document.body.onresize=alertresize;}
alertresult=-1;return 0;}
function alertclose(b,fn)
{var o=document.getElementById('alert'+alertopencount);var o1=document.getElementById('alertpopup'+alertopencount);var o2=document.getElementById('alertpopuptext'+alertopencount);var ifr=document.getElementById('alertshim'+alertopencount);if(alertpreclosehandlers[b]!=null)
if(eval(alertpreclosehandlers[b])==false)
return false;if(alertopencount<alertreserve)
o2.innerHTML='';o1.style.display='none';ifr.style.display='none';if(alertclass>'')
classsub(o,alertclass);alertresult=b;alertopencount--;if(alertopencount==alertreserve)
alertopencount=alertreserveopencount;else if(alertopencount<alertreserve)
{alertopencount=0;alertreserveopencount=0;}
if(alertopencount==0)
{window.onscroll=alertwindowscroll;alertwindowscroll=null;document.body.onscroll=alertbodyscroll;alertbodyscroll=null;document.body.onresize=alertbodyresize;alertbodyresize=null;}
if(fn>'')
{fno=eval(fn);if(typeof(fno)=='function')
fno(b,alertvalue);}
if(alertopencount>0)
alertvalue=alertvaluestack[alertopencount-1];else
alertvalue='';return false;}
function alertsetpreclose(b,fn)
{if(typeof(fn)=='function')
alertpreclosehandlers[b]='return '+fn.toString()+'('+b+');';else
alertpreclosehandlers[b]=fn;}
function alertposition(m)
{var an=(arguments.length>1)?arguments[1]:alertopencount;var so=document.documentElement;var o=document.getElementById('alert'+an);var o1=document.getElementById('alertpopup'+an);var w=so.scrollLeft+Math.round((so.clientWidth-o.offsetWidth)/2);var h=so.scrollTop+Math.round((so.clientHeight-o1.offsetHeight)/2);o.style.left=w+"px";o.style.top=h+"px";if(m)
{var ifr=document.getElementById('alertshim'+an);ifr.style.width=document.body.offsetWidth+'px';ifr.style.height=document.body.offsetHeight+'px';ifr.style.display='block';}}
function alertscroll()
{var i;for(i=alertopencount;i>=1;i--)
alertposition(0,i);if(alertbodyscroll!=null)
alertbodyscroll();}
function alertscroll2()
{var i;for(i=alertopencount;i>=1;i--)
alertposition(0,i);if(alertwindowscroll!=null)
alertwindowscroll();}
function alertresize()
{var i;for(i=alertopencount;i>=1;i--)
alertposition(1,i);if(alertbodyresize!=null)
alertbodyresize();}
function alertflash()
{if(alertflashcount%2)
classadd('alertshim'+alertopencount,'flash');else
classsub('alertshim'+alertopencount,'flash');alertflashcount++;if(alertflashcount==3)
{window.clearInterval(alertflashtimer);alertflashtimer=null;}}
function alertshimclick()
{if(alertopencount<=0)
return false;if(alertflashtimer)
window.clearInterval(alertflashtimer);alertflashcount=0;classadd('alertshim'+alertopencount,'flash');alertflashtimer=window.setInterval(alertflash,100);return false;}
function alertactionlink(b,v)
{objectfind(v).click();alertresult=-1;}
function alertactionsubmit(b,v)
{objectfind(v).submit();alertresult=-1;}
function alertactioncancel(b,v)
{alertresult=-1;}
if(typeof(HTMLElement)!='undefined')
{HTMLElement.prototype.click=function()
{var e=this.ownerDocument.createEvent('MouseEvents');e.initMouseEvent('click',true,true,this.ownerDocument.defaultView,1,0,0,0,0,false,false,false,false,0,null);if(this.dispatchEvent(e)&&this.tagName&&this.tagName=='A'&&this.href)
relocate(this.href,window,this.target?this.target:'_self');}}
function getfield(f,ff)
{var fv="";if(document.forms[f][ff].type==null)
{for(i=0;i<document.forms[f][ff].length;i++)
if(document.forms[f][ff][i].checked)
{fv=document.forms[f][ff][i].value;break;}}
else if(document.forms[f][ff].type=="checkbox")
{if(document.forms[f][ff].checked)
fv=document.forms[f][ff].value;}
else if(document.forms[f][ff].type=="select-one")
if(document.forms[f][ff].selectedIndex==-1)
fv="";else
fv=document.forms[f][ff].options[document.forms[f][ff].selectedIndex].value;else
fv=document.forms[f][ff].value;fv=fv.replace(/\s+$/,"");fv=fv.replace(/^\s+/,"");return fv;}
function adderrormsg(et,f,ff,fl,mn,mx)
{var ffl=ff.split(/,/);var i;var m;if(arguments.length>6)
ff=arguments[6];if(errortemplates[f]!=null&&errortemplates[f][ff]!=null&&errortemplates[f][ff][et]!=null)
{m=errortemplates[f][ff][et];}
else if(errortemplates.base[et]!=null)
m=errortemplates.base[et];else
m=et;m=m.replace(/%%f%%/g,fl);m=m.replace(/%%min%%/g,mn);m=m.replace(/%%max%%/g,mx);for(i=0;i<ffl.length;i++)
if(errorfields[ffl[i]]==null)
errorfields[ffl[i]]=m+"|";else if(errorfields[ffl[i]].indexOf(m+"|")<0)
errorfields[ffl[i]]=errorfields[ffl[i]]+m+"|";if(errorarray[m]==null)
{errorarray[m]=1;if(errormsgs!="")
errormsgs=errormsgs+"|"+m;else
errormsgs=m;}}
function validaterequiredfield(f,ff)
{var fv=getfield(f,ff);if(fv=="")
adderrormsg("required",f,ff,fieldlabels[f][ff]);}
function validateminlength(f,ff,mn)
{var fv=getfield(f,ff);if(fv!=""&&errorfields[ff]==null)
if(fv.length<mn)
adderrormsg("minlength",f,ff,fieldlabels[f][ff],mn);}
function validatemaxlength(f,ff,mx)
{var fv=getfield(f,ff);if(fv!=""&&errorfields[ff]==null)
if(fv.length>mx)
adderrormsg("maxlength",f,ff,fieldlabels[f][ff],"",mx);}
function validaterangelength(f,ff,mn,mx)
{var fv=getfield(f,ff);if(fv!=""&&errorfields[ff]==null)
if(fv.length<mn||fv.length>mx)
adderrormsg("minmaxlength",f,ff,fieldlabels[f][ff],mn,mx);}
function validateminvalue(f,ff,mn)
{var fv=getfield(f,ff);if(fv!=""&&errorfields[ff]==null)
{fv=parseFloat(fv);if(isNaN(fv)||fv<mn)
adderrormsg("minvalue",f,ff,fieldlabels[f][ff],mn);}}
function validatemaxvalue(f,ff,mx)
{var fv=getfield(f,ff);if(fv!=""&&errorfields[ff]==null)
{fv=parseFloat(fv);if(isNaN(fv)||fv>mx)
adderrormsg("maxvalue",f,ff,fieldlabels[f][ff],"",mx);}}
function validaterange(f,ff,mn,mx)
{var fv=getfield(f,ff);if(fv!=""&&errorfields[ff]==null)
{fv=parseFloat(fv);if(isNaN(fv)||fv<mn||fv>mx)
adderrormsg("minmaxvalue",f,ff,fieldlabels[f][ff],mn,mx);}}
function validatealpha(f,ff)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^[A-Za-z]+$/)==-1)
adderrormsg("invalidalpha",f,ff,fieldlabels[f][ff]);}
function validatealphanumeric(f,ff)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^[- .,'`\/A-Za-z0-9]+$/)==-1)
adderrormsg("invalidalphanumeric",f,ff,fieldlabels[f][ff]);}
function validatealphaspace(f,ff)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^[ A-Za-z]+$/)==-1)
adderrormsg("invalidalphaspace",f,ff,fieldlabels[f][ff]);}
function validatecolor(f,ff,ws)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^[0-9a-fA-F]{6,6}$/)==-1)
adderrormsg("invalidcolor",f,ff,fieldlabels[f][ff]);else if(ws>0&&fv.search(/^(00|33|66|99|cc|ff)(00|33|66|99|cc|ff)(00|33|66|99|cc|ff)$/i)==-1)
adderrormsg("notwebsafe",f,ff,fieldlabels[f][ff]);}
colorpopupvisible=false;colorpopupvisibletimer=false;colorpopupvisiblekeep=false;colorpopupvisibleform=null;colorpopupvisiblefield=null;colorpopupvisiblebox=null;colorpopupvisiblecolor='';colorpopupdragstate=0;colorpopupsuggest=null;function colorpopup_dragstart(o,s)
{if(o.setCapture!=null)
o.setCapture();colorpopupdragstate=s;}
function colorpopup_dragend(o)
{if(o.releaseCapture!=null)
o.releaseCapture();colorpopupdragstate=0;}
function colorpopup_focus(f,ff,ws,tb,lr,sug)
{if(colorpopupvisible)
colorpopup_doblur();if(colorpopupvisibletimer!=null)
window.clearTimeout(colorpopupvisibletimer);var fo=document.forms[f][ff];if(fo.length!=null)
fo=fo[fo.length-1];var fv=getfield(f,ff);var o=document.getElementById('formcolorpopup');var w=fo.offsetWidth;var h=fo.offsetHeight;var a=getrelativepos(fo,o);o.style.left=a[0]+"px";o.style.top=(a[1]+h)+"px";colorpopupvisibleform=f;colorpopupvisiblefield=ff;colorpopupvisiblebox=(tb>0)?ff+'color':'';errorpopupissecondary=true;document.getElementById('colorpopuptitle').innerHTML=fieldlabels[f][ff];colorpopup_reset(fv,-1);if(sug)
{var sa=suggest(f,ff,colorpopup_suggestdata[f][ff]);var i=0;for(i=0;i<10;i++)
{if(i>=sa.length)
document.getElementById('colorpopupsuggested'+i).style.display='none';else
{sa[i]="000000"+sa[i].toString(16);document.getElementById('colorpopupsuggested'+i).style.backgroundColor='#'+sa[i].substr(sa[i].length-6);document.getElementById('colorpopupsuggested'+i).style.display='';}}
colorpopupsuggest=sa;}
o.style.display="block";if(lr)
o.style.left=(a[0]+w-o.offsetWidth)+"px";if(sug&&sa.length>0)
document.getElementById('colorpopupsuggest').style.display='block';else
document.getElementById('colorpopupsuggest').style.display='none';var o2=document.getElementById('formcolorpopuptext');var ifr=document.getElementById('formcolorpopupshim');ifr.style.left=o.style.left;ifr.style.top=o.style.top;ifr.style.width=o.offsetWidth+'px';ifr.style.height=o.offsetHeight+'px';ifr.style.display='block';}
function colorpopup_blur()
{if(colorpopupvisibletimer!=null)
window.clearTimeout(colorpopupvisibletimer);colorpopupvisibletimer=window.setTimeout(colorpopup_doblur,100);}
function colorpopup_doblur()
{if(!colorpopupvisiblekeep)
{document.getElementById('formcolorpopup').style.display='none';document.getElementById('formcolorpopupshim').style.display='none';colorpopupvisible=false;if(colorpopupdragstate>0)
colorpopupdragstate=0;}
colorpopupvisibletimer=null;}
function colorpopup_forceblur()
{colorpopupvisiblekeep=false;colorpopup_blur();}
function colorpopup_reset(fv,q)
{var rgb=parseInt(fv,16);if(isNaN(rgb)||fv.length<6)
return;var hsl=rgb2hsl(rgb);var h=(hsl&0xFF0000)>>16;var s=(hsl&0x00FF00)>>8;var l=(hsl&0x0000FF);if(q>=0)
h=q;var cs1=document.getElementById('colorselector1');var cs2=document.getElementById('colorselector2');var h1=Math.floor(h/42.5);var h2=Math.floor(h-h1*42.5);var y1=-128*h1;var y2=y1-128;cs1.style.backgroundPosition="0px "+y1+"px";cs2.style.backgroundPosition="0px "+y2+"px";if(cs2.style.filter!=null)
cs2.style.filter="alpha(opacity="+(h2*100/42.5)+")";else
cs2.style.opacity=h2/42.5;var cp=document.getElementById('colorpointer');var ct=document.getElementById('colortriangle');cp.style.left=(-3+Math.floor(s/2))+"px";cp.style.top=(124-Math.floor(l/2))+"px";if(q<0)
ct.style.top=(-4+Math.floor(h/2))+"px";if(colorpopupvisiblebox>'')
document.getElementById(colorpopupvisiblebox).style.backgroundColor='#'+fv;}
function colorpopup_select1(o,e)
{var x=e.offsetX==null?e.layerX-1:e.offsetX;var y=e.offsetY==null?e.layerY-1:e.offsetY;var s=Math.min(Math.max((x-4)*2,0),255);var l=255-Math.min(Math.max((y-4)*2,0),255);var h=(document.getElementById('colortriangle').offsetTop+4)*2;var hsl=(h<<16)|(s<<8)|l;var rgb=hsl2rgb(hsl);var fv="000000"+rgb.toString(16);fv=fv.substr(fv.length-6);document.forms[colorpopupvisibleform][colorpopupvisiblefield].value=fv;var cp=document.getElementById('colorpointer');cp.style.left=(-3+Math.floor(s/2))+"px";cp.style.top=(124-Math.floor(l/2))+"px";if(colorpopupvisiblebox>'')
document.getElementById(colorpopupvisiblebox).style.backgroundColor='#'+fv;colorpopupvisiblekeep=false;e.cancelBubble=true;}
function colorpopup_select2(o,e)
{var y=e.offsetY==null?e.layerY-1:e.offsetY;var h=Math.min(Math.max((y-1)*2,0),255);var s=(document.getElementById('colorpointer').offsetLeft+3)*2;var l=255-(document.getElementById('colorpointer').offsetTop+3)*2;var hsl=(h<<16)|(s<<8)|l;var rgb=hsl2rgb(hsl);var fv="000000"+rgb.toString(16);fv=fv.substr(fv.length-6);document.forms[colorpopupvisibleform][colorpopupvisiblefield].value=fv;var ct=document.getElementById('colortriangle');ct.style.top=(-4+Math.floor(h/2))+"px";colorpopup_reset(fv,h);colorpopupvisiblekeep=false;e.cancelBubble=true;}
function colorpopup_select3(idx,e)
{var rgb=colorpopupsuggest[idx];var fv="000000"+rgb.toString(16);fv=fv.substr(fv.length-6);document.forms[colorpopupvisibleform][colorpopupvisiblefield].value=fv;colorpopup_reset(fv,-1);e.cancelBubble=true;}
function rgb2hsl(rgb)
{var r=(rgb&0xFF0000)>>16;var g=(rgb&0x00FF00)>>8;var b=(rgb&0x0000FF);var h,s,l;var i=Math.max(Math.max(r,g),b);var j=Math.min(Math.min(r,g),b);l=Math.round((i+j)/2);if(i==j)
{h=0;s=0;}
else
{if(l<128)
s=Math.round(255.0*(i-j)/(i+j));else
s=Math.round(255.0*(i-j)/(510-i-j));if(r==i)
h=Math.round(42.5*(g-b)/(i-j));else if(g==i)
h=Math.round(42.5*(b-r)/(i-j)+85.0);else
h=Math.round(42.5*(r-g)/(i-j)+170.0);}
return(h<<16|s<<8|l);}
function hsl2rgb(hsl)
{var h=(hsl&0xFF0000)>>16;var s=(hsl&0x00FF00)>>8;var l=(hsl&0x0000FF);var r,g,b;if(s==0)
{r=l;g=l;b=l;}
else
{if(l<128)
j=l+l*s/255;else
j=l+s-l*s/255;i=(l<<1)-j;j-=i;b=hslcycle((h+170)&0xFF)*j/255+i;g=hslcycle((h)&0xFF)*j/255+i;r=hslcycle((h+85)&0xFF)*j/255+i;}
return(r<<16|g<<8|b);}
function hslcycle(h)
{if(h<43)
return Math.round(255.0*h/42.5);else if(h<128)
return 255;else if(h<170)
return Math.round(255.0*(170.0-h)/42.5);else
return 0;}
function getcardtype(fv)
{if(fv.search(/^4/)==0)
return'visa';if(fv.search(/^5[1-5]/)==0)
return'mc';if(fv.search(/^3[47]/)==0)
return'amex';if(fv.search(/^3(0[0-5]|6|8)/)==0)
return'diners';if(fv.search(/^6011/)==0)
return'disc';return'unknown';}
function validatecardchecksum(fv)
{var s=0;var j=0;for(j=0;j<fv.length;j++)
if(j%2==0)
s=s+(fv.charCodeAt(fv.length-j-1)-48);else if(fv.charAt(fv.length-j-1)>='5')
s=s+1+(fv.charCodeAt(fv.length-j-1)-48)*2-10;else
s=s+(fv.charCodeAt(fv.length-j-1)-48)*2;return(s%10==0);}
function validatecardnum(f,ff,tl)
{var fv=getfield(f,ff);var t=getcardtype(fv);var ta=tl.split(/,/);if(fv!="")
{fv=fv.replace(/[^0-9]/g,"");var i=0;for(i=0;i<ta.length;i++)
if(t==ta[i])
break;if(i>=ta.length)
{adderrormsg("invalidcardtype",f,ff,fieldlabels[f][ff]);return;}
i=0;switch(t)
{case"visa":if(fv.length==16||fv.length==13)
i=1;break;case"mc":if(fv.length==16)
i=1;break;case"amex":if(fv.length==15)
i=1;break;case"diners":if(fv.length==14)
i=1;break;case"disc":if(fv.length==16)
i=1;break;}
if(i==0||!validatecardchecksum(fv))
{adderrormsg("invalidcardnum",f,ff,fieldlabels[f][ff]);return;}}}
function validatecvv2(f,ff,cc)
{var fv=getfield(f,cc);var t=getcardtype(fv);fv=getfield(f,ff);if(fv!=""&&errorfields[cc]==null)
if((t=='amex'&&fv.length!=4)||(t!='amex'&&fv.length!=3))
{adderrormsg("invalidcvv2",f,ff,fieldlabels[f][ff]);}}
function isleapyear(y)
{if(y%4==0&&(y%400==0||y%100!=0))
return true;else
return false;}
function sortdate(dv,fmt,by)
{var t;if(fmt==0||dv[0].toString().length==4);else if(fmt==1||dv[0]>12)
{t=dv[0];dv[0]=dv[2];dv[2]=t;}
else
{t=dv[2];dv[2]=dv[1];dv[1]=dv[0];dv[0]=t;}
if(dv[0]<(by-1900))
dv[0]=dv[0]+2000;else if(dv[0]<100)
dv[0]=dv[0]+1900;return dv;}
function formatdate(dv,fmt)
{if(fmt==0)
return dv[0]+'-'+dv[1]+'-'+dv[2];else if(fmt==1)
return dv[2]+'/'+dv[1]+'/'+dv[0];else
return dv[1]+'/'+dv[2]+'/'+dv[0];}
function validatedatecore(f,ff,fl,dv,by,future,db,dbs,mna,mxa)
{var now;var then;var dm=new Array(31,28,31,30,31,30,31,31,30,31,30,31);if(dv.length>=2)
if(isleapyear(dv[0]))
dm[1]=29;if(dv.length!=3||dv[1]<1||dv[1]>12||dv[2]<1||dv[2]>dm[dv[1]-1])
{adderrormsg("invaliddate",f,ff,fl);return;}
then=new Date(dv[0],dv[1]-1,dv[2]);if(future!=0)
{if(db!=null)
{now=new Date(db[0],dv[1]-1,dv[2]);if(future<0&&now<then)
adderrormsg("needdatebefore",f,ff,fl,dbs);else if(future>0&&now>then)
adderrormsg("needdateafter",f,ff,fl,dbs);}
else
{now=new Date();if(future<0&&now<then)
adderrormsg("needpastdate",f,ff,fl);else if(future>0&&now>then)
adderrormsg("needfuturedate",f,ff,fl);}}
if(mna>0)
{now=new Date();now.setFullYear(now.getFullYear()-mna);if(then>now)
adderrormsg("minage",f,ff,fl,mna);}
if(mxa>0)
{now=new Date();now.setFullYear(now.getFullYear()-mxa);if(then<now)
adderrormsg("maxage",f,ff,fl,mxa);}}
function validatedate(f,ff,fmt,by,future,dbs,mna,mxa)
{var t;var db;var fv=getfield(f,ff);if(fv!="")
{var dv=fv.split(/[-.\/]/);dv[0]=parseInt(dv[0],10);dv[1]=parseInt(dv[1],10);dv[2]=parseInt(dv[2],10);if(dbs!=null)
db=dbs.split(/[-.\/]/);else
db=null;if(isNaN(dv[0])||isNaN(dv[1])||isNaN(dv[2]))
adderrormsg("invaliddate",f,ff,fieldlabels[f][ff]);else
{dv=sortdate(dv,fmt,by);validatedatecore(f,ff,fieldlabels[f][ff],dv,by,future,db,dbs,mna,mxa);if(errorfields[ff]==null||errorfields[ff]<='')
document.forms[f][ff].value=formatdate(dv,fmt);}}}
datepopupvisible=false;datepopupvisibletimer=false;datepopupvisiblekeep=false;datepopupvisiblemonth=0;datepopupvisibleyear=0;datepopupvisibleform=null;datepopupvisiblefield=null;datepopupvisibledate='';function datepopup_focus(f,ff,fmt,by)
{if(datepopupvisible)
datepopup_doblur();if(datepopupvisibletimer!=null)
window.clearTimeout(datepopupvisibletimer);var fo=document.forms[f][ff];if(fo.length!=null)
fo=fo[fo.length-1];var fv=getfield(f,ff);var dv=fv.split(/[-.\/]/);dv[0]=parseInt(dv[0]);dv[1]=parseInt(dv[1]);dv[2]=parseInt(dv[2]);fv=new Date();if(isNaN(dv[0])||isNaN(dv[1])||isNaN(dv[2]))
{dv=new Array(fv.getFullYear(),fv.getMonth()+1,fv.getDate());datepopupvisibledate='';}
else
{dv=sortdate(dv,fmt,by);datepopupvisibledate=formatdate(dv,0);}
if(dv[1]<1||dv[1]>12)
dv[1]=fv.getMonth()+1;var o=document.getElementById('formdatepopup');var w=fo.offsetWidth;var h=fo.offsetHeight;var a=getrelativepos(fo,o);o.style.left=a[0]+"px";o.style.top=(a[1]+h)+"px";document.getElementById('datepopuptitle').innerHTML=fieldlabels[f][ff];datepopup_reset(dv[0],dv[1]);o.style.display="block";datepopupvisibleform=f;datepopupvisiblefield=ff;errorpopupissecondary=true;var o2=document.getElementById('formdatepopuptext');var ifr=document.getElementById('formdatepopupshim');ifr.style.left=o.style.left;ifr.style.top=o.style.top;ifr.style.width=o.offsetWidth+'px';ifr.style.height=o.offsetHeight+'px';ifr.style.display='block';}
function datepopup_blur()
{if(datepopupvisibletimer!=null)
window.clearTimeout(datepopupvisibletimer);datepopupvisibletimer=window.setTimeout(datepopup_doblur,100);}
function datepopup_doblur()
{if(!datepopupvisiblekeep)
{document.getElementById('formdatepopup').style.display='none';document.getElementById('formdatepopupshim').style.display='none';datepopupvisible=false;}
datepopupvisibletimer=null;}
function datepopup_forceblur()
{datepopupvisiblekeep=false;datepopup_blur();}
function datepopup_reset(dvy,dvm)
{var dl="January,February,March,April,May,June,July,August,September,October,November,December".split(/,/);var dm=new Array(31,28,31,30,31,30,31,31,30,31,30,31);if(isleapyear(dvy))
dm[1]=29;document.forms.datepopup.datepopupmonth.selectedIndex=dvm-1;document.forms.datepopup.datepopupyear.value=dvy;document.getElementById('datepopupcurrentmonth').innerHTML=dl[dvm-1]+", "+dvy;var fv=new Date(dvy,dvm-1,1);if(fv.getDay()<2)
fv.setDate(fv.getDate()-7-fv.getDay());else
fv.setDate(1-fv.getDay());var i;var j;var o;for(i=1;i<=6;i++)
{o=document.getElementById('datepopuprow'+i);o=o.firstChild;for(j=1;j<=7;j++)
{if(fv.getFullYear()+'-'+(fv.getMonth()+1)+'-'+fv.getDate()==datepopupvisibledate)
o.className='selecteddate';else if(fv.getMonth()<dvm-1)
o.className='prevmonth';else if(fv.getMonth()==dvm-1)
o.className='thismonth';else
o.className='nextmonth';o.firstChild.innerHTML=fv.getDate();fv.setDate(fv.getDate()+1);o=o.nextSibling;}}
datepopupvisibleyear=dvy;datepopupvisiblemonth=dvm;}
function datepopup_update()
{datepopup_reset(getfield('datepopup','datepopupyear'),getfield('datepopup','datepopupmonth'));}
function datepopup_today()
{var fv=new Date;var dv=new Array(fv.getFullYear(),fv.getMonth()+1,fv.getDate());document.forms[datepopupvisibleform][datepopupvisiblefield].value=formatdate(dv,2);datepopupvisibledate=formatdate(dv,0);datepopup_reset(fv.getFullYear(),fv.getMonth()+1);}
function datepopup_prev()
{if(datepopupvisiblemonth==1)
datepopup_reset(datepopupvisibleyear-1,12);else
datepopup_reset(datepopupvisibleyear,datepopupvisiblemonth-1);}
function datepopup_next()
{if(datepopupvisiblemonth==12)
datepopup_reset(datepopupvisibleyear+1,1);else
datepopup_reset(datepopupvisibleyear,datepopupvisiblemonth+1);}
function datepopup_select(o)
{var fv=new Date(datepopupvisibleyear,datepopupvisiblemonth-1,1);if(fv.getDay()<2)
fv.setDate(fv.getDate()-7);else
fv.setDate(1-fv.getDay());fv.setDate(fv.getDate()+o);var dv=new Array(fv.getFullYear(),fv.getMonth()+1,fv.getDate());document.forms[datepopupvisibleform][datepopupvisiblefield].value=formatdate(dv,2);datepopupvisibledate=formatdate(dv,0);datepopup_reset(fv.getFullYear(),fv.getMonth()+1);}
function validateemail(f,ff,nd,rd)
{var fv=getfield(f,ff);if(fv!="")
{var ev=fv.split("@");if(nd==1&&ev.length!=1)
{adderrormsg("invalidemailnodomain",f,ff,fieldlabels[f][ff],fv.replace(/\|/g,''));return;}
var v=false;var r=false;if((ev.length==2&&nd==0)||(ev.length==1&&nd==1))
if(ev[0].search(/^[-!#-'*+\/-9?A-Z_-{}~]([-!#-'*+\.\/-9?A-Z_-{}~]*[-!#-'*+\/-9?A-Z_-{}~])?$/)==0)
if(nd==1||(ev[1].search(/^[a-zA-Z0-9]([a-zA-Z0-9\.\_\-]*[a-zA-Z0-9])?\.[a-zA-Z]+$/)==0&&ev[1].search(/\.[-_]/)<0&&ev[1].search(/[-_]\./)<0&&ev[1].indexOf("..")<0))
{if(rd==''||ev[1]==rd)
v=true;else
r=true;}
if(!v)
if(r)
adderrormsg("invalidemaildomain",f,ff,fieldlabels[f][ff],fv.replace(/\|/g,''));else
adderrormsg("invalidemail",f,ff,fieldlabels[f][ff]);}}
function validateemaillist(f,ff,nd,rd)
{var fv=getfield(f,ff);var fa=new Array();var ea=new Array();if(fv!="")
{var qs=new Array();var qt=new Array();var i;var j=0;var m=0;var c;var a='';var n='';for(i=0;i<=fv.length;i++)
{c=(i>=fv.length)?-1:fv.charAt(i);if(m==0||m==4)
{if(c=='"')
{qs.push(i);qt.push(m);m=1;n=n+c;}
else if(c=='(')
{qs.push(i);qt.push(m);m=2;}
else if(c=='<')
{qs.push(i);qt.push(m);m=3;n=n+c;if(a!='')
adderrormsg("doubleaddress",f,ff,fieldlabels[f][ff],a.replace(/\|/g,''));}
else if(c==':')
{qs.push(i);qt.push(m);j=i+1;m=4;n='';}
else if(c==','||c==';'||c==-1)
{fa.push(fv.substring(j,i));fa[fa.length-1]=fa[fa.length-1].replace(/\s+$/,"");fa[fa.length-1]=fa[fa.length-1].replace(/^\s+/,"");if(a=='')
ea.push(n);else
ea.push(a);ea[ea.length-1]=ea[ea.length-1].replace(/\s+$/,"");ea[ea.length-1]=ea[ea.length-1].replace(/^\s+/,"");if(fa[fa.length-1]=='')
{fa.pop();ea.pop();}
j=i+1;a='';n='';if(m==4&&c==';')
{qs.pop();m=qt.pop();}}
else
n=n+c;}
else if(m==1)
{if(c=='\\')
{if(i<fv.length-1)
{n=n+c;i++;}
else
adderrormsg("invalidbackslash",f,ff,fieldlabels[f][ff]);}
else if(c=='"')
{if(qs.length==0)
break;qs.pop();m=qt.pop();n=n+c;}
else
n=n+c;}
else if(m==2)
{if(c=='\\')
{if(i<fv.length-1)
i++;else
adderrormsg("invalidbackslash",f,ff,fieldlabels[f][ff]);}
else if(c=='(')
{qs.push(i);qt.push(m);m=2;}
else if(c==')')
{if(qs.length==0)
break;qs.pop();m=qt.pop();}}
else if(m==3)
{if(c=='>')
{if(qs.length==0)
break;m=qt.pop();n=n+c;}
else
a=a+c;}}
if(qt.length>0)
{if(m==1)
adderrormsg("unmatchedquote",f,ff,fieldlabels[f][ff]);else if(m==2)
adderrormsg("unmatchedparenthesis",f,ff,fieldlabels[f][ff]);else if(m==3)
adderrormsg("unmatchedbracket",f,ff,fieldlabels[f][ff]);else if(m==4)
adderrormsg("unmatchedcolon",f,ff,fieldlabels[f][ff]);}
else if(i<fv.length)
adderrormsg("invalidemailitem",f,ff,fieldlabels[f][ff],ff);else
{for(i=0;i<ea.length;i++)
{var na=(ea[i]==fa[i]);var ev=ea[i].split("@");var v=false;var r=false;var n=false;if(nd==1&&ev.length!=1)
n=true;else if((ev.length==2&&nd==0)||(ev.length==1&&nd==1))
if(ev[0].search(/^[-!#-'*+\/-9?A-Z_-{}~]([-!#-'*+\.\/-9?A-Z_-{}~]*[-!#-'*+\/-9?A-Z_-{}~])?$/)==0)
if(nd==1||(ev[1].search(/^[a-zA-Z0-9]([a-zA-Z0-9\.\_\-]*[a-zA-Z0-9])?\.[a-zA-Z]+$/)==0&&ev[1].search(/\.[-_]/)<0&&ev[1].search(/[-_]\./)<0&&ev[1].indexOf("..")<0))
{if(rd==''||ev[1]==rd)
v=true;else
r=true;}
if(!v)
if(r)
adderrormsg("invalidemaildomain",f,ff,fieldlabels[f][ff],ea[i].replace(/\|/g,''));else if(n)
adderrormsg("invalidemailnodomain",f,ff,fieldlabels[f][ff],ea[i].replace(/\|/g,''));else if(na)
adderrormsg("invalidemailitem",f,ff,fieldlabels[f][ff],ea[i].replace(/\|/g,''));else
adderrormsg("invalidemailaddress",f,ff,fieldlabels[f][ff],ea[i].replace(/\|/g,''));}}}}
function validateinteger(f,ff)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^-?(0|([1-9][0-9]*))$/)==-1)
adderrormsg("notinteger",f,ff,fieldlabels[f][ff]);}
function validateip(f,ff,fmtl,nl,tlds,mn,mx)
{var fv=getfield(f,ff);var fmta=fmtl.split(/,/);if(fv!="")
{var i=0;var j=0;var fva=fv.toLowerCase().split('.');var v=false;var em='invalidip';for(i=0;i<fmta.length;i++)
{switch(fmta[i])
{case'ip':if(fva.length==4)
{v=true;for(j=0;j<4;j++)
if(fva[j].search(/^[0-9]{1,3}$/)==-1||isNaN(parseInt(fva[j]))||fva[j]<0||fva[j]>255)
{v=false;em='invalidip';}
if(v&&nl)
{if(fva[0]==10||(fva[0]==172&&fva[1]>=16&&fva[1]<=31)||(fva[0]==192&&fva[1]==168))
{v=false;em='nolocalip';}}}
else
em='invalidip';break;case'fqdn':if(fv.search(/[a-zA-Z]/)>=0)
{v=true;for(j=0;j<fva.length;j++)
{if(fva[j].search(/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/)==-1)
{v=false;em='invaliddomainname';}}
if(v)
{if(tlds>'')
validatetld(f,ff,tlds,mn,mx);else if(mn>0&&mx>0&&(fva.length<mn||fva.length>mx))
adderrormsg('domainparts',f,ff,fieldlabels[f][ff],mn,mx);else if(mn>0&&fva.length<mn)
adderrormsg('domainminparts',f,ff,fieldlabels[f][ff],mn,mx);else if(mx>0&&fva.length>mx)
adderrormsg('domainmaxparts',f,ff,fieldlabels[f][ff],mn,mx);}}
break;case'hostname':if(fva.length!=1||fva[0].search(/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/)==-1)
em='invalidhostname';else
v=true;break;}
if(v)
break;}
if(!v)
adderrormsg(em,f,ff,fieldlabels[f][ff]);}}
function validatetld(f,ff,tlds,mn,mx)
{var fv=getfield(f,ff);var ta=tlds.split(/,/);var i=0;if(errorfields[ff]!=null)
return;for(i=0;i<ta.length;i++)
if(fv.substr(fv.length-ta[i].length)==ta[i])
break;if(i==ta.length)
adderrormsg('invalidtld',f,ff,fieldlabels[f][ff]);else
{var fva=fv.split(/\./);var tlda=ta[i].substr(1).split(/\./);var c=fva.length-tlda.length;if((c<mn&&mn>0)||(c>mx&&mx>0))
adderrormsg('nosubdomain',f,ff,fieldlabels[f][ff],mn+tlda.length,mx+tlda.length);}}
function validatelist(f,ff,l,m,inv,ig)
{var fv=getfield(f,ff);if(fv!="")
{if(m)
fa=fv.split(/,/);else
{fa=new Array();fa[0]=fv;}
l=l.split(/\|/);var i=0;var j=0;for(j=0;j<fa.length;j++)
{for(i=0;i<l.length;i++)
if((!ig&&fa[j]==l[i])||(ig&&fa[j].toLowerCase()==l[i].toLowerCase()))
break;if(inv&&i<l.length)
{adderrormsg("invalidinvertedlist",f,ff,fieldlabels[f][ff],fa[j]);return;}
else if(!inv&&i>=l.length)
{adderrormsg((m?"invalidmultiplelist":"invalidlist"),f,ff,fieldlabels[f][ff],fa[j]);return;}}}}
function validatename(f,ff)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^[- .,'`\/#:&A-Za-z0-9À-öø-ÿ]+$/)==-1)
adderrormsg("invalidname",f,ff,fieldlabels[f][ff]);}
function validatenumeric(f,ff)
{var fv=getfield(f,ff);if(fv!="")
{if(fv.search(/^-?(0|([1-9][0-9]*))(\.[0-9]+)?$/)==-1)
adderrormsg("notnumeric",f,ff,fieldlabels[f][ff]);else if(arguments.length>2)
{pr=arguments[2];fv=parseFloat(fv);if(isNaN(fv)||Math.abs(fv/pr-Math.round(fv/pr))>0.0000001)
adderrormsg("notprecise",f,ff,fieldlabels[f][ff],pr);else
{fv=Math.round(10000*fv/pr)*pr*0.0001;document.forms[f][ff].value=fv;}}}}
function validatepassword(f,ff)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^[a-zA-Z0-9][-!"#$%&*()+,.\/:;@^_~a-zA-Z0-9]*$/)==-1)
adderrormsg("invalidpassword",f,ff,fieldlabels[f][ff]);}
function validatephone(f,ff,fmt)
{var fv=getfield(f,ff);if(fv!="")
if(fmt)
{if(fv.search(/^[0-9]{10,10}$/)!=0)
adderrormsg("invalidphone",f,ff,fieldlabels[f][ff]);}
else
{if(fv.search(/^\+?[0-9]+$/)!=0)
adderrormsg("invalidphone",f,ff,fieldlabels[f][ff]);}}
function validateregex(f,ff,r,et)
{var fv=getfield(f,ff);if(fv!="")
{regex=new RegExp(r);if(fv.search(regex)==-1)
adderrormsg(et,f,ff,fieldlabels[f][ff]);}}
function validatessn(f,ff)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^[0-9]{3,3}-?[0-9]{2,2}-?[0-9]{4,4}$/)!=0)
adderrormsg("invalidssn",f,ff,fieldlabels[f][ff]);}
function validateurl(f,ff)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^https?:\/\/[a-zA-Z0-9]([\-\.\_a-zA-Z0-9]*[a-zA-Z0-9])?\.[a-zA-Z]+(\/.*)?$/)==-1)
adderrormsg("invalidurl",f,ff,fieldlabels[f][ff]);}
function validateusername(f,ff)
{var fv=getfield(f,ff);if(fv!="")
if(fv.search(/^[a-zA-Z]([-_a-zA-Z0-9]*[a-zA-Z0-9])?$/)==-1)
adderrormsg("invalidusername",f,ff,fieldlabels[f][ff]);}
function validatedateorder(f,ff,ffl,fmtl,byl)
{var fa=ffl.split(/,/);var fmta=fmtl.split(/,/);var bya=byl.split(/,/);var dva=new Array(3);var fv;for(i=0;i<fa.length;i++)
if(errorfields[fa[i]]!=null)
return;else
{fv=getfield(f,fa[i]);if(fv<='')
return;dva[i]=fv.split(/[-.\/]/);dva[i][0]=parseInt(dva[i][0]);dva[i][1]=parseInt(dva[i][1]);dva[i][2]=parseInt(dva[i][2]);dva[i]=sortdate(dva[i],fmta[i],bya[i]);}
if(fa.length==3)
{if((dva[0][0]>dva[1][0]||(dva[0][0]==dva[1][0]&&dva[0][1]>dva[1][1])||(dva[0][0]==dva[1][0]&&dva[0][1]==dva[1][1]&&dva[0][2]>dva[1][2]))||(dva[1][0]>dva[2][0]||(dva[1][0]==dva[2][0]&&dva[1][1]>dva[2][1])||(dva[1][0]==dva[2][0]&&dva[1][1]==dva[2][1]&&dva[1][2]>dva[2][2])))
{adderrormsg("invaliddatebetween",f,ffl,fieldlabels[f][fa[1]],fieldlabels[f][fa[0]],fieldlabels[f][fa[2]],ff);}}
else if(fa.length==2)
{if((dva[0][0]>dva[1][0]||(dva[0][0]==dva[1][0]&&dva[0][1]>dva[1][1])||(dva[0][0]==dva[1][0]&&dva[0][1]==dva[1][1]&&dva[0][2]>dva[1][2])))
{adderrormsg("invaliddateorder",f,ffl,fieldlabels[f][fa[0]],fieldlabels[f][fa[1]],ff);}}}
function validatedepends(f,ff,ffl,dol,ce)
{var fa=ffl.split(/,/);var da=dol.split(/,/);var i;var j=0;var k=-1;var fv;for(i=0;i<fa.length;i++)
if(errorfields[fa[i]]!=null)
return;for(i=0;i<da.length;i++)
if(errorfields[da[i]]!=null)
{j++;k=i;}
if(j>0)
{if(ce)
for(i=0;i<fa.length;i++)
errorfields[fa[i]]=errorfields[da[k]];else
for(i=0;i<fa.length;i++)
adderrormsg("depends",f,ffl,fieldlabels[f][ff],da[k],0,ff);}}
function validategroup(f,ff,ffl,mn,mx,mt,az)
{var fa=ffl.split(/,/);var i;var j=0;var fv;for(i=0;i<fa.length;i++)
if(errorfields[fa[i]]!=null)
return;else
{fv=getfield(f,fa[i]);if(fv.length>0)
j++;}
if(az&&j==0)
return;if(arguments.length>=8)
{fv=getfield(f,arguments[7]);if(fv>''&&((mn>0&&j<mn)||(mx>0&&j>mx)))
adderrormsg("requiredby",f,ffl+','+arguments[6],fieldlabels[f][ff],fieldlabels[f][arguments[6]],mx,ff);}
else
{if(mn==mx&&mn>0&&j!=mn)
adderrormsg("exactgroup",f,ffl,fieldlabels[f][ff],mn,mx,ff);else if(mn>0&&mx>0&&mx<fa.length&&(j<mn||j>mx))
adderrormsg("minmaxgroup",f,ffl,fieldlabels[f][ff],mn,mx,ff);else if(mn>0&&j<mn)
adderrormsg("mingroup",f,ffl,fieldlabels[f][ff],mn,mx,ff);else if(mx>0&&j>mx)
adderrormsg("maxgroup",f,ffl,fieldlabels[f][ff],mn,mx,ff);}
if(mt!=0)
{for(i=0;i<fa.length;i++)
if(errorfields[fa[i]]!=null)
break;if(i==fa.length)
{if(mt<0)
{for(i=0;i<fa.length-1;i++)
{fv=getfield(f,fa[i]);if(fv>'')
{for(j=i+1;j<fa.length;j++)
if(fv==getfield(f,fa[j]))
break;if(j<fa.length)
break;}}
if(i<fa.length-1)
adderrormsg("nomatch",f,fa[i]+','+fa[j],fieldlabels[f][fa[i]],fieldlabels[f][fa[j]],mx,ff);}
else if(mt>0)
{fv=getfield(f,fa[0]);for(i=1;i<fa.length;i++)
if(fv!=getfield(f,fa[i]))
break;if(i<fa.length)
adderrormsg("match",f,ffl,fieldlabels[f][fa[0]],fieldlabels[f][fa[i]],mx,ff);}}}}
function validateorder(f,ff,ffl)
{var fa=ffl.split(/,/);var dva=new Array(3);var fv;for(i=0;i<fa.length;i++)
if(errorfields[fa[i]]!=null)
return;else
{fv=getfield(f,fa[i]);if(fv<='')
return;dva[i]=parseFloat(fv);}
if(fa.length==3)
{if(dva[0]>dva[1]||dva[1]>dva[2])
adderrormsg("invalidbetween",f,ffl,fieldlabels[f][fa[1]],fieldlabels[f][fa[0]],fieldlabels[f][fa[2]],ff);}
else if(fa.length==2)
{if(dva[0]>dva[1])
adderrormsg("invalidorder",f,ffl,fieldlabels[f][fa[0]],fieldlabels[f][fa[1]],ff);}}
function filterssnin(f,ff)
{var fv=getfield(f,ff);fv=fv.replace(/[- .]/g,'');document.forms[f][ff].value=fv;}
function filterssnout(f,ff,tin)
{var fv=getfield(f,ff);if(!/^[x0-9]+$/.test(fv))
return;if(tin)
{if(fv.length>=3)
fv=fv.substr(0,2)+'-'+fv.substr(2);}
else
{if(fv.length>=4)
fv=fv.substr(0,3)+'-'+fv.substr(3);if(fv.length>=7)
fv=fv.substr(0,6)+'-'+fv.substr(6);}
document.forms[f][ff].value=fv;}
function filterphonein(f,ff)
{var fv=getfield(f,ff);fv=fv.replace(/[-.() ]/g,'');if(fv.length==11)
fv=fv.replace(/^1/g,'');document.forms[f][ff].value=fv;}
function filterphoneout(f,ff,fmt)
{var fv=getfield(f,ff);var cc=fv.match(/^\+(1|2(0|1[2368]|2[0-9]|3[0-9]|4[0-9]|5[0-8]|6[0-9]|7|9[01789])|3([0-4]|5[0-9]|6|7[0-9]|8[015679]|9)|4([01]|2[013]|[3-9])|5(0[0-9]|[12]|3(99)?|[4-8]|9[0-9])|6(0|18?|[2-6]|7[02-9]|8[0-9]|9[0-2])|7|8(0[08]|[124]|5[02356]|6|7[0-48]|8(0|1[01236789]?|21[36]|6))|9([0-5]|6[0-8]|7[0-7]|8|9[2-68]))/);if(cc!=null)
fv=fv.substr(0,cc.lastIndex)+' '+fv.substr(cc.lastIndex);else if(fmt=='US'||fmt<='')
{if(fv.length>4)
fv=fv.substr(0,3)+'-'+fv.substr(3);if(fv.length>8)
fv=fv.substr(0,7)+'-'+fv.substr(7);}
document.forms[f][ff].value=fv;}
function filterccin(f,ff)
{var fv=getfield(f,ff);fv=fv.replace(/[^x0-9]/g,'');document.forms[f][ff].value=fv;}
function filterccout(f,ff)
{var fv=getfield(f,ff);if(fv.length>=5)
fv=fv.substr(0,4)+'-'+fv.substr(4);if(fv.length>=10)
fv=fv.substr(0,9)+'-'+fv.substr(9);if(fv.length>=15)
fv=fv.substr(0,14)+'-'+fv.substr(14);document.forms[f][ff].value=fv;}
function filtercase(f,ff,m)
{var fv=getfield(f,ff);if(m==0)
fv=fv.toUpperCase();else
fv=fv.toLowerCase();document.forms[f][ff].value=fv;}