/*function get(id)
{
    return document.getElementById(id);
}

var scroller = get('scroller');
var scrollerBar = get('scroller_bar');
var object = get('object');
var content = get('content');
var bottom=get('bottom')

// Ширина видимой части объекта (в нашем случае — таблицы)
var objectHeight = galery_menu.offsetHeight; 

// Ширина объекта целиком
var objectTrackHeight = scroller.offsetHeight; 
// Захватить
bottom.onmousemove = drag;

// Перетащить
window.onmousemove = move;

// Бросить
bottom.onmouseover = drop;


/ Эта переменная нам поможет определить:
// Мы просто двигаем мышью по экрану или все-таки перетаскиваем ползунок
var canDrag = false;

// Здесь будем хранить начальный сдвиг ползунка
var shift_x;    

function drag(event)
{
    if (!event)
    {
        // Всем известно, что в Mozilla event передается как параметр
        // А в IE его можно получить вот так:
        event = window.event;
    }
    
    // Отметим, что мы захватили ползунок.
    // Теперь при сдвиге мыши, ползунок должен сдвинуться вместе с ней
    canDrag = true;
    
    // А так же запомним начальный сдвиг
    shift_x = event.clientX - parseInt(scroller.style.left);
    return false;
}

function move(event)
{
    if (!event)
    {
        event = window.event;
    }
    // Здесь мы как раз и проверяем:
    // Сдвигать ли нам ползунок вслед за мышью, или оставить его неподвижным
    if (canDrag)
    {
        setPosition(event.clientX - shift_x);
    }
    return false;
}

function drop()
{
    // Освобождаем ползунок
    canDrag = false; 
}

function setPosition(newPosition)
{
    // Проверим не выйдет ли наш ползунок за границы полосы прокрутки
    // Заметим что предельной точкой справа является разность ширины полосы прокрутки и ширины ползунка
    // Ведь мы устанавливаем позицию его левой границы
    if ( (newPosition <= scrollerTrackWidth - scrollerWidth) && (newPosition >= 0) )
    {
        scroller.style.left = newPosition + "px";
    }
    else if (newPosition > scrollerTrackWidth - scrollerWidth)
    {
        scroller.style.left = scrollerTrackWidth - scrollerWidth + "px";
    }
    else
    {
        scroller.style.left = 0 + "px";
    }
    // Вслед за ползунком передвинем меню:
    menu.style.marginLeft = Math.round( parseInt(scroller.style.left)  * delta * (-1) ) + "px";
    return false;
}
*/
window.onload=function(){
var imgs = new Array();
$('.small_photo').each(function(){
    

imgs.push(new Image());
imgs[imgs.length-1].src=$(this).attr('rel');
//console.log('1');
});
}

$(document).ready(function(){


//$("img.galery_screen").attr('src', $(".small_photo:last").attr('rel'));

$(".small_photo").click(function(){
var pict=$(this).attr('rel');
//$(".small_photo_div").css({background:"#000"});
$(".small_photo_div_activ").attr("class","small_photo_div");
$(this).parent().attr("class","small_photo_div_activ");
$("img.galery_screen_photo").fadeOut(300, function(){
	$("img.galery_screen_photo").attr('src',pict).load(function(){
	$("img.galery_screen_photo").fadeIn(300);
	});
});

      /* setTimeout(function(){
           $("img.galery_screen").attr('src',pict);
           $("img.galery_screen").fadeIn(300);}, 300);*/
});
});



















/*


function show(){
var scroll=$(".scroller");
var margin=$(".scroller").attr('margin-top');
var screen=$(".galery_menu");
heightScroll=scroll.height();
heightScreen=screen.height();
var step=((heightScroll-310)/(heightScreen+130))*(-1);
var max=302+heightScreen-108;
var maxM=-1*(heightScreen-heightScroll);
var mouseIn = false;
var animated = false;
//alert(heightScroll+","+heightScreen+","+max+","+step);
$('.scroller').mouseenter(function(mouse){
    animated = true;
    
    marg = (mouse.pageY-302)*step
  if (mouse.pageY>(max)){
    marg = maxM*(-1);
}
    $(".scroller").animate({marginTop:marg}, 250, function(){

        animated=false;
    });
});

$(".scroller").mousemove(function(kmouse){
mouseIn = true;
if (!animated){
$(".scroller").css({marginTop:((kmouse.pageY-302)*step)});
if (kmouse.pageY>(max)){
//$(".scroller").css({marginTop:maxM*(-1)});
}
if (kmouse.pageY<302){
$(".scroller").css({marginTop:0});
}

}
});

$(".galery_menu").mouseleave(function(kmouse){
mouseIn = false;
setTimeout(function(){
if (!mouseIn && ! animated)
$(".scroller").animate({marginTop:0}, 'slow');
}, 300);
});

}

*/



function show(){
var y=0;//координаты по оси Y
var nahozdenie;//Местоположение(Top/Center/Bottom)
var pos="out";
var i=0;
var max=$(".scroller").height()-$(".galery_menu").height();

jQuery.fx.interval = 50;

//$(".galery_menu").click(function(){
//alert(y)}
//)
    setInterval(function(){
     //$(".hleb").text(y+" "+nahozdenie+" "+pos+" "+i)
     if (pos=="in"){
         if (nahozdenie=="Bottom"){if (i<max){i=i+2}else{i=max}}
         if (nahozdenie=="Top"){if (i>0){i=i-2}else{i=0}}
     }
     $(".scroller").css({marginTop: -i});
    // $(".scroller").animate({marginTop:-i},3,"swing")

    }, 10)


$(".galery_menu").mouseenter(function(){pos="in"})
$(".galery_menu").mouseleave(function(){pos="out"})
$(document).mousemove(
function(kmouse){
y=kmouse.pageY; 
if ((y>302)&&(y<350)){nahozdenie="Top"}else if ((y>350)&&(y<610)){nahozdenie="Center"}else{nahozdenie="Bottom"}



})

}












  $(document).ready(function(){navigate();show()})

  



function navigate(){
var activ=0;
var slide=false;
$(".body_bag").click(function(){
   
       
          if (slide==true){
        $("#navigate_block").slideUp(300);
        setTimeout(function(){$(".nav_hover").hide();$(".navig").css({height:0});slide=false;},300 );
      }});
    $(".nav").click(function(){
	   


    
      if (slide==false){

        $(".navig").css({height:($("#navigate_block").height()+50)});
        $("#navigate_block").slideDown(300);
        $(".nav_hover").show();
         $("#navigate_block").css({opacity: "0.9"});
         slide=true; }else{
        $("#navigate_block").slideUp(300);
        setTimeout(function(){$(".nav_hover").hide();$(".navig").css({height:0});},300 );
        slide=false;
         }
       
    })
$("div#navigate_block").mousemove(function(){activ=2;})


};
