function showMBox(html,mode) 
{
	$('#overlay').css('height',$(document).height());
    $('#overlay').css('background','#000');
	$('#overlay').css('opacity',0).fadeTo('slow', '0.7');
	if(mode==1)
      $('#mbox').html(html);
      
	$('#mbox').css('visibility', 'visible').css('opacity',0).fadeTo('slow', '1');
	_centerPopin();
	$('#overlay').click(function(){
		$('#overlay').fadeOut('slow');
		$('#mbox').fadeOut('slow');
	});

	function _centerPopin(){
		if ($.browser.opera) {
			windowHeight = window.innerHeight;
			windowWidth = window.innerWidth;
		}
		else {
			windowHeight = $(window).height();
			windowWidth = $(window).width();
		};

		projectedTop = ($(window).height()/2) - ($('#mbox').height()/2);
		if (projectedTop < 0) {
			projectedTop = 10;
		}

		$('#mbox').css({
			'top': projectedTop,
			'left': ($(window).width()/2) - ($('#mbox').width()/2)
		});
	};
}

function getMbox(link)
{
	
    $.ajax({
      url: link,
      dataType: 'html',
      cache: false,
      success: function(html){
        showMBox($('#content', html),1);
      }
    });
}

$(function(){
$('a[rel|="mbox-ajax"]').click(function() {
  getMbox($(this).attr('href'),1);
  return false;
});
/*$('a[rel|="mbox"]').click(function() {
  $('#mbox .feedback_form .error').html('');
  $('#mbox .feedback_form form').css('display','block');
  showMBox('',2);
  return false;
});*/	

$('a[rel|="mbox-question"]').click(function() {
  $('#mbox .feedback_form .error').html('');
  $('#mbox .feedback_form form').css('display','none');
  $('#mbox .feedback_form.question form').css('display','block');
  showMBox('',2);
  return false;
});

$('a[rel|="mbox-mail"]').click(function() {
  $('#mbox .feedback_form .error').html('');
  $('#mbox .feedback_form form').css('display','none');
  $('#mbox .feedback_form.mail form').css('display','block');
  showMBox('',2);
  return false;
});

});
