function $(id)
{
 return document.getElementById(id);
}
//默认选中
function Selected(obj,value)
{
  for(var i=0;i<document.getElementById(obj).options.length;i++)
        { 
         if(document.getElementById(obj).options[i].value==value)
         {
            document.getElementById(obj).options[i].selected=true;break;
         }   
       }
}
//下拉框添加option obj，对象名，str,以逗号分隔的ID和VALUE value：开头的第一个默认选项
 function addOption(obj,str,value)
  {

    var strArr = str.split(',');
    document.all(obj).length=0;
      if(value!=0)
      {
      document.getElementById(obj).options.add(new Option(value,"0"));
      }
    for(var i = 0 ;i<strArr.length-1;i+=2)
    {
     document.getElementById(obj).options.add(new Option(strArr[i+1],strArr[i]));
    }
  }
  //图片等比缩放
var flag=false; 
function DrawImage(ImgD,width,height){ 
  if(!ImgD)
   {
    return false;
   }
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
  flag=true; 
  if(image.width/image.height>= width/height){ 
   if(image.width>width){
    ImgD.width=width; 
    ImgD.height=(image.height*width)/image.width; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  // ImgD.alt=image.width+"x"+image.height; 
  } 
  else{ 
   if(image.height>height){
    ImgD.height=height; 
    ImgD.width=(image.width*height)/image.height; 
   }else{ 
    ImgD.width=image.width;
    ImgD.height=image.height; 
   } 
  // ImgD.alt=image.width+"x"+image.height; 
  } 
 }
}
