var newsListFormSubmit = function () {
	new Ajax.Request('/ajax.php?function=subscribe', {parameters: $('newsListForm').serialize(),
        onComplete: function(transport){
            //console.log();
            show_lightbox(transport.responseText);
        }
    });
};

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();
};


var show_lightboxtwo = function (text) {
    Modalbox.show("<br><br><center><span style='font-size: 16px;font-weight: bold; color:black;'>" + text, {title: '<div style="float: right;height: 20px;color: white;"><a href="#" onclick="Modalbox.hide();"><strong>X</strong></a></div><div>&nbsp;</div>', width: 300,height : 250});
    Modalbox.deactivate();
};

var forgotPassword = function (email) {

   	new Ajax.Request('/ajax.php?function=forgot_password&email='+email, {
        onComplete: function(transport){
            show_lightboxtwo(transport.responseText);
        }
    });
};

var restoryPassword = function (email) {
	new Ajax.Request('/ajax.php?function=restoryPass&email='+email, {
        onComplete: function(transport){
            show_lightboxtwo(transport.responseText);
        }
    });
};

/**
 * Делаем левой меню одинаковым с правой-центральной частью.
 * @param {Boolean} time Вызывать этот метот ещё несколько раз после первого вызова.
 */
function resizeHeight(time) {
  var elm1 = $j('#row1');           // Левой меню.
  var elm2 = $j('#row2');           // Центральная часть.
  var elm3 = $j('#_row1');          // Центральная часть.
  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();      // Высота Центральной части.
    if (elm2H > minH) {
      elm3.height(elm2H);           // Устанавливаем высоту левого меню.
    } else {
      elm3.height(minH);
    }
    if (time == true) {             // Запускаем вызо этого меттода ещё в течении 10с
      elm1.everyTime(500, 'elm1', function(i) { resizeHeight(false); }, 50);
    }
  }
}

$j(document).ready(function(){
  resizeHeight(true);
});


var reloadPics  = function () {
	$j("#dix_zoom_img").scrollable({size: 5, items: '.items', hoverClass: 'hover'})
}