$(document).ready(function(){var h=$('#selected_year').text();$('.md a').live('click',function(){var b=$(this).parent();var c=b.attr('id');b.removeClass('h');b.addClass('g');$.ajax({url:'/ajax/toggleDay',data:{id:c,year:h},success:function(a){if(a.new_status){b.addClass('h')}b.removeClass('g');$('#ContiguousHolidays').load('/contiguous?year='+h)},dataType:'json'})});$('#select_year').live('change',function(){location='/'+$('#select_year').val()});$('.wh').live('click',function(){var b=$(this).parent();var c=$(this);var d=c.attr('id').substr(3);var e=c.attr('checked')?1:0;$.ajax({url:'/ajax/toggleWorkingHoliday',data:{id:d,status:e},success:function(a){if(a.new_status){b.addClass('selected')}else{b.removeClass('selected')}},dataType:'json'})});$('.nww').live('click',function(){var b=$(this).parent();var c=$(this);var d=c.attr('id').substr(4);var e=c.attr('checked')?1:0;$.ajax({url:'/ajax/toggleNoWorkingWeekday',data:{id:d,status:e},success:function(a){if(a.new_status){b.addClass('selected')}else{b.removeClass('selected')}},dataType:'json'})});$('#fixedRadioButton').live('click',function(){$('#MovingHolidayData').hide();$('#FixedHolidayData').show()});$('#movingRadioButton').live('click',function(){$('#FixedHolidayData').hide();$('#MovingHolidayData').show()});$('#AddHolidayButton').click(function(){var b=document.addExtraHolidayForm;var c=b.description.value;if(!c.length){alert('Το πεδίο "Περιγραφή" δεν πρέπει να είναι κενό.');return}var d=b.fixed[0].checked;var e=b.day_of_month.value;var f=b.month.value;var g=b.days_from_easter.value;if(b.before_after.value=='before'){g=-g}$.ajax({url:'/ajax/addExtraHoliday',data:{description:c,fixed:d?1:0,day_of_month:e,month:f,days_from_easter:g},success:function(a){if(a){document.addExtraHolidayForm.reset();$('#ehdiv').load('/extraholidays')}else{alert('Παρουσιάστηκε σφάλμα.')}},dataType:'json'})});$('.reh').live('click',function(){var b=$(this);var c=b.attr('id').substr(4);$.ajax({url:'/ajax/removeExtraHoliday',data:{id:c},success:function(a){if(a){$('#ehdiv').load('/extraholidays')}else{alert('Παρουσιάστηκε σφάλμα.')}},dataType:'json'})});$('#login').live('click',function(){$('#username_error').hide();$('#password_error').hide();var b=$('#login_username').val();if(!b.length){$('#username_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Όνομα Χρήστη".');$('#username_error').show();$('#login_username').focus();return false}var c=$('#login_password').val();if(!c.length){$('#password_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Κωδικός".');$('#password_error').show();$('#login_password').focus();return false}var d=$('#rememberme').attr('checked')?1:0;$('#throbber').show();$.ajax({url:'/ajax/login',data:{username:b,password:c,rememberme:d},success:function(a){$('#throbber').hide();if(a){$('#success').show();location='/'}else{$('#password_error td.Error').html('Το Όνομα Χρήστη ή/και ο Κωδικός που δώσατε δεν είναι σωστοί.');$('#password_error').show();$('#login_password').focus();return false}},dataType:'json'});return false});$('#cancel_button').live('click',function(){location='/'});$('#change_password_button').live('click',function(){$('#old_password_error').hide();$('#new_password_error').hide();$('#confirm_new_password_error').hide();$('#success').hide();var b=$('#old_password').val();if(!b.length){$('#old_password_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Παλιός Κωδικός".');$('#old_password_error').show();$('#old_password').focus();return false}var c=$('#new_password').val();if(!c.length){$('#new_password_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Νέος Κωδικός".');$('#new_password_error').show();$('#new_password').focus();return false}var d=$('#confirm_new_password').val();if(!d.length){$('#confirm_new_password_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Επιβεβαίωση".');$('#confirm_new_password_error').show();$('#confirm_new_password').focus();return false}if(c!=d){$('#new_password_error td.Error').html('Η Επιβεβαίωση κωδικού δε συμφωνεί με τον Νέο Κωδικό.');$('#new_password_error').show();$('#new_password').focus();return false}if(c==b){$('#new_password_error td.Error').html('Ο νέος κώδικος είναι ίδιος με τον παλιό.');$('#new_password_error').show();$('#new_password').focus();return false}$('#throbber').show();$.ajax({url:'/ajax/changePassword',data:{old_password:b,new_password:c},success:function(a){$('#throbber').hide();if(a){$('#buttons').hide();$('#success').show()}else{$('#old_password_error td.Error').html('Ο Κωδικός που δώσατε είναι λάθος.');$('#old_password_error').show();$('#old_password').focus();return false}},dataType:'json'});return false});$('#save_email_button').live('click',function(){$('email_error').hide();$('#success').hide();var b=$('#email').val();$('#throbber').show();$.ajax({url:'/ajax/changeEmail',data:{email:b},success:function(a){$('#throbber').hide();if(a){$('#buttons').hide();$('#success').show()}else{$('#email_error td.Error').html('Παρουσιάστηκε σφάλμα κατά την αλλαγή του e-mail σας.');$('#email_error').show();$('#email').focus();return false}},dataType:'json'});return false});$('#register_button').live('click',function(){$('#username_error').hide();$('#password_error').hide();$('#confirm_password_error').hide();$('#success').hide();var b=$('#username').val();if(!b.length){$('#username_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Όνομα Χρήστη".');$('#username_error').show();$('#username').focus();return false}var c=$('#password').val();if(!c.length){$('#password_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Κωδικός".');$('#password_error').show();$('#password').focus();return false}var d=$('#confirm').val();if(!d.length){$('#confirm_password_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Επιβεβαίωση".');$('#confirm_password_error').show();$('#confirm').focus();return false}if(c!=d){$('#password_error td.Error').html('Η Επιβεβαίωση κωδικού δε συμφωνεί με τον Κωδικό.');$('#password_error').show();$('#password').focus();return false}var e=$('#rememberme').attr('checked')?1:0;$('#throbber').show();$.ajax({url:'/ajax/register',data:{username:b,password:c,rememberme:e},success:function(a){$('#throbber').hide();if(a){$('#buttons').hide();$('#success').show();location='/'}else{$('#username_error td.Error').html('Το Όνομα Χρήστη που επιλέξατε υπάρχει ήδη.');$('#username_error').show();$('#username').focus();return false}},dataType:'json'});return false});$('#send_message_button').live('click',function(){$('#message_error').hide();$('#success').hide();var b=$('#message').val();if(!b.length){$('#message_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Μήνυμα".');$('#message_error').show();$('#message').focus();return false}var c=$('#email').val();var d=$('#name').val();var e=$('#subject').val();$('#throbber').show();$.ajax({url:'/ajax/sendMessage',data:{email:c,name:d,subject:e,message:b},success:function(a){$('#throbber').hide();if(a){$('#buttons').hide();$('#success').show()}else{alert('Παρουσιάστηκε σφάλμα κατά την αποστολή του μηνύματός σας.');return false}},dataType:'json'});return false});$('#send_password_button').live('click',function(){$('#username_error').hide();$('#email_error').hide();$('#success').hide();var b=$('#username').val();if(!b.length){$('#username_error td.Error').html('Δεν συμπληρώσατε το πεδίο "Όνομα Χρήστη".');$('#username_error').show();$('#username').focus();return false}var c=$('#email').val();if(!c.length){$('#email_error td.Error').html('Δεν συμπληρώσατε το πεδίο "E-mail".');$('#email_error').show();$('#email').focus();return false}$('#throbber').show();$.ajax({url:'/ajax/sendPassword',data:{username:b,email:c},success:function(a){$('#throbber').hide();if(a){$('#buttons').hide();$('#success').show()}else{alert('Ο Κωδικός Χρήστη και το E-mail που δηλώσατε δεν ταιριάζουν.');return false}},dataType:'json'});return false})});
