function set_wizard_select_events()
{
	if ( $('.shape_size') )
	{
		$('.shape_size').bind('change',function(){
			var current_selection = this.id;
			var shape_value = this.id.replace('wiz_shape_size_','');
			var size_value = $('#'+this.id+' option:selected').val();
			
			if (size_value == 'Rectangle' || size_value == 'Square' || size_value == 'Circle' || size_value == 'Oval' )
			{
				alert('Please choose a label size');
				return false;
			}
			
			$.get('/shared/ajax_configurator_material_list',{shape:shape_value,size:size_value},function(resp){
				// update material list
				$("#wiz_col_wrapper").html(resp);
				
				$('#wiz_materials_list').show();
			});
			
			$('.shape_size').each(function(){
				if ( this.id != current_selection )
				{
					this.selectedIndex = 0;
				}
			});
		});
		
	}
}
function set_by_material_wizard_select_events()
{
	if ( $('.mat_shape_size') )
	{
		$('.mat_shape_size').bind('change',function(){
			var current_selection = this.id;
			var shape_value = this.id.replace('wiz2_shape_size_','');
			var size_value = $('#'+this.id+' option:selected').val();
			var material_value = $('#wc_by_material_value').val();
			//console.log(shape_value,size_value,material_value);
			if (size_value == 'Rectangle' || size_value == 'Square' || size_value == 'Circle' || size_value == 'Oval' )
			{
				alert('Please choose a label size');
				return false;
			}
			
			$.get('/shared/ajax_configurator_label_list',{shape:shape_value,size:size_value,material_value:material_value},function(resp){
				// update material list
				if(resp.match(/goto/))
				{
					url = resp.replace('goto:','');
					window.location = url;
				}
				else
				{
					$("#wiz_mat_col_wrapper").html(resp);
					$('#wiz2_materials_list').show();
				}
			});
			
			$('.mat_shape_size').each(function(){
				if ( this.id != current_selection )
				{
					this.selectedIndex = 0;
				}
			});
		});
		
	}
}
$(document).ready(function()
{
	set_wizard_select_events();
	set_by_material_wizard_select_events();
	$('#wizard_mat_configurator').appendTo('#wiz_configuration_btn');
});