  function display_image(){
	
	var cObj = document.createElement("div");
	cObj.setAttribute("id","cdiv");
	cObj.style.position = "absolute";
	cObj.className="mydiv";
	cObj.style.zIndex = "1000";
	cObj.innerHTML="<img src='"+document.getElementById('upload_image').src+"'/>";
	document.body.appendChild(cObj);
	
}

//验证文件上传个数
function check_form_upload(fileType,num)
{
	if(fileType==0){
    	if(num>=20){alert("写真は20枚のみ掲載できます。");
		return false;}
    }else if(fileType==1){
    	  if(num>=1){alert("動画は1本のみ掲載できます。");
		return false;}
    }else if(fileType==2){
        	  if(num>=5){alert("PDFは5枚のみ掲載できます。");
		return false;}
    }else {return false;}
	return true;
}
//验证文件格式
function check_file_type(file_type,file_name){
	try{
		if(file_name==""){
			alert("アップロードするファイルを指定してください！");
			return false;
		}
		var filetype = file_name.substring(file_name.lastIndexOf("."),file_name.length);
  if(file_type==0){
    if(filetype.toUpperCase()!=".GIF"&&filetype.toUpperCase()!=".BMP"&&filetype.toUpperCase()!=".PNG"&&filetype.toUpperCase()!=".JPEG"&&filetype.toUpperCase()!=".JPG")
	    	{
	 			alert("このファイル形式はサポートしません！");
	 			return false;
	 		}
    }else if(file_type==1){
        if(filetype.toUpperCase()!=".MP4"&&filetype.toUpperCase()!=".FLV")
	    	{
	 			alert("このファイル形式はサポートしません！");
	 			return false;
	 		}
    }else if(file_type==2){
            if(filetype.toUpperCase()!=".PDF")
	    	{
	 			alert("このファイル形式はサポートしません！");
	 			return false;
	 		}
    }else {return false;}
	    return true;
    }catch(e){
    	alert("このファイル形式はサポートしません！");
    	return false;
    }
}

function resizeImage(tempImgId,fitWidth,fitHeight,i)
{
	//tempImg.style.display="none";
	var width=0,height=0,scale=1;
	var tempImg=document.getElementById(tempImgId);
	var imgs=new Image();
	imgs.src=tempImg.src;
	i=i+1;
	if(document.all)//如果是ie
	{
		if(tempImg.readyState=='complete')
		{
			//tempImg.style.display="block";
			width = imgs.width;//获取源图片宽,高
			height = imgs.height;
			//tempImg.style.display="none";
		}
		else
		{
			return false;
		}
	}
	else if(tempImg.complete)//fire fox ,netscape
	{
		width = imgs.width;
		height = imgs.height;
	}
	else
	{
		return false;
	}
	scale = width/height;//宽度比例因子
	//if(width > fitWidth)//等比例调整
	//{
 		width = fitWidth;
 		height = width/scale;  
 		if(height > fitHeight)
 		{
  			height = fitHeight;
  			width = height*scale;
 		}
	//}
	if(height > fitHeight)
	{
 		height = fitHeight;
 		width = height*scale;
	}
	//width=Math.round(width); 
	//height=Math.round(height);
	//alert("图片"+tempImg.src+"原宽："+tempImg.width+"原长："+tempImg.height +"现宽："+width+"现长："+height);
	tempImg.width = width;//调整后的宽,高
	tempImg.height = height;
	tempImg.style.display="block";
	if(i<10){
		
		setTimeout('resizeImage(\''+tempImgId+'\','+fitWidth+','+fitHeight+','+i+')',1000);
		}
	
  }
    function change_default_image(image_id,form_id,fileType,video_num,image_num,pdf_num){
    var file_type = document.getElementById(fileType).value;
    var file=document.getElementById('file').value;
    var form=document.getElementById(form_id);
    if(file_type==0){
      	if(check_form_upload(0,image_num)){
	  		if(check_file_type(0,file)){
		  		form.submit();
		  	}
  		}
    }else if(file_type==1){
      	if(check_form_upload(1,video_num)){
	  		if(check_file_type(1,file)){
		  		form.submit();
		  	}
  		}
    }else if(file_type==2){
      	if(check_form_upload(2,pdf_num)){
	  		if(check_file_type(2,file)){
		  		form.submit();
		  	}
  		}
    }else {return false;}
		
  }
  
  function replace_image(select_part,image_id,image_src)//image.jsp中的图片转换
  {
  	var cur=document.getElementById("current");
  	cur.id=cur.name;
  	var thispart=document.getElementById(select_part);
  	thispart.id="current";
  	//select_part.name="current";
  	var img=new Image();
  	var real_img=document.getElementById(image_id);
  	img.src=image_src;
  	resizeImage(img.id,652,490,4);
  	real_img.width=img.width;
  	real_img.height=img.height;
  	real_img.src=img.src;
  	
  	
  }

function changeImg(img_path){
	if(img_path!=""){
		document.getElementById("img_big").src = img_path;
	}
}
function bian(imgId){
	var img = document.getElementById(imgId);
	if(imgId=="b1"){
		img.src="images/b_img_1_1.gif"
	}
	if(imgId=="b2"){
		img.src="images/b_img_2_2.gif"
	}
	if(imgId=="b3"){
		img.src="images/b_img_3_3.gif"
	}
	if(imgId=="b4"){
		img.src="images/b_img_4_4.gif"
	}
	if(imgId=="b5"){
		img.src="images/b_img_5_5.gif"
	}
	if(imgId=="b6"){
		img.src="images/b_img_6_6.gif"
	}
	if(imgId=="b7"){
		img.src="images/b_img_7_7.gif"
	}
}
function huan(imgId){
	var img = document.getElementById(imgId);
	if(imgId=="b1"){
		img.src="images/b_img_1.gif"
	}
	if(imgId=="b2"){
		img.src="images/b_img_2.gif"
	}
	if(imgId=="b3"){
		img.src="images/b_img_3.gif"
	}
	if(imgId=="b4"){
		img.src="images/b_img_4.gif"
	}
	if(imgId=="b5"){
		img.src="images/b_img_5.gif"
	}
	if(imgId=="b6"){
		img.src="images/b_img_6.gif"
	}
	if(imgId=="b7"){
		img.src="images/b_img_7.gif"
	}
	
}