$(document).ready(function(){
	$('#fp_radio1').change(function()
	{
		$('#fp_selection_info').html("Johnnie Walker's most prestigious whisky. Probably the most famous super-premium blend, made up of the finest old-aged malt and grain whiskies. The Cristal of the blended whiskey world.");
		$('#fp_bottle_area').removeClass('fp_bottle2').addClass('fp_bottle1');
		fp_set_max_lengths();
		fp_enable_enhanced_radios();
		fp_toggle_enhanced();
		checkImgs();

	});
	$('#fp_radio2').change(function()
	{

		$('#fp_selection_info').html("A new extension of the Johnnie Walker range for travel retail, this celebrates the first Royal Warrant granted to John Walker and Sons Ltd to supply scotch whisky to the British Royal household.");
		$('#fp_bottle_area').removeClass('fp_bottle1').addClass('fp_bottle2');
		$("#fp_enhance_checkbox").attr('checked', false);
		fp_toggle_enhanced();
		fp_set_max_lengths();
		fp_disable_enhanced_radios();
		fp_clear_enhanced_radios();
		checkImgs();
	});
	$('#fp_engraving_suggestions').change(function()
	{
		fp_load_suggestion();
	});
	$('#fp_enhance_checkbox').change(function()
	{
		fp_toggle_enhanced();
	});

	$('#fp_t_line1,#fp_t_line2,#fp_t_line3').keyup(function()
	{
		fp_update_bottle();
	});
	fp_update_bottle();
	fp_set_max_lengths();
	fp_set_enhanced_radios();
});
function fp_update_bottle()
{
	$('div.fp_line1').html($('#fp_t_line1').val());
	$('div.fp_line2').html($('#fp_t_line2').val());
	$('div.fp_line3').html($('#fp_t_line3').val());
}
function fp_load_suggestion()
{
	var suggestion = $('#fp_engraving_suggestions').val();
	if(suggestion != "")
	{
		parts = suggestion.split(":");
		$('#fp_t_line1').val(parts[0]);
		$('#fp_t_line2').val(parts[1]);
		$('#fp_t_line3').val(parts[2]);
		fp_set_max_lengths();
		fp_update_bottle();
	}
}
function fp_toggle_enhanced()
{
	if($("#fp_radio1").is(":checked"))
	{
		$('#fp_radio1').attr('checked', true)
		$('div.fp_enhance_wrapper').show('blind');
	}
	else
	{
		$('div.fp_enhance_wrapper').hide('blind');
	}
	fp_set_max_lengths();
}
function fp_set_max_lengths()
{
	if($("#fp_radio2").is(":checked"))
	{
		setformfieldsize($('#fp_t_line1'), 15, "fp_t_line1_remaining");
		setformfieldsize($('#fp_t_line2'), 15, "fp_t_line2_remaining");
		setformfieldsize($('#fp_t_line3'), 5, "fp_t_line3_remaining");
	}
	else
	{
		setformfieldsize($('#fp_t_line1'), 15, "fp_t_line1_remaining");
		setformfieldsize($('#fp_t_line2'), 15, "fp_t_line2_remaining");
		setformfieldsize($('#fp_t_line3'), 15, "fp_t_line3_remaining");

	}
}
function fp_set_enhanced_radios()
{
	$(".checkbox_as_radios").click(function() {
		flag = $(this)[0].checked;
		fp_clear_enhanced_radios();
		if(flag == true)
		{
			$(this)[0].checked = true;
		}
	});
	/*
	$('#fp_option1_img').click(function(){
		flag = $('#fp_option1')[0].checked;
		fp_clear_enhanced_radios();
		if(flag == true)
		{
			$('#fp_option1').attr('checked', false);
		}
		else
		{
			$('#fp_option1').attr('checked', true);
		}
	});
	$('#fp_option2_img').click(function(){
		flag = $('#fp_option2')[0].checked;
		fp_clear_enhanced_radios();
		if(flag == true)
		{
			$('#fp_option2').attr('checked', false);
		}
		else
		{
			$('#fp_option2').attr('checked', true);
		}
	});
	$('#fp_option3_img').click(function(){
		flag = $('#fp_option3')[0].checked;
		fp_clear_enhanced_radios();
		if(flag == true)
		{
			$('#fp_option3').attr('checked', false);
		}
		else
		{
			$('#fp_option3').attr('checked', true);
		}
	});
	$('#fp_option4_img').click(function(){
		flag = $('#fp_option4')[0].checked;
		fp_clear_enhanced_radios();
		if(flag == true)
		{
			$('#fp_option4').attr('checked', false);
		}
		else
		{
			$('#fp_option4').attr('checked', true);
		}
	});
	*/
}
function fp_clear_enhanced_radios()
{
	$(".checkbox_as_radios").each(function() {
	$(this)[0].checked = false;});
}
function fp_disable_enhanced_radios()
{
        $('.checkbox_as_radios').attr('disabled', true);
		$('.checkbox_as_radios').addClass('fp_disabled');
}
function fp_enable_enhanced_radios()
{
        $('.checkbox_as_radios').removeAttr('disabled');
		$('.checkbox_as_radios').removeClass('fp_disabled');
}
