
// global variables.
var licenceAccepted = false;
var downloadFile = "";

// a package for download is selected
function selectPkg (ext) {
    // create filename
	downloadFile = "dynaworks-2.0" + ext;
	// licence accepted?
	if (licenceAccepted)
		document.download.file.value = downloadFile;
	else
		document.download.file.value = "Please accept Licence first!"
}

// licence accepted.
function acceptLicence () {
	// get new licencing state
	licenceAccepted = !licenceAccepted;

	if (licenceAccepted) {
		// check for selected package.
		if (downloadFile == "") {
			alert ("Please select a package for download before proceeding!");
			document.download.file.value = "Please select a package first!"
		} else
			document.download.file.value = downloadFile;
	} else {
		alert ("Please accept the licence agreement before you proceed...");
		document.download.file.value = "Please accept Licence first!"
	}
}

// start the download
function startDownload () {
	// make sure the Licence is accepted.
	if (!licenceAccepted) {
		alert ("Please accept the licence agreement before you proceed...");
		return;
	}

	// make sure a package is selected.
	if (downloadFile == "") {
		alert ("Please select a package for download before proceeding!");
		return;
	}

	// do we have to send an email?
	if (document.download.useremail.value != "") {

		// assemble the mail body.
	    var msg = document.download.username.value + " {" + document.download.useremail.value + "} " +
		          document.download.userinfo.checked + " " + document.download.userbeta.checked;

		// everything is fine. initiate the download.
		document.download.action = "mailto:brf@brainon.ch?subject='DynaWorks registration'&body='" + msg + "'";
		document.download.method = "post"
		document.download.submit();
	}

	// open a new document window for download
	open (downloadFile, "_blank")
}
