function hideDiv(divId) { document.getElementById(divId).style.display = "none"; } function showDiv(divId) { document.getElementById(divId).style.display = "block"; } function changeClass(elementId, className) { document.getElementById(elementId).setAttribute("class", className); } function switchLoginInfo() { $('#account_options').fadeOut(200, function(){ setTimeout("$('#login_container').fadeIn(200)", 60); }); setLoginDefaults(document.getElementById('login_email'), 'Электронная почта', true); setLoginDefaults(document.getElementById('login_password'), 'Пароль', true); } function switchForgotYourPassword() { $('#login_container').fadeOut(200, function(){ setTimeout("$('#password_forgotten').fadeIn(200)", 60); }); setLoginDefaults(document.getElementById('login_email'), 'Электронная почта', true); setLoginDefaults(document.getElementById('login_password'), 'Пароль', true); setLoginDefaults(document.getElementById('password_forgotten_email'), 'Электронная почта', true); } function switchForgotYourPasswordBack() { $('#password_forgotten').fadeOut(200, function(){ setTimeout("$('#login_container').fadeIn(200, function(){setLoginDefaults(document.getElementById('password_forgotten_email'), 'Электронная почта', false);})", 60); setTimeout("clearForgotYourPasswordErrors()", 65); setTimeout("document.getElementById('password_forgotten_notice').style.display = 'none'", 70); setTimeout("document.getElementById('password_forgotten_content').style.display = 'block'", 70); }); } function switchLoginInfoBack() { $('#login_container').fadeOut(200, function(){ setTimeout("$('#account_options').fadeIn(200, function(){setLoginDefaults(document.getElementById('login_email'), 'Электронная почта', false);setLoginDefaults(document.getElementById('login_password'), 'Пароль', false);})", 60); setTimeout("clearFieldErrors()", 65); }); } function setLoginDefaults(fieldHandler, fieldValue, checkForEmpty) { if(!checkForEmpty || fieldHandler.value == '') { fieldHandler.value = fieldValue; fieldHandler.style.color = "#bfbfbf"; } } function clearLoginDefaults(fieldHandler, fieldValue, checkForEmpty) { if(!checkForEmpty || fieldHandler.value == fieldValue) { fieldHandler.value = ''; fieldHandler.style.color = "gray"; } } function setRegistrationDefaults(fieldHandler, fieldValue, checkForEmpty) { if(!checkForEmpty || fieldHandler.value == '') { fieldHandler.value = fieldValue; fieldHandler.style.color = "#bfbfbf"; fieldHandler.style.fontStyle = "italic"; } } function clearRegistrationDefaults(fieldHandler, fieldValue, checkForEmpty) { if(!checkForEmpty || fieldHandler.value == fieldValue) { fieldHandler.value = ''; fieldHandler.style.color = "black"; fieldHandler.style.fontStyle = "normal"; } } function checkLogin() { var error = false; if(document.getElementById('login_email').value == '' || document.getElementById('login_email').value == 'Электронная почта') { document.getElementById('login_email').style.border = '1px solid #ff0000'; document.getElementById('login_username_error').innerHTML = 'Пожалуйста, заполни'; error = true; } if(document.getElementById('login_password').value == '') { document.getElementById('login_password').style.border = '1px solid #ff0000'; document.getElementById('login_password_error').innerHTML = 'Пожалуйста, заполни'; error = true; } if(error == false) { var dataString = 'email='+ document.getElementById('login_email').value + '&password=' + document.getElementById('login_password').value; $.ajax({ type: "POST", url: "/login", data: dataString, success: function(msg) { eval(msg); } }); } } function checkForgotYourPassword() { if(document.getElementById('password_forgotten_email').value == '' || document.getElementById('password_forgotten_email').value == 'Электронная почта') { document.getElementById('password_forgotten_email').style.border = '1px solid #ff0000'; document.getElementById('password_forgotten_email_error').innerHTML = 'Пожалуйста, заполни'; } else { var dataString = 'email='+ document.getElementById('password_forgotten_email').value; $.ajax({ type: "POST", url: "/forgotYourPassword", data: dataString, success: function(msg) { eval(msg); } }); } } function clearForgotYourPasswordErrors() { document.getElementById('password_forgotten_email').style.border = '1px solid #BFBFBF'; document.getElementById('password_forgotten_email_error').innerHTML = ''; } function clearFieldErrors() { document.getElementById('login_email').style.border = '1px solid #BFBFBF'; document.getElementById('login_password').style.border = '1px solid #BFBFBF'; document.getElementById('login_password_error').innerHTML = ''; document.getElementById('login_username_error').innerHTML = ''; } function keepOldPicture(choiceValue) { document.getElementById('registration_keep_old_photo').value = choiceValue; } function keepOldPassword(choiceValue) { document.getElementById('registration_keep_old_password').value = choiceValue; } function enableMessageToCaptain() { $('#message_to_captain_link').fadeOut(200, function(){ $('#message_to_captain_form_container').animate({width: 'show'}, 1000, function(){ $('#message_to_captain_form').fadeIn(200); }); }); } function disableMessageToCaptain() { $('#message_to_captain_form').fadeOut(200, function(){ $('#message_to_captain_form_container').animate({width: 'hide'}, 1000, function(){ $('#message_to_captain_link').fadeIn(200); }); }); setTimeout("clearMessageToCaptainErrors()", 2000); } function flipMessageToCaptain() { if(document.getElementById('message_to_captain_link').style.display == 'none') disableMessageToCaptain(); else enableMessageToCaptain(); } function clearMessageToCaptainErrors() { if(document.getElementById('message_to_captain_error')) { document.getElementById('message_to_captain_error').innerHTML = ''; document.getElementById('message_to_captain_error').style.display = 'none'; } } function displayMessageToCaptainNewFields() { hideDiv('message_to_captain_form'); showDiv('message_to_captain_fields_conf'); } function submitMessageToCaptain() { if(document.getElementById('message_to_captain_content').value == '') { document.getElementById('message_to_captain_error').innerHTML = 'Пишите здесь'; document.getElementById('message_to_captain_error').style.display = 'block'; } else { clearMessageToCaptainErrors(); var email = document.getElementById('message_to_captain_email').value; var phone = document.getElementById('message_to_captain_phone').value; if(!email && !phone) { email = document.getElementById('message_to_captain_email_conf').value; phone = document.getElementById('message_to_captain_phone_conf').value; } if(document.getElementById('sendWithoutEmail').value == 'no' && !email && !phone) { document.getElementById('sendWithoutEmail').value = 'yes'; displayMessageToCaptainNewFields(); return false; } var dataString = 'email=' + email + '&phone=' + phone + '&message='+ document.getElementById('message_to_captain_content').value; $.ajax({ type: "POST", url: "/messageToCaptain", data: dataString, success: function(msg) { eval(msg); } }); } } function joinGroup(group_id) { $.ajax({ type: "POST", url: "/joinGroup/"+group_id+"/form", data: '', success: function(msg) { eval(msg); } }); } function joinGroupLink(group_id) { $.ajax({ type: "POST", url: "/joinGroup/"+group_id+'/link', data: '', success: function(msg) { eval(msg); } }); } function postNewMessage(group_id) { var dataString = 'message='+ $('#new_message_content').html(); $.ajax({ type: "POST", url: "/postMessage/"+group_id, data: dataString, success: function(msg) { eval(msg); } }); } function reArrangeMessages(group_id, orderMethod) { changeClass('message_sort_desc', 'inactive'); changeClass('message_sort_asc', 'inactive'); if(orderMethod == 'ASC') changeClass('message_sort_asc', 'active'); else changeClass('message_sort_desc', 'active'); $.ajax({ type: "POST", url: "/rearrangeMessages/"+group_id+"/"+orderMethod, data: '', success: function(msg) { document.getElementById('group_messages').innerHTML = msg; } }); } function getFreeCruise() { var dataString = ''; $.ajax({ type: "POST", url: "/getFreeCruise", data: dataString, success: function(msg) { eval(msg); } }); }