var bundle_price = new Array();
var bundle_tax = new Array();
var bundle_name = new Array();
var bundle_images = new Array();
var bundle_pc_to_group = new Array();
var base_tax = "";
var base_price = "";
var bundle_image_group = "";
var add_price = 0;
var price = new Object();

function round_price(price){
    if (price == 0) return '0,00';
    var decimal_places = 2;
    var tmp_value = price;
    tmp_value = (tmp_value*100);
    tmp_value =  Math.round(tmp_value);
    tmp_value = tmp_value.toString()
    tmp_value_pre = tmp_value.substring(0,tmp_value.length-decimal_places);
    tmp_value_dez = tmp_value.substr(tmp_value.length-decimal_places,decimal_places);
    return tmp_value = tmp_value_pre + ',' + tmp_value_dez;
}

function calculateBundle(checkedID, thisObject) {

    var tax = base_tax;
    if (checkedID == null){
        jQuery('#bundleInfoContainer').html('');
        jQuery(".selectRow").removeClass("selectRow");
        jQuery(".ac_content input[type=radio]:checked").each(function(i, n) {
                var pc_id = jQuery(this).attr('value');
                var pc_group_id = bundle_pc_to_group[pc_id];
                jQuery(this).parent().parent().addClass('selectRow');

                price[pc_group_id] = bundle_price[pc_id];

                var pname = jQuery('#bundle_name_'+pc_id).html();
                var pgroupname = jQuery('#groupName_'+pc_group_id).html();
                var pdesc = jQuery('#pdesc_'+pc_id).html();
                if (pdesc == null) {
                	pdesc="";
                }

                jQuery("#selection_"+pc_group_id).html(pname);
        });
        jQuery("#bundleInfoContainer div").removeClass("hide");
    } else if (checkedID == 'noselect'){ 

		objdrueber = $(thisObject).parent().parent();
		objBez = $(".name",objdrueber).attr('id');
		getPCId = objBez.split('bundle_name_');
		
		var pc_id = getPCId[1];

		jQuery(".selectRow").removeClass("selectRow");
			
		productText = $(thisObject).attr('name');
		getGroupId = productText.split('products_info[pc_id_');
		get2GroupId = getGroupId[1].split(']');
			
		var pc_group_id = get2GroupId[0];
		jQuery(this).parent().parent().addClass('selectRow');
			
		pdesc = "";
		pname = jQuery("#bundle_name_"+pc_id).html();
			
		jQuery("#selection_"+pc_group_id).html(pname);
		
		price[pc_group_id] = 0;
	
    } else {
        
        var pc_id = checkedID;
        var pc_group_id = bundle_pc_to_group[pc_id];
        jQuery('#acContent'+ pc_group_id +' .selectRow').removeClass("selectRow");
        jQuery('#tableRow_'+pc_id).addClass('selectRow');
        
        price[pc_group_id] = bundle_price[pc_id];
        
        var pname = jQuery('#bundle_name_'+pc_id).html();
        jQuery('#bundleInfoGroup'+ pc_group_id).html('<h1 class="head2">'+pname+'</h1>' + jQuery('#pdesc_'+pc_id).html());
        jQuery("#selection_"+pc_group_id).html(pname);
    }

	add_price = 0;
	jQuery.each(price,function(priceGroupId) {
		add_price += price[priceGroupId];
	});

    if (add_price != 0) {
        jQuery('#calculate_box').removeClass('hide');
    } else {
        jQuery('#calculate_box').addClass('hide');
    }

    //jQuery('.bundleTax').html(formatPrice(tax));
    jQuery('.basePrice').html(formatPrice(base_price));

    if (add_price != 0) {
        jQuery('#bundlePrice').html(formatPrice(add_price));
        jQuery('.bundlePriceTotal').html(formatPrice(base_price + add_price));
    }
}

function displayInfo(id) {
}

