$(document).ready(function () {
	$("#upright-compare,#upright-compare-top,.upright-tune-up-container").fancybox({'frameWidth':780,'frameHeight':550}); 	

	(function () {
		var next, pix, index, count, interval, loops, delay, remainder;
		index = 0;
		loops = 3;
		delay = 3000;
		pix = $('#pilot-animation img');
		count = pix.length;
		remainder = count * loops;
		$(pix[index]).css({display: 'inline'});
		interval = setInterval(function () {
			next = (index + 1) % count;
			$(pix[index]).fadeOut('slow');
			$(pix[next]).fadeIn('slow');
			index = next;
			remainder -= 1;
			if(remainder <= 0) clearInterval(interval);
		}, delay);
	}());

	$('.special-offers-container').each(function () {
		var body, bodyPos, gift, giftPos;
		body = $('#main-inner');
		gift = $(this);
		bodyPos = body.offset();
		giftPos = gift.offset();
		gift.remove().appendTo(body);
		gift.css({
			top: giftPos.top - bodyPos.top,
			left: giftPos.left - bodyPos.left
		});
	});

	$('.label-link-hack').each(function () {
		var self = this;
		$('.special-promotion, .category-grid-top', self).css({
			cursor: 'pointer'
		}).click(function () {
			Broadway.showSpinner(self,256,3);
			location.href = $('a',self).attr('href');
		});
	});

});


