function getPageScroll()
{
    var scrolly = typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement.scrollTop;   
    var scrollx = typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement.scrollLeft;   

	var arrayScroll = new Array(scrollx, scrolly);
	return arrayScroll;	
}

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;
}

function showArtwork(container, left, tohide)
{
	if(tohide)
	{
		document.getElementById(tohide).style.left = '-50000px';
	}
	var obg = document.getElementById('page-bg');
	var ovr = document.getElementById(container);
	ovr.style.top = '10px';
	obg.style.display = '';
	
	var size = getPageSize();
	var scroll = getPageScroll();

	obg.style.width = size[0]+'px';
	obg.style.height = size[1]+10+'px';
	
	ovr.style.left = '50%';
	ovr.style.marginLeft = '-'+left+'px';
}

function hideArtwork(container)
{
	var obg = document.getElementById('page-bg');
	var ovr = document.getElementById(container);

	ovr.style.left = '-50000px';
	obg.style.display = 'none';
}

function validate()
{
	df = document.mainFrm;
	if (df.emailAddress.value == "")
	{
		alert("EMail Address Is Required!")
		return false;
	}
	else
	{
		return true;
	}
}

function validateWeMail()
{
	if (! validate())
	{
		return false;
	}
	if (eMailExists())
	{
		return false;
	}
}

function eMailExists()
{
	df = document.mainFrm;
	
	var url = 'ContactExists.php?emailAddress=' + df.emailAddress.value;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	var retVal = xmlhttp.responseText;
	if (retVal != "0")
	{
		alert("A contact with this email address exists already!");
		return true;
	}
	else
	{
		return false;
	}
}

function moveDiv(x)
{

	newLoc = size[0] / 2;
	divWidth = 	document.getElementById(x).style.width.replace('px','');
	divWidth = divWidth / 2;
	document.getElementById(x).style.left=newLoc - divWidth;
	
}

