/**
 * Parses collection with delimiter
 * 
 * @param collection	Collection of HTML elements
 * @param delimiter		String delimiter to split the collection
 * @return	collectionString	Parsed collection String
 */
function CMParseCollection(collection, delimiter)
{
	var collectionString = "";
	for (var i=0; i<collection.length; i++)
	{
		collectionString += jQuery(collection[i]).text();
		if (collection.length != i + 1)
		{
			collectionString += delimiter;
		}
	}
	return collectionString;
}

/**
 * Formats any price string to required default Coremetrics price: "xx.xx"
 * @param str		Price string to parse
 * @return	str 	Parsed price string
 */
function CMPrice(str) {
	if (str) {
		str = str.replace(/[^0-9,.-]/g, '');
		if (str.indexOf(',') > -1) {
			if (str.indexOf('.') > -1) {
				intComaLastIndex = str.lastIndexOf(',');
				intDotLastIndex = str.lastIndexOf('.');
				if( intComaLastIndex > intDotLastIndex ) {
					str = str.replace(/\./g, '');
					str = str.replace(/,/g, '.');
				} else {
					str = str.replace(/,/g, '');
				}
			} else {
				str = str.replace(/,/g, '.');
			}
		}
	}
	return str;
}

