
function change_image(image_url,image_id,video_id,image,link_id,src_image,link_url){
	if(image!=''){
		var img=document.getElementById(image);
		document.getElementById(video_id).style.display="none";
		document.getElementById(image_id).style.display="block";
		
		document.getElementById(image).src=image_url;
		document.getElementById(link_id).href=link_url;
		var so = new SWFObject("/style/player.swf", "cqlFlash", "100%", "100%", "9", "#FFFFFF");
		so.addParam("allowScriptAccess", "always");
		so.addParam("allowFullScreen","true");
		so.addParam("wmode", "Opaque");
		so.addParam("flashvars","file=");
		so.write(video_id);
		//alert(document.getElementById(image_id).width);
		if(src_image!=''){
			var srcimage=document.getElementById(src_image);
			img.width=srcimage.width;
			img.height=srcimage.height;
			resizeImage(img.id,470,353,4);
		}
	}else{
		document.getElementById(image_id).style.display="none";
		document.getElementById(video_id).style.display="block";
		var so = new SWFObject("/style/player.swf", "cqlFlash", "100%", "100%", "9", "#FFFFFF");
		so.addParam("allowScriptAccess", "always");
		so.addParam("allowFullScreen","true");
		so.addParam("wmode", "Opaque");
		so.addParam("flashvars","file="+image_url);
		so.write(video_id);
	}
}




function change_image_provider(image_url,image_id,video_id,image,link_id,src_image,link_url){
	if(image!=''){

		var div=document.getElementById(image_id);
		div.style.display="block";
		div.innerHTML="<table width='470' height='353' border='0' cellpadding='0' cellspacing='0'><tr><td align='center' valign='middle'><img id=\'"+image+"\' src=\'"+image_url+"\' id=\'myprovider_img\' width=\'470\' height=\'353\' onload=\'resizeImage(this.id,470,353,0);\' /></td></tr></table>";
	}else{
	
		document.getElementById(video_id).style.display="block";
		var so = new SWFObject("/style/player.swf", "cqlFlash", "100%", "100%", "9", "#FFFFFF");
		so.addParam("allowScriptAccess", "always");
		so.addParam("allowFullScreen","true");
		so.addParam("wmode", "Opaque");
		so.addParam("flashvars","file="+image_url);
		so.write(video_id);
	}
}

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,select_type,video_num,image_num,isprovider){
  	var  ispic=1;
  	if(document.getElementById(select_type).value=='1')
  		ispic=0;
  	if(check_form_upload(select_type,video_num,image_num,isprovider)){
  		var file=document.getElementById('file').value;
  		if(check_file_type(ispic,file)){
	  		display_image();
	  		var form=document.getElementById(form_id);
	  		form.submit();
	  	}
  	}
  	//return true;
  }
  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 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'+languageHobby).src+"'/>";
	document.body.appendChild(cObj);
	
}
