$(function(){
  /*-------------------------------------------------------------------*/
    var photoboxSRC = $('#photosrc').val(),ctlnkhov = false;
    if($('#photosrc').size()>0 && 0==$('#photobox').size())
      $('#content').append('<div id="photobox"><div id="photoboxtext"></div><div id="photoboxpre">Идет загрузка изображения.<br><span>Пожалуйста, подождите.</span></div><center><img id="photoboximg" border="0" width="1" height="1"></center></div>');
    var  photobox = $('#photobox');

    $("#photoboximg").load( function() { $('#photoboxpre').hide(); $(this).fadeIn('fast');} );

    $("a.ctlnk").hover(function(){
      ctlnkhov = true;
      $('#photoboxpre').show();
      photobox.show();

      var bfile = $(this).attr('bfile');
      var h = $(this).attr('h');
      var w = $(this).attr('w');
      var alt =  $(this).children("img").attr('alt');

      $('#photoboxtext').text(alt).width((w-12)+'px');
      photobox.width(w+'px').height(h+'px');

      $('#photoboximg').hide().attr('width', w).attr('height', h).attr('src', photoboxSRC+bfile);
    },function(){
     ctlnkhov = false;
     photobox.height('auto');
     //setTimeout(function (){if(!ctlnkhov) photobox.animate({ width: 0, height: 0}, 'fast',function (){$(this).hide();});},500);
     setTimeout(function (){if(!ctlnkhov) photobox.hide()},700);
     $('#photoboxpre').hide();
     $('#photoboximg').hide().attr('width', 1).attr('height', 1);
    });
  /*-------------------------------------------------------------------*/
   // Раздел с изделием
  /*Привьюшки click*/
  var bigitemimg = $('#bigitemimg');
  $('.itemsimg img').click( function() {
      if($(this).is('.itemsimgsel'))
        return false;
      $('.itemsimg img').removeClass('itemsimgsel');
      $(this).addClass('itemsimgsel');
      var idimg = $(this).attr('idimg');
      var bh=$(this).attr('bh'),bw=$(this).attr('bw');

      bigitemimg.fadeOut('slow',function(){
         bigitemimg.attr('src', bigitemimg.attr('presrc')+idimg+'.jpg' )
         .load( function() { bigitemimg.fadeIn('slow');})
         .attr('height',bh).attr('width',bw);
      });
      return false;
    });
  /*--------------------------эффекты для заголовков--------------------------*/
  if (!$.browser.msie)
     $('h1',content).append('<b></b>');
  /*-------------------------------------------------------------------*/
 var iteminsert = $('#iteminsert');
 if(iteminsert.size()>0)
   {
    iteminsert.height( Math.min(700,iteminsert.get(0).scrollHeight) );
    if((iteminsert.height()+20) < iteminsert.get(0).scrollHeight )
      {
       var insitem = $('.insitem',iteminsert);
       iteminsert.get(0).scrollTop = parseInt(insitem.index( $('.selinsitem')[0] ))*parseInt(iteminsert.get(0).scrollHeight/insitem.size());
      }
   }
});