$(window).scroll(function(){ var test = $(document).height() - $(window).height() - 2620; if ($(window).scrollTop() >= test) { if ($('div[rel=more-container]:last').html() == '') { execute_load(); } } }); function find_product_to_scroll(){ if($('#viewall_cat_scroll').length>0 && !$('#viewall_cat_scroll').attr('done')){ var prodtoscrollto=$('#viewall_cat_scroll').val(); if($('.pbox a[href*="/'+prodtoscrollto+'"').length==0){ execute_load(prodtoscrollto); }else{ window.scrollTo(0,$('.pbox a[href*="/'+prodtoscrollto+'"').position().top-300); $('#viewall_cat_scroll').attr('done',true); } } } function execute_load(prodtoscrollto) { if($('#viewall_cat_scroll').attr('loading')!='true'){ $('#viewall_cat_scroll').attr('loading',true); var d = $('#jsapi_domain').val(); $('div[rel=more-container]:last').html('
'); $.ajax({type:'post', url:'//www.yandy.com/jsapi.php?mode=sloadmore', data: { query:$('#query').val(), seq:$('div[rel=more-container]:last').attr('id'), prod_to_scroll:prodtoscrollto }, success: function(r) { $('div[rel=more-container]:last').html(r); attach_hoverme(); attach_color_box(); if ($('#listen-landing2').length > 0) { rearrange_landing2(); } if ($('#listen-landing-big').length > 0) { rearrange_landing5(); } $('#viewall_cat_scroll').attr('loading',false); find_product_to_scroll(); }}); } }