
//--------------------------------------------------------------------------------
//- Function resize for printing.
//--------------------------------------------------------------------------------
function ResizeForPrint(pnMode) {

	if (pnMode == 0) {
		document.getElementById('banner-upper').style.width = '1024px';
		document.getElementById('banner-lower').style.width = '1024px';

		document.getElementById('canvas').style.width = '1024px';

		document.getElementById('innerworkingarealeft').style.display = 'block';
		document.getElementById('workingareawrapper').style.width = '1024px';
		document.getElementById('innerworkingarearight').style.display = 'block';

		document.getElementById('footer').style.width = '1024px';

		document.getElementById('ep_Emailbutton').style.display = 'block';
		document.getElementById('ep_Resizebutton').style.display = 'block';

		document.getElementById('ep_Printbutton').style.display = 'none';
		document.getElementById('ep_Cancelbutton').style.display = 'none';

	} else {

		document.getElementById('banner-upper').style.width = '800px';
		document.getElementById('banner-lower').style.width = '800px';

		document.getElementById('canvas').style.width = '800px';

		document.getElementById('innerworkingarealeft').style.display = 'none';
		document.getElementById('workingareawrapper').style.width = '800px';
		document.getElementById('innerworkingarearight').style.display = 'none';

		document.getElementById('footer').style.width = '800px';

		document.getElementById('ep_Emailbutton').style.display = 'none';
		document.getElementById('ep_Resizebutton').style.display = 'none';

		document.getElementById('ep_Printbutton').style.display = 'block';
		document.getElementById('ep_Cancelbutton').style.display = 'block';

	}
}

//--------------------------------------------------------------------------------
//- Function to show pop-up window and get an email address.
//--------------------------------------------------------------------------------
function doShowEmailWindow() {

	doShowInfo(true, 200, 500, 150);

	document.getElementById('popupheadertext').innerHTML = "email a friend";

	switch (msPageType) {
		case 'introduction':
			document.getElementById('popupheader').style.backgroundColor = '#3333FF';
			break;
		case 'state':
			document.getElementById('popupheader').style.backgroundColor = '#FF9933';
			break;
		case 'pressure':
			document.getElementById('popupheader').style.backgroundColor = '#CC0000';
			break;
		case 'response':
			document.getElementById('popupheader').style.backgroundColor = '#66CC66';
			break;
		default:
			document.getElementById('popupheader').style.backgroundColor = '#3333FF';
	}

	sHtml = "<table cellspacing='3'>" +
			"<tr><td colspan='2'>&#160;</td></tr>" +
			"<tr><td>From</td><td><input type=text id=txtemailfrom size=50 maxlength=200 name=txtemailfrom value=''/></td></tr>" +
			"<tr><td>Email</td><td><input type=text id=txtemailaddress size=50 maxlength=100 name=txtemailaddress value=''/></td></tr>" +
			"<tr><td colspan='2' align='right'><input type=button id=txtsend name=txtsend value='Send' onClick='doSendEmail();' class='qpqsubmit'/></td></tr>" +
			"</table>";

	document.getElementById('popupcontent').innerHTML = sHtml;
}

//--------------------------------------------------------------------------------
//- Function works in conjunction with doShowEmailWindow() to send email to
//- specified address and close window.
//--------------------------------------------------------------------------------
function doSendEmail() {

	if (msCurrentPageURL == '') {
		alert('Error: The current URL has not been set in the page!');
		return false;
	}

	if (document.getElementById('txtemailfrom').value == '') {
		alert('Please enter a from value - your name or short greeting.');
		document.getElementById('txtemailform').focus();
		return false;
	}

	if (document.getElementById('txtemailaddress').value == '') {
		alert('Please enter an email address.');
		document.getElementById('txtemailaddress').focus();
		return false;
	}

	doShowInfo(false, 0, 0, 0);

	// Callback to send email.
	createAjaxRequest();

	var url = "getdata.php?a=EMAIL&em=" + document.getElementById('txtemailaddress').value + "&fr=" + document.getElementById('txtemailfrom').value + "&url=" + escape(msCurrentPageURL);
	goHttpRequest.open("GET", url, false);
	goHttpRequest.send(null);
	var sResponse = goHttpRequest.responseText;

	if (sResponse != 'OK') {
		alert('Response was:' + sResponse + ' email was probably not sent.');
	} else
		alert('Email sent to ' + document.getElementById('txtemailaddress').value);
}

//--------------------------------------------------------------------------------
//- Function XSL function DisplayImage to display an enlarged image from the
//- Case Study
//--------------------------------------------------------------------------------
function doDisplayLargeImage(psPath, pnWidth, pnHeight, psHeader, psFooter){

	doShowInfo(true, 65, pnWidth+40, pnHeight+200);

	document.getElementById('popupheadertext').innerHTML = "";
	document.getElementById('popupheader').style.backgroundColor = '#016698';
	document.getElementById('popupwrapper').style.border = 'solid 1px black';

	sHtml = "<br/>" +
			"<div style=\"width:100%;\">";

	if (psHeader != '') {
		sHtml += "<div style=\"width:100%;\"><span style=\"font-size:10pt;\">" + psHeader + "</span><br/><br/></div>";
	}

	sHtml += "<img src=\"" + psPath + "\"/><br/>";

	if (psFooter != '') {
		sHtml += "<div style=\"width:100%;\"><br/><span style=\"font-size:10pt;\">" + psFooter + "</span></div><br class=\"DivTerminator\"/>";
	}

	sHtml += "<br class=\"DivTerminator\"/>" +
			 "</div>";

	document.getElementById('popupcontent').innerHTML = sHtml;
}

//--------------------------------------------------------------------------------
//- Function XSL function DisplayImage to display an enlarged image from the
//- Case Study
//--------------------------------------------------------------------------------
function GetCountryList(psRegionFieldName, psCountryFieldName) {

	// Callback to get country list.
	createAjaxRequest();

	var nIdx = document.getElementById(psRegionFieldName).selectedIndex;
	var url = "getdata.php?a=CTY&re=" + document.getElementById(psRegionFieldName).options[nIdx].value;
	goHttpRequest.open("GET", url, false);
	goHttpRequest.send(null);
	var sResponse = goHttpRequest.responseText;

	if (sResponse == 'ERROR') {
		alert('Response was:' + sResponse);
	} else {
/*
		var oList = document.getElementById(psCountryFieldName);
		qpqListClearNotFirst(oList);
		var arrItems = sResponse.split("~");
		for (i = 0; i < arrItems.length-1; i += 2) {
			qpqListAddItem(oList, arrItems[i], arrItems[i+1]);
		}
*/
		var oList = document.getElementById(psCountryFieldName);
		qpqListClearNotFirst(oList);
		qpqListLoadItems(oList, sResponse);
	}

}

