// JavaScript Document
var zoom_timer;
var zoom_photo_id;
function zoom_photo(photo)
{
 clearTimeout(zoom_timer);
 scroll_photos(0);
 zoom_photo_id = photo;
 var h = parseInt(document.getElementById(photo).style.height);
 h = h ? (h+2) : 110;
 document.getElementById(photo).style.height = h +'px';
 var x = 13 - parseInt( (h-108)/(140-108)*(13+12) );
 var y = 16 - parseInt( (h-108)/(140-108)*(16) );
 document.getElementById(photo).style.marginLeft = x +'px';
 document.getElementById(photo).style.marginRight = x +'px';
 document.getElementById(photo).style.marginTop = y +'px';
 document.getElementById(photo).style.marginBottom = y +'px';
 if ( h < 140 )
  { zoom_timer = setTimeout( "zoom_photo('"+ photo + "')", 33 ); }
 else
  { zoom_photo_id = ''; }
}

var unzoom_timer;
function unzoom_photo(photo)
{
 if ( zoom_photo_id == photo )
  { clearTimeout(zoom_timer); }
// clearTimeout(unzoom_timer);
 var h = parseInt(document.getElementById(photo).style.height);
 h = h ? (h-4) : 136;
 document.getElementById(photo).style.height = h +'px';
 var x = 13 - parseInt( (h-108)/(140-108)*(13+12) );
 var y = 16 - parseInt( (h-108)/(140-108)*(16) );
 document.getElementById(photo).style.height = h +'px';
 document.getElementById(photo).style.marginLeft = x +'px';
 document.getElementById(photo).style.marginRight = x +'px';
 document.getElementById(photo).style.marginTop = y +'px';
 document.getElementById(photo).style.marginBottom = y +'px';
 if ( h > 108 )
  { unzoom_timer = setTimeout( "unzoom_photo('"+ photo + "')", 33 ); }
}

var scroll_timer;
function scroll_photos(direction)
{
 clearTimeout(scroll_timer);
 if ( direction )
 {
  document.getElementById('divphotos').scrollLeft = document.getElementById('divphotos').scrollLeft+direction;
  if ( (direction < 0) && (document.getElementById('divphotos').scrollLeft<=0) )
   { document.getElementById('divphotos').scrollLeft = document.getElementById('divphotos').scrollWidth / 2; }

  if ( (direction > 0) && ( (document.getElementById('divphotos').scrollLeft > (document.getElementById('divphotos').scrollWidth / 2) ) ) )
   { document.getElementById('divphotos').scrollLeft = 0; }

  scroll_timer = setTimeout( "scroll_photos("+ direction + ")", 50 );
 }
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
