function akcioPopup() {
  var popup = $('#akcio_popup');

  popup.css({
    display:'block',
    position:'fixed',
    opacity:'0',
    left:'50%',
    marginLeft:-(popup.width() / 2),
    top: '50%',
    marginTop:-(popup.height() / 2)
  });

  popup.delay(2000).animate({opacity:1}, 500);

  $('.popupwindow_close').click(function(){
    popup.animate({opacity:0}, 300, function() { popup.remove(); });
  });
}

function gyors_ajanlatkeres() {
  $.ajax({
    type:"POST",
    url:"$url",
    data:$("#guestbook_form").serialize(),
    dataType:"json",
    success:function(response, textStatus, XMLHttpRequest) {
      removeAjaxLoading(btn)
      $('#message_place').html(response.message_box);
      if (response.message_box == "") {
        $('#guestbook_form .textbox').each(function() { this.value = ""; });
        $('#guestbook_form .textarea').attr('value','');
        $('#messages').html(response.messages);
        $('#secure').html(response.secure);
        $('html').animate({scrollTop:$("#messages").offset().top}, 'slow');
      }
    }
  });
}

function showAjaxLoading(ref_obj)
{
  $("body").append('<div id="xajax_loading_icon"></div>');
  var pos = $(ref_obj).offset();
  $("#xajax_loading_icon").css({"left":pos.left-32, "top":pos.top+3}); //32
  $("#xajax_loading_icon").show();
}

function showDiv(that)
{
  var divElem = $(that);

  divElem.remove();

  $('body').append(divElem);

  divElem.css({
    display: 'block'
  });

  positionDivCenter(that);

  $(window).resize(function(){ positionDivCenter(that); });
}

function hideDiv(that)
{
  var divElem = $(that);
  divElem.css({
    display: 'none'
  });
  return false;
}

function positionDivCenter(that)
{
  var st = $(document).scrollTop();
  var wh = $.browser.opera && $.browser.version > "9.5" && $.fn.jquery <= "1.2.6" ? document.documentElement["clientHeight"] : $(window).height();

  var div = $(that);
  div.css({
    left: '50%',
    marginLeft: -(div.width() / 2),
    top: (st + (wh / 2)) - (div.height() / 2)
  });
}

function showPopup(that)
{
  $('body').append('<div class="overdiv"></div>');
  $('.overdiv').css({'opacity': '0.6'});
  resizeOverdiv();
  $(window).resize(function(){ resizeOverdiv() });

  showDiv(that);

  $('.popupwindow_close').click(function(){ hidePopup(that); });
}

function hidePopup(that)
{
  var divElem = $(that);
  divElem.css({
    display: 'none'
  });

  $('.overdiv').remove();
  return false;
}

function resizeOverdiv(){
  var dims = ___getPageSize();
  $('.overdiv').css({
    'width': dims[0]+'px',
    'height': dims[1]+'px'
  });
}

/**
 * getPageSize() by quirksmode.com
 *
 * @return Array Return an array with page width, height and window width, height
 */
function ___getPageSize() {
 var xScroll, yScroll;
 if (window.innerHeight && window.scrollMaxY) {
 xScroll = window.innerWidth + window.scrollMaxX;
 yScroll = window.innerHeight + window.scrollMaxY;
 } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
 xScroll = document.body.scrollWidth;
 yScroll = document.body.scrollHeight;
 } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
 xScroll = document.body.offsetWidth;
 yScroll = document.body.offsetHeight;
 }
 var windowWidth, windowHeight;
 if (self.innerHeight) { // all except Explorer
 if(document.documentElement.clientWidth){
 windowWidth = document.documentElement.clientWidth;
 } else {
 windowWidth = self.innerWidth;
 }
 windowHeight = self.innerHeight;
 } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
 windowWidth = document.documentElement.clientWidth;
 windowHeight = document.documentElement.clientHeight;
 } else if (document.body) { // other Explorers
 windowWidth = document.body.clientWidth;
 windowHeight = document.body.clientHeight;
 }
 // for small pages with total height less then height of the viewport
 if(yScroll < windowHeight){
 pageHeight = windowHeight;
 } else {
 pageHeight = yScroll;
 }
 // for small pages with total width less then width of the viewport
 if(xScroll < windowWidth){
 pageWidth = xScroll;
 } else {
 pageWidth = windowWidth;
 }
 arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
 return arrayPageSize;
};
