$(function(){
	$(".CheckBoxClass").each(function(){
		if($(this).is(":checked")){
			$(this).next("label").addClass("LabelSelected");
		}else{
			$(this).next("label").removeClass("LabelSelected");
		}
	}).change(function(){
		if($(this).is(":checked")){
			$(this).next("label").addClass("LabelSelected");
		}else{
			$(this).next("label").removeClass("LabelSelected");
		}
	});
	$(".RadioClass").each(function(){
		if($(this).attr("checked")){
			$(".RadioSelected:not(:checked)").removeClass("RadioSelected");
			$(this).next("label").addClass("RadioSelected");
		}
	}).change(function(){
		if($(this).attr("checked")){
			$(".RadioSelected:not(:checked)").removeClass("RadioSelected");
			$(this).next("label").addClass("RadioSelected");
		}
	});
	
	/*
	$('#form_additionalData div.checkbox').click(function(){
		var parentId = $(this).attr('id').replace('_checkbox','');
		$('#'+parentId).click();
	});
	*/
	
	// Zakładki w sekcji FRIENDS
	var friend_section_current_id = null;
	var friend_section_previous_id = null;
	$('.section_friend_box a').click(function(){
		
		if(friend_section_current_id == null)
			friend_section_previous_id = friend_section_current_id = $('.section_friend_box a:first').attr('id');
		else friend_section_previous_id = friend_section_current_id;
		
		if(friend_section_current_id == $(this).attr('id')) return false;
		friend_section_current_id = $(this).attr('id');
		
		$('.section_friend_box a').removeClass('_current');
		var target = $(this).attr('id')+'-text';
		$(this).addClass('_current');
			
		// Wersja prosta
		/*	 
		$('#'+friend_section_previous_id+'-text').hide();
		$('#'+target).show();
		*/
		
		// Wersja fadowalna
		/*
		$('#'+friend_section_previous_id+'-text').fadeOut('fast', function(){
			$('#'+target).fadeIn('fast');
		});
		*/
		
		// Wersja anomowalna
		$('#'+friend_section_previous_id+'-text').animate({
			top: '-430px'
		}, 'slow',function(){$(this).hide().css('top','430px')});
			$('#'+target).show().animate({
				top: 0
			}, 'slow');
		
		return false;
	});
	
	/* DATE PICKER */
	$("#groupBookingForm .choose_date").datepicker({
		minDate: -1,
		showOn: 'button',
		buttonImage: 'css/gfx/layout/start/group_booking_box/choose_date.png',
		buttonImageOnly: true
	});
	
	/* WYBÓR Z "rozwijalnej" LISTY */
	$('#groupBookingForm ul.select_list a').click(function(){
		$(this).parents('ul.select_list').siblings('.text').val($(this).text());
		$(this).parents('ul.select_list').slideUp('fast');
		return false;	
	});
	
	/* LISTA ROZWIJALNA */
	$('#groupBookingForm .ico_select').click(function(){
		$(this).siblings('ul.select_list').slideToggle('fast');
	});
	
});

/**
 * Usuwanie domyślnego tekstu
 **/
function gb_default_input(that, act, dtext){
	if(act == 'focus'){
		if(that.value == dtext)
			that.value = ''; 
	}else if(act == 'blur'){
		if(that.value == '')
			that.value = dtext; 
	}
}
