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 += '
 ');
});
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++;
				});
			});
		}
	}
}
');
});
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++;
				});
			});
		}
	}
}