jQuery(document).ready(function(){
  for (i=1;i<20;i=i+1){
    if (jQuery('#img'+i).height()>0) {document.getElementById('photodiv').scrollLeft =i*91-90}}


  l=jQuery('#main').height();
  l2=jQuery('#scroll').height();
  fix=l2;
  if (l2<400) {l2=l2}
  kk=345;
  if(document.all && document.getElementById && !window.opera ){l=l-30;kk=455;l2=l2-20}
  l3=0;
  l5=0;
  l4=0;

  k=1;

  if (l>1000) {l=1000}
 if(jQuery('#sidebar .external_links').height()>10){
   if ((l-170-jQuery('#sidebar .external_links').height())>280){jQuery('#wrap_scroll').css('height',l-170-jQuery('#sidebar .external_links').height());}
   else{jQuery('#wrap_scroll').css('height',280);}
 }
 else{
   if((l-215)>425){jQuery('#wrap_scroll').css('height',l-215);}
   else{jQuery('#wrap_scroll').css('height',kk);}
 }

 if (fix<400) {jQuery('#wrap_scroll').css('height',l2)}

 if (l2>280){
    vvv=setInterval('movie2()',40);
    jQuery("#scroll").hover(function(){clearInterval (vvv);},
    function(){vvv=setInterval('movie2()',40);});

    jQuery("#scroll2").hover(
      function(){clearInterval (vvv);},
      function(){vvv=setInterval('movie2()',40);});
    }
})

function movie2(){
  if(l3>-l2){
    l3--;
    l5--;
    jQuery('#scroll').css('top',l3);
    jQuery('#scroll2').css('top',l5);
  }
  else{if (l4>0){l4=l4-1;l5=l5-1;jQuery('#scroll').css('top',l4);jQuery('#scroll2').css('top',l5);} else {l3=0;l5=0;}}
}

function view_img(src, title)
{
  show_loader();
  jQuery('.view_photo').attr({'src': src, 'alt': title});
  jQuery('.title').text(title);
}
function show_loader()
{
  height = jQuery('.main_img').height();
  jQuery('.view_photo').css({display: "none"});
  jQuery('.loader').css({display: "block", height: height});
}

function hide_loader()
{
  jQuery('.loader').css({display: "none"});
  jQuery('.view_photo').css({display: "block"});
}

