var $j = jQuery.noConflict();
$j(document).ready(function() {
$j("img#offersnotice[title]").tooltip({tip: '#tooltip', effect: 'bouncy'});
$j('#bfbcomments').cycle({fx: 'fade', timeout: 7500});

// paging triggers search
$j('ul.paging li a').live("click",function() {
//$j("#pages").empty();
$j(".pagingstrip p").remove();
$j("#loading").loading({img: 'elements/images/loader.gif'});
//var searchvalues = $j("#bfbsearch").serialize();
var pagenumber = $j(this).html();
values = "&showpage="+pagenumber;
//$j("#pages").empty();
$j("#loading").loading({img: 'elements/images/loader.gif'});
var sorttype = $j('#sorttype').val();
values+= "&search_orderby="+sorttype;
$j.ajax({
type: "POST",
url: "scripts/xhr_get_offers.php",
cache: false,
data: values,
success: function(html){
location.href="#column_top";
$j("#loading").loading(false).empty();
var newhtml = html.split("---");
$j(".pagingstrip").html(newhtml[0]).fadeIn(200).show();
$j(".column_main").empty().html(newhtml[1]).fadeIn(400).show()
$j(".column_main").effect("highlight", {}, 1500);
}
});
return false;
});


// sort
$j("#sorttype").change( function() {
//$j("#pages").empty();
$j(".pagingstrip p").remove();
$j("#loading").loading({img: 'elements/images/loader.gif'});
//var searchvalues = $j("#bfbsearch").serialize();
var pagenumber=$j('ul.paging li.active a').html();
//alert(pagenumber);
values = "showpage="+pagenumber;
var sorttype = $j('#sorttype').val();
values+= "&search_orderby="+sorttype;
//alert(values);
//$j("#pages").empty();
$j("#loading").loading({img: 'elements/images/loader.gif'});
$j.ajax({
type: "POST",
url: "scripts/xhr_get_offers.php",
cache: false,
data: values,
success: function(html){
location.href="#column_top";
$j("#loading").loading(false).empty();
var newhtml = html.split("---");

$j(".pagingstrip").html(newhtml[0]).fadeIn(200).show();
$j(".column_main").empty().html(newhtml[1]).fadeIn(400).show()
$j(".column_main").effect("highlight", {}, 1500);

/*var results = newhtml[2].split("###");
$j("#searchreturned").fadeOut(200).empty().html(newhtml[0]).fadeIn(250).show();
$j("#listing_displayresults").empty().html(newhtml[1]).fadeIn(400).show()
$j(".listingblock").effect("highlight", {}, 1500);
$j("#pages, #pages_bottom").empty().html(newhtml[4]).show();
$j("#results_checkin").empty().html(results[0]).show();
$j("#results_nights").empty().html(results[1]).show();
$j("#results_guests").empty().html(results[2]).show();*/


}
});
return false;
});

// end of document ready
});
