
// Check product option is selected before attempting to add to cart
 function checkProductOptions(id,mod) {
	if ($('form[name=product_' + id + ']').length) {
        var field = $('form[name=product_' + id + '] > select[name=id]');
	} else {
        var field = $('select#productOptionsSelect');
	}

	if (field.val() == '0' || field.val() == '') {
		alert("Please select a product option");
		field.focus();
		return false;
	}

	if (field.length) {
        id = field.val();
    }

	// Extra type information
	var extra = '';
	if (typeof mod != 'undefined') {
		extra = '/mod/' + mod;
	}

	document.location.href = SG_URL_PREFIX + 'shopping/cart/add/' + id + extra;
	return false;
 }

 // Product optional views
 function productImageRollovers() {
	var mainImage = $('img#productMainImageView');
	var mainImageSrc = mainImage.attr('src');
	var imageBasePath = SG_SITE_DIR + 'upload/product_images/';
	var imageMedMod = '-one-med.jpg';
	var imageLgMod = '-one-lg.jpg';

	// Remove w & h attrs from main
	mainImage.removeAttr('width');
	mainImage.removeAttr('height');

	$('#productViewsOptions a.productViewsLink').each(function() {

		$(this).hover(
			function() {
				$(this).css('opacity',0.6);
				mainImage.attr('src', imageBasePath + $(this).attr('rel') + imageMedMod);

			},
			function() {
				$(this).css('opacity',1);
				mainImage.attr('src', mainImageSrc);
			}
		);
	});

	// LightBox
	$('a.productViewsLink').lightBox({
		imageLoading: SG_SITE_DIR + 'images/lightbox/loading.gif',
		imageBtnClose: SG_SITE_DIR + 'images/lightbox/close.gif',
		imageBtnPrev: SG_SITE_DIR + 'images/lightbox/prev.gif',
		imageBtnNext: SG_SITE_DIR + 'images/lightbox/next.gif',
		imageBlank: SG_SITE_DIR + 'images/lightbox/blank.gif'
	});


 }