String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

function maximizeWindow() {
	window.moveTo(0, 0);
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth) {
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
}

function getCharCodeAt(text,position) {
	var tmp = text.substring(position, position + 1);
	for (var i = 1; i <= 255; i++) {
		if (unescape('%' + i.toString(16)) == tmp) {
			return i;
		}
	}
	return 0;
}

function validateEmailFormat(emailAddress) {
	var c = '';
	var checked = false;
	if (emailAddress.length == 0 || emailAddress == "") {
		return false;
	}
	for (var i = 0; i < emailAddress.length; i++) {
		c =  getCharCodeAt(emailAddress,i);
		if ( !(c >= 97 && c <= 122) && !(c >= 48 && c <= 57) && !(c == 64) && !(c == 45) && !(c == 46) && !(c == 95)) {
			return false;
		}
	}
	i = emailAddress.indexOf("@");
	j = emailAddress.indexOf(".", i);
	jj = emailAddress.lastIndexOf(".") + 1;
	len = emailAddress.length;
	if (!((i > 0) && (j > (1 + 1)) && (len - jj >= 2) && (len - jj <= 3))) {
		return false;
	}
	return true;
}

function showHelp(sURL) {
	var iWidth = Math.round(screen.availWidth * 0.3);
	var iHeight = Math.round(screen.availHeight * 0.5);
	var iLeft = screen.availWidth - iWidth - 20;
	var iTop = 10;
	var oWindow = window.open(sURL,"_help","width=" + iWidth + ", height=" + iHeight + ", left=" + iLeft + ", top=" + iTop + ", channelmode=no, directories=no, fullscreen=no, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no");
	oWindow.focus();
}

function menuOver(oMenuDiv) {
	oMenuDiv.style.color = "white";
}

function menuOut(oMenuDiv) {
	oMenuDiv.style.color = "#c0c0c0";
}

function buttonInvestorLoginOver(oLoginImage) {
	oLoginImage.setAttribute("src", "/images/button_investor_login_over.gif");
}

function buttonInvestorLoginOut(oLoginImage) {
	oLoginImage.setAttribute("src", "/images/button_investor_login.gif");
}

function selectFund() {
	var oList = document.getElementById("fund");
	var oListedLoginComputershare = document.getElementById("listedlogincomputershare");
	var oListedLoginLink = document.getElementById("listedloginlink");
	var oUnlistedLogin = document.getElementById("unlistedlogin");
	var oListedUserID = document.getElementById("listedusername");
	var oUnlistedUserID = document.getElementById("unlistedusername");

	if (oList.options[oList.selectedIndex].value == "listedcomputershare") {
		oUnlistedLogin.style.display = "none";
		oListedLoginLink.style.display = "none";
		oListedLoginComputershare.style.display = "block";
	}
	else if (oList.options[oList.selectedIndex].value == "listedlink") {
		oUnlistedLogin.style.display = "none";
		oListedLoginComputershare.style.display = "none";
		oListedLoginLink.style.display = "block";
	}
	else if (oList.options[oList.selectedIndex].value == "unlisted") {
		oListedLoginComputershare.style.display = "none";
		oListedLoginLink.style.display = "none";
		oUnlistedLogin.style.display = "block";
		oUnlistedUserID.focus();
	}
	else {
		oListedLoginComputershare.style.display = "none";
		oListedLoginLink.style.display = "none";
		oUnlistedLogin.style.display = "none";
	}
}

function launchComputershareLogin() {
	var oList = document.getElementById("fund");
	var sURL = "https://www-au.computershare.com/Investor/loginholder.asp?issuerid=scau";
	sURL = sURL + oList.options[oList.selectedIndex].getAttribute("asxcode");
	window.open(sURL, "_blank");
}

function launchLinkLogin() {
	var oList = document.getElementById("fund");
	var sURL = "https://www.linkmarketservices.com.au/public/investors/login.html?issuer=";
	sURL = sURL + oList.options[oList.selectedIndex].getAttribute("asxcode");
	window.open(sURL, "_blank");
}

function validatePageUpdate() {
	var bValid = true;
	var oFileBrowser = document.getElementById("pagedoc");
	var oUploadButton = document.getElementById("uploadbutton");
	if (bValid && oFileBrowser.value.length == 0) {
		bValid = false;
		alert("Please selected a document to upload.");
		oFileBrowser.focus();
	}
	if (bValid && oFileBrowser.value.substring(oFileBrowser.value.length-4) != ".doc") {
		bValid = false;
		alert("Only Word documents may be uploaded for the page content.");
		oFileBrowser.focus();
	}
	if (bValid) {
		oUploadButton.value = "Uploading...";
		oUploadButton.disabled = true;
	}
	return bValid;
}

function previewPage(sPageURL) {
	var iHeight = Math.round(screen.availHeight * 0.8);
	var iWidth = Math.round(screen.availWidth * 0.8);
	var iTop = Math.round((screen.availHeight - iHeight) / 2) - 20;
	var iLeft = Math.round((screen.availWidth - iWidth) / 2);
	var oWindow = window.open(sPageURL, "_preview", "top=" + iTop + ",left=" + iLeft + ",width=" + iWidth + ",height=" + iHeight + ",channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,scrollbars=yes");
	oWindow.focus();
}

function hidePageUpdateProcessing() {
	document.getElementById("processing").style.display = "none";
	document.getElementById("processingbr").style.display = "none";
	document.getElementById("complete").style.display = "block";
	document.getElementById("completebr").style.display = "";
}

function countryChange() {
	var oStateAUBlock = document.getElementById("stateaublock");
	var oStateOtherBlock = document.getElementById("stateotherblock");
	var oStateOther = document.getElementById("stateother");
	var oCountryList = document.getElementById("country");
	
	if (oCountryList.options[oCountryList.selectedIndex].value == "Australia") {
		oStateAUBlock.style.display = "block";
		oStateOtherBlock.style.display = "none";
	}
	else {
		oStateAUBlock.style.display = "none";
		oStateOtherBlock.style.display = "block";
		oStateOther.focus();
	}
}

function addHolding() {
	var bValid = true;
	var bDuplicated = false;
	var oInvestorID = document.getElementById("investorid");
	var sInvestorID = oInvestorID.value
	for (var i=0; i<255; i++) {
		sInvestorID = sInvestorID.replace(" ","");
		sInvestorID = sInvestorID.replace("	","");
	}
	oInvestorID.value = sInvestorID.toUpperCase();
	if (bValid && oInvestorID.value.length == 0) {
		bValid = false;
		alert("Investor ID may not be empty.");
		oInvestorID.focus();
	}
	if (bValid && oInvestorID.value.search("-0") != -1) {
		bValid = false;
		alert("When entering an investor ID,\nthe numeric portion (after the hyphen)\ncannot contain leading zeros.\n\nExmaple:\n\nUTA-01 is not correct.\nUTA-1 is correct.");
		oInvestorID.focus();
	}
	for (var i=0; i<aHoldings.length; i++) {
		if (aHoldings[i].toUpperCase().trim() == oInvestorID.value.toUpperCase().trim()) {
			bDuplicated = true;
		}
	}
	if (bValid && bDuplicated) {
		bValid = false;
		alert("Investor ID " + oInvestorID.value + " already exists.");
		oInvestorID.focus();
	}
	return bValid;
}

function deleteHoldings() {
	if (deleteHoldingsConfirm()) {
		document.getElementById("holdings").setAttribute("action","/manage/holdingdelete.asp");
		document.getElementById("holdings").submit();
	}
}

function deleteContacts() {
	if (deleteContactsConfirm()) {
		document.getElementById("deletecontacts").submit();
	}
}

function deleteStatements() {
	if (deleteStatementsConfirm()) {
		document.getElementById("deletestatements").submit();
	}
}

function deleteReports() {
	if (deleteReportsConfirm()) {
		document.getElementById("deletereports").submit();
	}
}

function deleteAnnouncements() {
	if (deleteAnnouncementsConfirm()) {
		document.getElementById("deleteannouncements").submit();
	}
}

function deletePDFs() {
	if (deleteAnnouncementsConfirm()) {
		document.getElementById("deletepdfs").submit();
	}
}

function deleteCharts() {
	if (deleteChartsConfirm()) {
		document.getElementById("deletecharts").submit();
	}
}

function deleteHoldingsConfirm() {
	return confirm("Are you use you wish to delete the selected holdings?");
}

function deleteContactsConfirm() {
	return confirm("Are you use you wish to delete the selected contacts?");
}

function deleteStatementsConfirm() {
	return confirm("Are you use you wish to delete the selected statements?");
}

function deleteReportsConfirm() {
	return confirm("Are you use you wish to delete the selected report?");
}

function deleteAnnouncementsConfirm() {
	return confirm("Are you use you wish to delete the selected announcements?");
}

function deletePDFConfirm() {
	return confirm("Are you use you wish to delete the selected PDF?");
}

function deleteChartsConfirm() {
	return confirm("Are you use you wish to delete the selected charts?");
}

function contactExists(sContact, sHolding) {
	var bExists = false;
	for (var i=0; i<aHoldingContacts.length; i++) {
		for (var j=1; j<aHoldingContacts[i].length; j++) {
			if (aHoldingContacts[i][0] == sHolding && aHoldingContacts[i][j] == sContact) {
				bExists = true;
			}
		}
	}
	return bExists;
}

function editContact() {
	var bValid = true;
	var oEmail = document.getElementById("email");
	var oInvestorID = document.getElementById("investorid");
	var sEmail = oEmail.value;
	for (var i=0; i<255; i++) {
		sEmail = sEmail.replace(" ","");
		sEmail = sEmail.replace("	","");
	}
	oEmail.value = sEmail.toLowerCase();
	if (bValid && oEmail.value == "") {
		bValid = false;
		alert("You must enter an e-mail address.");
		oEmail.focus();
	}
	if (bValid && !validateEmailFormat(oEmail.value)) {
		bValid = false;
		alert("E-mail address format is invalud.\nE-mail address must appear in the format: someone@company.com");
		oEmail.focus();
	}
	if (bValid && contactExists(oEmail.value, oInvestorID.value)) {
		bValid = false;
		alert("There is already a contact with this e-mail address for " + oInvestorID.value + ".");
		oEmail.focus();
	}
	return bValid;
}

function addContact() {
	var bValid = true;
	var oEmail = document.getElementById("email");
	var oHolding = document.getElementById("holding");
	var sEmail = oEmail.value;
	for (var i=0; i<255; i++) {
		sEmail = sEmail.replace(" ","");
		sEmail = sEmail.replace("	","");
	}
	oEmail.value = sEmail.toLowerCase();
	if (bValid && oHolding.selectedIndex == 0) {
		bValid = false;
		alert("You must select a holding to which this contact belongs.");
		oHolding.focus();
	}
	if (bValid && oEmail.value == "") {
		bValid = false;
		alert("You must enter an e-mail address.");
		oEmail.focus();
	}
	if (bValid && !validateEmailFormat(oEmail.value)) {
		bValid = false;
		alert("E-mail address format is invalud.\nE-mail address must appear in the format: someone@company.com");
		oEmail.focus();
	}
	if (bValid && contactExists(oEmail.value, oHolding.options[oHolding.selectedIndex].getAttribute("investorid"))) {
		bValid = false;
		alert("There is already a contact with this e-mail address for " + oHolding.options[oHolding.selectedIndex].getAttribute("investorid") + ".");
		oEmail.focus();
	}
	return bValid;
}

function changeStatementsDate() {
	var oMonth = document.getElementById("month");
	var sMonth = oMonth.options[oMonth.selectedIndex].value;
	window.open("/manage/statements.asp?month=" + sMonth,"_self");
}

function uploadSingleStatement() {
	var bValid = true;
	var oFile = document.getElementById("statementfiles");
	var sExt = oFile.value.substring(oFile.value.length-4).toLowerCase();
	if (bValid && oFile.value == "") {
		bValid = false;
		alert("You must select a .pdf file to upload.");
		oFile.focus();
	}
	if (bValid && sExt != ".pdf") {
		bValid = false;
		alert("You must select a .pdf file.");
		oFile.focus();
	}
	return bValid;
}

function uploadMultipleStatement() {
	var bValid = true;
	var oFile = document.getElementById("statementfiles");
	var sExt = oFile.value.substring(oFile.value.length-4).toLowerCase();
	if (bValid && oFile.value == "") {
		bValid = false;
		alert("You must select a .zip file or a .pdf file to upload.");
		oFile.focus();
	}
	if (bValid && (sExt != ".pdf") && (sExt != ".zip")) {
		bValid = false;
		alert("You must select a .zip file or a .pdf file.");
		oFile.focus();
	}
	return bValid;
}

function hideStatementUpdateProcessing() {
	document.getElementById("processing").style.display = "none";
	document.getElementById("processingbr").style.display = "none";
	document.getElementById("complete").style.display = "block";
	document.getElementById("completebr").style.display = "";
}

function hideReportUpdateProcessing() {
	document.getElementById("processing").style.display = "none";
	document.getElementById("processingbr").style.display = "none";
	document.getElementById("complete").style.display = "block";
	document.getElementById("completebr").style.display = "";
}

function hideAnnouncementUpdateProcessing() {
	document.getElementById("processing").style.display = "none";
	document.getElementById("processingbr").style.display = "none";
	document.getElementById("complete").style.display = "block";
	document.getElementById("completebr").style.display = "";
}

function hidePDFUpdateProcessing() {
	document.getElementById("processing").style.display = "none";
	document.getElementById("processingbr").style.display = "none";
	document.getElementById("complete").style.display = "block";
	document.getElementById("completebr").style.display = "";
}

function openURL(sURL, sTarget, iDelay) {
	setTimeout("_openURL('" + sURL + "', '" + sTarget + "');",iDelay);
	return true;
}
function _openURL(sURL, sTarget) {
	var oWindow = window.open(sURL,sTarget);
	oWindow.focus();
	return true;
}

function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function clearCookie(name) {
	setCookie(name,"",-1);
}

function selectFundFromCookie() {
	var oFund = document.getElementById("fund");
	var sSelectedFund = getCookie("investorloginfund");
	if (sSelectedFund > 0) {
		oFund.selectedIndex = sSelectedFund;
		selectFund();
	}
}

function setFundToCookie() {
	var oFund = document.getElementById("fund");
	if (oFund.selectedIndex != 0) {
		setCookie("investorloginfund", oFund.selectedIndex, 365);
	}
}
function resetPasswordHoldingsConfirm() {
	return confirm("Are you sure you wish to reset the passwords for the selected holdings?");
}
function resetPasswordHoldings() {
	if (resetPasswordHoldingsConfirm()) {
		document.getElementById("holdings").setAttribute("action","/manage/holdingpassword.asp");
		document.getElementById("holdings").submit();
	}
}

function hideHoldingPasswordProcessing() {
	document.getElementById("processing").style.display = "none";
	document.getElementById("processingbr").style.display = "none";
	document.getElementById("complete").style.display = "block";
	document.getElementById("completebr").style.display = "";
}

function listedChanged() {
	var oListed = document.getElementById("listed");
	var oPriceLabel = document.getElementById("pricelabel");
	var oPriceValue = document.getElementById("pricevalue");
	var oASXCodeLabel = document.getElementById("asxcodelabel");
	var oASXCodeValue = document.getElementById("asxcodevalue");
	var oPrice = document.getElementById("price");
	var oASXCode = document.getElementById("asxcode");
	if (oListed.selectedIndex == 0) {
		//oPriceLabel.style.display = "none";
		//oPriceValue.style.display = "none";
		oPrice.disabled = true;
		//oASXCodeLabel.style.display = "block";
		//oASXCodeValue.style.display = "block";
		//oASXCode.disabled = false;
		//oASXCode.focus();
	}
	else {
		//oPriceLabel.style.display = "block";
		//oPriceValue.style.display = "block";
		oPrice.disabled = false;
		//oASXCodeLabel.style.display = "none";
		//oASXCodeValue.style.display = "none";
		//oASXCode.disabled = true;
		oPrice.focus();
	}
}

function saveFund() {
	var bValid = true;
	var oListed = document.getElementById("listed");
	var oASXCode = document.getElementById("asxcode");
	//if (oListed.selectedIndex == 0) {
		if (bValid && oASXCode.value.length <= 0) {
			bValid = false;
			alert("You must enter and ASX code.");
			oASXCode.focus();
		}
	//}
	return bValid;
}

function uploadReport() {
	var bValid = true;
	var oFileBrowser = document.getElementById("reportfile");
	var oUploadButton = document.getElementById("uploadbutton");
	if (bValid && oFileBrowser.value.length == 0) {
		bValid = false;
		alert("Please selected a report PDF to upload.");
		oFileBrowser.focus();
	}
	if (bValid && oFileBrowser.value.substring(oFileBrowser.value.length-4) != ".pdf") {
		bValid = false;
		alert("Only PDF files may be uploaded for Fund Reports.");
		oFileBrowser.focus();
	}
	if (bValid) {
		oUploadButton.value = "Uploading...";
		oUploadButton.disabled = true;
	}
	return bValid;
}

function uploadAnnouncement() {
	var bValid = true;
	var oFileBrowser = document.getElementById("announcementfile");
	var oUploadButton = document.getElementById("uploadbutton");
	if (bValid && oFileBrowser.value.length == 0) {
		bValid = false;
		alert("Please select an announcement PDF to upload.");
		oFileBrowser.focus();
	}
	if (bValid && oFileBrowser.value.substring(oFileBrowser.value.length-4) != ".pdf") {
		bValid = false;
		alert("Only PDF files may be uploaded for announcements.");
		oFileBrowser.focus();
	}
	if (bValid) {
		oUploadButton.value = "Uploading...";
		oUploadButton.disabled = true;
	}
	return bValid;
}

function uploadPDF() {
	var bValid = true;
	var oFileBrowser = document.getElementById("pdffile");
	var oUploadButton = document.getElementById("uploadbutton");
	if (bValid && oFileBrowser.value.length == 0) {
		bValid = false;
		alert("Please select a PDF to upload.");
		oFileBrowser.focus();
	}
	if (bValid && oFileBrowser.value.substring(oFileBrowser.value.length-4) != ".pdf") {
		bValid = false;
		alert("Only PDF files may be uploaded.");
		oFileBrowser.focus();
	}
	if (bValid) {
		oUploadButton.value = "Uploading...";
		oUploadButton.disabled = true;
	}
	return bValid;
}

function uploadChart() {
	var bValid = true;
	var oFileBrowser = document.getElementById("chartfile");
	var oUploadButton = document.getElementById("uploadbutton");
	var oUploaded = window.opener.document.getElementById("uploaded");
	var sChartUploadFileName = oFileBrowser.value;
	if (bValid && oFileBrowser.value.length == 0) {
		bValid = false;
		alert("Please select a char XML file to upload.");
		oFileBrowser.focus();
	}
	if (bValid && oFileBrowser.value.substring(oFileBrowser.value.length-4) != ".xml") {
		bValid = false;
		alert("Only XML files may be uploaded for charts.");
		oFileBrowser.focus();
	}
	if (bValid) {
		oUploadButton.value = "Uploading...";
		oUploadButton.disabled = true;
		oUploaded.value = "yes";
		window.opener.document.getElementById("chartxmlfile").innerHTML = "<span style=\"color: #005395;\">" + sChartUploadFileName + "</span>";
	}
	return bValid;
}

function startUploadChart() {
	var iWidth = 570;
	var iHeight = 140;
	var iLeft = Math.round((screen.availWidth - iWidth) / 2);
	var iTop = Math.round((screen.availHeight - iHeight) / 2) - 30;
	var oWindow = window.open("/manage/chartupload.asp","_chartupload","width=" + iWidth + ", height=" + iHeight + ", left=" + iLeft + ", top=" + iTop + ", channelmode=no, directories=no, fullscreen=no, location=no, menubar=no, resizable=yes, scrollbars=no, status=no, titlebar=no, toolbar=no");
	oWindow.focus();
}

function completeChartUpload() {
	window.close();
}

function addReport() {
	var bValid = true;
	var oTitle = document.getElementById("title");
	var oURL = document.getElementById("url");
	var oDate = document.getElementById("date");
	oTitle.value = oTitle.value.trim();
	oURL.value = oURL.value.trim();
	if (bValid && oDate.value.length == 0) {
		bValid = false;
		alert("You must select a date for this report.");
		oTitle.focus();
	}
	if (bValid && oTitle.value.length == 0) {
		bValid = false;
		alert("You must enter a title for this report.");
		oTitle.focus();
	}
	if (bValid && oURL.value.length != 0) {
		var sURLPrefix = oURL.value.substring(0,7).toLowerCase();
		if (sURLPrefix != "http://") {
			bValid = false;
			alert("The Online URL must beging with http://");
			oURL.focus();
		}
	}
	return bValid;
}

function addAnnouncement() {
	var bValid = true;
	var oTitle = document.getElementById("title");
	var oDate = document.getElementById("date");
	oTitle.value = oTitle.value.trim();
	oDate.value = oDate.value.trim();
	if (bValid && oDate.value.length == 0) {
		bValid = false;
		alert("You must select a date for this announcement.");
		oTitle.focus();
	}
	if (bValid && oTitle.value.length == 0) {
		bValid = false;
		alert("You must enter a title for this announcement.");
		oTitle.focus();
	}
	return bValid;
}

function addPDF() {
	var bValid = true;
	var oTitle = document.getElementById("title");
	var oDate = document.getElementById("date");
	oTitle.value = oTitle.value.trim();
	if (bValid && oTitle.value.length == 0) {
		bValid = false;
		alert("You must enter a title for this PDF.");
		oTitle.focus();
	}
	return bValid;
}

function addChart() {
	var bValid = true;
	var oName = document.getElementById("name");
	var oType = document.getElementById("type");
	var oWidth = document.getElementById("width");
	var oHeight = document.getElementById("height");
	var oUploaded = document.getElementById("uploaded");
	oName.value = oName.value.trim();
	if (bValid && oName.value.length == 0) {
		bValid = false;
		alert("You must enter a name for this chart.");
		oName.focus();
	}
	if (bValid && oType.selectedIndex == 0) {
		bValid = false;
		alert("You must select a type for this chart.");
		oType.focus();
	}
	if (bValid && oWidth.value.length == 0) {
		bValid = false;
		alert("You must enter a width for this chart.");
		oWidth.focus();
	}
	if (bValid && oWidth.value.length == 0) {
		bValid = false;
		alert("You must enter a height for this chart.");
		oWidth.focus();
	}
	if (bValid && oUploaded.value != "yes") {
		bValid = false;
		alert("You haven't uploaded an XML file for this chart.");
	}
	return bValid;
}


function selectAllDeleteCheckboxes(sFormID, oCheckbox) {
	var oForm = document.getElementById(sFormID);
	var aCheckboxes = oForm.getElementsByTagName("input");
	for (var i=0; i<aCheckboxes.length; i++) {
		if (aCheckboxes(i).type == "checkbox" && aCheckboxes(i).getAttribute("id").search("delete_") && aCheckboxes(i).getAttribute("id") != oCheckbox.getAttribute("id")) {
			aCheckboxes(i).checked = oCheckbox.checked;
		}
	}
}

function subscribeToUpdates() {
	var bValid = true;
	var oForm = document.getElementById("subscribe");
	var aInputs = oForm.getElementsByTagName("input");
	var bCheckboxSelected = false;
	var oFirstName = document.getElementById("firstname");
	var oSurname = document.getElementById("surname");
	var oEmail = document.getElementById("email");
	oFirstName.value = oFirstName.value.trim();
	oSurname.value = oSurname.value.trim();
	oEmail.value = oEmail.value.trim();
	for (var i=0; i<aInputs.length; i++) {
		if (aInputs(i).type == "checkbox") {
			bCheckboxSelected |= aInputs(i).checked;
		}
	}
	bValid &= bCheckboxSelected;
	if (!bCheckboxSelected) {
		bValid = false;
		alert("You must selected at least one fund.");
	}
	if (bValid && oFirstName.value.length == 0) {
		bValid = false;
		alert("You must enter your first name.");
		oFirstName.focus();
	}
	if (bValid && oSurname.value.length == 0) {
		bValid = false;
		alert("You must enter your surname.");
		oSurname.focus();
	}
	if (bValid && oEmail.value.length == 0) {
		bValid = false;
		alert("You must enter your e-mail address.");
		oEmail.focus();
	}
	if (bValid && !validateEmailFormat(oEmail.value)) {
		bValid = false;
		alert("Your e-mail address appears to be invalid.");
		oEmail.focus();
	}
	return bValid;
}
function announcementsYear() {
	var oASXAnnouncementsForm = document.getElementById("asxannouncementsform");
	oASXAnnouncementsForm.submit();
}

function toggleRememberAdminUser() {
	var oAdminUserRemember = document.getElementById("adminuserrememberme");
	var oAdminPasswordRemember = document.getElementById("adminpasswordrememberme");
	if (oAdminUserRemember.checked) {
		oAdminPasswordRemember.disabled = false;
	}
	else {
		oAdminPasswordRemember.checked = false;
		oAdminPasswordRemember.disabled = true;
	}
}

function setAdminLoginToCookie() {
	var oAdminUser = document.getElementById("administratorusername");
	var oAdminPassword = document.getElementById("administratorpassword");
	var oAdminUserRemember = document.getElementById("adminuserrememberme");
	var oAdminPasswordRemember = document.getElementById("adminpasswordrememberme");

	oAdminUser.value = oAdminUser.value.trim();

	if (oAdminUserRemember.checked) {
		setCookie("adminuser", oAdminUser.value, 365);
		setCookie("adminuserremember", "yes", 365);
	}
	else {
		clearCookie("adminpassword");
	}

	if (oAdminPasswordRemember.checked) {
		setCookie("adminpassword", oAdminPassword.value, 365);
		setCookie("adminpasswordremember", "yes", 365);
	}

	

	return true;
}

function getAdminLoginToCookie() {
	var oAdminUser = document.getElementById("administratorusername");
	var oAdminPassword = document.getElementById("administratorpassword");
	var oAdminUserRemember = document.getElementById("adminuserrememberme");
	var oAdminPasswordRemember = document.getElementById("adminpasswordrememberme");
	var oSubmit = document.getElementById("submitbutton");

	if (getCookie("adminuserremember") == "yes") {
		oAdminUser.value = getCookie("adminuser");
		oAdminUserRemember.checked = true;
	}

	if (getCookie("adminpasswordremember") == "yes") {
		oAdminPassword.value = getCookie("adminpassword");
		oAdminPasswordRemember.checked = true;
	}

	if (oAdminUser.value.length > 0) {
		if (oAdminPassword.value.length > 0) {
			oSubmit.focus();
		}
		else {
			oAdminPassword.focus();
		}
	}
	else {
		oAdminUser.focus();
	}

	return true;
}

function changeSharePriceGraphPeriod() {
	var oDiv = document.getElementById("sharepricegraph");
	var oPeriodList = document.getElementById("sharepricegraphperiod");
	var sImageSource = oDiv.getAttribute("imagebase");
	var sURL = sImageSource + oPeriodList.options[oPeriodList.selectedIndex].value;
	oDiv.style.background = "url(" + sURL + ")";
}

function showRecentReportsOnHome(iReports, iAnnouncements) {
	var oRecentReports;
	var oRecentAnnouncements;
	var i;
	for (i=1; i<=iReports; i++) {
		oRecentReports = document.getElementById("homereports_" + i);
		oRecentReports.style.display = "block";
	}
	for (i=1; i<=iAnnouncements; i++) {
		oRecentAnnouncements = document.getElementById("homeannouncements_" + i);
		oRecentAnnouncements.style.display = "none";
	}
	return false;
}

function showRecentAnnouncementsOnHome(iReports, iAnnouncements) {
	var oRecentReports;
	var oRecentAnnouncements;
	var i;
	for (i=1; i<=iReports; i++) {
		oRecentReports = document.getElementById("homereports_" + i);
		oRecentReports.style.display = "none";
	}
	for (i=1; i<=iAnnouncements; i++) {
		oRecentAnnouncements = document.getElementById("homeannouncements_" + i);
		oRecentAnnouncements.style.display = "block";
	}
	return false;
}


function changeASXAnnouncementInclude(oCheckbox, iAnnounement) {
	var oTD = document.getElementById("include_td_" + iAnnounement);
	var oForm = document.getElementById("include_form_" + iAnnounement);
	if (oCheckbox.checked) {
		oTD.style.backgroundColor = "white";
	}
	else {
		oTD.style.backgroundColor = "red";
	}
	oForm.submit();
}

function previewChart(iChart, iWidth, iHeight) {
	iWidth += 40;
	iHeight += 40;
	var iLeft = Math.round((screen.availWidth - iWidth) / 2);
	var iTop = Math.round((screen.availHeight - iHeight) / 2) - 30;
	var oWindow = window.open("/charts/preview/?id=" + iChart,"_chartpreview","width=" + iWidth + ", height=" + iHeight + ", left=" + iLeft + ", top=" + iTop + ", channelmode=no, directories=no, fullscreen=no, location=no, menubar=no, resizable=yes, scrollbars=no, status=no, titlebar=no, toolbar=no");
	oWindow.focus();
}

function submitSearch() {
	var oSearchForm = document.getElementById("searchform");
	oSearchForm.submit();
}

function pendingUpdates() {
	var oUpdateActionPublish = document.getElementById("update_action_publish");
	var oUpdateActionReplace = document.getElementById("update_action_replace");
	var oUpdateActionDiscard = document.getElementById("update_action_discard");

	var oUpdateDivPublish = document.getElementById("pending_update_publish");
	var oUpdateDivReplace = document.getElementById("pending_update_replace");
	var oUpdateDivDiscard = document.getElementById("pending_update_discard");

	if (oUpdateActionPublish.checked) {
		oUpdateDivPublish.style.display = "block";
		oUpdateDivReplace.style.display = "none";
		oUpdateDivDiscard.style.display = "none";
	}

	if (oUpdateActionReplace.checked) {
		oUpdateDivPublish.style.display = "none";
		oUpdateDivReplace.style.display = "block";
		oUpdateDivDiscard.style.display = "none";
	}

	if (oUpdateActionDiscard.checked) {
		oUpdateDivPublish.style.display = "none";
		oUpdateDivReplace.style.display = "none";
		oUpdateDivDiscard.style.display = "block";
	}
}
