<!--
/*
*验证输入的数量是不是有效值
*可在输入框中加入onKeyUp="checkNums(form,menuname)"
*/
function checkNums(form,menuname){
 box = eval("form."+menuname);
if (box.value==0 && box.value==""){
	alert("请输入数量！");box.focus();box.select();box.value=1;return;
}
	str=box.value;
	var Expression=/^[1-9]+(\d*$)/; 	
	var objExp=new RegExp(Expression);
	if(objExp.test(str)==false){
		alert("您输入的不是有效值（请输入自然数）！");box.focus();box.select();box.value=1;return;
	}
}


// 图片 自动 按比例缩小 onload="DrawImage(this)" 
function DrawImagev(img,width,height){ 
var MaxWidth=width;//设置图片宽度界限
var MaxHeight=height;//设置图片高度界限
var HeightWidth=img.offsetHeight/img.offsetWidth;//设置高宽比
var WidthHeight=img.offsetWidth/img.offsetHeight;//设置宽高比
if(img.offsetWidth>MaxWidth){
img.width=MaxWidth;
img.height=MaxWidth*HeightWidth;
}
if(img.offsetHeight>MaxHeight){
img.height=MaxHeight;
img.width=MaxHeight*WidthHeight;
}
}



function   DrawImage(ImgD,iwidth,iheight){   
  var   image=new   Image();   
  image.src=ImgD.src;   
  if(image.width>0&&image.height>0){     
      if(image.width/image.height>=iwidth/iheight){   
           if(image.width>iwidth){     
           ImgD.width=iwidth;   
           ImgD.height=(image.height*iwidth)/image.width;   
           }else{   
           ImgD.width=image.width;     
           ImgD.height=image.height;   
           }   
     ImgD.alt=image.width+"×"+image.height;   
     }else{   
           if(image.height>iheight){     
           ImgD.height=iheight;   
           ImgD.width=(image.width*iheight)/image.height;     
           }else{   
           ImgD.width=image.width;     
           ImgD.height=image.height;   
           }   
     ImgD.alt=image.width+"×"+image.height;   
     }   
  }   
}



//显示放大图
var iDivHeight = 320; //放大显示区域宽度
var iDivWidth = 420;//放大显示区域高度
var iMultiple = 1; //放大倍数

//显示放大图，鼠标移动事件和鼠标点击事件都会调用本事件
//参数：src代表缩略图，sFileName放大图片名称
//原理：依据鼠标对应缩略图左上角（0，0）上的位置控制放大图左上角对应显示区域左上角（0，0）的位置
function show(ob)
{
//判断鼠标事件产生时是否同时按下了
if ((event.button == 1) && (event.ctrlKey == true))
iMultiple -= 1;
else
if (event.button == 1)
iMultiple += 1;
if (iMultiple < 2) iMultiple = 2;

if (iMultiple > 14) iMultiple = 14;

var iPosX, iPosY; //放大图对应显示区域左上角的坐标
var iMouseX = event.offsetX; //鼠标对应缩略图左上角的横坐标
var iMouseY = event.offsetY; //鼠标对应缩略图左上角的纵坐标
var iBigImgWidth = ob.clientWidth * iMultiple; //放大图宽度，是缩略图的宽度乘以放大倍数
var iBigImgHeight = ob.clientHeight * iMultiple; //放大图高度，是缩略图的高度乘以放大倍数
if (iBigImgWidth <= iDivWidth)
{
iPosX = (iDivWidth - iBigImgWidth) / 2;
}
else
{
if ((iMouseX * iMultiple) <= (iDivWidth / 2))
{
iPosX = 0;
}
else
{
if (((ob.clientWidth - iMouseX) * iMultiple) <= (iDivWidth / 2))
{
iPosX = -(iBigImgWidth - iDivWidth);
}
else
{
iPosX = -(iMouseX * iMultiple - iDivWidth / 2);
}
}
}

if (iBigImgHeight <= iDivHeight)
{
iPosY = (iDivHeight - iBigImgHeight) / 2;
}
else
{
if ((iMouseY * iMultiple) <= (iDivHeight / 2))
{
iPosY = 0;
}
else
{
if (((ob.clientHeight - iMouseY) * iMultiple) <= (iDivHeight / 2))
{
iPosY = -(iBigImgHeight - iDivHeight);
}
else
{
iPosY = -(iMouseY * iMultiple - iDivHeight / 2);
}
}
}
div1.style.display = "block";
div1.style.height = iDivHeight;
div1.style.width = iDivWidth;

if (div1.innerHTML == "")
{
div1.innerHTML = "<img id=BigImg style='position:relative'>";
BigImg.src = ob.src;
}
BigImg.width = iBigImgWidth;
BigImg.height = iBigImgHeight;
BigImg.style.top = iPosY;
BigImg.style.left = iPosX;
}


//--> 

