var coordinates = new Array();

jQuery(document).ready(function($){
	$("h4.search-field-title").bind("click", function() {
		var search_field_list = $(this).parent().children()[1];
		if ($(search_field_list).hasClass("hide")) {
			$(search_field_list).removeClass("hide");
		}
		else {
			$(search_field_list).addClass("hide");
		}
	});
	
	$('.show_hide a').click(function() {
		$('.nonpaid').toggle("fast");
		$('.show_hide').hide();
	});

	//show image previews
	$(".stat_icon.photos").hover(function() {
		$(".image_preview", $(this).parents(".col_body_inner")).show(50);
	}, function() {
		var preview_plane = $(".image_preview", $(this).parents(".col_body_inner"));
		var timeout_preview = setTimeout(function() {$(preview_plane).hide(50)}, 2000);
		imgPreviewReset(preview_plane, timeout_preview);
	});
});

/* swap the sponsored listings */
function swap_cpc_listings(elem) {
    if (typeof(swap_cpc) != 'undefined') {
        if (swap_cpc == 1) {
            var adhtml = $('#'+elem+' #ad-list').html();
            if(adhtml != null) {
                $('#end_of_paid_listings').html('<div id="ad-list">' + adhtml + '</div>').show();
                $('#'+elem+' #ad-list #listing-1').hide();
                $('#'+elem+' #ad-list #listing-2').hide();
                $('#'+elem+' #ad-list #listing-3').hide();
                $('#end_of_paid_listings #listing-4').hide();
                $('#end_of_paid_listings #listing-5').hide();
                //$('#sidebar #ad-list').html('');
            }
        }
    }
}

function imgPreviewReset(preview_plane, ref) {
	$(preview_plane).hover(function() {
		clearTimeout(ref);
	}, function() {
		$(this).hide(50);
	});	
}
