function submitacymailingform(task,formName){var varform=eval('document.'+formName);if(!varform.elements)varform=varform[1];if(task!='optout'){nameField=varform.elements['user[name]'];if(nameField&&((typeof acymailing!='undefined'&&nameField.value==acymailing['NAMECAPTION'])||nameField.value.length<2)){if(typeof acymailing!='undefined'){alert(acymailing['NAME_MISSING']);}nameField.className=nameField.className+' invalid';return false;}}var emailField=varform.elements['user[email]'];if(emailField){if(typeof acymailing=='undefined'||emailField.value!=acymailing['EMAILCAPTION'])emailField.value=emailField.value.replace(/ /g,"");var filter=/^([a-z0-9_'&\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,10})+$/i;if(!emailField||(typeof acymailing!='undefined'&&emailField.value==acymailing['EMAILCAPTION'])||!filter.test(emailField.value)){if(typeof acymailing!='undefined'){alert(acymailing['VALID_EMAIL']);}emailField.className=emailField.className+' invalid';return false;}}if(varform.elements['hiddenlists'].value.length<1){var listschecked=false;var alllists=varform.elements['subscription[]'];if(alllists&&typeof alllists.value=='undefined'){for(b=0;b<alllists.length;b++){if(alllists[b].checked)listschecked=true;}if(!listschecked){alert(acymailing['NO_LIST_SELECTED']);return false;}}}if(task!='optout'&&typeof acymailing!='undefined'&&typeof acymailing['reqFields'+formName]!='undefined'&&acymailing['reqFields'+formName].length>0){for(var i=0;i<acymailing['reqFields'+formName].length;i++){elementName='user['+acymailing['reqFields'+formName][i]+']';elementToCheck=varform.elements[elementName];if(elementToCheck){var isValid=false;if(typeof elementToCheck.value!='undefined'){if(elementToCheck.value==' '&&typeof varform[elementName+'[]']!='undefined'){if(varform[elementName+'[]'].checked){isValid=true;}else{for(var a=0;a<varform[elementName+'[]'].length;a++){if((varform[elementName+'[]'][a].checked||varform[elementName+'[]'][a].selected)&&varform[elementName+'[]'][a].value.length>0)isValid=true;}}}else{if(elementToCheck.value.length>0){if(typeof acymailing['excludeValues'+formName]=='undefined'||typeof acymailing['excludeValues'+formName][acymailing['reqFields'+formName][i]]=='undefined'||acymailing['excludeValues'+formName][acymailing['reqFields'+formName][i]]!=elementToCheck.value)isValid=true;}}}else{for(var a=0;a<elementToCheck.length;a++){if(elementToCheck[a].checked&&elementToCheck[a].value.length>0)isValid=true;}}if(!isValid){elementToCheck.className=elementToCheck.className+' invalid';alert(acymailing['validFields'+formName][i]);return false;}}else{if((varform.elements[elementName+'[day]']&&varform.elements[elementName+'[day]'].value<1)||(varform.elements[elementName+'[month]']&&varform.elements[elementName+'[month]'].value<1)||(varform.elements[elementName+'[year]']&&varform.elements[elementName+'[year]'].value<1902)){if(varform.elements[elementName+'[day]']&&varform.elements[elementName+'[day]'].value<1)varform.elements[elementName+'[day]'].className=varform.elements[elementName+'[day]'].className+' invalid';if(varform.elements[elementName+'[month]']&&varform.elements[elementName+'[month]'].value<1)varform.elements[elementName+'[month]'].className=varform.elements[elementName+'[month]'].className+' invalid';if(varform.elements[elementName+'[year]']&&varform.elements[elementName+'[year]'].value<1902)varform.elements[elementName+'[year]'].className=varform.elements[elementName+'[year]'].className+' invalid';alert(acymailing['validFields'+formName][i]);return false;}}}}var captchaField=varform.elements['acycaptcha'];if(captchaField){if(captchaField.value.length<1){if(typeof acymailing!='undefined'){alert(acymailing['CAPTCHA_MISSING']);}captchaField.className=captchaField.className+' invalid';return false;}}if(task!='optout'){var termsandconditions=varform.terms;if(termsandconditions&&!termsandconditions.checked){if(typeof acymailing!='undefined'){alert(acymailing['ACCEPT_TERMS']);}termsandconditions.className=termsandconditions.className+' invalid';return false;}}taskField=varform.task;taskField.value=task;if(!varform.elements['ajax']||!varform.elements['ajax'].value||varform.elements['ajax'].value=='0'){varform.submit();return false;}if(typeof String.prototype.parseQueryString!='function'){String.prototype.parseQueryString=function(){var vars=this.split(/[&;]/),res={};if(vars.length)vars.each(function(val){var index=val.indexOf('='),keys=index<0?['']:[val.substr(0,index)],value=decodeURIComponent(val.substr(index+1)),obj=res;keys.each(function(key,i){var current=obj[key];if(i<keys.length-1)obj=obj[key]=current||{};else if($type(current)=='array')current.push(value);else
obj[key]=$defined(current)?[current,value]:value;});});return res;}}data=$(formName).toQueryString().parseQueryString();if(typeof Ajax=='function'){new Ajax($(formName).action,{data:data,method:'post',onRequest:function(){$(formName).addClass('acymailing_module_loading');$(formName).setStyle("filter:","alpha(opacity=50)");$(formName).setStyle("-moz-opacity","0.5");$(formName).setStyle("-khtml-opacity","0.5");$(formName).setStyle("opacity","0.5");},onSuccess:function(response){response=Json.evaluate(response);acymailingDisplayAjaxResponse(unescape(response.message),response.type,formName);},onFailure:function(){acymailingDisplayAjaxResponse('Ajax Request Failure','error',formName);}}).request();}else{new Request.JSON({url:$(formName).action,data:data,method:'post',onRequest:function(){$(formName).addClass('acymailing_module_loading');$(formName).setStyle("filter:","alpha(opacity=50)");$(formName).setStyle("-moz-opacity","0.5");$(formName).setStyle("-khtml-opacity","0.5");$(formName).setStyle("opacity","0.5");},onSuccess:function(response){acymailingDisplayAjaxResponse(unescape(response.message),response.type,formName);},onFailure:function(){acymailingDisplayAjaxResponse('Ajax Request Failure','error',formName);}}).send();}return false;}function acymailingDisplayAjaxResponse(message,type,formName){var responseContainer=$$('#acymailing_module_'+formName+' .responseContainer')[0];if(typeof responseContainer=='undefined'){responseContainer=new Element('div');responseContainer.inject($('acymailing_module_'+formName),'top');oldContainerHeight='0px';}else{oldContainerHeight=responseContainer.getStyle('height');}responseContainer.className='responseContainer';$(formName).removeClass('acymailing_module_loading');responseContainer.innerHTML=message;if(type=='success'){responseContainer.addClass('acymailing_module_success');}else{responseContainer.addClass('acymailing_module_error');$(formName).setStyle("filter:","alpha(opacity=100)");$(formName).setStyle("-moz-opacity","1");$(formName).setStyle("-khtml-opacity","1");$(formName).setStyle("opacity","1");}newContainerHeight=responseContainer.getStyle('height');if(typeof Ajax=='function'){if(type=='success'){var myEffect=new Fx.Styles($(formName),{duration:500,transition:Fx.Transitions.linear});myEffect.start({'height':[$(formName).getSize().size.y,0],'opacity':[1,0]});}responseContainer.setAttribute('style','height: '+oldContainerHeight+';'+'opacity: 0;');var myEffect2=new Fx.Styles(responseContainer,{duration:500,transition:Fx.Transitions.linear});myEffect2.start({'height':[oldContainerHeight,newContainerHeight],'opacity':[0,1]});}else{if(type=='success'){$(formName).set('morph');$(formName).morph({'height':'0px','opacity':0});}responseContainer.setStyles({'height':oldContainerHeight,'opacity':0});responseContainer.set('morph');responseContainer.morph({'height':newContainerHeight,'opacity':1});}}