function wfg_is_valid_szallasfoglalas_person_nr(el){if(el.toString().match(/^[1-6]$/i)){return true;}return false;}
function wfg_is_valid_szallasfoglalas_children_nr(el){if(el.toString().match(/^[0-6]$/i)){return true;}return false;}
function wfg_is_valid_szallasfoglalas_name(el){if(el.toString().match(/^.{4,}$/i)){return true;}return false;}
function wfg_is_valid_szallasfoglalas_firstname(el){if(el.toString().match(/^.{3,}$/i)){return true;}return false;}
function wfg_is_valid_szallasfoglalas_city(el){if(el.toString().match(/^.{2,}$/i)){return true;}return false;}
function wfg_is_valid_szallasfoglalas_person_nr(el){if(el.toString().match(/^[0-9]+$/i)){return true;}return false;}
function wfg_is_valid_szallasfoglalas_street(el){if(el.toString().match(/^.{4,}$/i)){return true;}return false;}
function wfg_is_valid_szallasfoglalas_postalcode(el){if(el.toString().match(/^[0-9]{4,}$/i)){return true;}return false;}
function wfg_is_valid_szallasfoglalas_phone(el){if(el.toString().match(/^[\d\.\/\(\) +-]{7,}$/i)){return true;}return false;}
function wfg_szallasfoglalas_form_submit(e){var error=false;document.getElementById('szallasfoglalas_person_nr_block').className='valid';
if(!wfg_is_valid_szallasfoglalas_person_nr(document.getElementById('szallasfoglalas_person_nr').value)){document.getElementById('szallasfoglalas_person_nr_block').className='error';error=true;}document.getElementById('szallasfoglalas_children_nr_block').className='valid';
if(!wfg_is_valid_szallasfoglalas_children_nr(document.getElementById('szallasfoglalas_children_nr').value)){document.getElementById('szallasfoglalas_children_nr_block').className='error';error=true;}document.getElementById('szallasfoglalas_name_block').className='valid';
if(!wfg_is_valid_szallasfoglalas_name(document.getElementById('szallasfoglalas_name').value)){document.getElementById('szallasfoglalas_name_block').className='error';error=true;}
document.getElementById('szallasfoglalas_person_nr_block').className='valid';
if(!wfg_is_valid_szallasfoglalas_person_nr(document.getElementById('szallasfoglalas_person_nr').value)){document.getElementById('szallasfoglalas_person_nr_block').className='error';error=true;}
document.getElementById('szallasfoglalas_firstname_block').className='valid';
if(!wfg_is_valid_szallasfoglalas_firstname(document.getElementById('szallasfoglalas_firstname').value)){document.getElementById('szallasfoglalas_firstname_block').className='error';error=true;}document.getElementById('szallasfoglalas_city_block').className='valid';
if(!wfg_is_valid_szallasfoglalas_city(document.getElementById('szallasfoglalas_city').value)){document.getElementById('szallasfoglalas_city_block').className='error';error=true;}document.getElementById('szallasfoglalas_street_block').className='valid';
if(!wfg_is_valid_szallasfoglalas_street(document.getElementById('szallasfoglalas_street').value)){document.getElementById('szallasfoglalas_street_block').className='error';error=true;}document.getElementById('szallasfoglalas_postalcode_block').className='valid';
if(!wfg_is_valid_szallasfoglalas_postalcode(document.getElementById('szallasfoglalas_postalcode').value)){document.getElementById('szallasfoglalas_postalcode_block').className='error';error=true;}document.getElementById('szallasfoglalas_phone_block').className='valid';
if(!wfg_is_valid_szallasfoglalas_phone(document.getElementById('szallasfoglalas_phone').value)){document.getElementById('szallasfoglalas_phone_block').className='error';error=true;}
if(error){alert('Kérjük valamennyi mezőt kitölteni!');if(e&&e.preventDefault){ e.preventDefault();}return false;}/*document.getElementById('szallasfoglalas_form').submit();*/}
function setBaseDate(){
var now=new Date();
$('szallasfoglalas_date_from_year').value=now.getFullYear();
if(now.getMonth()+1<10){$('szallasfoglalas_date_from_month').value="0"+(now.getMonth()+1);}
else{$('szallasfoglalas_date_from_month').value=""+(now.getMonth()+1);}
if(now.getDate()<10){$('szallasfoglalas_date_from_day').value="0"+(now.getDate());}
else{$('szallasfoglalas_date_from_day').value=""+(now.getDate());}
var now=new Date(now.getTime()+(60*60*24*1000));
$('szallasfoglalas_date_till_year').value=now.getFullYear();
if(now.getMonth()+1<10){$('szallasfoglalas_date_till_month').value="0"+(now.getMonth()+1);}
else{$('szallasfoglalas_date_till_month').value=""+(now.getMonth()+1);}
if(now.getDate()<10){$('szallasfoglalas_date_till_day').value="0"+(now.getDate());}
else{$('szallasfoglalas_date_till_day').value=""+(now.getDate());}
}
function addEvent(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,false);return true;}else if(obj.attachEvent){return obj.attachEvent('on'+evType,fn);}return false;}
function setAccommodation() {
    var loc = window.location.hash.match( /\d$/ );
    if( document.getElementById( "szallasfoglalas_apartman_" + loc ) ) {
        document.getElementById( "szallasfoglalas_apartman_" + loc ).setAttribute( "checked", "checked" );
    }
}
function wfg_szallasfoglalas_load_events(){setAccommodation();setBaseDate();addEvent(document.getElementById('szallasfoglalas_submit'),'click',wfg_szallasfoglalas_form_submit);}addEvent(window,'load',wfg_szallasfoglalas_load_events);

