
var DAYS=['tu','we','th','fr','sa','su'];copyDay=function(event){var regex=new RegExp("^cpy_([a-z]{2})_report$");var match=regex.exec(event.element().id);if(match!==null){var to=match[1];var from=$('id_'+to+'_report').getValue();$('id_'+to+'_mo_min_0').setValue($('id_'+from+'_mo_min_0').getValue());$('id_'+to+'_mo_min_2').setValue($('id_'+from+'_mo_min_2').getValue());$('id_'+to+'_af_min_0').setValue($('id_'+from+'_af_min_0').getValue());$('id_'+to+'_af_min_2').setValue($('id_'+from+'_af_min_2').getValue());$('id_'+to+'_mo_max_0').setValue($('id_'+from+'_mo_max_0').getValue());$('id_'+to+'_mo_max_2').setValue($('id_'+from+'_mo_max_2').getValue());$('id_'+to+'_af_max_0').setValue($('id_'+from+'_af_max_0').getValue());$('id_'+to+'_af_max_2').setValue($('id_'+from+'_af_max_2').getValue());}}
var autocompletes=[['id_home_city','id_home_zipcode'],['id_firm_city','id_firm_zipcode']]
var Autocompleter=Class.create(Ajax.Autocompleter,{initialize:function(element,update,zipcode,url,options){this.baseInitialize(element,update,options);this.zipcode=zipcode;this.options.asynchronous=true;this.options.onComplete=this.onComplete.bind(this);this.options.defaultParams=this.options.parameters||null;this.url=url;this.options.afterUpdateElement=this.afterUpdateElement.bind(this);},afterUpdateElement:function(text,li){$(this.zipcode).setValue(li.id);}});for(index=0,len=autocompletes.length;index<len;index++){new Autocompleter(autocompletes[index][0],autocompletes[index][0]+'_autocomplete',autocompletes[index][1],autocomplete_url,{paramName:autocomplete_paramName,frequency:autocomplete_frequency,minChars:autocomplete_minChars});}
for(index=0;index<6;index++){$('cpy_'+DAYS[index]+'_report').observe('click',copyDay);}
