function displayDownloadDialog()
{
	var oDownloadOverlay = document.getElementById('oDownloadOverlay');
	var oDownloadDialog = document.getElementById('oDownloadDialog');
	
	if (oDownloadOverlay.style.display == 'none')
	{
		oDownloadOverlay.style.display = 'block';
		oDownloadDialog.style.display = 'block';
		oDownloadOverlay.style.visibility = 'visible';
		oDownloadDialog.style.visibility = 'visible';
		document.getElementById('oFormDownload').reset();
		document.getElementById('oDownload').style.visibility = 'visible';
		document.getElementById('bCancel').value = 'Cancel';		
		document.getElementById('oName').focus();
	}
	else
	{
		oDownloadOverlay.style.display = 'none';
		oDownloadDialog.style.display = 'none';
		oDownloadOverlay.style.visibility = 'hidden';
		oDownloadDialog.style.visibility = 'hidden';
	}
}

function displayDownloadDialogList(ReportID)
{
	var oDownloadOverlay = document.getElementById('oDownloadOverlay');
	var oDownloadDialog = document.getElementById('oDownloadDialog');
	
	if (oDownloadOverlay.style.display == 'none')
	{
		oDownloadOverlay.style.display = 'block';
		oDownloadDialog.style.display = 'block';
		oDownloadOverlay.style.visibility = 'visible';
		oDownloadDialog.style.visibility = 'visible';
		document.getElementById('oFormDownload').reset();
		document.getElementById('oDownload').style.visibility = 'visible';
		document.getElementById('bCancel').value = 'Cancel';		
		document.getElementById('oName').focus();
	}
	else
	{
		oDownloadOverlay.style.display = 'none';
		oDownloadDialog.style.display = 'none';
		oDownloadOverlay.style.visibility = 'hidden';
		oDownloadDialog.style.visibility = 'hidden';
	}
	
	document.getElementById('oFile').value = ReportID;
}

function closeSprite(Sprite, ActionType)
{
	switch (ActionType)
	{
		case "Over":
			Sprite.style.backgroundPosition = 'bottom left';
			break;
		case "Out":
		  Sprite.style.backgroundPosition = 'top left';
			break;		
		case "Down":
      Sprite.style.backgroundPosition = 'top right';
			break;
	}
}

function validate_required()
{
	var oName = document.getElementById('oName');
	var oCompany = document.getElementById('oCompany');
	var oSubscribe = document.getElementById('oSubscribe');
	var oEmail = document.getElementById('oEmail');
	var oTerms = document.getElementById('oTerms');
	var oFocus = null;
	
	var sErrorMessage = 'You have not completed the form correctly:';
	
	var isValid = true;
	
	if (oName.value.trim() == '')
	{
		sErrorMessage += '\n - You have not provided your name';
		isValid = false;
		oFocus = oName;
	}
	if (oCompany.value.trim() == '')
	{
		sErrorMessage += '\n - You have not provided company name';
		isValid = false;
		if (oFocus == null) { oFocus = oCompany; }
	}
	if (oSubscribe.checked == true)
	{
		if (validate_email(oEmail) == false)
		{
			sErrorMessage += '\n - You have not provided a valid email address for subscriptions';
			isValid = false;
			if (oFocus == null) { oFocus = oEmail; }
		}
	}
	if (oTerms.checked == false)
	{
		sErrorMessage += '\n - You have not agreed to the Terms and Conditions';
		isValid = false;
		if (oFocus == null) { oFocus = oSubscribe; }
	}
	
	if (isValid == false)
	{
		sErrorMessage += '\n\n Please correct the incorrect fields and try again';
		alert(sErrorMessage);
		oFocus.focus();
		return false;
	}
	else
	{
		document.getElementById('oDownload').style.visibility = 'hidden';
		document.getElementById('bCancel').value = 'Close';
		return true;
	}
}

function validate_email(field)
{
	with (field)
  {
  	apos=value.indexOf("@");
  	dotpos=value.lastIndexOf(".");
  	if (apos<1||dotpos-apos<2)
    	return false;
  	else 
  		return true;
  }
}