/**
* Sumar Carrito Diego
*/
	
	
function SumarCarrito(){
	
	var booking_initial_fee = document.getElementById("hid_booking_initial_fee").value;
	var vat_percent = document.getElementById("hid_vat_percent").value;
	var vat_sum = 0;
	var order_price = document.getElementById("hid_order_price").value;
	var currency_symbol = document.getElementById("hid_currency_symbol").value;
	var extras_total_sum = 0;
	var cart_total_sum = 0;
	
		extras_total_sum = 0;
	
	vat_sum = parseFloat((parseFloat(order_price) + parseFloat(booking_initial_fee) + parseFloat(extras_total_sum)) * parseFloat(vat_percent / 100));
	cart_total_sum = parseFloat((parseFloat(order_price) + parseFloat(booking_initial_fee) + parseFloat(extras_total_sum)) + parseFloat(vat_sum));
	
	document.getElementById("reservation_vat").innerHTML = currency_symbol+appSetDecimalPoint(vat_sum.toFixed(2));
	document.getElementById("reservation_total").innerHTML = currency_symbol+appSetDecimalPoint(cart_total_sum.toFixed(2));
	//Diego
	document.getElementById("reservation_vat2").innerHTML = currency_symbol+appSetDecimalPoint(vat_sum.toFixed(2));
	document.getElementById("reservation_total2").innerHTML = currency_symbol+appSetDecimalPoint(cart_total_sum.toFixed(2));
	//Fin Diego
	
	// show effect on changed text
	jQuery("#reservation_vat").animate({opacity: 0.25}, 70).animate({opacity: 1}, 70);  
	jQuery("#reservation_total").animate({opacity: 0.25}, 70).animate({opacity: 1}, 70); 
	//Diego
	jQuery("#reservation_vat2").animate({opacity: 0.25}, 70).animate({opacity: 1}, 70);  
	jQuery("#reservation_total2").animate({opacity: 0.25}, 70).animate({opacity: 1}, 70); 
	//Diego 	
}


/**
 *   Set decimal point
 */	
function appSetDecimalPoint(num){
	var num_ = (num != null) ? num.toString() : "";
	var currency_format = document.getElementById("hid_currency_format").value;
	
	if(currency_format == 'european'){
		num_ = num_.replace(".", ",");
		return num_;
	}
	return num_;
}

/**
 *   Update total sum of shopping cart
 */	
function appUpdateTotalSum(ind, num, total_extras){
	arrExtrasSelected[ind] = num;
	
	var booking_initial_fee = document.getElementById("hid_booking_initial_fee").value;
	var vat_percent = document.getElementById("hid_vat_percent").value;
	var vat_sum = 0;
	var order_price = document.getElementById("hid_order_price").value;
	var currency_symbol = document.getElementById("hid_currency_symbol").value;
	var extras_total_sum = 0;
	var cart_total_sum = 0;
	
	for(i=0; i < total_extras; i++){
		extras_total_sum += (arrExtrasSelected[i] * arrExtras[i]);
	}
	
	vat_sum = parseFloat((parseFloat(order_price) + parseFloat(booking_initial_fee) + parseFloat(extras_total_sum)) * parseFloat(vat_percent / 100));
	cart_total_sum = parseFloat((parseFloat(order_price) + parseFloat(booking_initial_fee) + parseFloat(extras_total_sum)) + parseFloat(vat_sum));
	
	document.getElementById("reservation_vat").innerHTML = currency_symbol+appSetDecimalPoint(vat_sum.toFixed(2));
	document.getElementById("reservation_total").innerHTML = currency_symbol+appSetDecimalPoint(cart_total_sum.toFixed(2));
	//Diego
	document.getElementById("reservation_vat2").innerHTML = currency_symbol+appSetDecimalPoint(vat_sum.toFixed(2));
	document.getElementById("reservation_total2").innerHTML = currency_symbol+appSetDecimalPoint(cart_total_sum.toFixed(2));
	//Fin Diego
	
	// show effect on changed text
	jQuery("#reservation_vat").animate({opacity: 0.25}, 70).animate({opacity: 1}, 70);  
	jQuery("#reservation_total").animate({opacity: 0.25}, 70).animate({opacity: 1}, 70); 
	//Diego
	jQuery("#reservation_vat2").animate({opacity: 0.25}, 70).animate({opacity: 1}, 70);  
	jQuery("#reservation_total2").animate({opacity: 0.25}, 70).animate({opacity: 1}, 70); 
	
	//Diego 	
}

function agregarCajas(ind, num){
	if(ind == 0 && num >0){
		jQuery("#trca_1").show();
		jQuery("#trca_2").show();
		jQuery("#trca_3").show();
		jQuery("#trca_4").show();
		jQuery("#trca_5").show();
		jQuery("#trca_6").show();
	}else if(ind == 1 && num >0){
		jQuery("#trca_1").show();
		jQuery("#trca_2").show();
		jQuery("#trca_3").show();
		jQuery("#trca_4").show();
		jQuery("#trca_5").show();
		jQuery("#trca_6").show();
	}else{
		jQuery("#trca_1").hide();
		jQuery("#trca_2").hide();
		jQuery("#trca_3").hide();
		jQuery("#trca_4").hide();
		jQuery("#trca_5").hide();
		jQuery("#trca_6").hide();

	}
}
