jQuery.noConflict();

jQuery(document).ready( function ($) {
	
	$("#carousel").css({'display':'block'});

	function carousel_itemFirstInCallback(carousel, item, idx, state) {
		var current = $(item).find('.carousel_btn');
		
		var title = $(current).siblings('.title').html();
		$('#title .nr', $("#copy")).html(title);
		
		var prod_title = $(current).siblings('.prod_title').html();
		$('#prod_title h3', $("#copy")).html(prod_title);
		
		var prod_desc = $(current).siblings('.prod_desc').html();
		$('#prod_description p', $("#copy")).html(prod_desc);
		
		var items = $(current).siblings('.buy_now').find('.item');
		
		if(items.length) {
			
			$('#buy-now').html('');
			
			// Add buy now links for items
			items.each(function(index, item) {
		
				var title 	= $('.title', item).html();
				var url		= $('.url', item).html();
				
				// Add link to buy now box
				$('#buy-now').append(title+' <a href="'+url+'" title="Buy Now" class="buy-button">Buy Now</a><br />');
			});
			
			$('#buy-now').show();
			$('#contact-info').hide();
		}
		else {
			$('#buy-now').hide();
			$('#contact-info .desc').html(prod_title+' Only Available In Store');
			$('#contact-info').show();
		}
		
		var prod_img = $(current).siblings('.prod_img').html();
		var image = '<img src='+prod_img+' alt="Designer Jewellery, Pendants, Rings, Earrings" height="819" width="647" style="display:none" />'
		$('#prod_image', $("#col2")).html(image);
		$('#prod_image img', $("#col2")).fadeIn('slow');
		
		Cufon.replace('#content .gillsanslight', { fontFamily: 'gillsanslight' });
		
		return false;
	};

	//initialize carousel
	 $("#carousel").jcarousel({
        scroll: 1,
		itemFirstInCallback:  carousel_itemFirstInCallback
    });
	
});

