/**
 * Делаем левой меню одинаковым с правой-центральной частью.
 * @param {Boolean} time Вызывать этот метот ещё несколько раз после первого вызова.
 */
function resizeHeight(time) {
  var elm1 = $j('#rightMenu_box');  // Левой меню.
  var elm2 = $j('#main_box');       // Центральная часть.
  if (elm1.length && elm1.length) {
    var minH = 0;                   // Минимальня высота левого меню.
    if (elm1.data('minH') == undefined) {
      minH = elm1.height();
      elm1.data('minH', minH);
    } else {
      minH = elm1.data('minH');
    }
    var elm2H = elm2.height()-10;      // Высота Центральной части.
    if (elm2H > minH) {
      elm1.height(elm2H);           // Устанавливаем высоту левого меню.
    } else {
      elm1.height(minH);
    }

    if (time == true) { // Запускаем вызо этого меттода ещё в течении 10с
      elm1.everyTime(500, 'elm1', function(i) { resizeHeight(false); }, 50);
    }
  }
}

var newsListFormSubmit = function () {
	new Ajax.Request('/ajax.php?function=subscribe', {parameters: $('newsListForm').serialize(),
        onComplete: function(transport){
            //console.log();
            show_lightbox(transport.responseText);
        }
    });
    return false;
};

var show_lightbox = function (text) {
    Modalbox.show("<br><br><br><center><span style='font-size: 16px;font-weight: bold;'>" + text, {title: '<div style="float: right;height: 20px;color: white;"><a href="#" onclick="Modalbox.hide();">X</a></div><div>&nbsp;</div>', width: 300,height : 150});
    Modalbox.deactivate();
};

$j(document).ready(function(){
  // Делаем левой меню одинаковым с правой-центральной частью.
  resizeHeight(true);

  // У связанных продуктов выравниваем по высоте картинку и описание.
  $j('div.product_box > div.product_box_In').each(function(){
  	var obg_picture_box = $j(this).children('.picture_box');
  	var obg_productInfo_box = $j(this).children('.productInfo_box');
  	if (obg_picture_box.length && obg_productInfo_box.length) {
        var picture_box = obg_picture_box.height();
        var productInfo_box = obg_productInfo_box.height();
        var max = (picture_box > productInfo_box) ? picture_box : productInfo_box;
        obg_picture_box.height(max);
        obg_productInfo_box.height(max);
  	}
  });
});

var reloadPics  = function () {
	$j("#dix_zoom_img").scrollable({size: 5,	items: '.items', hoverClass: 'hover'});
}

