/*
	Copyright 2008 Lee S. Barney
	
	
    This file is part of QuickConnectiPhoneHybrid.

    QuickConnectAJAX is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QuickConnectAJAX is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with QuickConnectAJAX.  If not, see <http://www.gnu.org/licenses/>.


*/

//remove white space from the beginning and end of a string
function trim(aString){
    return aString.replace(/^\s+|\s+$/g, '');
}
//stop an event from doing its' default behavior since it will be handled in the BCO and VCO
function stopDefault(event){
    if(event){
        if (event.preventDefault)// non-IE
                event.preventDefault();
        event.returnValue = false;// IE
    }
}
/*
* These mapping functions require functions for the business rules,
* view controls, error controls, and security controls NOT the names 
* of these items as strings.
*/
function mapCommandToBCF(aCmd, aBRule){
    aMappingBean = new Array();
	aMappingBean['bcf'] = aBRule;
    businessMap[aCmd] = aMappingBean;
    
}
function mapCommandToView(aCmd, aVCF){
    var aMappingBean = viewMap[aCmd];
	if(aMappingBean == null){
		aMappingBean = new Array();
		aMappingBean['viewFunctionArray'] = new Array();
		viewMap[aCmd] = aMappingBean;
	}
	var funcArray = aMappingBean['viewFunctionArray'];
	funcArray.push(aVCF);
}
function mapErrorToControl(anErrorCmd, anECF){
	var aMappingBean = new Array();
	aMappingBean['ecf'] = anECF;
	errorMap[anErrorCmd] = aMappingBean;
}
function mapCommandToSecurity(aCmd, aSCF){
	var aMappingBean = securityMap[aCmd];
	if(aMappingBean == null){
		aMappingBean = new Array();
		aMappingBean['securityFunctionArray'] = new Array();
		securityMap[aCmd] = aMappingBean;
	}
	var funcArray = aMappingBean['securityFunctionArray'];
	funcArray.push(aSCF);
}

function mapCommandToValidation(aCmd, aValCF){
	var aMappingBean = validationMap[aCmd];
	if(aMappingBean == null){
		aMappingBean = new Array();
		aMappingBean['validationFunctionArray'] = new Array();
		validationMap[aCmd] = aMappingBean;
	}
	aMappingBean['validationFunctionArray'].push(aValCF);
}

function debug(msg){
	document.getElementById('debug').innerHTML = msg;
}
