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 == 'Vaše jméno') this.value=''; }); $('cf_name').addEvent('blur', function(e) { if(this.value == '') this.value='Vaše 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 == 'Specifikujte poptávku nebo napiště svůj dotaz...') this.value=''; }); $('cf_question').addEvent('blur', function(e) { if(this.value == '') this.value='Specifikujte poptávku nebo napiště svůj dotaz...'; }); } if ($('cf_liame') != null) { $('cf_liame').addEvent('focus', function(e) { if(this.value == 'Váš e-mail') this.value=''; }); $('cf_liame').addEvent('blur', function(e) { if(this.value == '') this.value='Váš e-mail'; }); } if ($('cf_phone') != null) { $('cf_phone').addEvent('focus', function(e) { if(this.value == 'Váš telefon') this.value=''; }); $('cf_phone').addEvent('blur', function(e) { if(this.value == '') this.value='Váš telefon'; }); } $('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ý údaj 'CONTACTFORM_TITLE'.\n"; } if (this.cf_liame != null) with (this.cf_liame) { if (value==null || value=="" || value=="Váš e-mail") alerttext += "Povinný údaj 'Váš e-mail'.\n"; else if (!regExpPatternemail.test(value)) alerttext += "Špatně vyplněný údaj 'Váš e-mail'\n"; } if (this.cf_phone != null) with (this.cf_phone) { if (value==null || value=="" || value=="Váš telefon") alerttext += "Povinný údaj 'Váš telefon'.\n"; } if (this.cf_name != null) with (this.cf_name) { if (value==null || value=="" || value=="Vaše jméno") alerttext += "Povinný údaj 'Vaše jméno'.\n"; } if (this.cf_question != null) with (this.cf_question) { if (value==null || value=="" || value=="Specifikujte poptávku nebo napiště svůj dotaz...") alerttext += "Povinný údaj 'Specifikujte poptávku nebo napiště svůj dotaz...'.\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... } }); });