var printing = '';
var printing_changeable = true;


var printing_posible = new Array();

printing_posible['thermos1'] = new Array();
printing_posible['thermos1']['engraving'] = true;
printing_posible['thermos1']['silkscreen'] = true;
printing_posible['thermos1']['hottransfer'] = false;

printing_posible['thermos2'] = new Array();
printing_posible['thermos2']['engraving'] = true;
printing_posible['thermos2']['silkscreen'] = true;
printing_posible['thermos2']['hottransfer'] = false;

printing_posible['thermos3'] = new Array();
printing_posible['thermos3']['engraving'] = true;
printing_posible['thermos3']['silkscreen'] = true;
printing_posible['thermos3']['hottransfer'] = false;

printing_posible['thermos4'] = new Array();
printing_posible['thermos4']['engraving'] = true;
printing_posible['thermos4']['silkscreen'] = true;
printing_posible['thermos4']['hottransfer'] = true;

printing_posible['thermos5'] = new Array();
printing_posible['thermos5']['engraving'] = true;
printing_posible['thermos5']['silkscreen'] = true;
printing_posible['thermos5']['hottransfer'] = false;


var printings = new Array('engraving', 'silkscreen', 'hottransfer');
var temporary_printing = 1;
var temporary_printing2 = 0;
var temporary_printing_img = '';

function thermos_choose_printing_load() {
	if(temporary_printing2 == 3){
		temporary_printing2 = 0;
		temporary_printing++;
	}
	
	if(temporary_printing <= 5){
		if(temporary_printing_img == '' || (temporary_printing_img.width != undefined && temporary_printing_img.height != undefined && temporary_printing_img.width > 0 && temporary_printing_img.height > 0)){
			if(printing_posible['thermos' + temporary_printing][printings[temporary_printing2]]){
				temporary_printing_img = new Image;
				temporary_printing_img.src = 'img/thermoses/thermos' + temporary_printing + '_' + printings[temporary_printing2] + '.jpg';
			}else{
				temporary_printing_img = '';
			}
			
			temporary_printing2++;
		}
		
		setTimeout('thermos_choose_printing_load()', 50);
	}else{
		//alert('LOADING READY!');
	}
}

function start_before_thermos_choose_printing() {
	for(var i in printing_posible[thermos]){
		if(printing_posible[thermos][i]){
			$('#' + i).show();
			$('#' + i).attr('src', 'img/thermoses/' + thermos + '_' + i + '.jpg');
		}else{
			$('#' + i).hide();
		}
	}
}

function reset_thermos_choose_printing() {
	printing = '';
	printing_changeable = true;
	
	$('.printing').css('opacity', 1.0);
	
	$('#choose_printing_next').css('opacity', 0.3);
}

$('document').ready(
	function() {
		thermos_choose_printing_load();
		
		$('.printing').hover(
			function() {
				$(this).css('border', '3px solid #EE1D23');
			}, function() {
				$(this).css('border', '3px solid black');
			}
		);
		
		$('.printing').click(
			function() {
				if(printing_changeable && printing != $(this).attr('id')){
					printing_changeable = false;
					
					printing = $(this).attr('id');
					
					$('.printing').stop().not(this).animate({'opacity': 0.3}, 400);
					$(this).stop().animate({'opacity': 1.0}, 400);
					
					$('#choose_printing_next').animate({'opacity': 1.0}, 400);
					
					setTimeout('printing_changeable = true', 400);
				}
			}
		);
		
		$('#engraving').tooltip(
			{
				delay: 0,
				showURL: false,
				fade: 250,
				bodyHandler: function() {
					return $('#engraving_tooltip').html();
				},
				fixPNG: true,
				track: true,
				left: -100
			}
		);
		
		$('#silkscreen').tooltip(
			{
				delay: 0,
				showURL: false,
				fade: 250,
				bodyHandler: function() {
					return $('#silkscreen_tooltip').html();
				},
				fixPNG: true,
				track: true,
				left: -100
			}
		);
		
		$('#hottransfer').tooltip(
			{
				delay: 0,
				showURL: false,
				fade: 250,
				bodyHandler: function() {
					return $('#hottransfer_tooltip').html();
				},
				fixPNG: true,
				track: true,
				left: -100
			}
		);
		
		$('#choose_printing_skip').click(
			function() {
				show_next('step_thermos_preview');
			}
		);
		
		$('#choose_printing_next').click(
			function() {
				if($(this).css('opacity') == 1){
					show_next();
				}
			}
		);
		
		$('.step_header_back', $('#step_thermos_choose_printing')).click(
			function() {
				reset_steps('step_thermos_choose_printing');
			}
		);
	}
);

