jQuery(document).ready(function(){

    // On document ready hide all images first
    jQuery("#image img").hide();
    jQuery("#productImgDefault").show();
    jQuery("#productImgPlace").show();
    
    jQuery(".color").change(function() {
        // Hide all images on slect element change action
        jQuery("#image img").hide();

        // Get the value of selected option
        var optionValue = jQuery(this).attr('value');
        // Just a test to see if you're getting option value
        // alert(optionValue);

        // Get the content (aka inner HTML) of selected option
        var optionValueText = jQuery.trim(jQuery('.color :selected').text());

        // Just a test to see if you're getting right selected option inner text
        // alert(optionValueText);
        // alert('Selected option has value: ' + optionValue + ' and inner text: ' + optionValueText);


        // Show the image based on selected value
        // Whatch out, case sensitive...
		
		if(optionValueText == "-- Please Select --") {
		jQuery("#productImgDefault").show();
		jQuery("#productImgPlace").show();
		} else {
		optionValueText = optionValueText.replace(/ /gi,'_');
		optionValueText = optionValueText.replace(/\//g,'_');
        optionValueText = optionValueText.replace(/\(Out of Stock\)/,'');
		optionValueText = optionValueText.replace(/\(Out_of_Stock\)/,'');
		var optionValueText = optionValueText.toLowerCase();
		jQuery(".productImg" + optionValueText).show();
		jQuery("#productImgPlace").show();
		}
    });


//jQuery(".color, .color:parent").hide();

			jQuery("a[rel=product_gallery]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'fade',
				'titleShow' 	: false
			});
   
});
 

jQuery.noConflict();	
