$(window).load(function (){
  persons_pics = $('a.profile_photo img');
  for(i=0;i<persons_pics.length;i++)
  {
   //alert($(persons_pics[i]).width());
    if ($(persons_pics[i]).width()>=145)
    {
      t =  ($(persons_pics[i]).width()-144)/(-2);
      $(persons_pics[i]).css('margin-left',t+'px');
    }
  }
 
  $('input.vote-star').rating({ 
    callback:  function(value, link) {
      var bookId = $(this).attr('rel');
      objects_add_vote(bookId,  value);
      $('input[rel=' + bookId + ']').rating('readOnly',  true);
    } 
  });
  
  $('.clear_compare').click(function() {
    objects_clear_compare_list(function(data) {
      document.location = '/catalog.html';
    });
  });

  $('.add_compare').click(function() {
    $(this).fadeOut();
    $('#compare').fadeOut();
    objects_add_to_compare_list($(this).attr('rel'),  function(data) {
      if (data > 0) {  
         //$('#compare').html('Сравнить (' +  data + ')');
        $('#compare').fadeIn();
      }
    });
  });
  
  $('.del_compare').click(function() {
    $(this).fadeOut();
    $('#compare').fadeOut();
    objects_del_from_compare_list($(this).attr('rel'),  function(data) {
      if (data > 0) {  
         //$('#compare').html('Сравнить (' +  data + ')');
        $('#compare').fadeIn();
      }
    });
  });
  
  $('.del_compare_compare').click(function() {
    $('#compare').fadeOut();
    var objectId =  $(this).attr('rel'); 
    objects_del_from_compare_list(objectId, function(data)  {
      $('.compare_row_' + objectId).fadeOut();
      if (data > 0)  {  
        //$('#compare').html('Сравнить (' + data + ')');
        $('#compare').fadeIn();
      }
    });
  });
  
  sh_highlightDocument();

  /*$(".tableDiv").each(function()  {
    var  Id = $(this).get(0).id;

    $("#" + Id + " .FixedTables").fixedTable({
      width: 942,
      height: 835,
      fixedColumns: 1,
      classHeader:  "fixedHead",
      classFooter: "fixedFoot",
      classColumn:  "fixedColumn",
      fixedColumnWidth: 230,
      outerId: Id
    });
  });*/
  
  
});


function  showAddress (value, name, mapId) {
  var map = new YMaps.Map(YMaps.jQuery(mapId)[0]);
  map.setCenter(new  YMaps.GeoPoint(37.64, 55.76), 10);
  map.addControl(new YMaps.TypeControl());
  map.addControl(new  YMaps.Zoom());
  var geocoder = new YMaps.Geocoder(value, {results: 1,  boundedBy: map.getBounds()});
  YMaps.Events.observe(geocoder, geocoder.Events.Load,  function () {
    if (this.length()) {
       geoResult = this.get(0);
      //map.addOverlay(geoResult);
      map.setBounds(geoResult.getBounds());
      //map.panTo(geoResult.getGeoPoint());
      map.openBalloon(geoResult.getGeoPoint(),  name, {hasCloseButton:false});
    }
  });
}


