function cp_tab_control(){var e=[],r=[];jQuery("ul.tabnavig a").each(function(){window.location.pathname.match(this.pathname)&&(e.push(this),r.push(jQuery(this.hash).get(0)))}),""!==window.location.hash&&window.location.hash.search("block")>=0?(jQuery(r).hide().filter(window.location.hash).show(),jQuery(e).filter(function(){return jQuery(this).attr("href")===window.location.hash}).addClass("selected"),jQuery("html").scrollTop(jQuery(window.location.hash).parent().position().top)):(jQuery(r).hide().filter(":first").show(),jQuery(e).filter(":first").addClass("selected")),jQuery(e).click(function(){return jQuery(r).hide().filter(this.hash).fadeIn(100),jQuery(e).removeClass("selected"),jQuery(this).addClass("selected"),!1})}function imagePreview(){var e=10,r=30;jQuery("a.preview").hover(function(t){var a=jQuery(this).find("img").attr("alt");jQuery("body").append("

"+a+"

"),jQuery("#preview").css("top",t.pageY-e+"px").css("left",t.pageX+r+"px").fadeIn("fast")},function(){jQuery("#preview").remove()}),jQuery("a.preview").mousemove(function(t){jQuery("#preview").css("top",t.pageY-e+"px").css("left",t.pageX+r+"px")})}function unescapeHtml(e){var r=document.createElement("div");r.innerHTML=e;var t=r.childNodes[0].nodeValue;return r.removeChild(r.firstChild),t}function addRemoveCheckboxValues(e,r){var t;e.checked===!0?(t=document.getElementById(r),t.value+=","+e.value,t.value=t.value.replace(/^\,/,"")):(t=document.getElementById(r),t.value=t.value.replace(e.value+",",""),t.value=t.value.replace(e.value,""),t.value=t.value.replace(/\,$/,""))}function trim(e){for(var e=e.replace(/^\s\s*/,""),r=/\s/,t=e.length;r.test(e.charAt(--t)););return e.slice(0,t+1)}function enableNextImage(e,r){jQuery("#upload"+r).removeAttr("disabled")}function cp_currency_position(e){var r=classipress_params.currency_position,t=classipress_params.ad_currency;switch(r){case"left":return t+e;case"left_space":return t+" "+e;case"right":return e+t;default:return e+" "+t}}function cp_show_price_slider(e,r,t,a,i){a=!i&&1e3>=a?r:i&&a>=1e3?1e3:a,jQuery("#slider-range").slider({range:!0,min:e,max:i?1e3:r,step:1,values:[t,a],slide:function(e,r){jQuery("#amount").val(cp_currency_position(r.values[0])+" - "+cp_currency_position(r.values[1]))}}),jQuery("#amount").val(cp_currency_position(jQuery("#slider-range").slider("values",0))+" - "+cp_currency_position(jQuery("#slider-range").slider("values",1)))}function cp_reposition_widgets(){jQuery(window).width()>800?(jQuery(".content_left #welcome_widget").prependTo(".content_right"),jQuery(".content_left #refine_widget").prependTo(".content_right")):(jQuery(".content_right #welcome_widget").prependTo(".content_left"),jQuery(".content_right #refine_widget").prependTo(".content_left"))}function confirmBeforeDeleteAd(){return confirm(classipress_params.text_before_delete_ad)}function cp_handle_form_category_select(){jQuery("#catlvl0").attr("level",0),jQuery("#catlvl0 #ad_cat_id").val()>0&&cp_get_subcategories(jQuery("#catlvl0 #ad_cat_id"),"catlvl",1,classipress_params.ad_parent_posting),jQuery(document).on("change","#ad_cat_id",function(){currentLevel=parseInt(jQuery(this).parent().attr("level"),10),cp_get_subcategories(jQuery(this),"catlvl",currentLevel+1,classipress_params.ad_parent_posting),jQuery.each(jQuery(this).parent().parent().children(),function(e,r){e>currentLevel+1&&jQuery(r).remove(),currentLevel+1===e&&jQuery(r).removeClass("hasChild")}),jQuery("#chosenCategory input:first").val(jQuery(this).val()>0?jQuery(this).val():jQuery("#catlvl"+(currentLevel-1)+" select").val()>0?jQuery("#catlvl"+(currentLevel-1)+" select").val():"-1")})}function cp_get_subcategories(e,r,t,a){parent_dropdown=jQuery(e).parent(),category_ID=jQuery(e).val(),results_div=r+t,jQuery(parent_dropdown).hasClass("hasChild")||jQuery(parent_dropdown).addClass("hasChild").parent().append('
'),jQuery.ajax({type:"POST",url:classipress_params.ajax_url,dataType:"json",data:{action:"dropdown-child-categories",cat_id:category_ID},beforeSend:function(){jQuery("#getcat").hide(),jQuery("#ad-categories-footer").addClass("ui-autocomplete-loading").slideDown("fast")},complete:function(){jQuery("#ad-categories-footer").removeClass("ui-autocomplete-loading")},error:function(){},success:function(i){i.success===!0?(jQuery("#"+results_div).html(i.html).slideDown("fast"),whenEmpty=1===t?!1:!0):(jQuery("#"+results_div).slideUp("fast"),whenEmpty=-1===jQuery(e).val()&&2===t?!1:!0),"yes"===a&&jQuery("#chosenCategory input:first").val()>0?jQuery("#getcat").fadeIn():whenEmpty&&"whenEmpty"===a&&jQuery("#chosenCategory input:first").val()>0?jQuery("#getcat").fadeIn():jQuery("#"+r+(t-1)).hasClass("childCategory")&&jQuery(e).val()>-1&&"no"===a?jQuery("#getcat").fadeIn():jQuery("#getcat").fadeOut()}})}jQuery(document).ready(function(e){jQuery.isFunction(jQuery.fn.selectBox)&&(jQuery("select").selectBox({menuTransition:"fade",menuSpeed:"fast"}),jQuery(".form_step #ad-categories select").selectBox("destroy"),jQuery(".reports_form select").selectBox("destroy")),jQuery.isFunction(jQuery.fn.tinyNav)&&jQuery(".header_menu_res .menu").tinyNav({active:"current-menu-item",header:classipress_params.text_mobile_navigation,header_href:classipress_params.home_url,indent:"-",excluded:["#adv_categories"]}),jQuery(".img-main img, .post-gallery img").mouseover(function(){jQuery(this).stop().animate({opacity:.6},200)}).mouseout(function(){jQuery(this).stop().animate({opacity:1},200)}),jQuery("#step1 .form_step").length>0&&cp_handle_form_category_select(),imagePreview(),cp_tab_control(),jQuery(window).bind("resize",cp_reposition_widgets),cp_reposition_widgets(),jQuery("#s").autocomplete({source:function(e,r){jQuery.ajax({url:classipress_params.ajax_url,dataType:"json",data:{action:"ajax-tag-search-front&tax="+classipress_params.appTaxTag,term:e.term},error:function(){},success:function(e){r(jQuery.map(e,function(e){return{term:e,value:unescapeHtml(e.name)}}))}})},minLength:2}),jQuery(".entry-content a, .post a").each(function(e,r){var t=r.href;/\.(jpg|jpeg|png|gif)$/.test(t)&&jQuery(this).has("img").attr("data-rel","colorbox")}),jQuery.isFunction(jQuery.colorbox)&&(jQuery("a[data-rel='colorbox']").colorbox({transition:"fade",rel:"colorbox",current:"",scrolling:!1,slideshow:!1,maxWidth:"100%",maxHeight:"100%",slideshowAuto:!1,title:function(){return jQuery(this).find("img").attr("title")}}),jQuery("#mainImageLink").click(function(){jQuery("#thumb1").click()})),jQuery(document).bind("cbox_open",function(){jQuery("object, embed, iframe").css({visibility:"hidden"})}),jQuery(document).bind("cbox_closed",function(){jQuery("object, embed, iframe").css({visibility:"inherit"})}),jQuery.isFunction(jQuery.fn.validate)&&(jQuery("#your-profile").validate({errorClass:"invalid"}),jQuery(".form_contact").validate({errorClass:"invalid"}),jQuery(".form_step, .form_edit").validate({ignore:".ignore",errorClass:"invalid",errorPlacement:function(e,r){var t=r.hasClass("wp-editor-area");if(t){var a=jQuery("#"+r.attr("id")+"_ifr");jQuery(a).addClass("tinymce-invalid"),jQuery(r).addClass("tinymce-invalid"),jQuery(r).parent().find(".tinymce-invalid").css({border:"1px solid #C00"})}if("checkbox"==r.attr("type")||"radio"==r.attr("type"))r.closest("ol").after(e);else if(jQuery.isFunction(jQuery.fn.selectBox)&&r.is("select"))if(jQuery(window).width()>600){var i=jQuery(r).next();e.insertAfter(i),e.css("display","block")}else e.insertBefore(r);else jQuery(window).width()>600?(e.insertAfter(r),e.css("display","block")):e.insertBefore(r)},highlight:function(e,r,t){jQuery(e).addClass(r).removeClass(t),jQuery(e).parent().find("a.selectBox").addClass(r).removeClass(t).focus(),jQuery(e).parent().find(".tinymce-invalid").css({border:"1px solid #C00"}),jQuery(e).parent().find(".tinymce-invalid").css({"background-color":"#FFEBE8"})},unhighlight:function(e,r,t){jQuery(e).removeClass(r).addClass(t),jQuery(e).parent().find("a.selectBox").removeClass(r).addClass(t),jQuery(e).parent().find(".tinymce-invalid").css({border:"none"})},submitHandler:function(e){setTimeout(function(){jQuery("input[type=submit]").attr("disabled",!0).attr("value",classipress_params.text_processing).addClass("clicked")},1),e.submit()}}),jQuery("#commentform").validate({errorClass:"invalid",errorElement:"div",errorPlacement:function(e,r){e.insertAfter(r)}}),jQuery("#commentform").fadeIn()),classipress_params.require_images&&"undefined"!=typeof window.appFileCount&&jQuery("input[type=submit]").on("click",function(){return window.appFileCountBrowser=0,jQuery('input[type="file"]').each(function(){""!=jQuery(this).val()&&(window.appFileCountBrowser+=1)}),0==window.appFileCountBrowser&&0==window.appFileCount?(jQuery("#app-attachment-upload-container .app-attachment-info .required-image").remove(),jQuery("#app-attachment-upload-container .app-attachment-info").append('

'+classipress_params.text_require_images+"

"),jQuery("#app-attachment-upload-container .app-attachment-info .required-image").delay(5e3).fadeOut("slow"),!1):void 0}),jQuery.isFunction(jQuery.fn.easyTooltip)&&jQuery("#mainform a").easyTooltip(),jQuery.isFunction(jQuery.fn.footable)&&jQuery(".footable").footable(),jQuery(".edit a.reports_form_link").on("click",function(){return jQuery(this).parent().parent().find(".reports_form").slideToggle(400),!1}),jQuery("#ad_cat_id").val()>0&&jQuery("#ad_cat_id").trigger("change"),e("a.button, a.btn_orange, .subcat-list .cat-item a, .post-meta a, .comment-bubble a, .tagcloud a, a[class*=tag-link], .paging a").addClass("cp-fixed-color"),jQuery(".pages a").addClass("btn_orange"),jQuery(".dynamic-content").on("click",function(){var e=jQuery(this).attr("id"),r="."+e+"-placeholder";if(jQuery(r).length){jQuery(r).append('');var t={action:"cp_dynamic_content",content:e,security:classipress_params.nonce};jQuery.post(classipress_params.ajax_url,t,function(e){jQuery(r).after(e),jQuery(r).remove()})}}),jQuery(".order-gateway button.button, .order-gateway input[type=submit]").addClass("btn_orange"),jQuery("#critic-review-wrap").addClass("shadowblock"),jQuery("#critic-review-wrap input[type=submit]").addClass("btn_orange"),jQuery("#critic-review-wrap .critic-reviews-title").addClass("dotted")}),jQuery.fn.extend({highlight:function(e,r,t){var a=new RegExp("(<[^>]*>)|(\\b"+e.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")+")",r?"ig":"g");return this.html(this.html().replace(a,function(e,r,a){return"<"===e.charAt(0)?e:''+a+""}))}});