jQuery(document).ready(function(){
jQuery(".main .list-view img").removeAttr("src");
jQuery(".main .list-view").html('');
jQuery(".table-view .btn-toolbar.pull-right").hide();
//jQuery('.gv-table-view').hide(); //used css instead
jQuery('.gv-table-view tr').each(function() {
if (jQuery(this).find('#gv-field-2-139').text() == 'Inactive') {
jQuery(this).remove();
}
});
jQuery('.gv-field-2-139').remove();
jQuery('.gv-table-view').show();
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
var thegategory = getParameterByName('1', jQuery("input[name=gform_field_values]").val());
if(thegategory=='parent-barrels') { thegategory='Barrels & Tanks'; }
if(thegategory=='parent-real-estate-business-opportunities') { thegategory='Real Estate & Business Opportunities'; }
if(thegategory=='parent-jobs') { thegategory='Jobs'; }
if(thegategory=='parent-products') { thegategory='Products'; }
if(jQuery('#choice_2_78_0').prop('checked')==true){ jQuery('#choice_2_62_0').prop('checked',true); }
if(jQuery('#choice_2_78_1').prop('checked')==true){ jQuery('#choice_2_62_1').prop('checked',true); }
if(jQuery('#choice_2_78_2').prop('checked')==true){ jQuery('#choice_2_62_2').prop('checked',true); }
jQuery('#input_2_60').val(jQuery('#input_2_79').val());
jQuery('#input_2_61').val(jQuery('#input_2_80').val());
if(jQuery("#gv-field-2-78").length > 0){
if(jQuery("#gv-field-2-78 td").html().search("Phone") > 0 || jQuery("#gv-field-2-78 td").html().search("Email") > 0 || jQuery("#gv-field-2-78 td").html().search("Both") > 0){
var i_email = jQuery("#gv-field-2-79 a").html();
var i_phone = jQuery("#gv-field-2-80 a").html();
var i_returnsting = '';
if( i_email != undefined ){ i_returnsting += '
('+thegategory+')');
}
jQuery('.page-id-528 #gform_2').show();
jQuery('.page-child .gv-table-view').show();
jQuery('.gv-table-view-content').show();
if(jQuery('#gv-field-2-entry_map').length=='1'){
var stringtoparse_entryid = JSON.stringify(wc_add_to_cart_params).match("\/entry\/(.*)\\/\\?gvid\=");
var current_entryid = stringtoparse_entryid[1];
if(current_entryid>0){
jQuery.post( '/wp-admin/admin-ajax.php', { action: "showmapornot", e: current_entryid}, function(data, status){
if(data=='yes'){
jQuery('#gv-field-2-entry_map').show();
}
else{
jQuery('#gv-field-2-entry_map').html('');
jQuery('#gv-field-2-entry_map').hide();
}
});
}
}
jQuery('.table-view').each(function(){
if(jQuery(this).html()=="You are not allowed to view this content.") {
jQuery(this).html("This url or ad is no longer active on this website. We apologize for the inconvenience.")
}
});
if(jQuery('.gv-table-single-container').length==0){
var i_url = window.location.href;
//if((i_url.search('gv_search=')>0) || (i_url.search('filter_72=')>0)){
if((jQuery('.gv-search-field-search_all input[name=gv_search]').val()!='') || (jQuery('#search-box-filter_72').val()!='')){
jQuery('.gv-table-view tbody tr').each(function(){
var i_html = jQuery(this).html();
if(i_html.search('filter_hide')){
if(i_url.search('/listings/categories/products/')>0){
if(i_html.search('filter_hide gv-field-2-1">Products')<0 &&
i_html.search('filter_hide gv-field-2-1">Grapes')<0 &&
i_html.search('filter_hide gv-field-2-1">Bulk Wine')<0 &&
i_html.search('filter_hide gv-field-2-1">Cased Goods')<0 &&
i_html.search('filter_hide gv-field-2-1">Products Other')<0){
jQuery(this).remove();
}
}
//
//
if(i_url.search('/listings/categories/barrels-tanks/')>0){
if(i_html.search('filter_hide gv-field-2-1">Barrels & Tanks')<0 &&
i_html.search('filter_hide gv-field-2-1">Barrels')<0 &&
i_html.search('filter_hide gv-field-2-1">Tanks')<0 &&
i_html.search('filter_hide gv-field-2-1">Racks')<0 &&
i_html.search('filter_hide gv-field-2-1">Barrels & Tanks Other')<0){
jQuery(this).remove();
}
}
//
//
if(i_url.search('/listings/categories/jobs/')>0){
if(i_html.search('filter_hide gv-field-2-1">Jobs')<0 &&
i_html.search('filter_hide gv-field-2-1">Help Wanted')<0 &&
i_html.search('filter_hide gv-field-2-1">Internships')<0 &&
i_html.search('filter_hide gv-field-2-1">Position Wanted')<0){
jQuery(this).remove();
}
}
//
//
if(i_url.search('/listings/categories/real-estate-business-opportunities/')>0){
if(i_html.search('filter_hide gv-field-2-1">Real Estate & Business Opportunities')<0 &&
i_html.search('filter_hide gv-field-2-1">Vineyards/Wineries')<0 &&
i_html.search('filter_hide gv-field-2-1">Real Estate & Business Opportunities Other')<0){
jQuery(this).remove();
}
}
//
//
if(i_url.search('/listings/categories/winery-equipment-supplies/')>0){
if(i_html.search('filter_hide gv-field-2-1">Winery Equipment & Supplies')<0 &&
i_html.search('filter_hide gv-field-2-1">Cellar Equipment')<0 &&
i_html.search('filter_hide gv-field-2-1">Crush Equipment')<0 &&
i_html.search('filter_hide gv-field-2-1">Chemicals')<0 &&
i_html.search('filter_hide gv-field-2-1">Winery Equipment & Supplies Other')<0){
jQuery(this).remove();
}
}
//
//
if(i_url.search('/listings/categories/vineyard-equipment-supplies/')>0){
if(i_html.search('filter_hide gv-field-2-1">Vineyard Equipment & Supplies')<0 &&
i_html.search('filter_hide gv-field-2-1">Heavy Equipment')<0 &&
i_html.search('filter_hide gv-field-2-1">Vineyard Development')<0 &&
i_html.search('filter_hide gv-field-2-1">Rootstock')<0 &&
i_html.search('filter_hide gv-field-2-1">Vineyard Equipment & Supplies Other')<0){
jQuery(this).remove();
}
}
//
//
if(i_url.search('/listings/categories/custom-services/')>0){
if(i_html.search('filter_hide gv-field-2-1">Custom Services')<0 &&
i_html.search('filter_hide gv-field-2-1">Custom Winemaking')<0 &&
i_html.search('filter_hide gv-field-2-1">Barrel Storage')<0 &&
i_html.search('filter_hide gv-field-2-1">Case Storage')<0 &&
i_html.search('filter_hide gv-field-2-1">Custom Other')<0){
jQuery(this).remove();
}
}
}
});
}
/*
*/
//refine even more if location filter
if(i_url.search('filter_72=')>0){
if(jQuery('#search-box-filter_72').val()!=''){
jQuery('.gv-table-view tbody .gv-field-2-72').each(function(){
if(jQuery(this).html().search(jQuery('#search-box-filter_72').val())<0){
jQuery(this).closest("tr").remove();
}
});
}
}
/*
*/
//part 1 of the toplevelsearch fix
if(amitoplevel == 1){
jQuery('.gv-left form.gv-widget-search').attr('id', 'textsearchform');
var form = document.getElementById('textsearchform');
form.onsubmit = function() {
return false;;
}
jQuery('.gv-left .gv-widget-search .gv-search-box-submit').html('
');
}
}
jQuery(".gv-table-container").not(".manage-ads .gv-table-container").hide();
jQuery(".table-view .gv-widgets-header").append('
');
});
jQuery(window).on("load", function() {
jQuery('.gv-featured-entry').prependTo(".gv-table-view");
var numberofelements = (jQuery('.gv-featured-entry').length)/2;
for (i = 1; i <= numberofelements; i++) {
if(i!=1){
jQuery('.gv-featured-entry:nth-child('+i+')').prependTo(".gv-table-view");
}
}
jQuery(".loadinggif").hide();
jQuery(".gv-table-container").show();
});
var original_status;
var continue_submit = 0;
function memory_pause(miliseconds) {
var currentTime = new Date().getTime();
while (currentTime + miliseconds >= new Date().getTime()) {
}
}
if(jQuery('#choice_2_139_0').length>0){
if(jQuery('#choice_2_139_0').prop("checked")==true){
original_status = 'active';
} else {
original_status = 'inactive';
}
}
jQuery('#gform_2').submit(function() {
var new_status;
if(jQuery('#choice_2_139_0').prop("checked")==true){
new_status = 'active';
} else {
new_status = 'inactive';
}
if(original_status != new_status){
var the_ad_id = jQuery("input[name=lid]").val();
jQuery.post( '/wp-admin/admin-ajax.php', { action: "notify_on_ad_status_change", a: the_ad_id, t: "from "+original_status+" to "+new_status }, function(data, status){
if(status=="success"){ continue_submit=1; }
});
}
memory_pause(2000);
});
var amitoplevel = 0;
var i_url = window.location.href;
if((i_url.search('/listings/categories/products/')>0) ||
(i_url.search('/listings/categories/barrels-tanks/')>0) ||
(i_url.search('/listings/categories/jobs/')>0) ||
(i_url.search('/listings/categories/real-estate-business-opportunities/')>0) ||
(i_url.search('/listings/categories/winery-equipment-supplies/')>0) ||
(i_url.search('/listings/categories/vineyard-equipment-supplies/')>0) ||
(i_url.search('/listings/categories/custom-services/')>0)){
amitoplevel = 1;
}
function toplevelsearch(){
//fix for top level category text searching not working
jQuery('.temp_filterhide').removeClass("temp_filterhide");
if(jQuery('.gv-search-field-search_all input[name=gv_search]').val()!=''){
if(amitoplevel == 1){
var ajax_total_count = jQuery('.gv-table-view tbody .gv-field-2-id').length;
var ajax_counter = 1;
jQuery('.gv-table-view tbody .gv-field-2-id').each(function(){
jQuery('.gv-table-container').not(".manage-ads .gv-table-container").hide();
jQuery('.loadinggif').show();
var entryid_str = jQuery(this).html();
entryid_str = entryid_str.replace(/[^0-9]/g, '');
var newclass = 'filter_text_'+entryid_str;
jQuery(this).addClass(newclass);
jQuery.post( '/wp-admin/admin-ajax.php', { action: "amiinsearch", e: entryid_str, s: jQuery('.gv-search-field-search_all input[name=gv_search]').val()}, function(data, status){
if(data=='no'){
jQuery('.'+newclass).closest("tr").addClass("temp_filterhide");
}
if(ajax_counter==ajax_total_count){
jQuery('.loadinggif').hide();
jQuery('.gv-table-container').show();
}
ajax_counter++;
});
});
}
}
}