/**
 * @author adam
 */

var display_timeout = 0;

$(document).ready(function() {
	
	$.scrollTo($('ul#collections'), 500);
	
	$('.blank').blankTarget();
	
	// check ie 6
	var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
	var src = (isIE6 == true) ? "gif" : "png";

	// loop round each collection link in list
	$('#collections li a').each(function() {
		
		var collectionSafe = $(this).parent().attr('class');
		
		// set content background image onClick
		$(this).click(function() {
			
			$('#wrapper').attr(
				'style', 'height:900px;'
			);
			
			// display loading gif
			$('#content').fadeOut(500, function() {
				$('#content').attr(
					'style', 'background:url('+REL_ROOT+'images/collection/collection_'+collectionSafe+'.'+src+') no-repeat'
				).fadeIn(500);
				
				// if christmas collection show sparks logo
				if (collectionSafe == "christmas") {
					$('#sparks').fadeIn(800);
				} else {
					$('#sparks:visible').fadeOut(800);
				}
			});
			
			return false;
		});

		// set content background image onmouseover
		/*$(this).hover(function() {
			var this_element = $(this);
			
			if(display_timeout != 0) {
				clearTimeout(display_timeout);
			}
			
			display_timeout = setTimeout(function() {
				$('#sparks:visible').fadeOut(800);
				$('#content').attr('style', 'background:url('+REL_ROOT+'images/collection/hover_'+collectionSafe+'.'+src+') no-repeat');
			}, 200);
			
		}, function() {
			if(display_timeout != 0) {
				clearTimeout(display_timeout);
			}
		});*/
	});
	
});


