//跳转菜单
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//弹出窗口
function newin (url,w,h){
	window.open(url,"","toolbar=no,width="+w+",height="+h+",directories=no,status=no,scrollbars=yes,resizable=no,menubar=no")
}

//自动跳动图片大小
function ReImgSize()
{
	for (i=0;i<document.images.length;i++)
	{
		if (document.getElementsByTagName("*"))
		{
			if (document.images[i].width>530)
			{
				if(document.images[i].style.width!="100%")
				{
					document.images[i].height = Number(document.images[i].height)*550/Number(document.images[i].width);
					document.images[i].width = "530";
					document.images[i].border = "0";
					document.images[i].outerHTML="<a href='"+document.images[i].src+"' target='_blank' title='在新窗口打开图片'>"+document.images[i].outerHTML+"</a>"
				}
			}
		}else{
			if (document.images[i].width>500)
			{
				document.images[i].title="在新窗口打开图片";
				document.images[i].style.cursor="pointer";
				document.images[i].onclick=function(e){window.open(this.src)};
			}
		}
	}
}

//控制商品详细页图片大小自动缩略
function Wa_SetImgAutoSize(img,w,h) 
{ 
	//var img=document.all.img1;//获取图片
	var MaxWidth=w;//设置图片宽度界限 
	var MaxHeight=h;//设置图片高度界限 
	var HeightWidth=img.offsetHeight/img.offsetWidth;//设置高宽比 
	var WidthHeight=img.offsetWidth/img.offsetHeight;//设置宽高比 
	if(img.readyState!="complete")return false;//确保图片完全加载

	if(img.offsetWidth>0)
	{
		if(img.offsetWidth>MaxWidth){ 
			img.width=MaxWidth; 
			//img.removeAttribute("height");
			//img.addAttribute("height",MaxWidth*HeightWidth); 
			img.height=MaxWidth*HeightWidth;
		}
		if(img.offsetHeight>MaxHeight){ 
			img.height=MaxHeight; 
			//img.removeAttribute("width");
			img.width=MaxHeight*WidthHeight; 
			//img.addAttribute("width",MaxHeight*WidthHeight);
		}
	}
	else
	{
		setTimeout(function() {Wa_SetImgAutoSize(img,w,h);},50);
	}
}

function Wa_SetImgAutoSize2(img,w,h) 
{ 
	//var img=document.all.img1;//获取图片 
	var MaxWidth=w;//设置图片宽度界限 
	var MaxHeight=h;//设置图片高度界限 
	var HeightWidth=img.offsetHeight/img.offsetWidth;//设置高宽比 
	var WidthHeight=img.offsetWidth/img.offsetHeight;//设置宽高比 
	if(img.readyState!="complete")return false;//确保图片完全加载 
	if(img.offsetWidth>MaxWidth){ 
		img.width=MaxWidth; 
		img.height=MaxWidth*HeightWidth; 
	} 
	if(img.offsetHeight>MaxHeight){ 
		img.height=MaxHeight; 
		img.width=MaxHeight*WidthHeight; 
	} 
}
