var Configurator = { 
	
	summary: 0,
	
	form: 'productsForm',
	
	prices: Array(),
	
	doMath: function( productListId, count ){
		var product = $('products[' + productListId + ']').value;
		var productData = product.split("|");
		var productQuantity = $('cart[' + productListId + ']').value;  
		var id = productData[0];
		var price = productData[1]; 
		var fullPrice = 0;
		
		if( id == 0 ) {
			productQuantity == 0;			
			$('cart[' + productListId + ']').value = "0"; 
			$('cart[' + productListId + ']').disabled = true;
		} else {                                             
			$('cart[' + productListId + ']').disabled = false;  
			if(productQuantity == 0){
				productQuantity = "1";
				$('cart[' + productListId + ']').value = 1; 				
			}
		} 
		  
		this.prices[productListId] = productQuantity * price;
		$('price[' + productListId + ']').innerHTML = this.numberFormat(this.prices[productListId].toFixed(2)); 
		$('cart_id[' + productListId + ']').value = id;
		
 
		this.prices.each(function(item, index) {
			if (item > 0)
				fullPrice += item;
		});
		
		$('fullPrice').innerHTML = this.numberFormat(fullPrice.toFixed(2));  
		
	},
	
	numberFormat: function(nStr, prefix){
	    var prefix = prefix || '';
	    nStr += '';
	    x = nStr.split('.');
	    x1 = x[0];
	    x2 = x.length > 1 ? ',' + x[1] : '';
	    var rgx = /(\d+)(\d{3})/;
	    while (rgx.test(x1))
	        x1 = x1.replace(rgx, '$1' + '.' + '$2');
	    return prefix + x1 + x2;
	}	
	
}


