/*按比例生成缩略图*/
function DrawImage(MyPic,W,H){
  var flag=false;
  var image=new Image();
  image.src=MyPic.src;
  if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= W/H){
      if(image.width>W){  
        MyPic.width=W;
        MyPic.height=(image.height*W)/image.width;
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
    else{
      if(image.height>H){  
        MyPic.height=H;
        MyPic.width=(image.width*H)/image.height;     
      }
	  else{
        MyPic.width=image.width;  
        MyPic.height=image.height;
      }
    }
  }
} 

/*FLASH*/
function banner(Url,width,height,wmode,menuNum )
{
document.write("<embed src="+ Url +" width="+ width +" height="+ height +" quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode="+ wmode +" "+"flashvars='menuNum="+menuNum+"'" + "/>")
}


function subform_onsubmit() {
if (document.subform.RealName.value=="")
	{
	  alert("联系人不能为空。")
	  document.subform.RealName.focus()
	  return false
	 }
else if(document.subform.Address.value=="")
	{
	  alert("联系地址不能为空。")
	  document.subform.Address.focus()
	  return false
	 }
else if(document.subform.Telephone.value=="")
	{
	  alert("联系电话不能为空。")
	  document.subform.Telephone.focus()
	  return false
	 }
	 
else if(document.subform.Email.value.length!=0)
  {
    if (document.subform.Email.value.charAt(0)=="." ||        
         document.subform.Email.value.charAt(0)=="@"||       
         document.subform.Email.value.indexOf('@', 0) == -1 || 
         document.subform.Email.value.indexOf('.', 0) == -1 || 
         document.subform.Email.value.lastIndexOf("@")==document.subform.Email.value.length-1 || 
         document.subform.Email.value.lastIndexOf(".")==document.subform.Email.value.length-1)
     {
      alert("Email地址格式不正确！");
      document.subform.Email.focus();
      return false;
      }
   }
 else
  {
   alert("Email不能为空！");
   document.subform.Email.focus();
   return false;
   }	 	 
}

function ConfirmDel(message)
{
   if (confirm(message))
   {
      document.form1.submit()
   }
}

/*IE6 下透明PNG */

function correctPNG()  
{ 
for(var i=0; i<document.images.length; i++) 
{ 
  var img = document.images[i] 
  var imgName = img.src.toUpperCase() 
  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
  { 
   var imgID = (img.id) ? "id='" + img.id + "' " : "" 
   var imgClass = (img.className) ? "class='" + img.className + "' " : "" 
   var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 
   var imgStyle = "display:inline-block;" + img.style.cssText  
   if (img.align == "left") imgStyle = "float:left;" + imgStyle 
   if (img.align == "right") imgStyle = "float:right;" + imgStyle 
   if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle   
   var strNewHTML = "<span " + imgID + imgClass + imgTitle 
   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
   + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"  
   img.outerHTML = strNewHTML 
   i = i-1 
  } 
} 
} 
window.attachEvent("onload", correctPNG); 

function OpenScript(url,width,height)
{
  //var win = window.open(url,"SelectToSort",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no' );
  showModalDialog(url, "", "dialogWidth:"+ width +"px; dialogHeight:"+ height +"px; status:yes; help:no; ");
}


