﻿$(document).ready(function() {
    //Left Chest Option
    $(".swapSellc").change(function() {
        //var optRefine = $(".swapSellc").val().replace(/\s\(\+\$[0-9]+(?:\.[0-9]*)?\)/, "").replace(/\s/g, "-");
        //var imgPath = "http://lib.store.yahoo.net/lib/yhst-42000695909641/" + optRefine.toLowerCase() + ".jpg";
        
        if (this.selectedIndex>=0) {
        
			var option=this.options[this.selectedIndex];
        
			var optRefine = option.value.replace(/\s\(\+\$[0-9]+(?:\.[0-9]*)?\)/, "").replace(/\s/g, "-").replace(/[\(]|[\)]/g,"");
        	var imgPath = "http://lib.store.yahoo.net/lib/yhst-42000695909641/" + optRefine + ".jpg";
			if($(option).attr("label") != "") {
				$("#swatchPreviewArea td").html("<img src='http://lib.store.yahoo.net/lib/yhst-42000695909641/" + $(option).attr("label") + "' />");
			} else {
				$("#swatchPreviewArea td").html("<img src='" + imgPath + "' />");
			}
        
        }		
        /*if ($(this).val() == "novalue") {
            $("#swatchPreviewArea td").html("<img src='http://lib.store.yahoo.net/lib/yhst-42000695909641/swatch-preview-hint.png' />");
        } else {
            $("#swatchPreviewArea td").html("<img src='" + imgPath + "' />");
        }*/
    });
    //Upper Sleeve Option
    $(".swapSelus").change(function() {
        //var optRefine = $(".swapSelus").val().replace(/\s\(\+\$[0-9]+(?:\.[0-9]*)?\)/, "").replace(/\s/g, "-").replace(/[\(]|[\)]/g,"");
        //var imgPath = "http://lib.store.yahoo.net/lib/yhst-42000695909641/" + optRefine.toLowerCase() + ".jpg";
        
        if (this.selectedIndex>=0) {
        
			if(this.selectedIndex==0) {
					$("#swatchPreviewArea2 td").html("<img src='http://lib.store.yahoo.net/lib/yhst-42000695909641/Uppersleeve-default.jpg' />");
			} else {
			
				var option=this.options[this.selectedIndex];
			
				var optRefine = option.value.replace(/\s\(\+\$[0-9]+(?:\.[0-9]*)?\)/, "").replace(/\s/g, "-").replace(/[\(]|[\)]/g,"");
        		var imgPath = "http://lib.store.yahoo.net/lib/yhst-42000695909641/" + optRefine + ".jpg";
				if($(option).attr("label") != "") {
					$("#swatchPreviewArea2 td").html("<img src='http://lib.store.yahoo.net/lib/yhst-42000695909641/" + $(option).attr("label") + "' />");
				} else {
					$("#swatchPreviewArea2 td").html("<img src='" + imgPath + "' />");
				}
			}
		}
        /*if ($(this).val() == "novalue") {
            $("#swatchPreviewArea2 td").html("<img src='http://lib.store.yahoo.net/lib/yhst-42000695909641/Uppersleeve-default.jpg' />");
        } else {
            $("#swatchPreviewArea2 td").html("<img src='" + imgPath + "' />");
        }*/
    });
    //Lower Sleeve Option
    $(".swapSells").change(function() {
        //var optRefine = $(".swapSells").val().replace(/\s\(\+\$[0-9]+(?:\.[0-9]*)?\)/, "").replace(/\s/g, "-").replace(/[\(]|[\)]/g,"");
        //var imgPath = "http://lib.store.yahoo.net/lib/yhst-42000695909641/" + optRefine.toLowerCase() + ".jpg";
        
        if (this.selectedIndex==0) {
			$("#swatchPreviewArea3 td").html("<img src='http://lib.store.yahoo.net/lib/yhst-42000695909641/Lowersleeve-default.jpg' />");
        } else {
			var option=this.options[this.selectedIndex];
			var optRefine = option.value.replace(/\s\(\+\$[0-9]+(?:\.[0-9]*)?\)/, "").replace(/\s/g, "-").replace(/[\(]|[\)]/g,"");
        	var imgPath = "http://lib.store.yahoo.net/lib/yhst-42000695909641/" + optRefine + ".jpg";
			if($(option).attr("label") != "") {
				$("#swatchPreviewArea3 td").html("<img src='http://lib.store.yahoo.net/lib/yhst-42000695909641/" + $(option).attr("label") + "' />");
			} else {
				$("#swatchPreviewArea3 td").html("<img src='" + imgPath + "' />");
			}
        }
        
        /*if ($(this).val() == "novalue") {
            $("#swatchPreviewArea3 td").html("<img src='http://lib.store.yahoo.net/lib/yhst-42000695909641/Lowersleeve-default.jpg' />");
        } else {
            $("#swatchPreviewArea3 td").html("<img src='" + imgPath + "' />");
        }*/
    });
});
