

function changeImg(formName, selectedImg, dispW, dispH) {
	
	with(document.forms[formName]) {
	
		var productImgs = document.getElementsByName('productImg');
		if( productImgs != null ){  
            var len = productImgs.length;
            if(len){
                var currentNo = document.forms[formName].currentImgNum.value;
				productImgs[currentNo].style.borderTop = '5px solid #e6e6e6'; 

                for(var i=0; i<len; i++) {
                   if (productImgs[i] == selectedImg) {
                       var index = selectedImg.src.lastIndexOf(".");
                       currentImg.src = selectedImg.src.substring(0, index) + "_o." + selectedImg.src.substring(index+1);
                       ImageSizeSetting.fillImageWidthHeight(currentImg.src, dispW, dispH, function(size) {
                           if (size.width != null || size.width != 0 || size.height != null || size.width != 0) {
                               currentImg.width = size.width;
                               currentImg.height = size.height;
                           }
                       })
                       
					   selectedImg.style.borderTop = '5px solid orange';     
                       currentImgNum.value = i ;           
                   } else {
                       productImgs[i].style.borderTop = '5px solid #e6e6e6';  
                   }
                }
            } 
        } else {
            return;
        }
    }
}


function changeImg2(id1, id2, id3, thumbIndex, color){

	var main_img_div = document.getElementById(id1 + '_' + id2 + '_' + id3);
	
	if (main_img_div != null) {
		var main_img_s = main_img_div.getElementsByTagName('img');
		
		if (main_img_s != null) {
			var main_img = main_img_s[0];
			
			var thumb_img_div = document.getElementById(id1 + '_' + id2 + '_' + id3 + '_' + thumbIndex);
			thumb_img_div.style.borderTop = '5px solid gray';
			
			if (thumb_img_div != null) {
				var thumb_img_s = thumb_img_div.getElementsByTagName('img');
				
				if (thumb_img_s != null) {
					thumb_img = thumb_img_s[0];
				
					thumb_img_src = thumb_img.src;
					var index = thumb_img_src.lastIndexOf('.');
                    main_img.src = thumb_img_src.substring(0, index) + "_o." + thumb_img_src.substring(index+1);
                    ImageSizeSetting.fillImageWidthHeight(main_img.src, '280', '210', function(size) {
                       if (size.width != null || size.width != 0 || size.height != null || size.width != 0) {
                           main_img.width = size.width;
                           main_img.height = size.height;
                       }
                   })
				}
			}

			
    		for (i = 1; i < 6; i++) {
				var suffix = '0'+i;
				
				if(thumbIndex == suffix) {
					continue;
				}
				
    			var other_thumb_img_div = document.getElementById(id1 + '_' + id2 + '_' + id3 + '_' + suffix);
    			if(other_thumb_img_div != null){
    				if (color == '01') {
    					other_thumb_img_div.style.borderTop = '5px solid #E6C4C4';
    				} else if (color == '02') {
    					other_thumb_img_div.style.borderTop = '5px solid #F3C4AF';
    				} else if (color == '03') {
    					other_thumb_img_div.style.borderTop = '5px solid #F2D7A4';
    				} else if (color == '04') {
    					other_thumb_img_div.style.borderTop = '5px solid #F1EBA6';
    				} else if (color == '05') {
    					other_thumb_img_div.style.borderTop = '5px solid #D3DDA6';
    				} else if (color == '06') {
    					other_thumb_img_div.style.borderTop = '5px solid #D7E2C9';
    				} else if (color == '07') {
    					other_thumb_img_div.style.borderTop = '5px solid #C9DBC3';
    				} else if (color == '08') {
    					other_thumb_img_div.style.borderTop = '5px solid #C1D3C4';
    				} else if (color == '09') {
    					other_thumb_img_div.style.borderTop = '5px solid #D3E0D8';
    				} else if (color == '10') {
    					other_thumb_img_div.style.borderTop = '5px solid #CCDBD8';
    				} else if (color == '11') {
    					other_thumb_img_div.style.borderTop = '5px solid #D1DCDC';
    				} else if (color == '12') {
    					other_thumb_img_div.style.borderTop = '5px solid #DBE0E1';
    				} else if (color == '13') {
    					other_thumb_img_div.style.borderTop = '5px solid #DDDEDF';
    				} else if (color == '14') {
    					other_thumb_img_div.style.borderTop = '5px solid #DCDCDF';
    				} else if (color == '15') {
    					other_thumb_img_div.style.borderTop = '5px solid #DBD1D7';
    				} else if (color == '16') {
    					other_thumb_img_div.style.borderTop = '5px solid #E1D2DB';
    				} else if (color == '17') {
    					other_thumb_img_div.style.borderTop = '5px solid #E0CBD4';
    				} else if (color == '18') {
    					other_thumb_img_div.style.borderTop = '5px solid #E7C7D5';
    				} else if (color == '19') {
    					other_thumb_img_div.style.borderTop = '5px solid #E0BAC7';
    				} else if (color == '20') {
    					other_thumb_img_div.style.borderTop = '5px solid #E6CDCD';
    				}
    			}

			}

		}
	}
}