var CF_ALLOW_AJAX = true; window.addEvent('domready', function() { if (CF_ALLOW_AJAX) $('cf_form').setProperty('action', 'ajax_sendcontactform'); if ($('cf_name') != null) { $('cf_name').addEvent('focus', function(e) { if(this.value == 'Jméno') this.value=''; }); $('cf_name').addEvent('blur', function(e) { if(this.value == '') this.value='Jméno'; }); } if ($('cf_title') != null) { $('cf_title').addEvent('focus', function(e) { if(this.value == 'CONTACTFORM_TITLE') this.value=''; }); $('cf_title').addEvent('blur', function(e) { if(this.value == '') this.value='CONTACTFORM_TITLE'; }); } if ($('cf_question') != null) { $('cf_question').addEvent('focus', function(e) { if(this.value == 'Zpráva') this.value=''; }); $('cf_question').addEvent('blur', function(e) { if(this.value == '') this.value='Zpráva'; }); } if ($('cf_liame') != null) { $('cf_liame').addEvent('focus', function(e) { if(this.value == 'E-mail') this.value=''; }); $('cf_liame').addEvent('blur', function(e) { if(this.value == '') this.value='E-mail'; }); } $('cf_form').addEvent('submit', function(e) { /** * Prevent the submit event */ if (CF_ALLOW_AJAX) new Event(e).stop(); /*KONTOLA SPRAVNOSTI FORMULARE*/ var alerttext = ""; //email regExpPatternemail=/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/ if (this.cf_title != null) with (this.cf_title) { if (value==null || value=="" || value=="CONTACTFORM_TITLE") alerttext += "Povinná položka 'CONTACTFORM_TITLE'.\n"; } if (this.cf_liame != null) with (this.cf_liame) { if (value==null || value=="" || value=="E-mail") alerttext += "Povinná položka 'E-mail'.\n"; else if (!regExpPatternemail.test(value)) alerttext += "Nesprávný formát položky 'E-mail'\n"; } if (this.cf_name != null) with (this.cf_name) { if (value==null || value=="" || value=="Jméno") alerttext += "Povinná položka 'Jméno'.\n"; } if (this.cf_question != null) with (this.cf_question) { if (value==null || value=="" || value=="Zpráva") alerttext += "Povinná položka 'Zpráva'.\n"; } if (alerttext.length > 0) { //alert(alerttext); $('log').empty().set('html', '

' + alerttext + '

'); return false; } if (CF_ALLOW_AJAX) { /** * This empties the log and shows the spinning indicator */ var log = $('log').empty().addClass('ajaxLoading'); var action = this.getProperty('action'), method = this.getProperty('method'); this.set('send', { url: action, method: method, update: $('log'), onComplete: function(response) { log.removeClass('ajaxLoading'); $('log').set('html',response); } }); this.send(); // now it knows how to send it... } }); });