$(document).ready(function() {
  if ($('div#product-list div#pictures div.thumbnail').length) {
	  $('div#pictures div a[rel^="thumbnail-"]').click(function() {
      var picturesid = $(this).attr('rel').substr(10);
			$('div#picture a').css('height', $('div#picture img').height()).attr('href', '/products/picture_'+picturesid+'-600x_-f.jpg')
				   .children('img').hide().attr('src', '').attr('src', '/products/picture_'+picturesid+'-500x_-c.jpg').load(function() {
           $('div#picture a img').show();
    			 $('div#picture a').css('height', 'auto');
				 });
			$(this).parent('div').addClass('active').siblings('div').removeClass('active');		
			return false;
		});
	}
	if ($('div#product-list div#drawings').length) {
	  if (!$.browser.msie) $('div#product-list').jScrollPane({reinitialiseOnImageLoad:true, showArrows:true, scrollbarWidth: 13, arrowSize: 16});
		$('div#content div.product div#drawings table td.image > div').hover(
		 function() {
			 $(this).children('div.options').show();
		 },
		 function() {
			 $(this).children('div.options').hide();
		 }
		);
  }
	if ($('div#product-list div#pictures').length && !$.browser.msie) {
	  $('div#product-list').jScrollPane({reinitialiseOnImageLoad:true, showArrows:true, scrollbarWidth: 13, arrowSize: 16});
	}
	$('div#pdfimage a[rel]').click(function() {
	  $('a#'+$(this).attr('rel')).trigger('click');
	  return false;
	});
	  if ($.browser.msie) {
    var activeelement = $('#product-list tr.active');
    if (activeelement.length) {
      activeelement = document.getElementById(activeelement.attr('id'));
      document.getElementById('product-list').scrollTop = activeelement.offsetTop;
    }
  }
});
