/*按比例生成缩略图*/
function DrawImage(ImgD,W,H){ 
  var flag=false; 
  var image=new Image(); 
  image.src=ImgD.src; 
  if(image.width>0 && image.height>0){ 
    flag=true; 
    if(image.width/image.height>= W/H){ 
      if(image.width>W){
        ImgD.width=W; 
        ImgD.height=(image.height*H)/image.width; 
      }
	  else{ 
        ImgD.width=image.width;
        ImgD.height=image.height; 
      } 
      ImgD.alt= ""; 
    } 
    else{ 
      if(image.height>H){
        ImgD.height=H; 
        ImgD.width=(image.width*W)/image.height; 
      }
	  else{ 
        ImgD.width=image.width;
        ImgD.height=image.height; 
      } 
      ImgD.alt=""; 
    } 
  }
}
//显示页面前
function show_img(){
	//document.styleSheets();
	var k=document.readyState;
	var obj=document.getElementById("info");
	if(k=="loading"){
		obj.style.display="block";
		
	}else{
		obj.style.display="none";
		setTimeout(show,100)
	}
}

function preloadimg(url,obj,wid,hei){
var img=new Image();
obj.innerHTML="<img src=include/loading.gif border=0 />";
img.onload=function(){obj.innerHTML="";obj.style.width=wid+"px";obj.style.height=hei+"px";obj.appendChild(img);};
img.onerror=function(){obj.innerHTML="图片加载失败!"};
img.src=url; //img.src一定要写在img.onload之后，否则在IE中会出现问题
}
//function show1(){
//var div=document.getElementById("pic");
//var div=document.getElementsByTagName("div")[0];
//var input=document.getElementsByTagName("input");
//preloadimg("images/ffffbb.jpg",div,329,239);
//input[0].onclick=function(){this.value=""};
//input[1].onclick=function(){preloadimg(input[0].value,div,input[0]);}
//}
//window.onload=show1;
function zifu(filed,maxzi)
{  
	if (filed.value.length>maxzi)
	{
		alert("你输入的字数不已经超过了300");
		filed.value=filed.value.substring(0,maxzi);
		
	}
	else
	{
		document.getElementById("letter").innerHTML=""+maxzi - filed.value.length+"";
		document.getElementById("counter2").innerHTML=""+filed.value.length+"";
	}
}