//添加到收藏夹
	function JSAddFavorite()
		{
			if ( window.sidebar && "object" == typeof( window.sidebar ) && "function" == typeof( window.sidebar.addPanel ) )
			{
				// firefox
				window.sidebar.addPanel( '欢乐美食网', 'http://www.hlmsw.cn/', '' );
			}
			else if ( document.all && "object" == typeof( window.external ) )
			{
				// ie
				window.external.addFavorite( 'http://www.hlmsw.cn/', '欢乐美食网' );
			}
		}
		
	//设置成主页
	function SetHomePage(sid,sUrl)
	{
		if(!sUrl) sUrl = "http://www.hlmsw.cn/";
		if(!sid) return false;
		
		if("function" == typeof(sid.setHomePage))
		{
			sid.style.behavior='url(#default#homepage)';
			sid.setHomePage(sUrl);
		}
		else
		{
			return false;
		}
		return true;
	}
	
	
	function ShowDivVisible(DivID,state)
	{	
		var DivRef =document.getElementById(DivID);
		if(state)
		{
			DivRef.style.display = "block";
		}
		else
		{
			DivRef.style.display = "none";
		}		
	}
	
	function ChkUserLogin()
	{
		if (document.forms["Form1"].elements["txtUserName"].value =="")
		{
			alert("请输入你的用户名！");
			document.forms["Form1"].elements["txtUserName"].focus();
			return false;
		}
		if (document.forms["Form1"].elements["txtPassword"].value =="")
		{
			alert("请输入你的密码！");
			document.forms["Form1"].elements["txtPassword"].focus();
			return false;
		}
		//return false;
	}

	function ChkNum()
	{
		if (event.keyCode <48 || event.keyCode>59)  
		{
			alert('请输入数字！'); 
			return false;
		}
		//event.returnValue = false;
	}
	
function by(id)
{
	return document.getElementById(id);
}
function $(id)
{
	return document.getElementById(id);
}
	
function searSub(){
$("keyword").value=$("keyword").value.replace(/(^\s*)/, "");
$("keyword").value=$("keyword").value.replace(/(\s*$)/, "");
if (/^请输入你要搜索的餐厅或酒楼名称的关键字$/.test($("keyword").value)){
$("keyword").value="";
alert("请输入关键字！");
$("keyword").focus();
return false;}
if ($("keyword").value.length<1||$("keyword").value.length>50){
alert("关键字字数只能在1到50个之间!");
$("keyword").select();
return false;}
return true;}

 
//图片按比例缩放

function DrawImage(ImgD){
var flag=false;
var image=new Image();
var iwidth = 550; //定义允许图片宽度，当宽度大于这个值时等比例缩小
var iheight = 413; //定义允许图片高度，当宽度大于这个值时等比例缩小
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
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;
}
}
}
 


