// JavaScript Document
popupStatus = 0;
popupDiv = "#popupform";
function disablePopupform()
{
	if (popupStatus == 1)
  {
  	$('#fullbg').fadeOut("slow");
    $(popupDiv).fadeOut("slow");
	  $(popupDiv).css("height", "");
    popupStatus = 0;
  }
}
function showPopup()
{
	popupDiv = "#popupform";
	$('#fullbg').click(function() { disablePopupform(); } );
	$('#fullbg').css({"opacity": "0.7"});
	$('#fullbg').fadeIn("slow");
	$('#popupform').fadeIn("slow");
	$('#close').click(function () { disablePopupform(); } );
	popupStatus = 1;
}

function showEditcopy()
{
	popupDiv = "#edittext";
	$('#fullbg').click(function() { disablePopupform(); } );
	$('#fullbg').css({"opacity": "0.7"});
	$('#fullbg').fadeIn("slow");
	$('#edittext').fadeIn("slow");
	centerEdittext();
	$('#close').click(function () { disablePopupform(); } );
	popupStatus = 1;
}

function centerEdittext()
{
	var winW = document.documentElement.clientWidth;
  var winH = document.documentElement.clientHeight;
  var popupW = $('#edittext').width();
  var popupH = $('#edittext').height();
  $('#edittext').css("position", "fixed");
  $('#edittext').css("top", (winH/2)-(popupH/2)-10);
  $('#edittext').css("left", (winW/2)-(popupW/2));
//  $('#fullbg').css({ "height": winH });
}


function centerPopupform()
{
	var winW = document.documentElement.clientWidth;
  var winH = document.documentElement.clientHeight;
  var popupW = $('#popupform').width();
  var popupH = $('#popupform').height();
  $('#popupform').css("position", "fixed");
  $('#popupform').css("top", (winH/2)-(popupH/2)-10);
  $('#popupform').css("left", (winW/2)-(popupW/2));
//  $('#fullbg').css({ "height": winH });
}

function centerPopupform500()
{
	var winW = document.documentElement.clientWidth;
  var winH = document.documentElement.clientHeight;
  var popupW = $('#popupform').width();
	if (popupW > 525) popupW = 525;
  var popupH = $('#popupform').height();
	if (popupH > 500) { popupH = 500; popupW += 10; }
  $('#popupform').css("position", "fixed");
  $('#popupform').css("top", (winH/2)-(popupH/2)-10);
  $('#popupform').css("left", (winW/2)-(popupW/2));
  $('#popupform').css("height", popupH);
  $('#popupform').css("width", popupW);
//  $('#fullbg').css({ "height": winH });
}
function centerPopupform600()
{
	var winW = document.documentElement.clientWidth;
  var winH = document.documentElement.clientHeight;
  var popupW = $('#popupform').width();
	if (popupW > 600) popupW = 625; else popupW = 625;
  var popupH = $('#popupform').height();
	if (popupH > 500) { popupH = 500; } 
	if (popupH < 300) popupH = 310;
	else popupH += 10;
  $('#popupform').css("position", "fixed");
  $('#popupform').css("top", (winH/2)-(popupH/2)-10);
  $('#popupform').css("left", (winW/2)-(popupW/2));
  $('#popupform').css("height", popupH);
  $('#popupform').css("width", popupW);
//  $('#fullbg').css({ "height": winH });
}

$(document).keypress(function(e) { if (e.keyCode==27 && popupStatus==1) disablePopupform(); } );
