//**********************************************************************************//
//* CSLA Custom Methods															
//* By Darryn van der Walt (www.ventureflow.co.za)																        
//* Last Updated : 30 July 2006    
//**********************************************************************************//

//**********************************************************************************//
// Function to post the Databind fields to the server, in order to bind formfields 
// value to a business object
//**********************************************************************************//
function AJAX_DataBind(thisControl, sessionName, dataMember, useBitProperty, currentURL) {
	newValue = GetValueOfControl(thisControl, useBitProperty);
	clearParameters();
	addParameter('useAJAX', 'true');
	addParameter('functionName', 'UpdateBusinessObjectData');
	addParameter('functionArgs', newValue + '|' + sessionName + '|' + dataMember + '|' + thisControl.id + '|' + currentURL);
	doPost();
}

//**********************************************************************************//
// Function to post the Databind fields to the server, in order to bind formfields 
// value to a business object
//**********************************************************************************//
function AJAX_DataBindValue(newValue, sessionName, dataMember, currentURL) {
	clearParameters();
	addParameter('useAJAX', 'true');
	addParameter('functionName', 'UpdateBusinessObjectData');
	addParameter('functionArgs', newValue + '|' + sessionName + '|' + dataMember + '|' + '' + '|' + currentURL);
	
	doPost();
}

//**********************************************************************************//
// Function to post the Databind fields to the server, in order to bind a specified 
// formfields value to a business object
//**********************************************************************************//
function AJAX_BindOtherControlsValueWithAJAX(thisControl, controlIDOfValue, sessionName, dataMember, useBitProperty, currentURL) {
	if(DOMGetElement(controlIDOfValue) != null)	{
		controlToUse = DOMGetElement(controlIDOfValue);
		AJAX_DataBind(controlToUse, sessionName, dataMember, useBitProperty, currentURL);
	}
}

//**********************************************************************************//
// Functions to save the business object without a postback
//**********************************************************************************//
function AJAX_SessionSave(thisControl, sessionName, redirectOnSuccess) {
	if(thisControl.disabled = false)
		thisControl.focus();
	// Add delay to ensure that the previously focused field is saved
	thisControl.disabled = true;
	thisControl.value = "Saving...";
	setTimeout("SaveSession('" + sessionName + "','" + thisControl.id + "', '" + redirectOnSuccess + "')",300);
}

//**********************************************************************************//
// Functions to save the business object without a postback
//**********************************************************************************//
function SaveSession(sessionName, thisControlID, redirectOnSuccess) {
	clearParameters();
	addParameter('useAJAX', 'true');
	addParameter('functionName', 'SaveSessionViaAJAX');
	addParameter('functionArgs', sessionName + '|' + thisControlID + '|' + redirectOnSuccess);
	doPost();
}



