/*
  $Id: new_products.php, v 1.00 2011/02/16 Harry Lee $

  HORIZONTAL PRODUCT SCROLLER

  Contribution based on:

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery.noConflict();
jQuery(document).ready(function($){
$(".gor").click(function(){
  var maxpn = parseInt($(this).parents('table.scroller').find('.txt_maxpn').text());
  if(maxpn<=1) return false;
  var $thiser = $(this).parent().prev().find(".scrollblock");
  $thiser.slice(0,1).animate({ "left": "-=760" }, {
    duration: 400,
    step: function(now, fx){
      $thiser.slice(1).css("left", now);
    }
  });
  var pn = parseInt($(this).parents('table.scroller').find('.txt_pn').text());
  pn++;
  if(pn>=maxpn) { pn=maxpn; $(this).css("visibility","hidden"); }
  $(this).parents('table.scroller').find('.gol').css("visibility","visible");
  $(this).parents('table.scroller').find('.txt_pn').text(pn);
  $(this).parents('table.scroller').find('.scrollrestart').show();
}).mousedown(function(){
  $(this).attr({'src':'images/icons/bestsale-right-arrow.jpg'});
}).mouseup(function(){
  $(this).attr({'src':'images/icons/bestsale-right-arrow.jpg'});
});

$(".gol").click(function(){
  var $thiser = $(this).parent().next().find(".scrollblock");
  $thiser.slice(0,1).animate({ "left": "+=760" }, {
    duration: 400,
    step: function(now, fx){
      $thiser.slice(1).css("left", now);
    }
  });
  var pn = parseInt($(this).parents('table.scroller').find('.txt_pn').text());
  pn--;
  if(pn<=1) { pn=1; $(this).css("visibility","hidden"); $(this).parents('table.scroller').find('.scrollrestart').hide(); }
  $(this).parents('table.scroller').find('.gor').css("visibility","visible");
  $(this).parents('table.scroller').find('.txt_pn').text(pn);
}).mousedown(function(){
  $(this).attr({'src':'images/icons/bestsale-left-arrow.jpg'});
}).mouseup(function(){
  $(this).attr({'src':'images/icons/bestsale-left-arrow.jpg'});
});

$(".scrollrestart").click(function(){
  var p = parseInt($(this).siblings('.txt_pn').text());
  var oset = '+='+(p * 760 - 760);
  var $thiser = $(this).parents("tr").next().find(".scrollblock");
  $thiser.slice(0,1).animate({ "left": oset }, {
    duration: 400,
    step: function(now, fx){
      $thiser.slice(1).css("left", now);
    }
  });
  $(this).siblings('.txt_pn').text('1');
  $(this).parentsUntil('table').find('.gol').css("visibility","hidden");
  $(this).parentsUntil('table').find('.gor').css("visibility","visible");
  $(this).hide();
});

// featured scroller bof

jQuery('#mycarousel').jcarousel({
        auto: 2,
        wrap: 'circular',
		scroll: 1,
		start: 1,
		offset: 1,
		visible: null,
		size: 6,
		//buttonNextHTML: '<div></div>',
		//buttonPrevHTML: '<div></div>',
        initCallback: mycarousel_initCallback
    });

//$("ul#ticker01").liScroll({travelocity: 0.15});
//$("ul#ticker01").liScroll();
// featured scroller eof

})
