$(document).ready(function(){
	//Examples of how to assign the ColorBox event to elements
	$(".images-box a").attr('rel', 'photo').colorbox({maxWidth:'98%', maxHeight:'98%', transition:'elastic'});
	$.ajaxSetup ({cache: false}); 
	$("a[target=_blank]").colorbox({width:'450px', transition:'elastic'});
	if (window.location.href.substr(window.location.href.length-11, window.location.href.length) == '/color.html') {
		jQuery('.text-block').append('<div id="colorPreviewBox"></div>');
		var hide = '';
		window.colorSelectImages = new Array;
		jQuery('.text-block img').each(function(){
			window.colorSelectImages.push(this.src);
		});
		jQuery('.text-block p').remove();
		if (window.colorSelectImages.length) {
			var previewName = window.colorSelectImages[0].replace(/(.*)_.*/, '$1')+'_colors.png';
			jQuery('#colorPreviewBox')
				.css('background-image', 'url('+window.colorSelectImages[0]+')')
				.append('<div id="colorPreviewSelectBox" style="background: url('+previewName+') left top no-repeat"></div>');
			var colorPreviewSelectBox = jQuery('#colorPreviewSelectBox').css('width', window.colorSelectImages.length*79);
			for (i=0; i<window.colorSelectImages.length; i++) {
				colorPreviewSelectBox.append('<a href="#img-'+i+'" style="background-image: url('+previewName+');">&nbsp;</a>');
			}
			colorPreviewSelectBox.find('a').bind('click  mouseenter', function() {
				var index = parseInt(this.href.substring(this.href.length-1, this.href.length));
				jQuery('#colorPreviewBox')
					.css('background-image', 'url('+window.colorSelectImages[index]+')')
				jQuery('#colorPreviewSelectBox a').css('background-position', '79px -66px')
				jQuery(this).css('background-position', '-'+(index*79)+'px -66px')
				return false;
			});
		}
	}
});
