jQuery(document).ready(function($){ $.fn.popup_msg = function (html, option) { $(this).html(html).not(":animated").css({'left' : ($(window).width()-$(this).width())/2+ 'px','top' : ($(window).height()-$(this).height())/2+ 'px'}).fadeIn(300); if(!option) { $(this).click( function() { $(this).fadeOut(); }); } if(option == 'auto') { $(this).delay('300').fadeOut("slow"); } } $('#private_individuals').change(function(){ $("#loading_private").show(100); $.ajax({ type: "POST", url: "/wp-content/themes/theme-ttweb/action/private-individuals_action.php", data: "id="+$("#private_individuals").val(), success: function(html){ $("#private_individuals_html").html(html); $("#loading_private").hide(100); } }); return false; }); $('.sidebar_content li').not('.current-menu-item, .current-menu-ancestor').find('ul').hide(); $('.sidebar_content li a').click(function(){ $(this).next().slideToggle() }); $('#submit_comments').click(function(){ if($('#popup_msg').attr('rel') == 0) { var email = $("#email").val(); if($('#author').val() == '') { $('#popup_msg').popup_msg('Вы забыли ввести имя.'); return false; } if(!isValidEmailAddress(email)) { $('#popup_msg').popup_msg('Некорректный E-Mail.'); return false; } } if($('#comment').val() == '') { $('#popup_msg').popup_msg('Комментарий не может быть пустым.'); return false; } }); $.fn.isValidEmailAddress = function (emailAddress) { var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); return pattern.test(emailAddress); } /* FancyBox */ var fb_IMG_select = 'a[href$=".jpg"]:not(.nofancybox),a[href$=".JPG"]:not(.nofancybox),a[href$=".gif"]:not(.nofancybox),a[href$=".GIF"]:not(.nofancybox),a[href$=".png"]:not(.nofancybox),a[href$=".PNG"]:not(.nofancybox),a[href$=".bmp"]:not(.nofancybox),a[href$=".BMP"]:not(.nofancybox)'; $(fb_IMG_select).addClass('fancybox').attr('rel', 'gallery'); $("a.fancybox").fancybox({ 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'speedIn' : 300, 'speedOut' : 200, 'overlayShow' : true, 'overlayOpacity' : '0.4', 'centerOnScroll' : true, 'showCloseButton' : true, 'showNavArrows' : true, 'titleShow' : false }); });