var temp='';
var check_interval=5000;
var decimals=2;
var jq_const_fieldid_minquantity='';
var minquantity=0;
var jq_currency_symbol='';
var phases_number=5;
var phase_number_current=1;
var phase_4_empty=true;
var product_customizable=0;
var label_x= new Array();
var product_phase_descriptions=
[
	'Fase 1/5 - dettaglio prodotto',
	'Fase 2/5 - tipologia prodotto',
	'Fase 3/5 - tipo personalizzazione',
	'Fase 4/5 - immagine personalizzazione',
	'Fase 5/5 - riepilogo'
];
var color_picker_selected='';
var get_error_codes=
[
	'logo_big',
	'logo_exists'
];
var get_error_messages=
[
	'ATTENZIONE: si e\' tentato di caricare sul sistema un file troppo grande - si prega di ridurlo e riprovare',
	'ATTENZIONE: si e\' tentato di caricare sul sistema un file gia\' esistente - si prega di cambiare il nome e riprovare'
];
var report_personalizzazioni_label= [];
var report_personalizzazioni_value= [];

//function color_picker_init()
//{
//	var color_picker_width=$('#color_picker').width();
//	var color_picker_height=$('#color_picker').height();
//
//	var color_picker_x=parseInt((screen.width-color_picker_width)/2);
//	var color_picker_y=parseInt((screen.height-color_picker_height)/5);
//
//	$('#color_picker').css('left', color_picker_x);
//	$('#color_picker').css('top', color_picker_y);
//}
//


function console_log (msg)
{
	try
	{
		console.log(msg);
	}
	catch (event)
	{
	}
}


function product_table_check_start (event)
{
	$('.product_quantities_numbers').unbind('keyup', product_table_check_start);
	setTimeout (product_table_check, check_interval);
}


function product_custom_color_started (event)
{
	$('#prodotto_fase_4 .product_colors').unbind('keyup', product_custom_color_started);
	temp=$(this).attr('id').split('_');
	var classid=temp[1];
	$(this).parent().parent().find('.product_colors_choose').css('background-color', '#FFFFFF');
	product_colorpicker_set_checked(classid);
}


function product_custom_color_ended (event)
{
	$('#prodotto_fase_4 .product_colors').bind('keyup', product_custom_color_started);
}

function product_report_label_x_make ()
{
	label_x= new Array();
	var current_label_x= '';

	$('.product_quantities_table .product_quantities_columns').each
	(
		function (i, val)
		{
			temp=$(this).attr('class').split(' ');
			temp=temp[1].split('_');
			current_label_x=$('#jq_parametro_'+temp[1]).val();
			label_x[label_x.length]=current_label_x;
		}
	);
}


function product_phase_4_reset (classid)
{
	$('#prodotto_fase_4 .original_classid_'+classid).val('');

	$('#product_customize_logo_'+classid+' .product_colors_choose').each
	(
		function (i, val)
		{
			$(this).css('background-color', '#FFFFFF');
			$(this).parent().find('.product_colors_container input').val($('#jq_const_product_options_colors_none').val());
		}
	);

	$('#color_picker_'+classid+' .color_sample').removeClass('check').removeClass('checkwht').removeClass('checkblk');
}


function product_report_fill ()
{
	if (phase_number_current==2)
	{
		$('#report_output_note').html($('#report_input_note input').val());

		var current_quantity= 0;
		var current_label_y= 0;
		var current_classid= 0;
		var current_html= '';
		var first= true;
		var label_x_name= $('#jq_assex_name').val();
		var label_y_name= $('#jq_assey_name').val();
		$('#report_output_quantita').html('');

		$('.product_quantities_table .product_quantities_rows').each
		(
			function (i, val)
			{
				current_html= '';
				temp=$(this).attr('class').split(' ');
				temp=temp[1].split('_');
				current_classid=temp[1];

				current_total=parseInt($('.riga_'+current_classid+'_totale').text());

				if ( (!isNaN(current_total))&&(current_total) )
				{
					current_label_y=$('#jq_parametro_'+current_classid).val();

					current_innertable_html='<table><tr>';
					$('.product_quantities_table .riga_'+current_classid).each
					(
						function (i, val)
						{
							current_quantity=parseInt($(this).val());

							if (!i)
								current_html+='<td class="column_1">'+current_label_y+'</td>';

							if ( (!isNaN(current_quantity))&&(current_quantity) )
								current_innertable_html+='<td>'+label_x[i]+'/'+current_quantity+'</td>';
							else
								current_innertable_html+='<td>&nbsp;</td>';
						}
					);
					current_innertable_html+='</tr></table>';

					current_html+='<td class="column_2">'+current_innertable_html+'</td>';

					current_html+='<td class="column_3 report_quantity">'+current_total+'</td>';
					current_html+='<td class="column_4 report_price">'+parseFloat($('#jq_product_price').val()).toFixed(decimals)+'</td>';
					current_html+='<td class="column_4_currency">'+jq_currency_symbol+'</td>';
					current_html+='<td class="column_5 report_total">&nbsp;</td>';
					current_html+='<td class="column_5_currency">'+jq_currency_symbol+'</td>';

					if (first)
						first=false;
					else
						$('#report_output_quantita').append('<tr><td colspan="'+(label_x.length+4)+'"><hr noshade/></td></tr>')

					$('#report_output_quantita').append('<tr><th class="column_1">'+label_y_name+'</th><th class="column_2">pezzi/'+label_x_name+'</th><th class="column_3">pz</th><th class="column_4">prezzo</th><th class="column_4_currency">&nbsp;</th><th class="column_5">TOT</th><th class="column_5_currency">&nbsp;</th></tr>')
					$('#report_output_quantita').append('<tr>'+current_html+'</tr>')
				}

			}
		);
	}


	/* l'utente ha completato la fase 2, o la 3, o la 4 (l'utente infatti se non sceglie alcuna
		personalizzazione salta direttamente alla fase 5 - dalla fase 2 se sceglie "personalizzazione no" salta alla 5) */
	if ((phase_number_current==2)||(phase_number_current==3)||(phase_number_current==4))
	{
		/* compilo la parte del report che riguarda le personalizzazioni e gli impianti */
		var current_classid= 0;
		var first_customization=true;
		var first_plant=true;
		var current_colors= '';
		var current_colors_price= 0;
		var current_startup_color= 0;

		$('#report_output_personalizzazioni').html('');
		$('#report_output_impianti').html('');
		$('#prodotto_fase_3 input:radio:checked').each
		(
			function (i, val)
			{
				current_colors_price= 0;
				temp=$(this).attr('name').match(/[0-9]+/);
				var current_classid=temp[0];

				if ( (current_classid!=undefined) && ($(this).attr('class')!='') )
				{
					temp=$(this).attr('class').split('_');
					var current_tecnologyid=temp[1];

					/* calcolo il costo unitario dei colori della personalizzazione (dato
						dalla somma dei costi di vari colori) */
					current_colors=$('#prodotto_fase_4 .original_classid_'+current_classid).val().split(',');

					$.each
					(
						current_colors, function (i, current_color)
						{
							if (current_color!='')
							{
								current_startup_color=$('#jq_startup_colors_'+current_tecnologyid+'_'+current_color).val();
								if (current_startup_color!=undefined)
								{
									temp=current_startup_color.split('_');
									temp=parseFloat(temp[1]);
									current_colors_price+=temp;
								}
							}
						}
					);

					if ($(this).val()!=$('#nonevalueclass_'+current_classid).val())
					{
						if (!first_customization)
							$('#report_output_personalizzazioni').append('<tr><td colspan="7"><hr noshade/></td></tr>');

						$('#report_output_personalizzazioni')
							.append('<tr><td colspan="7">Logo '+(i+1)+': '+$('#prodotto_fase_4 #product_customize_logo_'+current_classid+' .product_logo_file').val()+'</td></tr>')
							.append('<tr><th class="column_1">&nbsp;</td><th class="column_2">colori</th><th class="column_3">pz</th><th class="column_4">prezzo</th><th class="column_4_currency">&nbsp;</th><th class="column_5">TOT</th><th class="column_5_currency">&nbsp;</th></tr>')
							.append('<tr><td class="column_1">'+$('#prodotto_fase_4 #product_customize_logo_'+current_classid+' .product_customize_logo_title').text()+'</td><td class="column_2">'+$('#prodotto_fase_4 .original_classid_'+current_classid).val()+'</td><td class="column_3 report_quantity">'+$('#totale_totale').text()+'</td><td class="column_4 report_price">'+current_colors_price.toFixed(decimals)+'</td><td class="column_4_currency">'+jq_currency_symbol+'</td><td class="column_5 report_total"></td><td class="column_5_currency">'+jq_currency_symbol+'</td></tr>')
							;
						first_customization=false;
					}


					if (current_tecnologyid!=undefined)
					{
						if (first_plant)
							$('#report_output_impianti').append('<tr><th class="column_1">&nbsp;</th><th class="column_2">&nbsp;</th><th class="column_3">pz</th><th class="column_4">prezzo</th><th class="column_4_currency">&nbsp;</th><th class="column_5">TOT</th><th class="column_5_currency">&nbsp;</th></tr>');
						else
							$('#report_output_impianti').append('<tr><td colspan="7"><hr noshade/></td></tr>')

						temp=$('#jq_startup_tecnologies_'+current_tecnologyid).val().split('_');
						var tecnology_name=temp[0];
						var tecnology_price=parseFloat(temp[1]);
						var tecnology_funccolors=temp[2];

						if (tecnology_funccolors==$('#jq_const_startup_option_funcnumcolors_true').val())
							var tecnology_quantity=current_colors.length;
						else
							var tecnology_quantity=1;

						$('#report_output_impianti').append('<tr><td class="column_1">'+tecnology_name+'</td><td class="column_2"></td><td class="column_3 report_quantity">'+tecnology_quantity+'</td><td class="column_4 report_price">'+tecnology_price.toFixed(decimals)+'</td><td class="column_4_currency">'+jq_currency_symbol+'</td><td class="column_5 report_total"></td><td class="column_5_currency">'+jq_currency_symbol+'</td></tr>');

						first_plant=false;
					}
				}

			}
		);


		/* compilo la parte del report che riguarda le note */
		$('#report_output_note').html('');
		$('.user_notes').each
		(
			function (i, val)
			{
				if ($(this).val()!='')
					$('#report_output_note').append('<tr><td>'+$(this).val()+'</td></tr>');
			}
		);


		/* effettuo le moltiplicazioni tra le quantità ed i prezzi unitari e mostro
			i totali parziali; alla fine mostro il totale finale */
		var current_quantity=0;
		var current_price=0;
		var current_total=0;
		var total=0;
		$('#product_report .report_total').each
		(
			function (i, element)
			{
				current_quantity=parseInt($('#product_report .report_quantity').eq(i).html());
				current_price=parseFloat($('#product_report .report_price').eq(i).html());
				current_total=(Math.round(current_quantity*current_price*100))/100;
				$(this).html(current_total.toFixed(decimals));
				total+=current_total;
			}
		);
		$('#report_output_total').html('<tr><td class="column_1"></td><td class="column_2"></td><td class="column_3"></td><td class="column_4"></td><td class="column_4_currency"></td><td class="column_5">'+total.toFixed(decimals)+'</td><td class="column_5_currency">'+jq_currency_symbol+'</td></tr>');
	}

}


function product_get_error_check ()
{
	var get_error=$('#jq_get_error').val();
	if (get_error!='')
	{
		var pos=$.inArray(get_error, get_error_codes);
		if (pos!=-1)
			alert (get_error_messages[pos]);
	}
}


function product_colorpicker_set_checked (class_id)
{
	$('#color_picker_'+class_id+' .color_sample').each
	(
		function (color_sample_index)
		{
			color_sample=$(this);
	      color_label=$('#color_picker_'+class_id+' .color_label').eq(color_sample_index).html();

			if (color_label!=$('#jq_const_product_options_colors_custom').val())
			{
				if (color_sample.hasClass('check'))
					color_sample.removeClass('check').removeClass('checkwht').removeClass('checkblk');

				$('#product_customize_logo_'+class_id+' .product_colors').each
				(
					function (product_colors_index)
					{
						if ($(this).val()==color_label)
						{
					      color_selected=$('#color_picker_'+class_id+' .color_value').eq(color_sample_index).val();
							color_sample.addClass('check').addClass(isdark(color_selected) ? 'checkwht' : 'checkblk');
							return;
						}
					}
				)
			}

		}
	);
}


function product_next_phase ()
{
	var phase_number_go=0;

	if (phase_number_current==1)
		phase_number_go=phase_number_current+1;

	if ((phase_number_current==2)&&(product_table_check ()))
	{
		product_customizable=parseInt($('.product_customizable .product_customizable_flag:checked').val())
		if (product_customizable)
			phase_number_go=phase_number_current+1;
		else
			phase_number_go=5;
	}

	if (phase_number_current==3)
	{
		phase_4_empty=true;

		$.each
		(
			$('#prodotto_fase_3 input:radio:checked'), function (i, val)
			{
				temp=$(this).attr('name').match(/[0-9]+/);
				var classid=temp[0];
				var selected_value=$(this).val();

				var none_value=$('#nonevalueclass_'+classid).val();

				if (selected_value==none_value)
					$('#product_customize_logo_'+classid).hide();
				else
				{
					$('#product_customize_logo_'+classid).show();
					phase_4_empty=false;

					$('#color_picker_'+classid+' .color_sample').hide();
					$('#color_picker_'+classid+' .color_label').hide();
					$('#color_picker_'+classid+' .'+$(this).attr('class')).show();
				}

				$('#product_customize_logo_'+classid+' .product_colors_select').show();
				var max_colors=$('#jq_product_maxcolors_'+classid+'_'+selected_value).val();
				if (max_colors!=undefined)
					$('#product_customize_logo_'+classid+' .product_colors_select:eq('+max_colors+'),#product_customize_logo_'+classid+' .product_colors_select:gt('+max_colors+')').hide();
			}
		);

		if (phase_4_empty)
			phase_number_go=5;
		else
			phase_number_go=phase_number_current+1;
	}


	if (phase_number_current==4)
	{
		if (product_file_check())
		{
			var nocolor=$('#jq_const_product_options_colors_none').val();
			var current_classid=0;
			var current_product_options_id=0;
			var first=true;
			var current_product_options_value='';
			var color_current='';
			var error=0;
			var total_error=0;

			$('#prodotto_fase_4 .product_options_colors').val('');

			$('#prodotto_fase_4 .product_customize_logo_box').each
			(
				function (i, val)
				{
					error=0;
					var colors_list=new Array;

					if ($(this).is(':visible'))
					{
						first=true;
						current_product_options_value='';

						$(this).find('.product_customize_colors input').each
						(
							function (i, val)
							{
								color_current=$(this).val();

								if (first)
								{
									temp=$(this).attr('id').split('_');
									current_classid=temp[1];
									current_product_options_id=temp[2];

									first=false;
								}

								if ((color_current!='')&&(color_current!=nocolor))
								{
									if ($.inArray(color_current, colors_list)==-1)
										colors_list[colors_list.length]=color_current;
									else
										error=2;

									if (current_product_options_value!='')
										current_product_options_value+=',';
									current_product_options_value+=$(this).val();
								}
							}
						);

						if (!colors_list.length)
						{
							error=1;
							$('#system_msg_fase4-'+current_classid).html('ATTENZIONE: &egrave; necessario selezionare almeno un colore');
						}
						else if (error==2)
							$('#system_msg_fase4-'+current_classid).html('ATTENZIONE: non &egrave; possibile scegliere lo stesso colore pi&ugrave; volte');
						else
						{
							$('#system_msg_fase4-'+current_classid).html('');
							$('#prodotto_fase_4 .product_options_colors#po_'+current_product_options_id).val(current_product_options_value);
						}

						if (error)
							total_error=error;
					}

				}
			);

			if (!total_error)
				phase_number_go=phase_number_current+1;
		}
	}


	if (phase_number_go)
		product_go_phase (phase_number_go);
}


function product_prev_phase ()
{
	var phase_number_go=phase_number_current-1;

	if ( (phase_number_go==4)&&(phase_4_empty) )
		phase_number_go--;

	if ( (phase_number_current==5)&&(!product_customizable) )
		phase_number_go=2;

	product_go_phase (phase_number_go);
}


function product_go_phase (phase_number_go)
{
	$('.system_msg').html('');

	if ( (phase_number_go>=1)&&(phase_number_go<=phases_number) )
	{
		$('#color_picker').hide();
		$('.prodotto_zona_testo .titolo-descrizione').hide();
		$('.prodotto_fasi .prodotto_titolofase').html(product_phase_descriptions[phase_number_go-1]);

		$('.prodotto_fase').removeClass('active');
		$('.prodotto_fase').eq(phase_number_go-1).addClass('active');

		$('html,body').animate
		(
			{ scrollTop: 0 },
			'normal'
		);

		product_report_fill();
		$('.prodotto_zona_testo .titolo-descrizione#prodotto_fase_'+phase_number_go).fadeIn('slow');

		phase_number_current=phase_number_go;

		if (phase_number_current==5)
			$('.prodotto_zona_immagini').hide();
		else if (phase_number_current==1)
		{
			$('.prodotto_zona_immagini').show();
			$('.prodotto_zona_immagini #product_thumbnail').show();
			$('.prodotto_zona_immagini #product_thumbnail_mini').hide();
		}
		else
		{
			$('.prodotto_zona_immagini').show();
			$('.prodotto_zona_immagini #product_thumbnail').hide();
			$('.prodotto_zona_immagini #product_thumbnail_mini').show();
		}

		product_buttons_check ();
	}
}


function product_buttons_check ()
{
	if (phase_number_current<=1)
		$('.prodotto_colonna_2 .prodotto_navigazione .prodotto-precedente').hide();
	else
		$('.prodotto_colonna_2 .prodotto_navigazione .prodotto-precedente').show();

	if (phase_number_current>=phases_number)
		$('.prodotto_colonna_2 .prodotto_navigazione .prodotto-successivo').hide();
	else
		$('.prodotto_colonna_2 .prodotto_navigazione .prodotto-successivo').show();

	if (phase_number_current==5)
		$('.prodotto_colonna_2 .product_buttons.buy-btn_container').show();
	else
		$('.prodotto_colonna_2 .product_buttons.buy-btn_container').hide();
}


function product_table_check ()
{
	var all_ok=true;

	var total_quantity=0;
	var partial_quantity=0;
	var current_quantity=0;
	var current_value='';
	var current_class='';
	var current_codice=0;
	var table_classes= ['.product_quantities_columns', '.product_quantities_rows'];
	var table_classes_prefixes= ['colonna', 'riga'];

	$('#system_msg_fase2').html('');

	$.each
	(
		table_classes, function (table_class_key, table_class_current)
		{
			total_quantity=0;
			$.each
			(
				$(table_class_current), function (key, value)
				{
					temp=$(this).attr('class').split(' ');
					temp=temp[1].split('_');
					current_codice=temp[1];
					current_class='.'+table_classes_prefixes[table_class_key]+'_'+current_codice;

					partial_quantity=0;
					$.each
					(
						$(current_class), function (key, value)
						{
							if ($(this).val().length>0)
							{
								current_quantity=parseInt($(this).val().replace(/[^0-9]/g, ''), 10);

								if (isNaN(current_quantity))
									$(this).val('');
								else
								{
									$(this).val(current_quantity);
									total_quantity+=current_quantity;
									partial_quantity+=current_quantity;
								}
							}

						}
					);

					if (partial_quantity>0)
						$(current_class+'_totale').html(partial_quantity);
					else
						$(current_class+'_totale').html('&nbsp;');
				}
			);

		}
	);

	if (!total_quantity)
		/* -------------------------------------------------------------------- */
		/* GIOVANNI 2009-04-27
			prima se l'utente non selezionava la quantità assumevo quella di default; ora
			invece assumo 0 (e quindi l'utente è obbligato ad inserire una quantità) */
		/* CODE NEW */
		total_quantity=0;
		/* CODE OLD */
//		total_quantity=$('form[name=orderform] input[name=amount]').val();
		/* -------------------------------------------------------------------- */

	if (total_quantity>0)
		$('#totale_totale').html(total_quantity);
	else
		$('#totale_totale').html('&nbsp;');

	if ( (all_ok)&&(total_quantity<minquantity) )
	{
		$('#system_msg_fase2').html('ATTENZIONE: &egrave; necessario ordinare almeno '+minquantity+' pezzi');
		all_ok=false;
	}

	if (all_ok)
		$('#system_msg_fase2').html('');

	/* riattivo la funzione per far partire il controllo sulla tabella quando si preme
		un taso */
	$('.product_quantities_numbers').bind('keyup', product_table_check_start);

	return all_ok;
}



function product_file_check ()
{
	var function_output=true;
	var current_filename='';
	var current_classid='';
	var current_ext='';
	var allowed_ext=[];
	var pos=0;

	$.each
	(
		$('.product_customize_logo .product_logo_upload .product_logo_file'), function (index, element)
		{
			temp=$(this).attr('name').split('_');
			current_classid= temp[2];
			current_filename= $(this).val();

			if (current_filename!="")
			{
				temp=current_filename.split('.');
				current_ext=temp[1];
				allowed_ext=$('#product_logo_allowed_ext').html().split(',');

				pos=$.inArray(current_ext, allowed_ext);

				if ((current_ext="")||(pos==-1))
				{
					function_output=false;
					$('#system_msg_fase4-'+current_classid).html('ATTENZIONE: il tipo di file non &egrave; consentito');
				}
				else
					$('#system_msg_fase4-'+current_classid).html('&nbsp;');
			}

		}
	);

	return function_output;
}


$
(
	function()
	{
		jq_const_fieldid_minquantity=$('#jq_const_fieldid_minquantity').val();
		jq_currency_symbol=$('#jq_currency_symbol').val();
		minquantity=parseInt($('#'+jq_const_fieldid_minquantity).val());
		var classid='';
		var number='';

		/* setto la sidebar */
		home_height_navouter_set ();

		/* faccio un controllo sui pulsanti per passare da una fase all'altra e
			spengo i pulsanti che sono da spegnere */
		product_buttons_check ();

		/* se ci sono codici d'errore nell'url li gestisco */
		product_get_error_check ();

		/* memorizzo le etichette associate all'asse X (le userò per creare il report) */
		product_report_label_x_make();

		/* quando è stata inserita una quantità lancio la funzione product_table_check_start() */
		$('.product_quantities_numbers').bind('keyup', product_table_check_start);

		$('.color_picker').colorPicker();


		/* se clicco ovunque nel document nascondo il colorpicker (se è visibile) */
		$(document).click
		(
			function (event)
			{
				$('.color_picker').hide();
			}
		);


		$('.product_colors_choose').click
		(
			function (event)
			{
				$('.color_picker').hide();

				temp=$(this).attr('id').split('_');
				color_picker_selected=temp[2]+'_'+temp[3]+'_'+temp[4];

				classid=temp[2];

				var color_picker_width=$('#color_picker_'+classid).width();
				var color_picker_height=$('#color_picker_'+classid).height();

				var limit_x=parseInt($(document).width()*(2/3));

				var color_picker_x=0;
				var color_picker_y=0;

				if (event.pageX<limit_x)
					color_picker_x=event.pageX;
				else
					color_picker_x=event.pageX-parseInt(color_picker_width);

				color_picker_y=event.pageY-parseInt(color_picker_height);

				$('#color_picker_'+classid).css('left', color_picker_x+'px');
				$('#color_picker_'+classid).css('top', color_picker_y+'px');
				$('#color_picker_'+classid).fadeIn('slow');

				return false;
			}
		);

		/* se cambio tecnologia devo resettare i suoi color-picker dello step 4
			(e devo cancellare i colori memorizzati fino a quel momento)
			inoltre imposto il nome della tecnologia scelta nello step 4 */
		$('#prodotto_fase_3 input:radio').click
		(
			function (event)
			{
				temp=$(this).attr('name').match(/[0-9]+/);
				var classid=temp[0];
				product_phase_4_reset (classid);

				temp=$(this).attr('class').split('_');
				var current_tecnologyid=temp[1];

				if (current_tecnologyid==undefined)
					$('#product-subtitle-technology_'+classid).html('&nbsp;')
				else
				{
					temp=$('#jq_startup_tecnologies_'+current_tecnologyid).val().split('_');
					var current_tecnologyname=temp[0];
					$('#product-subtitle-technology_'+classid).html(': '+current_tecnologyname);
				}
			}
		);

		/* se ho scelto "personalizzazione: no" allora cancello le tecnologie scelte,
			i colori scelti, le note inserite nei passi 3 e 4 */
		$('#prodotto_fase_2 .product_customizable_flag').click
		(
			function (event)
			{
				if (!parseInt($(this).val()))
				{
					$('#prodotto_fase_4 .product_options_colors').each
					(
						function ()
						{
							temp=$(this).attr('class').split(' ');
							temp=temp[1].split('_');
							var classid=temp[2];
							product_phase_4_reset(classid);
						}
					);


					$('#prodotto_fase_3 input:radio[class=""]').each
					(
						function (i, val)
						{
							$(this).attr('checked', true);
						}
					);

					$('#prodotto_fase_3 .user_notes').val('');

					$('#prodotto_fase_4 .user_notes').val('');

				}
			}
		);

		/* se inizio a scegliere un colore personalizzato resetto il color picker corrispondente */
		$('#prodotto_fase_4 .product_colors').bind('keyup', product_custom_color_started);

		$('#prodotto_fase_4 .product_colors').bind('blur', product_custom_color_ended);


	}
);
