function terraform_textarea_counter(a,c,b){if(a.value.length>b)a.value=a.value.substring(0,b);else c.value=b-a.value.length}var terraFormApi={};terraFormApi.fields={};terraFormApi.forms={};terraFormApi.formatPrototypes={};function getDisabled(){return document.getElementById(this.id).disabled}function getValue(){return document.getElementById(this.id).value}function setDisabled(b){document.getElementById(this.id).disabled=b;if(this.suffixes){var a=this.suffixes.split(",");if(a.length)for(var c in a)if(document.getElementById(this.id+"_"+a[c]))document.getElementById(this.id+"_"+a[c]).disabled=b}return b}function setValue(a){document.getElementById(this.id).value=a;return a}function toggleDisabled(){return this.setDisabled(!this.getDisabled())}function doNothing(){}function booleanGetValue(){return document.getElementById(this.id).checked}function booleanSetValue(a){document.getElementById(this.id).checked=a;return a}terraFormApi.formatPrototypes["boolean"]=function(a){this.id=a;this.suffixes="label";this.getDisabled=getDisabled;this.getValue=booleanGetValue;this.setDisabled=setDisabled;this.setValue=booleanSetValue;this.toggleDisabled=toggleDisabled};terraFormApi.formatPrototypes.button=function(a){this.id=a;this.suffixes="";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=setDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};terraFormApi.formatPrototypes.calendar=function(a){this.id=a;this.suffixes="anchor";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=setDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};function checkboxGetValue(){for(var d=document.getElementById(this.id).title,c=[],a,b=0;b<d;b++){a=document.getElementById(this.id+"_value_"+b);a.checked&&c.push(a.value)}return c}function checkboxSetValue(b){for(var e=document.getElementById(this.id).title,a,c=0;c<e;c++){a=document.getElementById(this.id+"_value_"+c);a.checked=false;for(var d=0;d<b.length;d++)if(a.value==b[d])a.checked=true}return b}function checkboxSetDisabled(a){for(var c=document.getElementById(this.id).title,b=0;b<c;b++){document.getElementById(this.id+"_value_"+b).disabled=a;document.getElementById(this.id+"_label_"+b).disabled=a}document.getElementById(this.id+"_fieldset").disabled=a;return a}terraFormApi.formatPrototypes.checkbox=function(a){this.id=a;this.getDisabled=getDisabled;this.getValue=checkboxGetValue;this.setDisabled=checkboxSetDisabled;this.setValue=checkboxSetValue;this.toggleDisabled=toggleDisabled};terraFormApi.formatPrototypes.ckeditor=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.colorpicker=function(a){this.id=a;this.suffixes="anchor";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=setDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};terraFormApi.formatPrototypes.combo=function(a){this.id=a;this.suffixes="select";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=setDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};function datepickerGetValue(){var c=2e3,b=1,a=1;if(document.getElementById(this.id+"_year"))c=document.getElementById(this.id+"_year").value;if(document.getElementById(this.id+"_month"))b=document.getElementById(this.id+"_month").value;if(document.getElementById(this.id+"_day"))a=document.getElementById(this.id+"_day").value;return c>0&&b>0&&a>0?new Date(c,b-1,a):null}function datepickerSetValue(a){if(document.getElementById(this.id+"_year"))document.getElementById(this.id+"_year").value=a.getFullYear();if(document.getElementById(this.id+"_month"))document.getElementById(this.id+"_month").value=a.getMonth()+1;if(document.getElementById(this.id+"_day"))document.getElementById(this.id+"_day").value=a.getDate()}terraFormApi.formatPrototypes.datepicker=function(a){this.id=a;this.suffixes="day,month,year";this.getDisabled=getDisabled;this.getValue=datepickerGetValue;this.setDisabled=setDisabled;this.setValue=datepickerSetValue;this.toggleDisabled=toggleDisabled};function divSelectChoose(a,d,e){if(e){var c="";if(document.getElementById(a+"_option_"+d).className=="divSelectSelected")document.getElementById(a+"_option_"+d).className="";else document.getElementById(a+"_option_"+d).className="divSelectSelected";for(var b=1;b<=document.getElementById(a+"_wrapper").childNodes.length;b++)if(document.getElementById(a+"_option_"+b).className=="divSelectSelected")c=c+","+document.getElementById(a+"_value_"+b).innerHTML;if(c.length>0)c=c.substr(1);document.getElementById(a).value=c}else{document.getElementById(a).value=document.getElementById(a+"_value_"+d).innerHTML;for(var b=1;b<=document.getElementById(a+"_wrapper").childNodes.length;b++)document.getElementById(a+"_option_"+b).className="";document.getElementById(a+"_option_"+d).className="divSelectSelected"}}terraFormApi.formatPrototypes.divselect=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.enhancedfile=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.fckeditor=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.file=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.hidden=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.htmlarea=function(a){this.id=a;this.suffixes="";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=doNothing;this.setValue=setValue;this.toggleDisabled=doNothing};terraFormApi.formatPrototypes.image=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.moveselect=function(a){this.id=a;this.suffixes="left,right,heading1,heading2,button1,button2,button3,button4";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=setDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};terraFormApi.formatPrototypes.msslider=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes["null"]=function(a){this.id=a;this.suffixes="";this.getDisabled=doNothing;this.getValue=doNothing;this.setDisabled=doNothing;this.setValue=doNothing;this.toggleDisabled=doNothing};terraFormApi.formatPrototypes.numeric=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.password=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.radio=function(a){terraFormApi.formatPrototypes.radio.prototype.constructor.call(this,a);this.getValue=function(){var a=terraFormApi.formatPrototypes.radio.prototype.getValue.call(this);if(a&&a.length)return a[0]};this.setValue=function(a){terraFormApi.formatPrototypes.radio.prototype.setValue.call(this,[a])}};terraFormApi.formatPrototypes.radio.prototype=new terraFormApi.formatPrototypes.checkbox(null);function selectSetDisabled(b){document.getElementById(this.id).disabled=b;if(this.suffixes){var a=this.suffixes.split(",");if(a.length)for(var c in a)if(document.getElementById(this.id+"_"+a[c]))document.getElementById(this.id+"_"+a[c]).disabled=b}return b}terraFormApi.formatPrototypes.select=function(a){this.id=a;this.suffixes="";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=selectSetDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};function spineditSetDisabled(a){document.getElementById(this.id).disabled=a;if(a){document.getElementById(this.id+"_up").style.display="none";document.getElementById(this.id+"_down").style.display="none";document.getElementById(this.id+"_upDisabled").style.display="inline";document.getElementById(this.id+"_downDisabled").style.display="inline"}else{document.getElementById(this.id+"_up").style.display="inline";document.getElementById(this.id+"_down").style.display="inline";document.getElementById(this.id+"_upDisabled").style.display="none";document.getElementById(this.id+"_downDisabled").style.display="none"}return a}terraFormApi.formatPrototypes.spinedit=function(a){this.id=a;this.suffixes="";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=spineditSetDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};function starsSetDisabled(a){document.getElementById(this.id).disabled=a;if(a){document.getElementById(this.id+"_disabledStars").style.display="inline";document.getElementById(this.id+"_enabledStars").style.display="none"}else{document.getElementById(this.id+"_disabledStars").style.display="none";document.getElementById(this.id+"_enabledStars").style.display="inline"}return a}terraFormApi.formatPrototypes.stars=function(a){this.id=a;this.suffixes="";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=starsSetDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};function submitSetDisabled(a){document.getElementById(this.id).disabled=a;return a}terraFormApi.formatPrototypes.submit=function(a){this.id=a;this.suffixes="";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=submitSetDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};terraFormApi.formatPrototypes.submitbutton=terraFormApi.formatPrototypes.submit;terraFormApi.formatPrototypes.text=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.textarea=terraFormApi.formatPrototypes.button;function timepickerGetValue(){var a=document.getElementById(this.id+"_hours").value;if(document.getElementById(this.id+"_minutes"))a=a+":"+document.getElementById(this.id+"_minutes").value;if(document.getElementById(this.id+"_seconds"))a=a+":"+document.getElementById(this.id+"_seconds").value;if(document.getElementById(this.id+"_ampm"))a=a+" "+document.getElementById(this.id+"_ampm").value;return a}terraFormApi.formatPrototypes.timepicker=function(a){this.id=a;this.suffixes="hours,minutes,seconds,ampm";this.getDisabled=getDisabled;this.getValue=timepickerGetValue;this.setDisabled=setDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};function timespanpickerGetValue(){var a=0,b=document.getElementById(this.id+"_baseUnit").value;if(document.getElementById(this.id+"_days"))a+=parseInt(document.getElementById(this.id+"_days").value*86400);if(document.getElementById(this.id+"_hours"))a+=parseInt(document.getElementById(this.id+"_hours").value*3600);if(document.getElementById(this.id+"_minutes"))a+=parseInt(document.getElementById(this.id+"_minutes").value*60);if(document.getElementById(this.id+"_seconds"))a+=parseInt(document.getElementById(this.id+"_seconds").value);switch(b){case"d":return a/86400;case"h":return a/3600;case"n":return a/60;case"s":return a}}terraFormApi.formatPrototypes.timespanpicker=function(a){this.id=a;this.suffixes="days,hours,minutes,seconds";this.getDisabled=getDisabled;this.getValue=timespanpickerGetValue;this.setDisabled=setDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};terraFormApi.formatPrototypes.url=function(a){this.id=a;this.suffixes="button";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=setDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled};function terraFormRefresh(b){var a=b.target?b.target.form:b.srcElement.form;a.elements[a.name].value="refresh";a.submit()}isMac=navigator.appVersion.indexOf("Mac")!=-1?true:false;NS4=document.layers?true:false;IEmac=document.all&&isMac?true:false;IE4plus=document.all?true:false;IE4=document.all&&navigator.appVersion.indexOf("MSIE 4.")!=-1?true:false;IE5=document.all&&navigator.appVersion.indexOf("MSIE 5.")!=-1?true:false;ver4=NS4||IE4plus?true:false;NS6=!document.layers&&navigator.userAgent.indexOf("Netscape")!=-1?true:false;var gSafeOnload=[];function SafeAddOnload(a){if(IEmac&&IE4){window.onload=SafeOnload;gSafeOnload[gSafeOnload.length]=a}else if(window.onload){if(window.onload!=SafeOnload){gSafeOnload[0]=window.onload;window.onload=SafeOnload}gSafeOnload[gSafeOnload.length]=a}else window.onload=a}function SafeOnload(){for(var a=0;a<gSafeOnload.length;a++)gSafeOnload[a]()}function hidebuttons(b){document.body.style.cursor="wait";if(document.all||document.getElementById)for(i=0;i<b.length;i++){var a=b.elements[i];try{if(a.type.toLowerCase()=="submit"||a.type.toLowerCase()=="button"){var c=a.name.match(/_hidden$/);if(c)a.style.display="inline";else a.style.display="none"}}catch(d){}}}function comboLookup(f){var c=document.getElementById(f),b=document.getElementById(f+"_select");b.selectedIndex=-1;if(c.createTextRange){var g=window.event;if(g.keyCode!=8&&g.keyCode!=46){var d=c.value.toLowerCase();if(d.length)for(var a=0;a<b.options.length;a++)if(d==b.options[a].innerHTML.substr(0,d.length).toLowerCase()){b.selectedIndex=a;c.value=b.options[a].innerHTML;var e=c.createTextRange();e.moveStart("character",d.length);e.select()}}else{var d=c.value.toLowerCase();if(d.length)for(var a=0;a<b.options.length;a++)if(d==b.options[a].innerHTML.toLowerCase()){b.selectedIndex=a;c.value=b.options[a].innerHTML;var e=c.createTextRange();e.moveStart("character",d.length);e.select()}}}}terraFormApi.formatPrototypes.soeditor=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.tinymce=terraFormApi.formatPrototypes.button;terraFormApi.formatPrototypes.recaptcha=function(){this.id="recaptcha_response_field";this.suffixes="";this.getDisabled=getDisabled;this.getValue=getValue;this.setDisabled=submitSetDisabled;this.setValue=setValue;this.toggleDisabled=toggleDisabled}
