function hideForm() { if ($("#is-visible2").val() == "false") { $("#image2").css('display', 'none'); $("#image3-text").css('display', 'none'); } if ($("#is-visible3").val() == "false") { $("#image3").css('display', 'none'); $("#image4-text").css('display', 'none'); } if ($("#is-visible4").val() == "false") { $("#image4").css('display', 'none'); } } jQuery(document).ready(function($) { // photo gallery // contact form $("#contact-form").dialog({ title: 'Enquiry', bgiframe: true, autoOpen: false, width: 400, height: 470, modal: true, buttons: { 'Send enquiry': function() { // send mail var vals = $('#send-form').serialize(); $.post("/subpage/contact.php", vals, function(data){ $('#contact-form').html(data); updateListeners(); }); } }, close: function() { //allFields.val('').removeClass('ui-state-error'); } }); function updateListeners() { $('#close-dialog').unbind("click").click(function() { $('#contact-form').dialog('close'); }); } $('#show-contact-form').click(function() { $('#contact-form').dialog('open'); }); // hide image upload hideForm(); $(".add-new-link").each(function() { $(this).click(function () { var url = $(this).attr("href"); if (url == 2) { $("#image2-text").css("display", "none"); $("#image2").css("display", ""); $("#image3-text").css("display", ""); } else if (url == 3) { $("#image3-text").css("display", "none"); $("#image3").css("display", ""); $("#image4-text").css("display", ""); } else if (url == 4) { $("#image4-text").css("display", "none"); $("#image4").css("display", ""); } return false; }); }); $('.delete-ad').click(function() { var answer = confirm("Do you really want to delete this ad?"); if (!answer) return false; }); $('#query').autocomplete({ serviceUrl:'/ajax/manufacturer.php' }); // comments function showLinkCommentListener() { $(".edit-comment-link").each(function() { $(this).click(function () { var id = $(this).attr("href"); $("#comment-text-" + id).css('display', 'none'); $("#comment-edit-div-" + id).css('display', 'block'); return false; }); }); } function editCommentListener() { $(".comment-edit-form").each(function() { $(this).submit(function () { // element id var elementIdSelector = $(this).attr("id"); var dataId = elementIdSelector.substr(18); // comment type var ctype = $("#comment_type").val(); if (ctype != "") ctype = "_" + ctype; // update db $.post('/ajax/edit_comment' + ctype + '.php?id=' + dataId, $(this).serialize(), function() { // hide form, show new value $("#comment-edit-div-" + dataId).css('display', 'none'); var newValue = $("#comment-textarea-" + dataId).val(); $("#comment-text-" + dataId).text(newValue); $("#comment-text-" + dataId).css('display', ''); }); return false; }); }); } showLinkCommentListener(); editCommentListener(); $("#save-settings").click(function () { $("#settings").submit(); return false; }); $(".hide-settings").each(function() { $(this).click(function () { $("#settings-div").hide(); $("#show-settings-div").show(); return false; }); }); $(".show-settings").each(function() { $(this).click(function () { $("#show-settings-div").hide(); $("#settings-div").show(); return false; }); }); // submit ad handler /*$("#ad-submit").click(function () { $(this).attr('disabled', 'true'); $("#ad-loading").show(); });*/ $("#loginbtn").click(function () { $("#login-header-form").submit(); return false; }); $("#searchbtn").click(function () { $("#search-form").submit(); return false; }); $("#lang-select").mouseover(function () { $("#lang-select").hide(); $("#lang-select-list").show(); }); $("#lang-select-list").mouseleave(function () { $("#lang-select-list").hide(); $("#lang-select").show(); }); // hide old image upload form on init $("#img-upload-table").hide(); //$("#old-img-form-table").hide(); // show old image upload form $("#show-old-img-form").click(function () { $("#show-old-img-form").hide(); $("#img-upload-table").hide(); $("#old-img-form-table").show(); return false; }); });