//--------------------------------------------------------------------------------------------------------
// Show popup window of given size in centre of screen
// For full screen popup, set width and height to zero
//--------------------------------------------------------------------------------------------------------
function popup(mylink, windowname, width, height)
{
if (! window.focus)return true;
var href;
if (width == 0) width = screen.width;
if (height == 0) height = screen.height;
var left = (screen.width  - width)/2;
var top  = (screen.height - height)/2;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
var params = 'width=' + width + ',height=' + height;
params += ',left=' + left + ',top=' + top;
params += ',scrollbars=yes,resizable=yes,dependent=yes';
window.open(href,windowname,params);
return false;
}

//--------------------------------------------------------------------------------------------------------
// Code for a dynamic "Please Wait" graphic or text message
// Add an element to the page with id="PleaseWait" style="display:none"
// In the Form tag add attribute onsubmit="showElement('PleaseWait')"
// The element will become visible whenever the page is submitted and will vanish if the page is refreshed
//--------------------------------------------------------------------------------------------------------
function showElement(elementID) 
{
      document.getElementById(elementID).style.display = 'block';
}

function hideElement() 
{
      document.getElementById(elementID).style.display = 'none';
}

function pleaseWait(buttonId)
{
	var button = document.getElementById( buttonId );
	var pleaseWaitDiv = document.createElement("DIV");
	//var pleaseWaitP = document.createElement("P");
	var pleaseWaitText = document.createTextNode("Please Wait");
	var pleaseWaitImg = document.createElement("IMG");	
	pleaseWaitImg.src = "../home/images/pleasewait.gif";
	//pleaseWaitDiv.className = "pleaseWait"; 
	pleaseWaitDiv.appendChild( pleaseWaitText );
	pleaseWaitDiv.appendChild( pleaseWaitImg );
	//pleaseWaitDiv.appendChild( pleaseWaitP );
	button.parentNode.appendChild(pleaseWaitDiv);
	button.style.display = "none";
	
	// Also hide the back button
    var backbutton = document.getElementById( "btBack" );
    if (backbutton) backbutton.style.display = "none";
}
