var lang="en";document.observe('dom:loaded',initContact,false);function initContact(){lang=$$("body")[0].getAttribute("lang");if($('cp-contact'))Event.observe('submitcontact','click',sendMail,false);}
function sendMail(e){var txt='';var ids=['hotel','name','email','question','recaptcha_response_field'];for(var i=0;i<ids.length;i++){element=ids[i];if(element=='hotel'){if($F('case')!=5&&$F('hotel')=='-')txt=txt+' - '+langText[lang]['form'][0]+' "'+getLabelName('hotel')+'"'+'<br>';}
if(element=='email'&&!isEmail($F('email'))){if(txt=='')$(element).focus();txt=txt+' - '+langText[lang]['form'][0]+' "'+getLabelName('email')+'"'+'<br>';}else
if(isWhitespace($F(element))&&element!='hotel'){if(txt=='')$(element).focus();txt=txt+' - '+langText[lang]['form'][0]+' "'+getLabelName(element)+'"'+'<br>';}
if(i==4){if(txt!=''){Event.stop(e);setErrorText(txt);}
else{$('cp-contact').action=$F('urlaction');$('cp-contact').submit();}
break;}}}
function getLabelName(ele){var ret='';var req=$$('#cp-contact .required');req.each(function(element){if(element.attributes["for"].value==ele){ret=element.innerHTML.replace('*','').replace(':','');}});return ret;}
function setErrorText(txt){$('error').innerHTML=txt;$('error').style.display="block";Effect.run($('error'),true,10);return false;}
