//图片大小自动适应
function ChkImgSize(strImg,iWidth,iHeight)
{

	imgObj = new Image();
	imgObj.src = strImg;
	

	if (imgObj.width <= imgObj.height)
	{
		document.write("<img src='"+ strImg +"' height='"+ iHeight +"' border='0' style='overflow:hidden; max-width:" + iWidth + "; max-height="+ iHeight +"'>");
	}
	else
	{
		document.write("<img src='"+ strImg +"' width='"+ iWidth +"' border='0' style='overflow:hidden; max-width:" + iWidth + "; max-height="+ iHeight +"'>");
	}
	
}
//图片缩放函数
function ResizeImg(ImgD,iwidth,iheight)
{
	var image=new Image();
	image=ImgD;
	
	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;
			}
			
		}
		else
		{
			if(image.height>iheight)
			{
				  ImgD.height=iheight;
				  ImgD.width=(image.width*iheight)/image.height;
			}
			else
			{
			   ImgD.width=image.width;
			   ImgD.height=image.height;
			}
		}
	}
	
}
//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 over_change(src){
		if (!src.contains(event.fromElement)) 
	 		{ 
			src.style.background="url(../images/style_1/thismenu_bg.gif)";
	 		}
}
function out_change(src){
		if (!src.contains(event.toElement))
			{
			src.style.background="";
			}
}


function reSizepanelframe(i){
  document.all.panelframe.height = i;
	}

function turnPage(page)
{
	form1.page.value=page;
	form1.submit();
}
function JHshNumberText()
{
	if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) 
	|| (window.event.keyCode == 13) || (window.event.keyCode == 46) 
	|| (window.event.keyCode == 45)))
	{
		window.event.keyCode = 0 ;
	}
}

//上传图片比例控制
function chkUploadImgBl(iValue)
{
    if(iValue=="1")
    {
        document.getElementById("iWidth").value="150";
        document.getElementById("iHeight").value="150";
        document.getElementById("TmpiWidth").value="150";
        document.getElementById("TmpiHeight").value="150";
    }
    else if(iValue=="2")
    {
        document.getElementById("iWidth").value="150";
        document.getElementById("iHeight").value="115";
        document.getElementById("TmpiWidth").value="150";
        document.getElementById("TmpiHeight").value="115";
    }
    else if(iValue=="3")
    {
        document.getElementById("iWidth").value="115";
        document.getElementById("iHeight").value="150";
        document.getElementById("TmpiWidth").value="115";
        document.getElementById("TmpiHeight").value="150";
    }
    else
    {
        document.getElementById("iWidth").value="150";
        document.getElementById("iHeight").value="150";
        document.getElementById("TmpiWidth").value="150";
        document.getElementById("TmpiHeight").value="150";
    }
}