url_tab_id = location.hash;

$(document).ready(function() 
{
	//bezny nakup - pridavanie poloziek
	$(".purchase .add_item").click(function(){addItem(this);return false});
	
	current_items_count = 0;
	current_purchase_count = 0;
	function addItem(elem)
	{
		var current_purchase = $(elem).parent().parent();
		current_items = current_purchase.find('.items');
		current_items_count++;
		purchase_order = current_purchase.find('[name=purchase_order]').val();

		$(elem).before(
			'<div>\n'+
				'<input type="text" class="item_name" name="shop['+purchase_order+'][items][]"  />\n'+
				'<input type="text" class="item_count" name="shop['+purchase_order+'][items_count][]" />\n'+
				'<img src="/layout/minus.png" alt="remove_item" class="remove_item" />\n'+
			'</div>\n'
		)
		
		$(".purchase .remove_item").unbind();
		$(".purchase .remove_item").click(function(){removeItem(this);return false});
		$(".purchase .remove_item").mouseover(function(){$(this).parent().css('background','#FFDFDF')});
		$(".purchase .remove_item").mouseout(function(){$(this).parent().css('background','none')});
	}
	
	$(".purchase .remove_item").click(function(){removeItem(this);return false});
	$(".purchase .remove_item").mouseover(function(){$(this).parent().css('background','#FFDFDF')});
	$(".purchase .remove_item").mouseout(function(){$(this).parent().css('background','none')});
	function removeItem(elem)
	{
		$(elem).parent().remove();
	}
	
	$(".add_purchase").click(function(){addPurchase();return false})
	function addPurchase(elem)
	{
		current_purchase_count++;
		
		
		$('#purchases').append(
			'<tr class="purchase">'+
			'<td>'+
				'<input type="hidden" name="purchase_order" value="'+current_purchase_count+'" />\n'+
				'<input type="text" name="shop['+current_purchase_count+'][name]"  />\n'+
				'<img src="/layout/minus.png" alt="remove_purchase" class="remove_purchase" />\n'+
			'</td>\n'+
			'<td>\n'+
				'<input type="text" name="shop['+current_purchase_count+'][pay_number]"  />\n'+
			'</td>\n'+
			'<td class="items" colspan="2">\n'+
				'<div>\n'+
					'<input type="text" class="item_name" name="shop['+current_purchase_count+'][items][]" />\n'+
					'<input class="item_count" type="text" name="shop['+current_purchase_count+'][items_count][]" />\n'+
					'<img src="/layout/minus.png" alt="remove_item" class="remove_item" />\n'+
				'</div>\n'+
				'<img src="/layout/plus.png" alt="add item" class="add_item" />\n'+
			'</td>\n'+
			'</tr>\n'
		)
		
		$(".purchase .add_item").unbind();
		$(".purchase .remove_purchase").unbind();
		$(".purchase .remove_item").unbind();
		
		$(".purchase .add_item").click(function(){addItem(this);return false});
		$(".purchase .remove_purchase").click(function(){removePurchase(this);return false});
		$(".purchase .remove_item").click(function(){removeItem(this);return false});
		$(".purchase .remove_item").mouseover(function(){$(this).parent().css('background','#FFDFDF')});
		$(".purchase .remove_item").mouseout(function(){$(this).parent().css('background','none')});
		$(".purchase .remove_purchase").mouseover(function(){$(this).parent().parent().css('background','#FFDFDF')});
		$(".purchase .remove_purchase").mouseout(function(){$(this).parent().parent().css('background','none')});
		
		//este musim zvysit pocet poloziek
		current_items_count = parseInt($("#items_count").val());
		if (isNaN(current_items_count)) 
		{
			current_items_count = 0;
		}

		$("#items_count").val(++current_items_count);
		countPrice();
	}
	
	$(".purchase .remove_purchase").click(function(){removePurchase(this);return false});
	$(".purchase .remove_purchase").mouseover(function(){$(this).parent().parent().css('background','#FFDFDF')});
	$(".purchase .remove_purchase").mouseout(function(){$(this).parent().parent().css('background','none')});
	function removePurchase(elem)
	{
		$(elem).parent().parent().remove();
		//este musim znizit pocet poloziek
		current_items_count = parseInt($("#items_count").val());
		if (isNaN(current_items_count)) 
		{
			current_items_count = 0;
		}

		$("#items_count").val(--current_items_count);
		countPrice();
	}
	

	function getWeightPrice(weight)
	{
		if(0 == weight)
		{
			price = 0;
		}
		
		if(0 < weight && weight <= 5)
		{
			price = 15;
		}
		
		if(5 < weight && weight <= 10)
		{
			price = 20;
		}

		if(10 < weight && weight <= 15)
		{
			price = 25;
		}
		
		if(15 < weight && weight <= 20)
		{
			price = 30;
		}
		
		if(20 < weight && weight <= 30)
		{
			price = 45;
		}
		
		if(30 < weight && weight <= 50)
		{
			price = 70;
		}
		
		if(50 < weight && weight <= 75)
		{
			price = 100;
		}
		
		if(75 < weight && weight <= 100)
		{
			price = 125;
		}
		
		if(100 < weight)
		{
			price = 125;
		}
		
		return price;
	}
	
	$("#weight").keyup(function(){countPrice();})
	$("#items_count").keyup(function(){countPrice();})
	
	function countPrice()
	{
		weight = parseInt($("#weight").val());
		items_count = parseInt($("#items_count").val());
		
		vat = parseFloat($("#vat").val());
		collecting_charge = parseInt($("#collecting_charge").val());
		handling = parseInt($("#handling").val());
		
		$('#test').val('12');
		
		if(1 < items_count)
		{
			collecting = items_count*collecting_charge;
		}
		else
		{
			collecting = 0;
		}
		
		if(isNaN(weight))
		{
			weight = 0;
		}

		
		$("#price").val(getWeightPrice(weight));
		
		//cena objendavky podla poctu kilogramov
		weight_price = getWeightPrice(weight);
		updatet_items_price = parseFloat(roundNumber(weight_price*vat,2)+roundNumber(collecting*vat,2)+handling*vat);

		//$('#collecting').text(roundNumber(collecting,2)+' x 1.15 = '+roundNumber(collecting*1.15,2));
		
		//shipping
		$('#sending_price').text(roundNumber(weight_price,2));
		$('#vatfree_sending_price').text(roundNumber(weight_price,2));
		$('#vat_sending').text(roundNumber((parseFloat(weight_price*(vat-1))),2));
		$('#vat_sending_price').text(roundNumber(weight_price*vat,2));
		
		//collecting
		$('#collecting_count').text(items_count);
		$('#vatfree_collecting_price').text(collecting);
		$('#vat_collecting').text(roundNumber((parseFloat(collecting*(vat-1))),2));
		$('#vat_collecting_price').text(roundNumber(collecting*vat,2));
		
		//total
		vat_free_total = roundNumber(parseFloat(collecting + handling + weight_price),2);
		$('#vatfree_total_price').text(vat_free_total);
		$('#vat_total').text(roundNumber(vat_free_total*(vat-1),2));
		$('#vat_total_price').text(roundNumber(vat_free_total*vat,2));
		

		var pay_charge = $("#payment input:radio[name=payment_method]:checked").val();
		countPayCharge(pay_charge);
		
		
		
		
  	}
	
	$("#discount_points").keyup(function(){countFinalPrice();})
	function countFinalPrice()
	{
		discount = parseFloat($("#discount_points").val());
		if (isNaN(discount)) 
		{
			discount = 0;
		}
		raw_price = parseFloat($("#raw_price").text());
		final_price = raw_price - discount;

		$("#final_price").text(roundNumber(final_price,2));
		//$("#purchase_price").val(final_price);
		
		paypal_charge = final_price*0.039;
		pay_price = final_price+(final_price*0.039);
		$("#paypal_price").text(roundNumber(pay_price,2)+' GBP');
		
	}
	
	
	$('#post_invoice').click(function(){setPostAddress();});
	function setPostAddress()
	{
		$('#post_first_name').val($('#first_name').val());
		$('#post_last_name').val($('#last_name').val());
		$('#post_business_name').val($('#business_name').val());
    $('#post_street').val($('#street').val());
		$('#post_street_num').val($('#street_num').val());
		$('#post_city').val($('#city').val());
		$('#post_zip').val($('#zip').val());
		$('#post_country').val($('#country').val());
	}
  	
	$("#add_comfy_item").click(function(){addComfyItem();})
	
	function addComfyItem()
	{
		new_comfy_item = 	'<div><label>Popis položky</label>'+
						 	'<textarea name="item[]"></textarea>'+
						 	'<label>Url adresa (linka) položky:</label>'+
		 	                '<input class="item_url" type="text" name="url[]" />'+
						 	'<label>Cena</label>'+
						 	'<input type="text"  name="price[]"  class="item_price" />'+
							'<label>Približná hmotnosť</label>'+
		 					'<input type="text"  name="weight[]" class="weight" /></div>';
							
		$('#items').append(new_comfy_item);
		$("#items .weight").unbind();
		$("#items .item_price").unbind();
		$("#items .weight").keyup(function(){countComfyPrice(this);});
		$("#items .item_price").keyup(function(){countComfyPrice(this);});
	}
	
	$("#items .weight").keyup(function(){countComfyPrice(this);})
	$("#items .item_price").keyup(function(){countComfyPrice(this);})
	
	
	function countComfyPrice(elem)
	{
		vat = parseFloat($("#vat").val());
		collecting_charge = parseInt($("#collecting_charge").val());
		handling = parseInt($("#handling").val());
		
		weights = $('#items .weight');
		items_prices = $('#items .item_price');
		
		total_weight = 0;
		total_item_prices = 0;
		for(i = 0; i<weights.length;i++)
	    {
			curr_weight = parseFloat($(weights.get(i)).val().replace(',','.'));
			curr_price = parseFloat($(items_prices.get(i)).val().replace(',','.'));
			
			if(isNaN(curr_weight))
		    {
		        curr_weight = 0;
		    }
			
			if(isNaN(curr_price))
		    {
		        curr_price = 0;
		    }
			
			
			
			total_weight += curr_weight;
			total_item_prices += curr_price;
			//updatet_items_price += getWeightPrice(weight);
			//alert(weight);
	    }
		
		if(1 < weights.length)
		{
			collecting = weights.length*collecting_charge;
			var items_count = weights.length;
		}
		else
		{
			collecting = 0;
			var items_count = 0;
		}
		
		weight_price = getWeightPrice(total_weight);
		
		//items
		$('#items_count').text(weights.length);
		$('#vatfree_items_price').text(roundNumber(total_item_prices,2));

		//$('#vat_items').text(roundNumber((parseFloat(total_item_prices*(vat-1))),2));
		$('#vat_items').text('-');
		//$('#vat_items_price').text(roundNumber(total_item_prices*vat,2));
		$('#vat_items_price').text(roundNumber(total_item_prices,2));

		//shipping
		$('#sending_text').text('Doručenie ('+total_weight+' kg)');
		$('#sending_price').text(roundNumber(weight_price,2));
		$('#vatfree_sending_price').text(roundNumber(weight_price,2));
		$('#vat_sending').text(roundNumber((parseFloat(weight_price*(vat-1))),2));
		$('#vat_sending_price').text(roundNumber(weight_price*vat,2));
		
		//collecting
		$('#collecting_count').text(items_count);
		$('#vatfree_collecting_price').text(collecting);
		$('#vat_collecting').text(roundNumber((parseFloat(collecting*(vat-1))),2));
		$('#vat_collecting_price').text(roundNumber(collecting*vat,2));
		
		//total
		vat_free_total = roundNumber(parseFloat(collecting + handling + weight_price+total_item_prices),2);
		vat_base =  roundNumber(parseFloat(collecting + handling + weight_price),2);
		$('#vatfree_total_price').text(vat_free_total);
		$('#vat_total').text(roundNumber(vat_base*(vat-1),2));
		$('#vat_total_price').text(roundNumber(vat_base*vat,2)+total_item_prices);
		
		/*
		vat_free_total = roundNumber(parseFloat(collecting + handling + weight_price+total_item_prices),2);
		$('#vatfree_total_price').text(vat_free_total);
		$('#vat_total').text(roundNumber(vat_free_total*(vat-1),2));
		$('#vat_total_price').text(roundNumber(vat_free_total*vat,2));
		*/

		var pay_charge = $("#payment input:radio[name=payment_method]:checked").val();
		countPayCharge(pay_charge);
	}
	
	$("#payment input").click(function(){countPayCharge($("#payment input:radio[name=payment_method]:checked").val());})
	
	function countPayCharge(pay_type)
	{
		//pay_type = $(elem).val();
		//vat_price = parseFloat($('#vat_price').text());
		var vat_price = parseFloat($('#vat_total_price').text());
		var pay_price = vat_price;
		
		if('paypal' == pay_type)
		{
			paypal_charge = vat_price*0.039;
			pay_price = vat_price+(vat_price*0.039);
			$("#pay_charge_name").text('Poplatok za platbu(3.9%):');
			$("#pay_charge").text(roundNumber(paypal_charge,2));
			
			//$("#pay_charge").text('+ 3.9% = '+roundNumber(pay_price,2)+'GBP' );
		}
		
		if('cardpay' == pay_type)
		{
			$("#pay_charge_name").text('Poplatok za platbu(0%):');
			$("#pay_charge").text('0');
		}
		
		if('account' == pay_type)
		{
			$("#pay_charge_name").text('Poplatok za platbu(0%):');
			$("#pay_charge").text('0');
		}
		
		$('#pay_price').text(roundNumber(pay_price,2));
	}
	
	$("#accounts .radio").click(function(){selectAccount(this);})
	
	function selectAccount(elem)
	{
        $('#selected_account').html( $(elem).parent().parent().html());
        $('#selected_account').find('.radio').parent().remove();
    }
	
	function roundNumber(num, dec) 
	{
		var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
		return result;
	}
	
	$("#print").click(function(){print(this);return false;})
	function print(elem)
	{
		url = $(elem).attr('href');
		window.open(url,'_blank','width=620, height=1000, scrollbars=yes')
	}
	
	$('.transfer_start').change(function(){selectDestination(this);})
	
/*
 * L E T E N K Y
 */
$('#purchase_flight_choice').click(function()
{
	window.open('http://letenky.nakupy.co.uk','_blank');
})
	
	
/*
 * T R A N S F E R
 */
	
	function selectDestination(elem)
	{
		start_dest = $(elem).val();
		var transfer_finish_select = $(elem).parent().find('.transfer_finish_select');
		transfer_finish_select.html('Načítava sa zoznam lokalít. Čakajte prosím.');
		
		$.ajax({
				   type: "POST",
				   url: "/shop/ajax/transfer-target",
				   data: {'id':start_dest},
				   success: function(msg)
				   {
						transfer_finish_select.html(msg);
						$('.transfer_finish').unbind();
						$('.transfer_finish').change(function(){selectPrice(this);});
				   }
			   });	
	}
	
	function selectPrice(elem)
	{
		finish_dest = $(elem).val();
		var transfer_price = $(elem).parent().parent().find('.transfer_price');
		transfer_price.html('Načítava sa cena. Čakajte prosím.');
		
		$.ajax({
				   type: "POST",
				   url: "/shop/ajax/transfer-price",
				   data: {'id':finish_dest,'person_count':$('.transfer_person_count').val()},
				   success: function(msg)
				   {
						transfer_price.html(msg);
						updateTransferPrice();
				   }
			   });	
	}
	
	//$('.transfer_person_count').keyup(function(){updateTransferPrice();return false;})
	
	$('.transfer_person_count').keyup(function(){ updatePersonCount(this);return false;})
	
	function updatePersonCount(elem)
	{
		finish_dest = $(elem).parent().parent().find('.transfer_finish').val();
		
		var transfer_price = $(elem).parent().parent().find('.transfer_price');
		transfer_price.html('Načítava sa cena. Čakajte prosím.');
		var person_count = $(elem).val();
		
		$.ajax({
				   type: "POST",
				   url: "/shop/ajax/transfer-price",
				   data: {'id':finish_dest,'person_count':person_count},
				   success: function(msg)
				   {
						transfer_price.html(msg);
						updateTransferPrice();
				   }
			   });	
	}
	
	function updateTransferPrice()
	{
		var prices = $('#transfer_block .transfer_price');
		//var persons = $('#transfer_block .transfer_person_count');
		//alert(prices.length);
		var total_transfer_price = 0;
		for(i = 0; i<prices.length;i++)
	    {
			curr_price = parseInt($(prices.get(i)).text());
			//curr_persons = parseInt($(persons.get(i)).val());
			
			if(isNaN(curr_price))
		    {
		        curr_price = 0;
		    }
			
			/*
			if(isNaN(curr_persons))
		    {
		        curr_persons = 0;
		    }
		    */
			//alert(curr_price);
			//total_transfer_price += curr_price*curr_persons;
			total_transfer_price += curr_price;
	    }
		
		//alert(total_transfer_price);
		$('#transfer_total_price').text(total_transfer_price);
		$('#transfer_total_price_val').val(total_transfer_price);
		
		vat = $('#vat').val();
		vat_free_total = total_transfer_price;
		$('#tr_count').html(prices.length);
		$('#tr_unit_price').html();
		$('#tr_price').html(vat_free_total);
		
		/*
		$('#tr_vat').text(roundNumber(vat_free_total*(vat-1),2));
		$('#tr_vat_price').text(roundNumber(vat_free_total*vat,2));
		*/
		$('#tr_vat').text('-');
		$('#tr_vat_price').text(roundNumber(vat_free_total,2));
		
		updateTotalPrice();
	}
	
	
	$(".transfer_unit .transfer_date").datepicker({ 
    showOn: "both", 
    buttonImage: "/system/images/calendar.png", 
    buttonImageOnly: true 
	}); 
	
	$('#add_transfer_unit').click(function(){addTransfer();return false;})
	$('.remove_transfer_unit').click(function(){removeTransfer(this);return false;})
	function addTransfer()
	{
		//remove_transfer = '<a href="" class="remove_transfer_unit">- Odstrániť transfer</a>';
		new_transfer = '<div class="transfer_unit">'+$('#transfer_template').html()+'</div>';
		$('#add_transfer_unit').before(new_transfer);
		
		$('.transfer_start').unbind();
		$('.transfer_date').datepicker('destroy');
		
		$('.transfer_start').change(function(){selectDestination(this);})
		
		date_selectors = $('.transfer_date');
		for(i = 0; i<date_selectors.length;i++)
	    {
			$(date_selectors.get(i)).attr('id','transfer_date_'+i);
			
			$(date_selectors.get(i)).datepicker({ 
		    showOn: "both", 
		    buttonImage: "/system/images/calendar.png", 
		    buttonImageOnly: true 
			}); 
	    }
		
		$('.remove_transfer_unit').unbind();
		$('.transfer_person_count').unbind();
		$('.transfer_person_count').unbind();
		
		$('.transfer_person_count').keyup(function(){updateTransferPrice();return false;})
		$('.remove_transfer_unit').click(function(){removeTransfer(this);return false;})
		
		//$('.transfer_person_count').keyup(function(){ selectPrice($(this).parent().find('.transfer_finish'));return false;})
		$('.transfer_person_count').keyup(function(){ updatePersonCount(this);return false;})
	}
	
	function removeTransfer(elem)
	{
		$(elem).parent().remove();
		updateTransferPrice();
	}
	
/*
 * U B Y T O V A N I E
 */
	$("#accommodation_date").datepicker({ 
	    showOn: "both", 
	    buttonImage: "/system/images/calendar.png", 
	    buttonImageOnly: true 
		}); 
		
	$('#accommodation_level').change(function(){updateAccommodationPrice();})
	$('#accommodation_nights').keyup(function(){updateAccommodationPrice();})
	$('#accommodation_person_count').keyup(function(){updateAccommodationPrice();})
	$('#accommodation_rooms').change(function(){updateAccommodationPrice();})
	
	function updateAccommodationPrice(elem)
	{
		prices = [	[50,75,100,125,25],
					[55,85,105,135,25],
					[65,95,110,145,25]];
					
		level = $('#accommodation_level option:selected').val() - 2;
		nights = $('#accommodation_nights').val();if(null == nights) {nights = 1}
		person_count = $('#accommodation_person_count').val();if(null == person_count) {person_count = 1}
		rooms = $('#accommodation_rooms option:selected').val();
		
		$.ajax({
				   type: "POST",
				   url: "/shop/ajax/accommodation-price",
				   data: {'level':level,'rooms':rooms},
				   success: function(msg)
				   {
						total_price = parseFloat(msg)*nights*person_count;
						$('#accommodation_price').text(total_price);
						$('#accommodation_total_price').val(total_price);
						
						//este uprava predbezneho vypoctu
						vat = $('#vat').val();
						vat_free_total = parseFloat(msg)*nights*person_count;
						$('#acc_count').html(person_count);
						$('#acc_unit_price').html(parseFloat(msg)*nights);
						$('#acc_price').html(vat_free_total);
						
						/*$('#acc_vat').text(roundNumber(vat_free_total*(vat-1),2));
						$('#acc_vat_price').text(roundNumber(vat_free_total*vat,2));*/
						
						$('#acc_vat').text('-');
						$('#acc_vat_price').text(roundNumber(vat_free_total,2));
						
						updateTotalPrice();
				   }
			   });	

		//total_price = prices[level][rooms-1]*nights*person_count;
		
		
	}

/*V S T U P E N K Y*/
	$('#tickets li .radio').click(function() {updateTicketPrice()})
	
	function updateTicketPrice()
	{
		total_ticket_price = 0;
		ticket_prices = $('#tickets li input.radio:checked');
		for(i = 0; i<ticket_prices.length;i++)
	    {
			curr_price = parseInt($(ticket_prices.get(i)).val());

			if(isNaN(curr_price))
		    {
		        curr_price = 0;
		    }

			total_ticket_price += curr_price;
	    }

		$('#ticket_price').text(total_ticket_price);
		$('#ticket_total_price').val(total_ticket_price);
		
		//este uprava predbezneho vypoctu
		vat = $('#vat').val();
		vat_free_total = total_ticket_price;
		$('#tc_count').html(ticket_prices.length);
		$('#tc_price').html(vat_free_total);
		
		/*
		$('#tc_vat').text(roundNumber(vat_free_total*(vat-1),2));
		$('#tc_vat_price').text(roundNumber(vat_free_total*vat,2));
		*/
		$('#tc_vat').text('-');
		$('#tc_vat_price').text(roundNumber(vat_free_total,2));
		
		updateTotalPrice();
	}
	
	$('.personal_tab a').click(function(){showPersonalTab(this);return false;});
	$('#personal_teaser a').click(function(){showTeaserTab(this);return false;});
	$('#all_tabs').click(function(){showAllTabs();return false;});
	
	
	//zobrazovanie tabu podla url
	
	function urlTab(tab_id)
	{
		if('' != tab_id)
		{
			next_block_id = tab_id+'_block';
			$('#personal_teaser').hide();
			$('#info_calc_invoice').show();
			
			//najprv musim schovat akutualny
			$('.personal_tab a').attr('class','');
			hideAllTabs();
	
			//a teraz ukazat novy
			$(tab_id).attr('class','active_tab');
			$(next_block_id).show();
			current_tab = tab_id;
		}
	}
	urlTab(url_tab_id);
	
	
	$('.personal-next').click(function(){
		next_tab_id = '#'+$(this).attr('rel');
		next_block_id = next_tab_id+'_block';
		
		if('#all' == next_tab_id)
		{
			showAllTabs();
		}
		else
		{

			$('#personal_teaser').hide();
			$('#info_calc_invoice').show();
			
			//najprv musim schovat akutualny
			/*$('#'+current_tab).attr('class','');*/
			$('.personal_tab a').attr('class','');
			hideAllTabs();
	
			//a teraz ukazat novy
			$(next_tab_id).attr('class','active_tab');
			$(next_block_id).show();
			
			current_tab = next_tab_id;
		}
		return false;
	});
	
	var current_tab = 'transfer';
	function showPersonalTab(elem)
	{
		$('#personal_teaser').hide();
		$('#info_calc_invoice').show();
		block_id = '#'+$(elem).attr('id')+'_block';
		
		//najprv musim schovat akutualny
		$('#'+current_tab).attr('class','');
		//$('#'+current_tab+'_block').hide();
		hideAllTabs();

		//a teraz ukazat novy
		$(elem).attr('class','active_tab');
		$(block_id).show();
		
		current_tab = $(elem).attr('id');
	}

	
	
	function showTeaserTab(elem)
	{
		
		block_id = '#'+$(elem).attr('class')+'_block';
		
		$('#personal_teaser').hide();

		//a teraz ukazat novy
		$('.personal_tab').find('#'+$(elem).attr('class')).attr('class','active_tab');
		//$(elem).attr('class','active_tab');
		$(block_id).show();
		$('#info_calc_invoice').show();
		
		current_tab = $(elem).attr('class');
	}
	
	function updateTotalPrice()
	{
		var accommodation_total_price = parseInt($('#accommodation_total_price').val());
		var transfer_total_price_val = parseInt($('#transfer_total_price_val').val());
		var ticket_total_price = parseInt($('#ticket_total_price').val());
		vat = $('#vat').val();
		
		if (isNaN(accommodation_total_price)) 
		{
			accommodation_total_price = 0;
		}
		
		if (isNaN(transfer_total_price_val)) 
		{
			transfer_total_price_val = 0;
		}
		
		if (isNaN(ticket_total_price)) 
		{
			ticket_total_price = 0;
		}
		
		var total_personal_price = parseInt(accommodation_total_price + transfer_total_price_val + ticket_total_price);
		
		//$('#total_personal_price').html('Celková cena objednávky:'+total_personal_price+'&euro;');
		$('#vat_total_price').html(roundNumber(total_personal_price,2));
	}
	
	function showAllTabs()
	{
		$('#personal_teaser').hide();
		$('#info_calc_invoice').show();
		
		/*
		$('#transfer_block').show();
		$('#accomodation_block').show();
		$('#delivery_block').show();
		$('#ticket_block').show();
		$('#flight_block').show();
		*/
		//$('#personal_submit').show();
		
		$('#transfer_block').hide();
		$('#accomodation_block').hide();
		$('#delivery_block').hide();
		$('#ticket_block').hide();
		$('#flight_block').hide();
		
		updateTotalPrice();
		//$('#total_personal_price').show();
		$('#purchase_personal_sum').show();
		
	}
	
	
	function hideAllTabs()
	{
		$('#transfer_block').hide();
		$('#accomodation_block').hide();
		$('#delivery_block').hide();
		$('#ticket_block').hide();
		$('#flight_block').hide();
		
		$('#purchase_personal_sum').hide();
	}
	
	$('#personal_payment')
	$("#personal_payment input").click(function(){countPayPersonalCharge($("#payment input:radio[name=payment_method]:checked").val());})
	
	$('#tickets strong').click(function(){
		$('#tickets .active').slideUp(300);
		$('#tickets .active').attr('class','ticket_desc');
		
		
		$(this).parent().find('.ticket_desc').slideDown(300);
		$(this).parent().find('.ticket_desc').attr('class','active');
		
	})
	
	
	
	//var pay_charge = $("#payment input:radio[name=payment_method]:checked").val();
	//countPayCharge(pay_charge);
	
});

