$(document).ready(function(){ 	
	$('#ptImgSwitcher ul li')
		.click(function(){
			changeImg($('#ptImgSwitcher ul li').index(this)+1);
			restartSwitcher();
		})
		.eq(0).addClass('active');
	
	var feedbacks = $('#ptFeedback ul.ptFeedbackList > li');
	
	// Set width of the feedback list 
	$('#ptFeedback ul.ptFeedbackList').css("width",
		(feedbacks.width() + parseInt(feedbacks.css('marginRight')) + 2*parseInt(feedbacks.css('paddingRight'))) * feedbacks.length + "px"
	);
	
	$('#ptFeedback .hScrollBack,#ptFeedback .hScrollNext').hover(
		function(){$(this).addClass('hover');},
		function(){$(this).removeClass('hover');}
	);
	$('#ptFeedback .hScrollBack').click(function(){
		$('#ptFeedback .hScrollArea').scrollTo('-=690px',400);
	});
	$('#ptFeedback .hScrollNext').click(function(){
		$('#ptFeedback .hScrollArea').scrollTo('+=690px',400);
	});
	
	// Promo offers
	$('.promoOffer').hover(
		function(){
			$('.promoOffer .offerPic .smp').stop(true,true).show(); 
			$(this).find('.offerPic .smp').fadeOut();
		},
		function(){$(this).find('.offerPic .smp').fadeIn();} 
	);
	
	// Print Materials (Promo offers)
	$('#ptFormatPreview li').hover(
		function(){
			$('#ptFormatPreview .printPic img').stop(true,true).show(); 
			$(this).find('.printPic .smp').fadeOut();
		},
		function(){$(this).find('.printPic .smp').fadeIn();} 
	);
	/*
	$('.promoOffer .big_blue_bt').click(function(){
		$('#promoKeyBubble')
			.find('input[name="id"]').val($(this).attr('id').replace(/o/,'')).end()
			.appendTo($(this).parent())
			.show();
		
		return false;
	});
	*/
});

var intv;
var cur_img_id = 1;
var n = 4;
restartSwitcher();

function changeImg(img_id){	
	if(img_id>n){
		img_id = 1;
	}
	
	$('#ptImgSwitcher ul li').removeClass('active').eq(img_id-1).addClass('active');
	$('#uc_'+cur_img_id).fadeOut(1000);
	$('#uc_'+img_id).fadeIn(1000);
	cur_img_id = img_id;
}

function restartSwitcher(){
	window.clearInterval(intv);
	intv = window.setInterval("changeImg(cur_img_id+1)", 6000);
}

function goto_manual(step){
	$(".man_step").hide();
	$("#man_step"+step).show();
	window.scrollTo(1,1);
}

