// Global Variables

var ajax_controller = '/apps/reports/default_ajax.asp';
var guiForm;
var orderItemsForm;
var dictionaryForm;
var guiFormName = '';
var chooserFilter = '';
var queryCount = 1;

// ------------------------------------------------------------------------------

function showAddForm() {
	v_callmethod = 'showaddform';
	strURL = ajax_controller + '?' + 'callmethod=' + v_callmethod
	//alert(strURL); 
	PassAjaxResponseToFunction(strURL, 'showAddForm_return', 'null');
	return true;
}

function showAddForm_return(str_response) {
	//alert('Response: ' + str_response); 
	arr_response = str_response.split('||');
	if ( arr_response[0] == '1') {
		document.getElementById('ReportAddFormBody').innerHTML = arr_response[1];
	} else {
		alert(arr_response[1]);
	}
	return true;
}

// ------------------------------------------------------------------------------

function submitAddForm() {
    v_callmethod = 'submitaddform';
    strURL = 'callmethod=' + v_callmethod
    strURL = strURL + '&reporttype=' + escape(document.frmReport.reporttype.value);
    strURL = strURL + '&body=' + escape(document.frmReport.body.value);
    strURL = strURL + '&anon=' + escape(document.frmReport.anon.checked);
    if (document.frmReport.fname) { strURL = strURL + '&fname=' + escape(document.frmReport.fname.value); }
    if (document.frmReport.lname) { strURL = strURL + '&lname=' + escape(document.frmReport.lname.value); }
    if (document.frmReport.email) { strURL = strURL + '&email=' + escape(document.frmReport.email.value); }
    if (document.frmReport.phone) { strURL = strURL + '&phone=' + escape(document.frmReport.phone.value); }
    if (document.frmReport.username) { strURL = strURL + '&username=' + escape(document.frmReport.username.value); }
    if (document.frmReport.password) { strURL = strURL + '&password=' + escape(document.frmReport.password.value); }
    //alert(strURL); 
    PassAjaxResponseToFunctionUsingPost(ajax_controller,strURL, 'submitAddForm_return', 'null');
    return false;
}

function submitAddForm_return(str_response) {
	//alert('Response: ' + str_response); 
	arr_response = str_response.split('||');
	if ( arr_response[0] == '1') {
		document.getElementById('ReportAddFormBody').innerHTML = arr_response[1];
		//window.location.hash = '';
	} else {
		alert(arr_response[1]);
	}
	return true;
}

// ------------------------------------------------------------------------------

function deletePost(vReportID,vType) {
    if (confirm('Are you sure you want to delete this message from the site?')) {
	    v_callmethod = 'deletepost';
	    strURL = ajax_controller + '?' + 'callmethod=' + v_callmethod
	    strURL = strURL + '&reportid=' + vReportID;
	    strURL = strURL + '&reporttype=' + vType;
	    //alert(strURL); 
	    PassAjaxResponseToFunction(strURL, 'deletePost_return', 'null');
    }
	return true;
}

function deletePost_return(str_response) {
	//alert('Response: ' + str_response); 
	arr_response = str_response.split('||');
	if ( arr_response[0] == '1') {
		location.href = '/apps/reports/default.asp?type=' + arr_response[1];
	} else {
		alert(arr_response[1]);
	}
	return true;
}


