//daAlert v1.1 Original code - Ivan Ognev. Rewritten by Eugene Krotov
function daAlert(contentHTML, titleHTML, buttonText, messageClass){
  $('.daAlert').remove();//Удаляем другие информационные окна
  if (titleHTML == null) titleHTML = '';
  if (contentHTML == null) contentHTML = '';
  if (messageClass == null) messageClass = 'info';
  //Кнопка по умеолчанию
  var button = '';
  if ( (buttonText != null) && (buttonText != '') ) button = '<input type="button" value="'+buttonText+'" onclick="hideAlert();">';
  //Рисуем окно
  var windowTable = '<table cellpadding="0" class="daAlert '+messageClass+'"><tr class="daAlertT"><td class="daAlertTC" colspan="3">'+titleHTML+'</td></tr><tr class="daAlertC"><td class="daAlertCL"></td><td class="daAlertCC">'+contentHTML+'</td><td class="daAlertCR"></td></tr><tr class="daAlertB"><td class="daAlertBL"></td><td class="daAlertBC">'+button+'</td><td class="daAlertBR"><i></i></td></tr></table>';
  showAlert(windowTable);
  //$('body').prepend(windowTable);
  //Позиционируем окно
  	var st = getBodyScrollTop();
  $('.daAlert').css('width', $('.daAlert').css('max-width'));
  var y = ( $(window).height() / 2 ) - ($('.daAlert').height() / 2) + st;
  var x = ( $(window).width() / 2 ) - ($('.daAlert').width() / 2);
  $('.daAlert').css({'top':y, 'left':x});
}

function showAlert(param) {
	$('body').prepend(param);
	$('.daAlert').fadeIn("slow");
}

function hideAlert() {
	$(".daAlert").fadeOut("slow", function () {
											$(".daAlert").remove();
											});
}

function getBodyScrollTop()
{
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}
