var n = document.layers;
var ie = document.all;
var n6 = document.getElementById&&!document.all;
function onImageSelect(obj,img){
    imgPath = obj.value;		
	if (obj.value == "") {
	    return false;
	}
	if (imgPath.charAt(0,7).toLowerCase() == "http://" || imgPath.charAt(0,6).toLowerCase() == "ftp:///") {
		alert("Pictures from a web page cannot be upload - " + " : " + ImgPath);
		return false;
	}
	if(!isValidImageExt(imgPath)) {
		if(0) alert("請選入圖片檔案格式為 .jpg .png .gif 或 .swf(flash動畫)"); 
		else alert("http://www.cftex.com.tw/請選入圖片檔案格式為%20.jpg%20.png%20或%20.gif"); 									
		return false;
	}
	if(ie) {
	    if (imgPath.substring(imgPath.length - 3, imgPath.length).toLowerCase() == "swf") {
			document.all(img).src='http://www.cftex.com.tw/imgs/flash.gif';
		}else {
		    if(img == "pic_preview1"){
		      document.pic_preview1.src= document.getElementById("root_path").value+imgPath ;
		    }
		    if(img == "small_pic_preview1"){
		      document.small_pic_preview1.src= document.getElementById("root_path").value+imgPath ;
		    }
		    if(img == "big_pic_preview1"){
		      document.big_pic_preview1.src= document.getElementById("root_path").value+imgPath ;
		    }
		    if(img == "big_pic_preview2"){
		      document.big_pic_preview2.src= document.getElementById("root_path").value+imgPath ;
		    }
		    if(img == "big_pic_preview3"){
		      document.big_pic_preview3.src= document.getElementById("root_path").value+imgPath ;
		    }
		    if(img == "big_pic_preview4"){
		      document.big_pic_preview4.src= document.getElementById("root_path").value+imgPath ;
		    }
		    if(img == "change_preview_pic"){
		      document.change_preview_pic.src= document.getElementById("root_path").value+imgPath ;
		    }
			if(img == "front_change_preview_pic"){
			  	div1.innerHTML='<img src="'+ imgPath + '" border="0" width="280" height="220">';
		    }
		    /*
		    if(img == "big_pic_preview"){
		      big_pic_preview.innerHTML='<img src="/upload_files/2' + imgPath + '" border="0" width="50" height="50">';
		    }
		    */
			//document.all(img).src=imgPath;
		}
	}		
}			
			
function isValidImageExt(imageName) {
	if (imageName.substring(imgPath.length - 3, imageName.length).toLowerCase() != "jpg" && imageName.substring(imgPath.length - 3, imageName.length).toLowerCase() != "gif" && imageName.substring(imgPath.length - 3, imageName.length).toLowerCase() != "png" && imageName.substring(imgPath.length - 4, imageName.length).toLowerCase() != "jpeg") {
			if (imageName.substring(imgPath.length - 3, imageName.length).toLowerCase() == "swf" && 0 ){
                return true;
            }else{
			    return false;
			} 			
    }else{
        return true;
    }
}
