
	
	function checkCurrency(val){
		if(parent.patternValidate(val, 'currency2')){
			return 'English';
		}else if(parent.patternValidate(val, 'currency2-fr') && (document.location.pathname.indexOf('-fr.html') != -1)){
			return 'French';
		}else{
			return false;
		}
	}
			
	function processURL() {
		// RETRIEVE ERROR STRING AND OTHER PARAMETERS
		strUrlParams = document.location.search;
		errStrStart = strUrlParams.indexOf('errStr=');
		if (errStrStart != -1) {
			errStrEnd = strUrlParams.indexOf('&', errStrStart);
			otherParams1 = strUrlParams.slice(1,errStrStart-1);
			if(errStrEnd != -1){
				otherParams2 = strUrlParams.substr(errStrEnd);
				errCodes = strUrlParams.substring(errStrStart + 7, errStrEnd);
			}else{
				otherParams2 = '';
				errCodes = strUrlParams.substr(errStrStart + 7);
			}
			prevSearchParams = otherParams1 + otherParams2;
		}else{
			errCodes = '';
			prevSearchParams = strUrlParams.substr(1);
		}
	}
	
	function removeCurrencyFormatting(currVal){
		if(checkCurrency(currVal) == 'English'){
			currVal = replaceAll(replaceAll(replaceAll(currVal, ' ', ''), ',', ''), '$', '');
		}else if(checkCurrency(currVal) == 'French'){
			currVal = replaceAll(replaceAll(replaceAll(currVal, ' ', ''), ',', '.'), '$', '');
		}else{
			return currVal;
		}
		if(currVal.length > 0){
			if (currVal.indexOf('.') != -1){
				var valArr = currVal.split('.');
				if (valArr[1].length > 2){
					valArr[1] = valArr[1].substr(0, 2);
				}else{
					while(valArr[1].length < 2){
						valArr[1] += '0';
					}
				}
				currVal = valArr[0] + '.' + valArr[1];
			}else{
				currVal = currVal + '.00'
			}
		}
		return currVal;
	}
	
	// RETURNS TRUE IF ANY OF THE ERROR CODE ARGUMENTS ARE PRESENT
	function retrieveErrorCode(){
		errorPresent = false;
		for(i=0; i<arguments.length; i++){
			if(errCodes.indexOf(',' + arguments[i] + ',') != -1){
				errorPresent = true;
			}
		}
		return errorPresent;
	}

	//Performs string replacement
	function replaceAll(str, key, rplcmnt){
		while(str.indexOf(key) != -1){
			str = str.replace(key, rplcmnt);
		}
		return str;
	}
	
	function getValue(key){
		if (parent != this){
			return parent.getValue(key);
		}else{
			return '';
		}
	}
	
	function removeTrailingSpaces(str){
		for(i=0; str != '' && str.lastIndexOf(' ') == str.length - 1; i++){
			str = str.substr(0, str.length-1);
		}
		return str;
	}