/* lewasdesigns.com */

;(function($) {
	$.fn.myOptionSelector = function(options) {

		var defaults = {	'html'					: '',
							'selectorContainerId'	: '#selector-container'
		};

		var settings = $.extend({}, defaults, options);

		$(this).each(function() {  
			$(this).click(function(){
				var jSelection = $($(this).parent().get(0)).find('select');
				var jWindow = $(settings.html);
				$('body').append(jWindow);
				$(jWindow).find('.cancel').click(function(){
					$(settings.selectorContainerId).remove();
				});
				$(jWindow).find('map[name="items"] area').each(function(){
					$(this).click(function(){
						var choice = $(this).attr('rel');
						var optionValue;
						$(jSelection).find('option').each(function(){
							optionValue = $(this).val();
							if (optionValue.indexOf(choice) == 0) {
								$(jSelection).val(optionValue);
								return false;
							}
						});
						$(settings.selectorContainerId).remove();
						return true;
					});
				});
				return true;
			});
		});

		return $(this);  
	}  
})(jQuery);

$(document).ready(function(){
	$('.select-font-link').myOptionSelector({'html':myOptionSelectorFontHtml});
	$('.select-color-link').myOptionSelector({'html':myOptionSelectorColorHtml});
	$('#gallery').jqGalViewII();
	tb_init('a.iviewer', "/lib/yhst-10653689193826/loading.gif", "/lib/yhst-10653689193826/close.gif");
	$('.itemOrder form').submit(function(){
		var ok = true;
		$('.select-color-link, .select-font-link').each(function(){
			if (	($($(this).parent().get(0)).find('select').val() == 'Select')
				&&	($($(this).parents('tr')[0]).find('td.quantity input.quantity-input').val() > 0)	) {
				ok = false;
				alert('Please select a Color or Font Option before adding this item to your shopping cart.');
				return false;
			}
		});
		return ok;
	});
	$('ul.jd_menu').jdMenu({
		showDelay		: 90,
        hideDelay		: 110,
        disableLinks	: false,
        onAnimate		: null
	});
});

