// this function puts the dark screen over the entire page

function darkenPage()
{
	var page_screen = document.getElementById('page_screen');
	page_screen.style.height = document.body.parentNode.scrollHeight + 'px';
	page_screen.style.display = 'block';
	page_screen.style.visibility = 'visible';
}

// this function removes the dark screen and the page is light again

function lightenPage()
{
	var page_screen = document.getElementById('page_screen');
	page_screen.style.display = 'none';
	page_screen.style.visibility = 'hidden';
}

// ***** popup_exit ************************************************************

function exitPopup(myDivID)
{
	var myElement = document.getElementById(myDivID);
	myElement.style.display = 'none';
	myElement.style.visible = 'hidden';
}

// ***** popup_show ************************************************************

function showPopup(myDivID, myImageID)
{
	var myElement = document.getElementById(myDivID);
	var myImageOutput = "document." + myImageID + ".src = document." + myImageID + ".src";

	// Get Width and Height of Window Cross-Browser Compatible

	var myWidth = 0, myHeight = 0;
	
	if (typeof(window.innerWidth) == 'number' ) {
		// Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		// IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		// IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	// Show Popup

	myElement.style.display  = "block";
	myElement.style.visibility = "visible";

	// Position Popup

	myElement.style.position = "absolute";
	myElement.style.left = (document.documentElement.scrollLeft+(myWidth-myElement.clientWidth)/2)+'px';
	myElement.style.top  = (document.documentElement.scrollTop+(myHeight-myElement.clientHeight)/2)+'px';

	setTimeout(myImageOutput,100);

	return true;
}

function showandvalidatePopup(myDivID, myImageID, fieldName, xFieldA, xFieldB) {

	var validateResults = ValidateEmail(fieldName);
//	var xFieldA = document.getElementById(extraFieldA);
//	var xFieldB = document.getElementById(extraFieldB);

/*	if (xFieldA.value == '' || xFieldA.value == null)
	{
		window.alert("All fields are required");
		xFieldA.focus();
		return false;
	}
	
	if (xFieldB.value == '' || xFieldB.value == null)
	{
		window.alert("All fields are required");
		xFieldB.focus();
		return false;
	}
*/	
	if (validateResults == true)
	{
		showPopup(myDivID, myImageID);
		darkenPage();
		return true;
	} else {
		exitPopup(myDivID, myImageID);
		lightenPage();
		return false;
	}

}