// Global Variables

var ajax_controller_main = '/lib/ajax/download_ajax.asp';
var guiForm;
var orderItemsForm;
var dictionaryForm;
var guiFormName = '';
var chooserFilter = '';
var queryCount = 1;

// ------------------------------------------------------------------------------

function displayDownloadForm() {
	v_callmethod = 'displaydownloadform';
	strURL = 'callmethod=' + v_callmethod
	//alert(strURL); 
	PassAjaxResponseToFunctionUsingPost(ajax_controller_main, strURL, 'displayDownloadForm_return', 'null');
	return true;
}

function displayDownloadForm_return(str_response) {
	//alert('Response: ' + str_response); 
	arr_response = str_response.split('||');
	if ( arr_response[0] == '1') {
		document.getElementById('divDownloadStats').innerHTML = arr_response[1]
	} else {
		alert(arr_response[1]);
	}
	return true;
}

// ------------------------------------------------------------------------------

function processDownload() {
    vError = '';
    
	document.frmDownload.butSubmit.disabled = true;

    if (document.frmDownload.chvName.value == '') { vError = vError + 'Please enter your NAME.\n'; } 
    if (document.frmDownload.chvEmail.value == '') { vError = vError + 'Please provide us with your E-MAIL ADDRESS.\n'; } 
    if (document.frmDownload.chvPhone.value == '') { vError = vError + 'Please enter your PHONE NUMBER.\n'; } 
    if (document.frmDownload.bitAgree.checked == false) { vError = vError + 'Please check the box AGREEING to our terms and licensing.\n'; } 

	if (vError == '') {
	    v_callmethod = 'processdownload';
	    strURL = 'callmethod=' + v_callmethod
	    strURL = strURL + '&chvName=' + escape(document.frmDownload.chvName.value);
	    strURL = strURL + '&chvEmail=' + escape(document.frmDownload.chvEmail.value);
	    strURL = strURL + '&chvCompany=' + escape(document.frmDownload.chvCompany.value);
	    strURL = strURL + '&chvPhone=' + escape(document.frmDownload.chvPhone.value);
	    //alert(strURL); 
	    PassAjaxResponseToFunctionUsingPost(ajax_controller_main, strURL, 'processDownload_return', 'null');
    } else {
        alert(vError);
		document.frmDownload.butSubmit.disabled = false;
    }
	return true;
}

function processDownload_return(str_response) {
	//alert('Response: ' + str_response); 
	arr_response = str_response.split('||');
	if ( arr_response[0] == '1') {
		document.getElementById('divDownloadStats').innerHTML = arr_response[1]
		//alert(arr_response[1]);
		//document.frmOrder.butSubmit.disabled = false;
	} else {
		alert(arr_response[1]);
		document.frmDownload.butSubmit.disabled = false;
	}
	return true;
}

