/*
 * jQuery JavaScript Library v1.3.2
 * http://jquery.com/
 *
 * Copyright (c) 2009 John Resig
 * Dual licensed under the MIT and GPL licenses.
 * http://docs.jquery.com/License
 *
 * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
 * Revision: 6246
 */

jQuery.noConflict();
jQuery(document).ready(function($) {
 
  

  jQuery("div.scrollable").scrollable({         
    size: 1,         
    items: '#thumbs',           
    //hoverClass: 'hover',   
    // Autoscrolling
    //interval: 50,
   
    clickable: true,    
    loop: false,
    speed: 1000,  
    indexed: true,  
    onSeek: function() {
    //alert(this.getPageIndex());
    //alert(this.getPageAmount());
    var item = this.getVisibleItems();
   //alert(this.getIndex());
    
    jQuery("#cur_slider_page")[0].value = this.getIndex(); 
    },    
     // before seek starts get the clicked element
     onBeforeSeek: function() {
          
      if((this.get_clicked_index() >0)){
          
          // get the clicked element
          var new_cur_val = this.get_clicked_index();         
            
          // the slider holds at the second element (if 3, it is in the middle!) 
          if(new_cur_val>0){
              new_cur_val -= 2;
          }
          // set the cur_slider Page to the hidden field
          jQuery("#cur_slider_page")[0].value = new_cur_val;
          
      }else{
          jQuery("#cur_slider_page")[0].value = 0;      
      }
      
                   
     }
    /*
     // when seek ends resume items to full transparency
     onSeek: function() {
     this.getItems().fadeTo(300, 1);
     }, 
    */ 
  
        
  });  
  
 if(jQuery("#cur_slider_page").length > 0) {
    // get the current slider page form hidden field
    var cur = jQuery("#cur_slider_page")[0].value;
  
    var api = jQuery("div.scrollable").scrollable({api: true}); 
    
    // go to current slider page    
    api.move(cur);
 }
  
  
});

