/*
 * NumberFormat 1.5.3
 * v1.5.3 - 29-September-2004
 * v1.5.2 - 27-August-2004
 * v1.5.1 - 13-February-2004
 * v1.5.0 - 20-December-2002
 * v1.0.3 - 23-March-2002
 * v1.0.2 - 13-March-2002
 * v1.0.1 - 20-July-2001
 * v1.0.0 - 13-April-2000
 * http://www.mredkj.com
 */
  
/*
 * NumberFormat -The constructor
 * num - The number to be formatted.
 *  Also refer to setNumber
 * inputDecimal - (Optional) The decimal character for the input
 *  Also refer to setInputDecimal
 */
function NumberFormat(num, inputDecimal)
{
	// constants
	this.COMMA = ',';
	this.PERIOD = '.';
	this.DASH = '-'; // v1.5.0 - new - used internally
	this.LEFT_PAREN = '('; // v1.5.0 - new - used internally
	this.RIGHT_PAREN = ')'; // v1.5.0 - new - used internally
	this.LEFT_OUTSIDE = 0; // v1.5.0 - new - currency
	this.LEFT_INSIDE = 1;  // v1.5.0 - new - currency
	this.RIGHT_INSIDE = 2;  // v1.5.0 - new - currency
	this.RIGHT_OUTSIDE = 3;  // v1.5.0 - new - currency
	this.LEFT_DASH = 0; // v1.5.0 - new - negative
	this.RIGHT_DASH = 1; // v1.5.0 - new - negative
	this.PARENTHESIS = 2; // v1.5.0 - new - negative
	this.NO_ROUNDING = -1 // v1.5.1 - new

	// member variables
	this.num;
	this.numOriginal;
	this.hasSeparators = false;  // v1.5.0 - new
	this.separatorValue;  // v1.5.0 - new
	this.inputDecimalValue; // v1.5.0 - new
	this.decimalValue;  // v1.5.0 - new
	this.negativeFormat; // v1.5.0 - new
	this.negativeRed; // v1.5.0 - new
	this.hasCurrency;  // v1.5.0 - modified
	this.currencyPosition;  // v1.5.0 - new
	this.currencyValue;  // v1.5.0 - modified
	this.places;
	this.roundToPlaces; // v1.5.1 - new

	// external methods
	this.setNumber = setNumberNF;
	this.toUnformatted = toUnformattedNF;
	this.setInputDecimal = setInputDecimalNF; // v1.5.0 - new
	this.setSeparators = setSeparatorsNF; // v1.5.0 - new - for separators and decimals
	this.setCommas = setCommasNF;
	this.setNegativeFormat = setNegativeFormatNF; // v1.5.0 - new
	this.setNegativeRed = setNegativeRedNF; // v1.5.0 - new
	this.setCurrency = setCurrencyNF;
	this.setCurrencyPrefix = setCurrencyPrefixNF;
	this.setCurrencyValue = setCurrencyValueNF; // v1.5.0 - new - setCurrencyPrefix uses this
	this.setCurrencyPosition = setCurrencyPositionNF; // v1.5.0 - new - setCurrencyPrefix uses this
	this.setPlaces = setPlacesNF;
	this.toFormatted = toFormattedNF;
	this.toPercentage = toPercentageNF;
	this.getOriginal = getOriginalNF;
	this.moveDecimalRight = moveDecimalRightNF;
	this.moveDecimalLeft = moveDecimalLeftNF;

	// internal methods
	this.getRounded = getRoundedNF;
	this.preserveZeros = preserveZerosNF;
	this.justNumber = justNumberNF;
	this.expandExponential = expandExponentialNF;
	this.getZeros = getZerosNF;
	this.moveDecimalAsString = moveDecimalAsStringNF;
	this.moveDecimal = moveDecimalNF;
	this.addSeparators = addSeparatorsNF;

	// setup defaults
	if (inputDecimal == null) {
		this.setNumber(num, this.PERIOD);
	} else {
		this.setNumber(num, inputDecimal); // v.1.5.1 - new
	}
	this.setCommas(true);
	this.setNegativeFormat(this.LEFT_DASH); // v1.5.0 - new
	this.setNegativeRed(false); // v1.5.0 - new
	this.setCurrency(false); // v1.5.1 - false by default
	this.setCurrencyPrefix('$');
	this.setPlaces(2);
}

/*
 * setInputDecimal
 * val - The decimal value for the input.
 *
 * v1.5.0 - new
 */
function setInputDecimalNF(val)
{
	this.inputDecimalValue = val;
}

/*
 * setNumber - Sets the number
 * num - The number to be formatted
 * inputDecimal - (Optional) The decimal character for the input
 *  Also refer to setInputDecimal
 * 
 * If there is a non-period decimal format for the input,
 * setInputDecimal should be called before calling setNumber.
 *
 * v1.5.0 - modified
 */
function setNumberNF(num, inputDecimal)
{
	if (inputDecimal != null) {
		this.setInputDecimal(inputDecimal); // v.1.5.1 - new
	}
	
	this.numOriginal = num;
	this.num = this.justNumber(num);
}

/*
 * toUnformatted - Returns the number as just a number.
 * If the original value was '100,000', then this method will return the number 100000
 * v1.0.2 - Modified comments, because this method no longer returns the original value.
 */
function toUnformattedNF()
{
	return (this.num);
}

/*
 * getOriginal - Returns the number as it was passed in, which may include non-number characters.
 * This function is new in v1.0.2
 */
function getOriginalNF()
{
	return (this.numOriginal);
}

/*
 * setNegativeFormat - How to format a negative number.
 * 
 * format - The format. Use one of the following constants.
 * LEFT_DASH   example: -1000
 * RIGHT_DASH  example: 1000-
 * PARENTHESIS example: (1000)
 *
 * v1.5.0 - new
 */
function setNegativeFormatNF(format)
{
	this.negativeFormat = format;
}

/*
 * setNegativeRed - Format the number red if it's negative.
 * 
 * isRed - true, to format the number red if negative, black if positive;
 *  false, for it to always be black font.
 *
 * v1.5.0 - new
 */
function setNegativeRedNF(isRed)
{
	this.negativeRed = isRed;
}

/*
 * setSeparators - One purpose of this method is to set a
 *  switch that indicates if there should be separators between groups of numbers.
 *  Also, can use it to set the values for the separator and decimal.
 *  For example, in the value 1,000.00
 *   The comma (,) is the separator and the period (.) is the decimal.
 *
 * Both separator or decimal are not required.
 * The separator and decimal cannot be the same value. If they are, decimal with be changed.
 * Can use the following constants (via the instantiated object) for separator or decimal:
 *  COMMA
 *  PERIOD
 * 
 * isC - true, if there should be separators; false, if there should be no separators
 * separator - the value of the separator.
 * decimal - the value of the decimal.
 *
 * v1.5.0 - new
 */
function setSeparatorsNF(isC, separator, decimal)
{
	this.hasSeparators = isC;
	
	// Make sure a separator was passed in
	if (separator == null) separator = this.COMMA;
	
	// Make sure a decimal was passed in
	if (decimal == null) decimal = this.PERIOD;
	
	// Additionally, make sure the values aren't the same.
	//  When the separator and decimal both are periods, make the decimal a comma.
	//  When the separator and decimal both are any other value, make the decimal a period.
	if (separator == decimal) {
		this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
	} else {
		this.decimalValue = decimal;
	}
	
	// Since the decimal value changes if decimal and separator are the same,
	// the separator value can keep its setting.
	this.separatorValue = separator;
}

/*
 * setCommas - Sets a switch that indicates if there should be commas.
 * The separator value is set to a comma and the decimal value is set to a period.
 * isC - true, if the number should be formatted with separators (commas); false, if no separators
 *
 * v1.5.0 - modified
 */
function setCommasNF(isC)
{
	this.setSeparators(isC, this.COMMA, this.PERIOD);
}

/*
 * setCurrency - Sets a switch that indicates if should be displayed as currency
 * isC - true, if should be currency; false, if not currency
 */
function setCurrencyNF(isC)
{
	this.hasCurrency = isC;
}

/*
 * setCurrencyPrefix - Sets the symbol for currency.
 * val - The symbol
 */
function setCurrencyValueNF(val)
{
	this.currencyValue = val;
}

/*
 * setCurrencyPrefix - Sets the symbol for currency.
 * The symbol will show up on the left of the numbers and outside a negative sign.
 * cp - The symbol
 *
 * v1.5.0 - modified - This now calls setCurrencyValue and setCurrencyPosition(this.LEFT_OUTSIDE)
 */
function setCurrencyPrefixNF(cp)
{
	this.setCurrencyValue(cp);
	this.setCurrencyPosition(this.LEFT_OUTSIDE);
}

/*
 * setCurrencyPosition - Sets the position for currency,
 *  which includes position relative to the numbers and negative sign.
 * cp - The position. Use one of the following constants.
 *  This method does not automatically put the negative sign at the left or right.
 *  They are left by default, and would need to be set right with setNegativeFormat.
 *	LEFT_OUTSIDE  example: $-1.00
 *	LEFT_INSIDE   example: -$1.00
 *	RIGHT_INSIDE  example: 1.00$-
 *	RIGHT_OUTSIDE example: 1.00-$
 *
 * v1.5.0 - new
 */
function setCurrencyPositionNF(cp)
{
	this.currencyPosition = cp
}

/*
 * setPlaces - Sets the precision of decimal places
 * p - The number of places.
 *  -1 or the constant NO_ROUNDING turns off rounding to a set number of places.
 *  Any other number of places less than or equal to zero is considered zero.
 *
 * v1.5.1 - modified
 */
function setPlacesNF(p)
{
	this.roundToPlaces = !(p == this.NO_ROUNDING); // v1.5.1
	this.places = (p < 0) ? 0 : p; // v1.5.1 - Don't leave negatives.
}

/*
 * v1.5.2 - new
 *
 * addSeparators
 * The value to be formatted shouldn't have any formatting already.
 *
 * nStr - A number or number as a string
 * inD - Input decimal (string value). Example: '.'
 * outD - Output decimal (string value). Example: '.'
 * sep - Output separator (string value). Example: ','
 */
function addSeparatorsNF(nStr, inD, outD, sep)
{
	nStr += '';
	var dpos = nStr.indexOf(inD);
	var nStrEnd = '';
	if (dpos != -1) {
		nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
		nStr = nStr.substring(0, dpos);
	}
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(nStr)) {
		nStr = nStr.replace(rgx, '$1' + sep + '$2');
	}
	return nStr + nStrEnd;
}

/*
 * toFormatted - Returns the number formatted according to the settings (a string)
 *
 * v1.5.0 - modified
 * v1.5.1 - modified
 */
function toFormattedNF()
{	
	var pos;
	var nNum = this.num; // v1.0.1 - number as a number
	var nStr;            // v1.0.1 - number as a string
	var splitString = new Array(2);   // v1.5.0
	
	// round decimal places - modified v1.5.1
	// Note: Take away negative temporarily with Math.abs
	if (this.roundToPlaces) {
		nNum = this.getRounded(nNum);
		nStr = this.preserveZeros(Math.abs(nNum)); // this step makes nNum into a string. v1.0.1 Math.abs
	} else {
		nStr = this.expandExponential(Math.abs(nNum)); // expandExponential is called in preserveZeros, so call it here too
	}
	
	// v1.5.3 - lost the if in 1.5.2, so putting it back
	if (this.hasSeparators) {
		// v1.5.2
		// Note that the argument being passed in for inD is this.PERIOD
		//  That's because the toFormatted method is working with an unformatted number
		nStr = this.addSeparators(nStr, this.PERIOD, this.decimalValue, this.separatorValue);
	}
	
	// negative and currency
	// $[c0] -[n0] $[c1] -[n1] #.#[nStr] -[n2] $[c2] -[n3] $[c3]
	var c0 = '';
	var n0 = '';
	var c1 = '';
	var n1 = '';
	var n2 = '';
	var c2 = '';
	var n3 = '';
	var c3 = '';
	var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
	var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
		
	if (this.currencyPosition == this.LEFT_OUTSIDE) {
		// add currency sign in front, outside of any negative. example: $-1.00	
		if (nNum < 0) {
			if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
			if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
		}
		if (this.hasCurrency) c0 = this.currencyValue;
	} else if (this.currencyPosition == this.LEFT_INSIDE) {
		// add currency sign in front, inside of any negative. example: -$1.00
		if (nNum < 0) {
			if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
			if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
		}
		if (this.hasCurrency) c1 = this.currencyValue;
	}
	else if (this.currencyPosition == this.RIGHT_INSIDE) {
		// add currency sign at the end, inside of any negative. example: 1.00$-
		if (nNum < 0) {
			if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
			if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
		}
		if (this.hasCurrency) c2 = this.currencyValue;
	}
	else if (this.currencyPosition == this.RIGHT_OUTSIDE) {
		// add currency sign at the end, outside of any negative. example: 1.00-$
		if (nNum < 0) {
			if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
			if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
		}
		if (this.hasCurrency) c3 = this.currencyValue;
	}

	nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
	
	// negative red
	if (this.negativeRed && nNum < 0) {
		nStr = '<font color="red">' + nStr + '</font>';
	}

	return (nStr);
}

/*
 * toPercentage - Format the current number as a percentage.
 * This is separate from most of the regular formatting settings.
 * The exception is the number of decimal places.
 * If a number is 0.123 it will be formatted as 12.3%
 *
 * !! This is an initial version, so it doesn't use many settings.
 * !! should use some of the formatting settings that toFormatted uses.
 * !! probably won't want to use settings like currency.
 *
 * v1.5.0 - new
 */
function toPercentageNF()
{
	nNum = this.num * 100;
	
	// round decimal places
	nNum = this.getRounded(nNum);
	
	return nNum + '%';
}

/*
 * Return concatenated zeros as a string. Used to pad a number.
 * It might be extra if already have many decimal places
 * but is needed if the number doesn't have enough decimals. 
 */
function getZerosNF(places)
{
		var extraZ = '';
		var i;
		for (i=0; i<places; i++) {
			extraZ += '0';
		}
		return extraZ;
}

/*
 * Takes a number that JavaScript expresses in notational format
 * and makes it the full number (as a string).
 * e.g. Makes -1e-21 into -0.000000000000000000001
 *
 * If the value passed in is not a number (as determined by isNaN),
 * this function just returns the original value.
 *
 * Exponential number formats can include 1e21 1e+21 1e-21
 *  where 1e21 and 1e+21 are the same thing.
 *
 * If an exponential number is evaluated by JavaScript,
 * it will change 12.34e-9 to 1.234e-8,
 * which is a benefit to this method, because
 * it prevents extra zeros that occur for certain numbers
 * when using moveDecimalAsString
 *
 * Returns a string.
 *
 * v1.5.1 - new
 */
function expandExponentialNF(origVal)
{
	if (isNaN(origVal)) return origVal;

	var newVal = parseFloat(origVal) + ''; // parseFloat to let JavaScript evaluate number
	var eLoc = newVal.toLowerCase().indexOf('e');

	if (eLoc != -1) {
		var plusLoc = newVal.toLowerCase().indexOf('+');
		var negLoc = newVal.toLowerCase().indexOf('-', eLoc); // search for - after the e
		var justNumber = newVal.substring(0, eLoc);
		
		if (negLoc != -1) {
			// shift decimal to the left
			var places = newVal.substring(negLoc + 1, newVal.length);
			justNumber = this.moveDecimalAsString(justNumber, true, parseInt(places));
		} else {
			// shift decimal to the right
			// Check if there's a plus sign, and if not refer to where the e is.
			// This is to account for either formatting 1e21 or 1e+21
			if (plusLoc == -1) plusLoc = eLoc;
			var places = newVal.substring(plusLoc + 1, newVal.length);
			justNumber = this.moveDecimalAsString(justNumber, false, parseInt(places));
		}
		
		newVal = justNumber;
	}

	return newVal;
} 

/*
 * Move decimal right.
 * Returns a number.
 *
 * v1.5.1 - new
 */
function moveDecimalRightNF(val, places)
{
	var newVal = '';
	
	if (places == null) {
		newVal = this.moveDecimal(val, false);
	} else {
		newVal = this.moveDecimal(val, false, places);
	}
	
	return newVal;
}

/*
 * Move decimal left.
 * Returns a number.
 *
 * v1.5.1 - new
 */
function moveDecimalLeftNF(val, places)
{
	var newVal = '';
	
	if (places == null) {
		newVal = this.moveDecimal(val, true);
	} else {
		newVal = this.moveDecimal(val, true, places);
	}
	
	return newVal;
}

/*
 * moveDecimalAsString
 * This is used by moveDecimal, and does not run parseFloat on the return value.
 * 
 * Normally a decimal place is moved by multiplying by powers of 10
 * Multiplication and division in JavaScript can result in floating point limitations.
 * So use this method to move a decimal place left or right.
 *
 * Parameters:
 * val - The value to be shifted. Can be a number or a string,
 *  but don't include special characters. It should evaluate to a number.
 * left - If true, then move decimal left. If false, move right.
 * places - (optional) If not included, then use the objects this.places
 *  The purpose is so this method can be used independent of the state of the object.
 *
 * The regular expressions:
 * re1
 * Pad with zeros in case there aren't enough numbers to cover the spaces shift.
 * A left shift pads to the left, and a right shift pads to the right.
 * Can't just concatenate. There might be a negative sign or the value could be an exponential.
 *
 * re2
 * Switch the decimal.
 * Need the first [0-9]+ to force the search to start rightmost.
 * The \.? and [0-9]{} criteria are the pieces that will be switched
 *
 * Other notes:
 * This method works on exponential numbers, e.g. 1.7e-12
 * because the regular expressions only modify the number and decimal parts.
 *
 * Mozilla can't handle [0-9]{0} in the regular expression.
 *  Fix: Since nothing changes when the decimal is shifted zero places, return the original value.
 *
 * IE is incorrect if exponential ends in .
 *  e.g. -8500000000000000000000. should be -8.5e+21
 *  IE counts it as -8.5e+22
 *	Fix: Replace trailing period, if there is one, using replace(/\.$/, '').
 *
 * Netscape 4.74 cannot handle a leading - in the string being searched for the re2 expressions.
 *  e.g. /([0-9]*)(\.?)([0-9]{2})/ should match everything in -100.00 except the -
 *  but it matches nothing using Netscape 4.74.
 *  It might be a combination of the * ? special characters.
 *  Fix: (-?) was added to each of the re2 expressions to look for - one or zero times.
 *
 * Returns a string.
 *
 * v1.5.1 - new
 * v1.5.2 - modified
 */
function moveDecimalAsStringNF(val, left, places)
{
	var spaces = (arguments.length < 3) ? this.places : places;
	if (spaces <= 0) return val; // to avoid Mozilla limitation
			
	var newVal = val + '';
	var extraZ = this.getZeros(spaces);
	var re1 = new RegExp('([0-9.]+)');
	if (left) {
		newVal = newVal.replace(re1, extraZ + '$1');
		var re2 = new RegExp('(-?)([0-9]*)([0-9]{' + spaces + '})(\\.?)');		
		newVal = newVal.replace(re2, '$1$2.$3');
	} else {
		var reArray = re1.exec(newVal); // v1.5.2
		if (reArray != null) {
			newVal = newVal.substring(0,reArray.index) + reArray[1] + extraZ + newVal.substring(reArray.index + reArray[0].length); // v1.5.2
		}
		var re2 = new RegExp('(-?)([0-9]*)(\\.?)([0-9]{' + spaces + '})');
		newVal = newVal.replace(re2, '$1$2$4.');
	}
	newVal = newVal.replace(/\.$/, ''); // to avoid IE flaw
	
	return newVal;
}

/*
 * moveDecimal
 * Refer to notes in moveDecimalAsString
 * parseFloat is called here to clear away the padded zeros.
 *
 * Returns a number.
 *
 * v1.5.1 - new
 */
function moveDecimalNF(val, left, places)
{
	var newVal = '';
	
	if (places == null) {
		newVal = this.moveDecimalAsString(val, left);
	} else {
		newVal = this.moveDecimalAsString(val, left, places);
	}
	
	return parseFloat(newVal);
}

/*
 * getRounded - Used internally to round a value
 * val - The number to be rounded
 * 
 *  To round to a certain decimal precision,
 *  all that should need to be done is
 *  multiply by a power of 10, round, then divide by the same power of 10.
 *  However, occasional numbers don't get exact results in most browsers.
 *  e.g. 0.295 multiplied by 10 yields 2.9499999999999997 instead of 2.95
 *  Instead of adjusting the incorrect multiplication,
 *  this function uses string manipulation to shift the decimal.
 *
 * Returns a number.
 *
 * v1.5.1 - modified
 */
function getRoundedNF(val)
{
	val = this.moveDecimalRight(val);
	val = Math.round(val);
	val = this.moveDecimalLeft(val);
	
	return val;
}

/*
 * preserveZeros - Used internally to make the number a string
 * 	that preserves zeros at the end of the number
 * val - The number
 */
function preserveZerosNF(val)
{
	var i;

	// make a string - to preserve the zeros at the end
	val = this.expandExponential(val);
	
	if (this.places <= 0) return val; // leave now. no zeros are necessary - v1.0.1 less than or equal
	
	var decimalPos = val.indexOf('.');
	if (decimalPos == -1) {
		val += '.';
		for (i=0; i<this.places; i++) {
			val += '0';
		}
	} else {
		var actualDecimals = (val.length - 1) - decimalPos;
		var difference = this.places - actualDecimals;
		for (i=0; i<difference; i++) {
			val += '0';
		}
	}
	
	return val;
}

/*
 * justNumber - Used internally to parse the value into a floating point number.
 * Replace all characters that are not 0-9, a decimal point, or a negative sign.
 *
 *  A number can be entered using special notation.
 *  For example, the following is a valid number: 0.0314E+2
 *
 * v1.0.2 - new
 * v1.5.0 - modified
 * v1.5.1 - modified
 * v1.5.2 - modified
 */
function justNumberNF(val)
{
	newVal = val + '';
	
	var isPercentage = false;
	
	// check for percentage
	// v1.5.0
	if (newVal.indexOf('%') != -1) {
		newVal = newVal.replace(/\%/g, '');
		isPercentage = true; // mark a flag
	}
		
	// Replace everything but digits - + ( ) e E
	var re = new RegExp('[^\\' + this.inputDecimalValue + '\\d\\-\\+\\(\\)eE]', 'g');	// v1.5.2	
	newVal = newVal.replace(re, '');
	// Replace the first decimal with a period and the rest with blank
	// The regular expression will only break if a special character
	//  is used as the inputDecimalValue
	//  e.g. \ but not .
	var tempRe = new RegExp('[' + this.inputDecimalValue + ']', 'g');
	var treArray = tempRe.exec(newVal); // v1.5.2
	if (treArray != null) {
	  var tempRight = newVal.substring(treArray.index + treArray[0].length); // v1.5.2
		newVal = newVal.substring(0,treArray.index) + this.PERIOD + tempRight.replace(tempRe, ''); // v1.5.2
	}
	
	// If negative, get it in -n format
	if (newVal.charAt(newVal.length - 1) == this.DASH ) {
		newVal = newVal.substring(0, newVal.length - 1);
		newVal = '-' + newVal;
	}
	else if (newVal.charAt(0) == this.LEFT_PAREN
	 && newVal.charAt(newVal.length - 1) == this.RIGHT_PAREN) {
		newVal = newVal.substring(1, newVal.length - 1);
		newVal = '-' + newVal;
	}
	
	newVal = parseFloat(newVal);
	
	if (!isFinite(newVal)) {
		newVal = 0;
  }
	
	// now that it's a number, adjust for percentage, if applicable.
  // example. if the number was formatted 24%, then move decimal left to get 0.24
  // v1.5.0 - updated v1.5.1
  if (isPercentage) {
  	newVal = this.moveDecimalLeft(newVal, 2);
  }
		
	return newVal;
}

function submitOnce(formName)
{
	this.formName=(formName) ? formName:0;

	if (document.forms && document.getElementsByTagName)
	{
		var subFields=eval('document.forms["'+this.formName+'"].getElementsByTagName("input");');

		var subFieldsLen=subFields.length;
		for (k=0; k<subFieldsLen; k++)
		{
			if (subFields[k].getAttribute("type").toLowerCase() == "submit") subFields[k].disabled=true;
			if (subFields[k].getAttribute("type").toLowerCase() == "reset") subFields[k].disabled=true;
		}
	}
}




function selectAll(formField)
{
	temp=eval(formField);
	temp.focus();
	temp.select();
}




function radioButton(formName)
{
	this.formName=(formName) ? formName:0;
		
	this.select=function(what,radio)
	{
		if(what.checked==true){
			what.checked==false;
		}
		if (document.forms && document.getElementsByTagName)
		{
			var raFields=eval('document.forms["'+this.formName+'"].getElementsByTagName("input");');
//			var raFields=eval('document.forms["'+this.formName+'"].getElementsById("radio");');
			var raFieldsLen=raFields.length;
			for (i=0; i<raFieldsLen; i++)
			{
//				if( raFields[i].getAttribute("id")=="radio"){alert( raFields[i].getAttribute("id"));}
				if ((raFields[i].getAttribute("type").toLowerCase() == "checkbox") && raFields[i].getAttribute("id")==radio) raFields[i].checked=false;
				what.checked=true;
			}
		}
	}
}



function checkbox(nameOfForm)
{
	// Store variables.
	this.nameOfForm=(nameOfForm) ? nameOfForm:0;
	this.toggleOnOff=1;

	// Can be used externally, but meant for internal use only.
	this.set=function(bool)
	{
		if (document.forms && document.getElementsByTagName)
		{
			var theFields=eval('document.forms["'+this.nameOfForm+'"].getElementsByTagName("input");');

			var theFieldsLen=theFields.length;
			for (i=0; i<theFieldsLen; i++)
			{
				if (theFields[i].getAttribute("type").toLowerCase() == "checkbox") theFields[i].checked=bool;
			}
		}
		else alert('Not Supported');
	}

	// Basic functions to use externally.
	this.check=function() { this.set(true); }
	this.clear=function() { this.set(false); }

	// Just a nifty little feature.
	this.toggle=function()
	{
		if (this.toggleOnOff) { this.set(true); this.toggleOnOff=0; }
		else if (!this.toggleOnOff) { this.set(false); this.toggleOnOff=1; }
	}

	// Call this during BODY onLoad to add mouseover functionality to the form.
	this.enableMouseover=function()
	{
		if (document.forms && document.getElementsByTagName)
		{
			var moFields=eval('document.forms["'+this.nameOfForm+'"].getElementsByTagName("input");');

			var moFieldsLen=moFields.length;
			for (i=0; i<moFieldsLen; i++)
			{
				if (moFields[i].getAttribute("type").toLowerCase() == "checkbox")
				{
					onMO=moFields[i];
					onMO.onmouseover=this.change;
				}
			}
		}
	}

	this.change=function() { this.checked=(this.checked) ? false:true; }

	// By Peter Bailey, www.peterbailey.net
	// Slight modifications by Ryan Parman, www.skyzyx.com
	this.enableClickDrag=function(sameNameOnly)
	{
		// Abort if browser can't do script
		if (document.all && !document.attachEvent) return true;
		else if (!document.all && !document.addEventListener) return true;
		//else if (document.all && !document.addEventListener) return true; // For retarded-ass Opera 7...

		// Initialize Variables/properties
		var f=eval('document.forms["'+this.nameOfForm+'"]');
		var dragObj=this;
		this.checked=false;
		this.mousedown=false;
		this.validClick=false;
		this.same=Boolean( sameNameOnly );

		// Attach Events
		if ( document.attachEvent )
		{
			f.attachEvent( "onmousedown", function() { downHandler( event.srcElement, dragObj ) } );
			f.attachEvent( "onmouseover", function() { overHandler( event.srcElement, dragObj ) } );
			document.attachEvent( "onmouseup", function() { upHandler( event.srcElement, dragObj ) } );
		}
		else
		{
			f.addEventListener( "mousedown", function( e ) { downHandler( e.target, dragObj ) }, false );
			f.addEventListener( "mouseover", function( e ) { overHandler( e.target, dragObj ) }, false );
			document.addEventListener( "mouseup", function( e ) { upHandler( e.target, dragObj ) }, false );
		}

		// Handler for form.onMouseDown event
		function downHandler(elem, o)
		{
			if (elem.type=="checkbox")
			{
				o.validClick=true;
				o.firstCB=elem;
				o.mousedown=true;
				o.checked=!elem.checked
				if (o.same) o.name=elem.name;
			}
		}

		// Handler for document.onMouseUp event
		function upHandler(elem, o)
		{
			if (o.validClick && o.firstCB)
			{
				o.firstCB.checked=o.checked;
				o.mousedown=false;
				o.checked=!o.checked;
				o.validClick=false;
				if (elem===o.firstCB) elem.checked=o.checked;
			}
		}

		// Hanlder for form.onMouseOver event
		function overHandler(elem, o)
		{
			if (elem.type=="checkbox" && o.mousedown)
			{
				if (o.same && elem.name == o.name) elem.checked=o.checked;
				else if (!o.same) elem.checked=o.checked;
			}
		}
	}
}



function select_bvirtuel_us() {
document.write("<option value=\"0\">-choisir une place-</option><option value=\"750\">SCOTTSDALE, Arizona</option><option value=\"750\">NORTH LITTLE ROCKS, Arkansas</option><option value=\"850\">BEVERLY HILLS, California</option><option value=\"750\">LOS ANGELES, California</option><option value=\"750\">ASPEN, Colorado</option><option value=\"750\">NEW HAVEN, Connecticut</option><option value=\"750\">DOVER, Delaware</option><option value=\"750\">KEY LARGO, Florida</option><option value=\"750\">KEY WEST, Florida</option><option value=\"750\">MIAMI BEACH, Florida</option><option value=\"750\">ORLANDO, Florida</option><option value=\"750\">ATLANTA, Georgia</option><option value=\"750\">BOISE, Idaho</option><option value=\"750\">CHICAGO, Illinois</option><option value=\"750\">BALTIMORE, Maryland</option><option value=\"750\">BOSTON, Massachussets</option><option value=\"750\">CAMBRIDGE, Massachussets</option><option value=\"750\">ANN ARBOR, Michigan</option><option value=\"750\">DETROIT, Michigan</option><option value=\"750\">RAPIDS, Minnesota</option><option value=\"750\">KANSAS CITY, Missouri</option><option value=\"750\">LAS VEGAS, Nevada</option><option value=\"750\">RENO, Nevado</option><option value=\"750\">CONCORD, New Hampshire</option><option value=\"800\">DELMAR, New York</option><option value=\"800\">MANHATTAN, New York</option><option value=\"800\">NEW YORK, New York</option><option value=\"750\">CHAPEL HILL, North Carolina</option><option value=\"750\">CHARLOTTE, North Carolina</option><option value=\"750\">RALEIGHT, North Carolina</option><option value=\"750\">CINCINNATI, Ohio</option><option value=\"750\">PORTLAND, Oregon</option><option value=\"750\">REDMOND, Oregon</option><option value=\"750\">PHILADELPHIA, Pennsylvania</option><option value=\"750\">PROVIDENCE, Rhode Island</option><option value=\"800\">CHARLESTON, South Carolina</option><option value=\"750\">NASHVILLE, Tennessee</option><option value=\"750\">AUSTIN, Texas</option><option value=\"750\">DALLAS, Texas</option><option value=\"750\">SALT LAKE CITY, Utah</option><option value=\"750\">MONTPELIER, Vermont</option><option value=\"750\">RICHMOND, Virginia</option><option value=\"750\">CHRISTIANBURG, Virginia</option><option value=\"750\">SEATTLE, Washington</option><option value=\"800\">WASHINGTON D.C..</option><option value=\"750\">MADISON, Wisconsin</option>");
}

function select_maildrop_us() {
document.write("<option value=\"0\">-choisir une place-</option><option value=\"460\">SCOTTSDALE, Arizona</option><option value=\"460\">NORTH LITTLE ROCKS, Arkansas</option><option value=\"460\">BEVERLY HILLS, California</option><option value=\"460\">LOS ANGELES, California</option><option value=\"460\">ASPEN, Colorado</option><option value=\"460\">NEW HAVEN, Connecticut</option><option value=\"460\">DOVER, Delaware</option><option value=\"460\">KEY LARGO, Florida</option><option value=\"460\">KEY WEST, Florida</option><option value=\"460\">MIAMI BEACH, Florida</option><option value=\"460\">ORLANDO, Florida</option><option value=\"460\">ATLANTA, Georgia</option><option value=\"460\">BOISE, Idaho</option><option value=\"460\">CHICAGO, Illinois</option><option value=\"460\">BALTIMORE, Maryland</option><option value=\"460\">BOSTON, Massachussets</option><option value=\"460\">CAMBRIDGE, Massachussets</option><option value=\"460\">ANN ARBOR, Michigan</option><option value=\"460\">DETROIT, Michigan</option><option value=\"460\">RAPIDS, Minnesota</option><option value=\"460\">KANSAS CITY, Missouri</option><option value=\"460\">LAS VEGAS, Nevada</option><option value=\"460\">RENO, Nevado</option><option value=\"460\">CONCORD, New Hampshire</option><option value=\"530\">DELMAR, New York</option><option value=\"530\">MANHATTAN, New York</option><option value=\"530\">NEW YORK, New York</option><option value=\"460\">CHAPEL HILL, North Carolina</option><option value=\"460\">CHARLOTTE, North Carolina</option><option value=\"460\">RALEIGHT, North Carolina</option><option value=\"460\">CINCINNATI, Ohio</option><option value=\"460\">PORTLAND, Oregon</option><option value=\"460\">REDMOND, Oregon</option><option value=\"460\">PHILADELPHIA, Pennsylvania</option><option value=\"460\">PROVIDENCE, Rhode Island</option><option value=\"800\">CHARLESTON, South Carolina</option><option value=\"460\">NASHVILLE, Tennessee</option><option value=\"460\">AUSTIN, Texas</option><option value=\"460\">DALLAS, Texas</option><option value=\"460\">SALT LAKE CITY, Utah</option><option value=\"460\">MONTPELIER, Vermont</option><option value=\"460\">RICHMOND, Virginia</option><option value=\"460\">CHRISTIANBURG, Virginia</option><option value=\"460\">SEATTLE, Washington</option><option value=\"530\">WASHINGTON D.C..</option><option value=\"460\">MADISON, Wisconsin</option>");
}

function select_bvirtuel() {
document.write("<option value=\"0\">-choisir une place-</option><option value=\"720\" >BERLIN, Allemagne</option><option value=\"720\" >FRANKFURT, Allemagne</option><option value=\"720\" >MUNICH, Allemagne</option><option value=\"800\" >MELBOURNE, Australie</option><option value=\"800\" >QUEENSLAND, Australie</option><option value=\"800\" >SYDNEY, Australie</option><option value=\"720\" >GRAZ, Autriche</option><option value=\"1280\" >VIENNE, Autriche</option><option value=\"720\" >NASSAU, Bahmas</option><option value=\"720\" >BRUXELLES, Belgique</option><option value=\"720\" >SOFIA, Bulgarie</option><option value=\"720\" >ALBERTA, Canada</option><option value=\"720\" >BRITISH COLOMBIA, Canada</option><option value=\"680\" >MANITOBA, Canada</option><option value=\"720\" >ONTARIO, Canada</option><option value=\"1380\" >VANCOUVER, Canada</option><option value=\"720\" >WINDSOR, Canada</option><option value=\"1380\" >PRAGUE, Rep. Tch.</option><option value=\"720\" >COPENHAGUE, Danemark</option><option value=\"780\" >BARCELONE, Espagne</option><option value=\"680\" >MADRID, Espagne</option><option value=\"650\" >MARBELLA, Espagne</option><option value=\"650\" >SEVILLE, Espagne</option><option value=\"780\" >VALENCIA, Espagne</option><option value=\"720\" >HELSINKI, Finlande</option><option value=\"720\" >LE MANS, France</option><option value=\"720\" >PARIS, France</option><option value=\"800\" >GIBRALTAR</option><option value=\"720\" >ATHENE, Grèce</option><option value=\"1600\" >HOLLANDE</option><option value=\"1330\" >AMSTERDAM, Hollande (po box)</option><option value=\"780\" >LA HAGUE, Hollande (po box)</option><option value=\"720\" >HONG KONG</option><option value=\"680\" >DUBLIN, Irlande</option><option value=\"800\" >TEL AVIV, Israël</option><option value=\"680\" >MILAN, Italie</option><option value=\"780\" >ROME, Italie</option><option value=\"780\" >VENICE, Italie</option><option value=\"900\" >MEXICO CITY, Mexique</option><option value=\"900\" >PUERTO VALLARTA, Mexique</option><option value=\"720\" >AUKLAND, Nouvelle-Zélande</option><option value=\"720\" >OSLA, Norvège</option><option value=\"900\" >PANAMA CITY, Panama</option><option value=\"720\" >MANILLE, Philippines</option><option value=\"650\" >LONDRES, Royaume-Uni</option><option value=\"720\" >MOSCOU, Russie</option><option value=\"720\" >SINGAPOUR</option><option value=\"650\" >ST VINCENT ET GRENADINES</option><option value=\"720\" >STOCKHOLM, Suède</option><option value=\"1720\" >GENEVE, Suisse</option><option value=\"720\" >ZURICH, Suisse (proche)</option><option value=\"720\" >BANGKOK, Thailande</option><option value=\"650\" >ISTANBUL, Turquie</option>");
}

function select_maildrop() {
document.write("<option value=\"0\">-choisir une place-</option><option value=\"630\" >CAPETOWN, Afrique du Sud</option><option value=\"390\" >CAPETOWN, Afrique du Sud (po box)</option><option value=\"590\" >JOHANNERBURG, Afrique du Sud</option><option value=\"490\" >BERLIN, Allemagne</option><option value=\"490\" >FRANKFURT, Allemagne</option><option value=\"490\" >MUNICH, Allemagne</option><option value=\"680\" >MELBOURNE, Australie</option><option value=\"680\" >QUEENSLAND, Australie</option><option value=\"390\" >TOWNSVILLE, Australie</option><option value=\"680\" >SYDNEY, Australie</option><option value=\"540\" >GRAZ, Autriche</option><option value=\"540\" >VIENNA, Autriche</option><option value=\"540\" >NASSAU, Bahamas</option><option value=\"1090\" >BRUXELLES, Belgique</option><option value=\"410\" >BELIZE CITY, Belize</option><option value=\"490\" >BVI</option><option value=\"590\" >SOFIA, Bulgarie</option><option value=\"540\" >ALBERTA, Canada</option><option value=\"540\" >BRITISH COLOMBIA, Canada</option><option value=\"540\" >MAITOBA, Canada</option><option value=\"475\" >ONTARIO, Canada</option><option value=\"475\" >VANCOUVER, Canada</option><option value=\"540\" >WINDSOR, Canada</option><option value=\"590\" >COSTA RICA</option><option value=\"720\" >PRAGUE, Rep. Tch.</option><option value=\"540\" >COPENHAGE, Danemark</option><option value=\"790\" >SAINT DOMINGO, Rep. Dom.</option><option value=\"1380\" >DUBAI, EAU</option><option value=\"540\" >MADRID, Espagne</option><option value=\"390\" >MARBELLA, Espagne</option><option value=\"390\" >SEVILLE, Espagne</option><option value=\"540\" >HELSINKI, Finlande</option><option value=\"490\" >LE MANS, France</option><option value=\"630\" >PARIS, France</option><option value=\"1290\" >TAHITI, Polynésie Fr.</option><option value=\"540\" >GIBRALTAR</option><option value=\"540\" >ATHENS, Grèce</option><option value=\"1350\" >HOLLANDE</option><option value=\"1050\" >AMSTERDAM, Hollade (po box)</option><option value=\"790\" >LA HAGUE, Hollande (po box)</option><option value=\"540\" >HONG KONG</option><option value=\"540\" >BUDAPEST, Hongrie</option><option value=\"390\" >NEW DEHLI, Inde</option><option value=\"450\" >DUBLIN, Irlande</option><option value=\"540\" >JERUSALEM, Israël</option><option value=\"1480\" >TEL AVIV, Israël</option><option value=\"540\" >BOLOGNA, Italie</option><option value=\"450\" >MILAN, Italie</option><option value=\"490\" >ROME, Italie</option><option value=\"490\" >VENICE, Italie</option><option value=\"2700\" >LUXEMBOURG (ste)</option><option value=\"870\" >MALTE</option><option value=\"1220\" >MARSHALL, (Iles)</option><option value=\"620\" >ACAPULCO, Mexique</option><option value=\"620\" >GUADALAJARA, Mexique</option><option value=\"620\" >MEXICO CITY, Mexique</option><option value=\"620\" >PUERTO VALARTA, Mexique</option><option value=\"530\" >AUKLAND, Nouvelle-Zélande</option><option value=\"540\" >OSLO, Norvège</option><option value=\"590\" >PANAMA CITY, Panama</option><option value=\"540\" >MANILA, Philippines</option><option value=\"390\" >LISBONNE, Portugal</option><option value=\"450\" >BARTON-UPON-HUMBER, Royaume Uni</option><option value=\"530\" >LONDRES, Royaume Uni</option><option value=\"540\" >MOSCOU, Russie</option><option value=\"1380\" >SAN MARINO</option><option value=\"790\" >BELGRADE, Serbie</option><option value=\"540\" >SINGAPOUR</option><option value=\"630\" >BRATISLAVA, Slovaquie</option><option value=\"540\" >ST VINCENT ET LES GRENADINES</option><option value=\"450\" >ENKOPING, Suède</option><option value=\"450\" >FARLOV, Suède</option><option value=\"450\" >FROSON, Suède</option><option value=\"450\" >GOTEBORG, Suède</option><option value=\"450\" >HELINGBORG, Suède</option><option value=\"450\" >KARLSKOGA, Suède</option><option value=\"450\" >MALMO, Suède</option><option value=\"450\" >NORKOPPING, Suède</option><option value=\"450\" >OSTERSUND, Suède</option><option value=\"540\" >STOCKHOLM, Suède</option><option value=\"1500\" >GENEVE, Suisse</option><option value=\"540\" >ZURICH Suisse</option><option value=\"390\" >BANGKOK, Thailande</option><option value=\"540\" >ISTANBUL, Turquie</option><option value=\"630\" >TRINIDAD et TOBAGO, West Indies</option>");
}

function select_pays(vartxt) {
document.write("<select name=\""+vartxt+"\" id=\""+vartxt+"\"><option value='FR' selected=\"selected\">France</option><option value='PF'>Polyn&eacute;sie Fran&ccedil;aise</option><option value='TF'>French Southern Territories</option><option value='BE'>Belgium</option><option value='CA'>Canada</option><option value='GF'>Guin&eacute;e Fran&ccedil;aise</option><option value='LU'>Luxembourg</option><option value='MC'>Monaco</option><option value='MQ'>Martinique</option><option value='YT'>Mayotte</option><option value='RE'>Reunion</option><option value='CH'>Suisse</option><option value='AF'>Afghanistan</option><option value='AX'>&Aring;land Islands</option><option value='AL'>Albania</option><option value='DZ'>Algeria</option><option value='AS'>American Samoa</option><option value='AD'>Andorra</option><option value='AO'>Angola</option><option value='AI'>Anguilla</option><option value='AQ'>Antarctica</option><option value='AG'>Antigua and Barbuda</option><option value='AR'>Argentina</option><option value='AM'>Armenia</option><option value='AW'>Aruba</option><option value='AU'>Australia</option><option value='AT'>Austria</option><option value='AZ'>Azerbaijan</option><option value='BS'>Bahamas</option><option value='BH'>Bahre&iuml;n</option><option value='BD'>Bangladesh</option><option value='BB'>Barbados</option><option value='BY'>Belarus</option><option value='BZ'>Belize</option><option value='BJ'>Benin</option><option value='BM'>Bermuda</option><option value='BT'>Bhutan</option><option value='BO'>Bolivia</option><option value='BA'>Bosnia and Herzegovina</option><option value='BW'>Botswana</option><option value='BV'>Bouvet Island</option><option value='BR'>Brazil</option><option value='IO'>British Indian Ocean Territory</option><option value='BN'>Brunei Darussalam</option><option value='BG'>Bulgaria</option><option value='BF'>Burkina Faso</option><option value='BI'>Burundi</option><option value='KH'>Cambodia</option><option value='CM'>Cameroon</option><option value='CV'>Cape Verde</option><option value='KY'>Cayman Islands</option><option value='CF'>Central African Republic</option><option value='TD'>Chad</option><option value='CL'>Chile</option><option value='CN'>China</option><option value='CX'>Christmas Island</option><option value='CC'>Cocos (Keeling) Islands</option><option value='CO'>Colombia</option><option value='KM'>Comoros</option><option value='CG'>Congo</option><option value='CD'>Congo, the Democratic Republic of the</option><option value='CK'>Cook Islands</option><option value='CR'>Costa Rica</option><option value='CI'>Cote D&#039;Ivoire</option><option value='HR'>Croatia</option><option value='CU'>Cuba</option><option value='CY'>Cyprus</option><option value='CZ'>Czech Republic</option><option value='DK'>Denmark</option><option value='DJ'>Djibouti</option><option value='DM'>Dominica</option><option value='DO'>Dominican Republic</option><option value='EC'>Ecuador</option><option value='EG'>Egypt</option><option value='SV'>El Salvador</option><option value='GQ'>Equatorial Guinea</option><option value='ER'>Eritrea</option><option value='EE'>Estonia</option><option value='ET'>Ethiopia</option><option value='FK'>Falkland Islands (Malvinas)</option><option value='FO'>Faroe Islands</option><option value='FJ'>Fiji</option><option value='FI'>Finland</option><option value='GA'>Gabon</option><option value='GM'>Gambia</option><option value='GE'>Georgia</option><option value='DE'>Germany</option><option value='GH'>Ghana</option><option value='GI'>Gibraltar</option><option value='GR'>Greece</option><option value='GL'>Greenland</option><option value='GD'>Grenada</option><option value='GP'>Guadeloupe</option><option value='GU'>Guam</option><option value='GT'>Guatemala</option><option value='GN'>Guinea</option><option value='GW'>Guinea-Bissau</option><option value='GY'>Guyana</option><option value='HT'>Haiti</option><option value='HM'>Heard Island and McDonald Islands</option><option value='VA'>Holy See (Vatican City State)</option><option value='HN'>Honduras</option><option value='HK'>Hong Kong</option><option value='HU'>Hungary</option><option value='IS'>Iceland</option><option value='IN'>India</option><option value='ID'>Indonesia</option><option value='IR'>Iran, Islamic Republic of</option><option value='IQ'>Iraq</option><option value='IE'>Ireland</option><option value='IL'>Israel</option><option value='IT'>Italy</option><option value='JM'>Jamaica</option><option value='JP'>Japan</option><option value='JO'>Jordan</option><option value='KZ'>Kazakhstan</option><option value='KE'>Kenya</option><option value='KI'>Kiribati</option><option value='KP'>Korea, Democratic People&#039;s Republic of</option><option value='KR'>Korea, Republic of</option><option value='KW'>Kuwait</option><option value='KG'>Kyrgyzstan</option><option value='LA'>Lao People&#039;s Democratic Republic</option><option value='LV'>Latvia</option><option value='LB'>Lebanon</option><option value='LS'>Lesotho</option><option value='LR'>Liberia</option><option value='LY'>Libyan Arab Jamahiriya</option><option value='LI'>Liechtenstein</option><option value='LT'>Lithuania</option><option value='MO'>Macao</option><option value='MK'>Macedonia, the Former Yugoslav Republic of</option><option value='MG'>Madagascar</option><option value='MW'>Malawi</option><option value='MY'>Malaysia</option><option value='MV'>Maldives</option><option value='ML'>Mali</option><option value='MT'>Malta</option><option value='MH'>Marshall Islands</option><option value='MR'>Mauritania</option><option value='MU'>Mauritius</option><option value='MX'>Mexico</option><option value='FM'>Micronesia, Federated States of</option><option value='MD'>Moldova, Republic of</option><option value='MN'>Mongolia</option><option value='MS'>Montserrat</option><option value='MA'>Morocco</option><option value='MZ'>Mozambique</option><option value='MM'>Myanmar</option><option value='NA'>Namibia</option><option value='NR'>Nauru</option><option value='NP'>Nepal</option><option value='NL'>Netherlands</option><option value='AN'>Netherlands Antilles</option><option value='NC'>New Caledonia</option><option value='NZ'>New Zealand</option><option value='NI'>Nicaragua</option><option value='NE'>Niger</option><option value='NG'>Nigeria</option><option value='NU'>Niue</option><option value='NF'>Norfolk Island</option><option value='MP'>Northern Mariana Islands</option><option value='NO'>Norway</option><option value='OM'>Oman</option><option value='PK'>Pakistan</option><option value='PW'>Palau</option><option value='PS'>Palestinian Territory, Occupied</option><option value='PA'>Panama</option><option value='PG'>Papua New Guinea</option><option value='PY'>Paraguay</option><option value='PE'>Peru</option><option value='PH'>Philippines</option><option value='PN'>Pitcairn</option><option value='PL'>Poland</option><option value='PT'>Portugal</option><option value='PR'>Puerto Rico</option><option value='QA'>Qatar</option><option value='RO'>Romania</option><option value='RU'>Russian Federation</option><option value='RW'>Rwanda</option><option value='SH'>Saint Helena</option><option value='KN'>Saint Kitts and Nevis</option><option value='LC'>Saint Lucia</option><option value='PM'>Saint Pierre and Miquelon</option><option value='VC'>Saint Vincent and the Grenadines</option><option value='WS'>Samoa</option><option value='SM'>San Marino</option><option value='ST'>Sao Tome and Principe</option><option value='SA'>Saudi Arabia</option><option value='SN'>Senegal</option><option value='CS'>Serbia and Montenegro</option><option value='SC'>Seychelles</option><option value='SL'>Sierra Leone</option><option value='SG'>Singapore</option><option value='SK'>Slovakia</option><option value='SI'>Slovenia</option><option value='SB'>Solomon Islands</option><option value='SO'>Somalia</option><option value='ZA'>South Africa</option><option value='GS'>South Georgia and the South Sandwich Islands</option><option value='ES'>Spain</option><option value='LK'>Sri Lanka</option><option value='SD'>Sudan</option><option value='SR'>Suriname</option><option value='SJ'>Svalbard and Jan Mayen</option><option value='SZ'>Swaziland</option><option value='SE'>Sweden</option><option value='SY'>Syrian Arab Republic</option><option value='TW'>Taiwan</option><option value='TJ'>Tajikistan</option><option value='TZ'>Tanzania, United Republic of</option><option value='TH'>Thailand</option><option value='TL'>Timor-Leste</option><option value='TG'>Togo</option><option value='TK'>Tokelau</option><option value='TO'>Tonga</option><option value='TT'>Trinidad and Tobago</option><option value='TN'>Tunisia</option><option value='TR'>Turkey</option><option value='TM'>Turkmenistan</option><option value='TC'>Turks and Caicos Islands</option><option value='TV'>Tuvalu</option><option value='UG'>Uganda</option><option value='UA'>Ukraine</option><option value='AE'>United Arab Emirates</option><option value='GB'>United Kingdom</option><option value='US'>United States</option><option value='UM'>United States Minor Outlying Islands</option><option value='UY'>Uruguay</option><option value='UZ'>Uzbekistan</option><option value='VU'>Vanuatu</option><option value='VE'>Venezuela</option><option value='VN'>Vietnam</option><option value='VG'>Virgin Islands, British</option><option value='VI'>Virgin Islands, U.S.</option><option value='WF'>Wallis and Futuna</option><option value='EH'>Western Sahara</option><option value='YE'>Yemen</option><option value='ZM'>Zambia</option><option value='ZW'>Zimbabwe</option></select>");
}

function select_compta_uk() {
document.write("<option value=\"49\" selected=\"selected\">25 &eacute;critures mensuels</option><option value=\"75\">50 &eacute;critures mensuels</option><option value=\"99\">75 &eacute;critures mensuels</option><option value=\"149\">149 &eacute;critures mensuels</option>");
}

function toutenun(what){
if (what.elements['C0'].checked){
    what.C4.checked=true;
    getElementEcrit('tc4','inclus');
    what.C4.disabled=true;
    what.C4.value=0;

    what.C3.checked=true;
    getElementEcrit('tc3','inclus');
    getElementEcrit('aib','Assistance ouverture compte bancaire');
    what.C3.disabled=true;
    what.C3.value=0;

    what.C59.checked=true;
    getElementEcrit('tc59','inclus');
    what.C59.disabled=true;
    what.C59.value=0;

    what.C2.checked=true;
    getElementEcrit('tc2','inclus');
}else{
    what.C4.checked=true;
    getElementEcrit('tc4','49,90 £');
    what.C4.disabled=false;
    what.C4.value=49.90;

    what.C3.checked=true;
    getElementEcrit('tc3','350,00 £');
    getElementEcrit('aib','Introduction bancaire');
    what.C3.disabled=false;
    what.C3.value=350.00;

    what.C59.checked=true;
    getElementEcrit('tc59','99,00 £');
    what.C59.disabled=false;
    what.C59.value=99.00;

    what.C2.checked=false;
    getElementEcrit('tc2','indisponible');
}

if (what.elements['C31'].checked){
    what.C28.checked=true;
    getElementEcrit('tc28','inclus');
    what.C28.disabled=true;
    what.C28.value=0;
	
    what.C60.checked=true;
    what.C60.value=0;
    what.C60.disabled=true;
	what.SELECT60.disabled=true;
    getElementEcrit('SELECT60_value','inclus');
	what.SELECT60.selectedIndex=0;
	
    what.C25.checked=true;
    getElementEcrit('tc25','inclus');
    what.C25.disabled=true;
    what.C25.value=0;

    what.C38.checked=true;
    getElementEcrit('tc38','inclus');
    what.C38.disabled=true;
    what.C38.value=0;

    what.C67.checked=true;
    getElementEcrit('tc67','inclus');
    what.C67.disabled=true;
    what.C67.value=0;

    what.C68.checked=true;
    getElementEcrit('tc68','inclus');
    what.C68.disabled=true;
    what.C68.value=0;

    what.C69.checked=true;
    getElementEcrit('tc69','inclus');
    what.C69.disabled=true;
    what.C69.value=0;

    what.C9.checked=true;
    getElementEcrit('tc9','inclus');
    what.C9.disabled=true;
    what.C9.value=0;
}else{
    what.C28.checked=true;
    getElementEcrit('tc28','7,00 £');
    what.C28.disabled=false;
    what.C28.value=7;

    what.C60.disabled=false;
    what.C60.value=49;
	what.SELECT60.disabled=false;
    getElementEcrit('SELECT60_value','49,00 £');
	what.SELECT60.selectedIndex=0;

    what.C25.checked=true;
    getElementEcrit('tc25','10,00 £');
    what.C25.disabled=false;
    what.C25.value=10;

    what.C38.checked=true;
    getElementEcrit('tc38','19,00 £');
    what.C38.disabled=false;
    what.C38.value=19;

    what.C67.checked=true;
    getElementEcrit('tc67','290,00 £');
    what.C67.disabled=false;
    what.C67.value=490;

    what.C68.checked=true;
    getElementEcrit('tc68','9,00 £');
    what.C68.disabled=false;
    what.C68.value=9;

	what.C69.checked=true;
    getElementEcrit('tc69','72,00 £');
    what.C69.disabled=false;
    what.C69.value=72;

	if (what.elements['C67'].checked){
		what.C9.checked=true;
		getElementEcrit('tc9','inclus');
		what.C9.disabled=true;
		what.C9.value=0;
	}else{
		what.C9.checked=true;
		getElementEcrit('tc9','120,00 $');
		what.C9.disabled=false;
		what.C9.value=120;
	}
}
}

function calculate(what) {
        what.answer.value =0;
		var answer=0;
		var answerttc=0;

 		for (var i=0,answer=0;i<=70;i++){
            if(what.elements['C' + i]!=null && what.elements['C' + i].checked){
                answer+=what.elements['C' + i].value-0;
                //alert(i);
            }
        }
        
/*        var correspChkbx;
		for (var i=0;i<4;i++){
			selIndex = eval('what.SELECT'+i+'.selectedIndex');			
			selIndexMin = eval('what.SELECT'+i+'[what.SELECT'+i+'.selectedIndex].value');			
			selIndexTxt = eval('what.SELECT'+i+'[what.SELECT'+i+'.selectedIndex].text');
			eval('what.SELECT'+i+'_hidden.value="'+selIndexTxt+'";');
			var checkBoxToCheck = eval('what.SELECT'+i+'_hiddenCorrespondingCheckbox.value');
			checkBoxState = eval('what.'+checkBoxToCheck+'.checked');
        }
*/
        var numberTest = new NumberFormat(answer);
		numberTest.setInputDecimal('.');
		numberTest.setSeparators(true, '.', ',');		
		numberTest.setPlaces(2);
        what.answer.value = numberTest.toFormatted();
		answerttc=answer*1.175;
        var numberTest2 = new NumberFormat(answerttc);
		numberTest2.setInputDecimal('.');
		numberTest2.setSeparators(true, '.', ',');		
		numberTest2.setPlaces(2);
		getElementEcrit('answerttc',numberTest2.toFormatted());
}

function getNumberFormated(aValue) {
		aValue = aValue - 0;
		var numberTest = new NumberFormat(aValue);
		numberTest.setInputDecimal('.');
		numberTest.setSeparators(true, '.', ',');		
		numberTest.setPlaces(2);
		
		return numberTest.toFormatted();
}

var radioCheck = new radioButton("offerForm");

function formShowSubmit() {
formObj = document.forms.offerForm;
var responseOk = true;
	        
	        var correspChkbx;
			for (var i=0;i<4;i++){
				selIndex = formObj.elements['SELECT'+i].selectedIndex;			
				selIndexVal = formObj.elements['SELECT'+i][formObj.elements['SELECT'+i].selectedIndex].value;			
				selIndexTxt = formObj.elements['SELECT'+i][formObj.elements['SELECT'+i].selectedIndex].text;				
				var checkBoxToCheck = formObj.elements['SELECT'+i+'_hiddenCorrespondingCheckbox'].value;
				checkBoxState = formObj.elements[checkBoxToCheck].checked;
				
				if (checkBoxState==true && selIndex==0) {
					responseOk = false;
					alert("Choisir une place pour votre domiciliation ou décochez la case !");
					return false;
				}
				
	        }
			return responseOk;
}

function formCheckGlobal() {
formObj = document.forms.offerForm;
if (formShowSubmit()) {
return ValidateAll(formObj);
}
}
