function slider(container, count, ofset_move, imgs){
 
     this.container = jQuery(container); // jQuery("#container_name"); контайнер 
     this.count = count; // int количество отобрафаемых блоков в контайнере
     this.ofset_move = ofset_move; // int сдвиг движения в пикселях
     this.imgs = imgs; // array-object 
     this.array_block =new  Array(); //
     this.flag_move = true; // флаг для остановки прокрутки
     this.last_show_img = 0; // номер индекса массива imgs отображонного в блоке
     
     this.show_image = null;
 /////////////////////// функции класса slider
 this.init = init;
 this.get_cur_src = get_cur_src;
 this.move = move;
 this.show_block; 
 }
 ////////////// Обявление функций класса slider //////////////////////
 /////// START --------------------------------
 function get_cur_src(){ // возвращает следующий объект Image для показа
     var img_i = this.last_show_img;
           if( this.last_show_img < this.imgs.length-1 ){
             this.last_show_img++;
           } else  this.last_show_img = 0;      
     return this.imgs[img_i];
 } // END FUNCTION 

var big_img = false;
var flag_show_img = false; 
var big_img = new Image();
 
 function move(){ // двигаем массив  array_block
 
     if( this.flag_move == true && flag_show_img == false){
            var div_move = jQuery("#container > div.div_move");

        for(var i=div_move.length-1; i >= 0 ; i--){
         div_move[i].style.left = div_move[i].offsetLeft + this.ofset_move +"px";
            if( div_move[i].offsetLeft > this.container.get(0).clientWidth ){
                div_move[i].style.display = 'none';
                div_move[i].style.left = -1510 + "px";
                    for(var j=div_move[i].childNodes.length-1; j>=0 ; j--){
                        div_move[i].childNodes[j].childNodes[0].src = this.get_cur_src().src;
                    }
                div_move[i].style.display = '';
            }
        }
     }
 }

 
 function show_block( img ){
    if(flag_show_img == false){
 flag_show_img = true;
    
        var container = jQuery("#container");
        var animation = jQuery("div.animation");
    jTweener.addTween(container, {onComplete :pause, opacity: 0.2, time: 2 });

    var div = jQuery("<div id='show_div_img'></div>");
    var img_new = jQuery("<img src='images/transperent.gif' width='400' height='267' alt='' />");
        div.prepend(img_new);
    div.get(0).style.position = 'absolute';
    //alert((screen.availWidth / 2)-200);
    div.get(0).style.left = (screen.availWidth / 2)-200 + 'px';
    div.get(0).style.zIndex = 1200;
        animation.prepend(div);
    
        var src_path = img.src.split("/");
    src_path = src_path[src_path.length-1];
    big_img.src = "images/slider/big/"+src_path;
    
    }  
 }
 
 function pause(){
    setTimeout(show_load_img,3000);
    /*
    jTweener.addTween(jQuery("#show_div_img"),
                         {  delay : 2,
                            onComplete :show_load_img,
                            //opacity: 0.2,
                            time: 1 });                 
    }
    */
 }
  function pause_2(){
    setTimeout(show_load_img,3000);
 }
 
function show_load_img(){
            var show_div_img = jQuery("#show_div_img");
        if(show_div_img.length!=0 && show_div_img.get(0).childNodes.length == 1){
            show_div_img.get(0).childNodes[0].src = big_img.src;
        //jTweener.addTween(show_div_img, { onComplete :add_onclick, opacity: 1, time: 1 });
        setTimeout(move_back,6000);
        //jTweener.addTween(show_div_img, { onComplete :move_back, time:6 });
        
        }
 }
 /*
 function add_onclick(){
    var show_div_img = jQuery("#show_div_img");
     show_div_img.click( function() { move_back(); } );
 }
 */
 
 function move_back(){
     if(flag_show_img == true){
        var container = jQuery("#container");
        jTweener.addTween(container, {onComplete :delete_efect, opacity: 1, time:4, transition: 'linear'});
        }     
 }
 function delete_efect(){
    //jTweener.removeTween();
    jQuery("#show_div_img").remove();
    flag_show_img = false;
 }
 
 
 /* Array.shuffle( deep ) - র步᳼ 즬殲 飠 촷᪭졮Ⱡ诬

deep - 〧᳥콭顠䴬殲 쯣鸥믣鰠, 롧㡾驠
       쨠櫳飭Ⱡ⡲㡲 㬮禭 飻;
       ஠ᮨ false (ᢠ㡲)
*/
Array.prototype.shuffle = function( b )
{
 var i = this.length, j, t;
 while( i ) 
 {
  j = Math.floor( ( i-- ) * Math.random() );
  t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i];
  this[i] = this[j];
  this[j] = t;
 }

 return this;
};

 
  function init_slider_imgs( arr_imgs, arrtitle, width, height ){
        var imgs = new Array();
    for(var i=0; i<arr.length; i++){
      var img =new Image();
      img.src = arr[i];
      img.title = arrtitle[i];
      img.width = 300;
      img.height = 200;
      imgs[i] =  img;
    }
    return imgs.shuffle(); 
  }
 
 function init(){
   // создается массив блоков (Количество отображаемых блоков + 2-ва служебных)
  /////////////////////////////////////////////////// 
  var div_1 = jQuery("<div class='div_move'></div>");
  var div_2 = jQuery("<div class='div_move'></div>");
        div_1.get(0).style.left = -300 + "px";
        div_2.get(0).style.left = -1555 + "px";
       for( i = 0; i < (this.count+1); i++){  
           var img = jQuery("<img src='"+this.get_cur_src().src+"' title='"+ this.imgs[i].title +"' alt='"+ this.imgs[i].title +"' onclick='show_block(this);' width='"+this.imgs[0].width+"' height='"+this.imgs[0].height+"' />");
            var div = jQuery("<div></div>");
                if(i&1) div.addClass("divBottom"); // каждый нечетному присваеваем класс  
                
                div.prepend(img); 
                div_1.prepend(div);   
    }
        this.container.prepend(div_1);
    
    
    for( i = 0; i < (this.count+1); i++){  
           var img = jQuery("<img src='"+this.get_cur_src().src+"' title='"+ this.imgs[i].title +"' alt='"+ this.imgs[i].title +"' onclick='show_block(this);' width='"+this.imgs[0].width+"' height='"+this.imgs[0].height+"' />");
            var div = jQuery("<div></div>");
                if(i&1) div.addClass("divBottom"); // каждый нечетному присваеваем класс  

                div.prepend(img); 
                div_2.prepend(div);    
    }
        this.container.prepend(div_2);
 } // END FUNCTION
 /////// END ----------------------------------

