var dtCh="/";var minYear=1900;var maxYear=2100;function noSpam(user,domain){locationstring="mailto:"+user+"@"+domain;window.location=locationstring;}
function isInteger(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(((c<"0")||(c>"9")))return false;}
return true;}
function createDate(str){var valueArray=str.split("/");var mon=valueArray[0];var dt=valueArray[1];var yr=valueArray[2];var date=new Date(yr,mon-1,dt);if(!isNaN(date.getMonth())){return date;}else{return new Date();}}
function dateToString(date){var mon=date.getMonth()+1;var dt=date.getDate();var yr=date.getFullYear();if(mon<10){mon="0"+mon;}
if(dt<10){dt="0"+dt;}
return mon+"/"+dt+"/20"+new String(yr).substring(2,4);}
function stripCharsInBag(s,bag){var i;var returnString="";for(i=0;i<s.length;i++){var c=s.charAt(i);if(bag.indexOf(c)==-1)returnString+=c;}
return returnString;}
function daysInFebruary(year){return(((year%4==0)&&((!(year%100==0))||(year%400==0)))?29:28);}
function DaysArray(n){for(var i=1;i<=n;i++){this[i]=31
if(i==4||i==6||i==9||i==11){this[i]=30}
if(i==2){this[i]=29}}
return this}
function isDate(dtStr,fldName){var daysInMonth=DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strMonth=dtStr.substring(0,pos1)
var strDay=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if(strDay.charAt(0)=="0"&&strDay.length>1)strDay=strDay.substring(1)
if(strMonth.charAt(0)=="0"&&strMonth.length>1)strMonth=strMonth.substring(1)
for(var i=1;i<=3;i++){if(strYr.charAt(0)=="0"&&strYr.length>1)strYr=strYr.substring(1)}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if(year<100){if(year<50){year=parseInt("20"+strYr);}else{year=parseInt("19"+strYr);}}
if(pos1==-1||pos2==-1){return false}
if(month<1||month>12){return false}
if(day<1||day>31||(month==2&&day>daysInFebruary(year))||day>daysInMonth[month]){return false}
if(strYear.length!=4||year==0||year<minYear||year>maxYear){return false}
if(dtStr.indexOf(dtCh,pos2+1)!=-1||isInteger(stripCharsInBag(dtStr,dtCh))==false){return false}
return true}
function isEmail(cur){var string1=cur
if(string1.indexOf("@")==-1||string1.indexOf(".")==-1)
{return false;}else{return true;}}
function validate(theForm){return validateForm(theForm);}
function validateForm(theForm){var errors="";var setFocus=0;var started=false;var startAt;var firstErrorNode;var frmInputs=theForm.getElementsByTagName("input");for(f=0;f<frmInputs.length;f++){theField=frmInputs[f];if(theField.getAttribute('required')=='true'&&theField.value=="")
{if(!started){started=true;startAt=f;firstErrorNode="input";}
if(theField.getAttribute('message')==undefined){errors+=theField.name.toUpperCase()+' is required\n';}
else
{errors+=theField.getAttribute('message')+'\n';}}
else if(theField.getAttribute('validate')!=undefined&&theField.value!=''){if(theField.getAttribute('validate').toUpperCase()=='EMAIL'&&!isEmail(theField.value))
{if(!started){started=true;startAt=f;firstErrorNode="input";}
if(theField.getAttribute('message')==undefined){errors+=theField.name.toUpperCase()+' must be a valid email address\n';}
else
{errors+=theField.getAttribute('message')+'\n';}}
else if(theField.getAttribute('validate').toUpperCase()=='NUMERIC'&&isNaN(theField.value))
{if(!isNaN(theField.value.replace(/\$|\,|\%/g,'')))
{theField.value=theField.value.replace(/\$|\,|\%/g,'');}else{if(!started){started=true;startAt=f;firstErrorNode="input";}
if(theField.getAttribute('message')==undefined){errors+=theField.name.toUpperCase()+' must be numeric\n';}
else
{errors+=theField.getAttribute('message')+'\n';}}}
else if(theField.getAttribute('validate').toUpperCase()=='REGEX'&&theField.getAttribute('regex')!=undefined)
{var re=new RegExp(theField.getAttribute('regex'));if(!theField.value.match(re))
{if(!started){started=true;startAt=f;firstErrorNode="input";}
if(theField.getAttribute('message')==undefined){errors+=theField.name.toUpperCase()+' must be numeric\n';}
else
{errors+=theField.getAttribute('message')+'\n';}}}
else if(theField.getAttribute('validate').toUpperCase()=='MATCH'&&theField.getAttribute('matchfield')!=undefined&&theField.value!=theForm[theField.getAttribute('matchfield')].value)
{if(!started){started=true;startAt=f;firstErrorNode="input";}
if(theField.getAttribute('message')==undefined){errors+=theField.name.toUpperCase()+' must match'+theField.getAttribute('matchfield')+'\n';}
else
{errors+=theField.getAttribute('message')+'\n';}}
else if(theField.getAttribute('validate').toUpperCase()=='DATE'&&!isDate(theField.value))
{if(!started){started=true;startAt=f;firstErrorNode="input";}
if(theField.getAttribute('message')==undefined){errors+=theField.name.toUpperCase()+' must be a valid date [MM/DD/YYYY]'+'\n';}
else
{errors+=theField.getAttribute('message')+'\n';}}}}
var frmTextareas=theForm.getElementsByTagName("textarea");for(f=0;f<frmTextareas.length;f++){theField=frmTextareas[f];if(theField.getAttribute('required')=='true'&&theField.value=="")
{if(!started){started=true;startAt=f;firstErrorNode="textarea";}
if(theField.getAttribute('message')==undefined){errors+=theField.name.toUpperCase()+' is required\n';}
else
{errors+=theField.getAttribute('message')+'\n';}}}
var frmSelects=theForm.getElementsByTagName("select");for(f=0;f<frmSelects.length;f++){theField=frmSelects[f];if(theField.getAttribute('required')=='true'&&theField.value=="")
{if(!started){started=true;startAt=f;firstErrorNode="select";}
if(theField.getAttribute('message')==undefined){errors+=theField.name.toUpperCase()+' is required\n';}
else
{errors+=theField.getAttribute('message')+'\n';}}}
if(errors!=""){alert(errors);if(firstErrorNode=="input"){frmInputs[startAt].focus();}
else if(firstErrorNode=="textarea"){frmTextareas[startAt].focus();}
else if(firstErrorNode=="select"){frmSelects[startAt].focus();}
return false;}
else
{return true;}}
function submitForm(frm,doaction,theClass){if(validate(frm)){if(typeof(doaction)!='undefined'&&(action=='delete'&&confirm('Delete '+theClass+'?')||action!='delete')){var frmInputs=frm.getElementsByTagName("input");for(f=0;f<frmInputs.length;f++){if(frmInputs[f].getAttribute('name')=='doaction'){frmInputs[f].setAttribute('value',doaction);}}}
frm.submit();}
return false;}
function isMacIE5(){var agt=navigator.userAgent.toLowerCase();var ie=(agt.indexOf("msie")!=-1);var mac=(agt.indexOf("mac")!=-1);if(mac&&ie){return false;}else{return true;}}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return unescape(c.substring(nameEQ.length,c.length));}
return"";}
function eraseCookie(name){createCookie(name,"",-1);}
sfHover=function(){var sfEls=document.getElementById("navPrimary").getElementsByTagName("LI");for(var i=0;i<sfEls.length;i++){sfEls[i].onmouseover=function(){this.className+=" sfhover";}
sfEls[i].onmouseout=function(){this.className=this.className.replace(new RegExp(" sfhover\\b"),"");}}}
function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){oldonload();func();}}}
function addUnloadEvent(func){var oldonunload=window.onunload;if(typeof window.onunload!='function'){window.onunload=func;}else{window.onunload=function(){oldonunload();func();}}}
function keyCheck(e){var key=(window.event)?event.keyCode:e.keyCode;if(key==27){pressed_keys=key;}else if(key==36){pressed_keys=pressed_keys+""+key;}
if(key!=27&&key!=36){pressed_keys="";}
if(pressed_keys!=""){aux=new String(pressed_keys);if(aux.indexOf('2736')!=-1&&location.search.indexOf("display=login")==-1){if(typeof(loginURL)=="undefined"){lu="?display=login";}else{lu=loginURL;}
if(typeof(returnURL)=="undefined"){ru=location.href;}else{ru=returnURL;}
pressed_keys="";lu=new String(lu);if(lu.indexOf('?')!=-1){location.href=lu+"&returnUrl="+escape(ru);}else{location.href=lu+"?returnUrl="+escape(ru);}}}}
function setKeyCheck(){document.onkeydown=keyCheck;}
addLoadEvent(setKeyCheck);