/*显示菜单*/
function turnit(n)
{
	if (getObject("bb"+n).style.visibility == "hidden") 
	{
		getObject("bb"+n).style.visibility="visible"
		if (n==1) 
		{
		 var tmp = getObject('menutxt'+n).value
		 menulogin(tmp)
		}
	}
	else
	{
		getObject("bb"+n).style.visibility="hidden"
	}

}

/*移到菜单区*/
function over1 (n){
	 getObject("bb"+n).style.visibility="visible"
}

/*选中选项*/
function sele(n,m,mNav)
{

	var oValue=document.all.menutxt2.value;
	
	var tmpstr = ""
	var ss = getObject('t'+n+"_"+m).innerHTML
	var k = ss.replace(" ","")
	
	getObject('menutxt'+n).value=k;
	menulogin(k)
	
	//判断城市是否变化
	var nValue=document.all.menutxt2.value;
	if (nValue !=oValue)
	{
		if (mNav == "index")
		{
			window.location.href="indexPage.jsp?CITYNAME=" + nValue;
		}
		if (mNav == "search")
		{
			//var szOrptHref="getCityList.jsp?CITYNAME=" + nValue;
			//var szOrptHref="http://" + location.host + "/chihe/getCityList.jsp?CITYNAME=" + nValue;
			//var szOrptHref="http://map.sogou.com/sohu/chihe/getCityList.jsp?CITYNAME=" + nValue;
			//document.all.scriptOprtAsp.src = szOrptHref;
			
			
			var m_Response="999999!!全部,";
			
			if (nValue=="北京市")
			{
				m_Response+="100000!!海淀区,100001!!西城区,100002!!东城区,100003!!朝阳区,100004!!崇文区,100005!!宣武区,100006!!丰台区,100007!!石景山区,100008!!怀柔区,100009!!昌平区,100010!!平谷区,100011!!大兴区,100012!!通州区,100013!!顺义区,100014!!房山区,100015!!门头沟区,100016!!延庆县,100017!!密云县,";
			}
			if (nValue=="上海市")
			{
				m_Response+="101000!!奉贤区,101001!!松江区,101002!!青浦区,101003!!南汇区,101004!!金山区,101005!!虹口区,101006!!闸北区,101007!!普陀区,101008!!黄浦区,101009!!静安区,101010!!卢湾区,101011!!长宁区,101012!!徐汇区,101013!!嘉定区,101014!!闵行区,101015!!浦东新区,101016!!杨浦区,101017!!宝山区,101018!!崇明县,";

			}
			if (nValue=="广州市")
			{
				m_Response+="102000!!越秀区,102001!!海珠区,102002!!天河区,102003!!黄埔区,102004!!萝岗区,102005!!白云区,102006!!荔湾区,102007!!南沙区,102008!!番禺区,102009!!花都区,102010!!增城市,102011!!从化市,";
			}
			if (nValue=="成都市")
			{
				m_Response+="103000!!新都区,103001!!邛崃市,103002!!都江堰市,103003!!金牛区,103004!!锦江区,103005!!温江区,103006!!成华区,103007!!龙泉驿区,103008!!武侯区,103009!!青白江区,103010!!崇州市,103011!!青羊区,103012!!彭州市,103013!!大邑县,103014!!金堂县,103015!!双流县,103016!!新津县,103017!!浦江县,103018!!郫县,";
			}
			getLocation(m_Response);
		}
		
	}

}

// 获取区域列表处理函数
function getLocation(szMobile)
{
	var aryResItem;
	var i;
	var vName;
	var vHTML='';
	var iSer=1;
	
	//alert(szMobile);
	
	if (szMobile != 'SF')
	{
		aryResItem = szMobile.split(",");
		for (i=0;i<aryResItem.length-1;i++)
		{
			vName=aryResItem[i].split("!!")[1]; 		
			vHTML+="<li style=cursor:pointer;text-indent:4px id=t3_" +  iSer + " onmouseover =over(3," +  iSer + ") onclick=sele(3," +  iSer + ",'search') onmouseout=out1(3," +  iSer +")>" + vName + "</li>"
			iSer++;
		}
		_el("cmbRegion").innerHTML=vHTML;
		_el("menutxt3").value = aryResItem[0].split("!!")[1]; 
		if (iSer <15)
		{
			_el("cmbRegion").style.height='200px';
		}
		else
		{
			_el("cmbRegion").style.height='280px';
		}
	}
}


/*移动上选项上*/
function over(n,m){
getObject('t'+n+"_"+m).className='ss'
}
/*离开选项上*/
function out1(n,m){
getObject('t'+n+"_"+m).className=''
}
/*离开菜单区*/
function out(cont)
{ 	 
	var i=1;
	if (cont==2) i=1;
	if (cont>=3) i=2;
	for (;i<=cont;i++) {
	getObject('bb'+i).style.visibility="hidden"
	}
}

/*用户登录区菜单*/
function menulogin(n){
	var menuOpt = new Array ("ChinaRen用户","搜狐用户","手机用户")
	var tmpstr = ""
	for (var i=0;i<3;i++) {
		if (menuOpt[i]!=n) {
			tmpstr+="<li style='cursor:pointer;height:17px;padding-top:3px;text-indent:4px' id='t1_"+i+"' onmouseover =over(1,"+i+") onclick=sele(1,"+i+") onmouseout=out1(1,"+i+")>"+menuOpt[i]+"</li>"
		}
	}
	var start = "<ul style='width:100%;margin:0;padding:0'>"
	var end = "</ul>"
	var str = start + tmpstr + end
	getObject("bb1").innerHTML = str
}


/*=============搜索菜单选项================*/

	function sn(n)
	{
		for (i=2;i<=8;i+=2) {
			if (i == n) {
			getObject("z1_"+i).className="xyl4 lh22 bg01";
			getObject("z1_"+(i-1)).style.display="none"
			getObject("z1_"+(i+1)).style.display="none"
			if(n!=2) getObject("z1_1").style.display=""
			}
			else
			{
			getObject("z1_"+i).className="xyl1 lh22";
			getObject("z1_"+(i+1)).style.display=""
			}
		}
		
	}
	function getObject(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
}

	function menu(n) {
		var menutab = new Array ("menutab1","menutab2","menutab3")
		var mt = new Array ("mt1","mt2","mt3")
		for (var i=0;i<=3;i++) {
			if (i==n) {
				getObject(mt[i]).className="menubg a"
				getObject(menutab[i]).style.display=""
			}else
			{
				getObject(mt[i]).className="b"
				getObject(menutab[i]).style.display="none"
			}
		}
		
	}

//*****************************************************************czw*******************************************
		
	function mtCollect()
	{
		window.external.addFavorite('http://'+ location.host + '/' , '吃喝玩乐');
	}
	
	function goToSearch(pAction)
	{
		var vKeyWhat=_el("keyWhat").value;

		_el("keyWhat").value=vKeyWhat;
		if (vKeyWhat == '')
		{
			
		}
		_el("frmSearchBar").submit();	
	}
	
	function mtPagePre()
	{
		var nPage=document.all.page.value;
		var iPage=parseInt(nPage);
		_el("page").value=iPage-1;
		_el("frmSearchBar").submit();
	}
	
	function mtPageNext()
	{
		var nPage=document.all.page.value;
		var iPage=parseInt(nPage);
		_el("page").value=iPage+1;
		_el("frmSearchBar").submit();
	}
	function mtPageFirst()
	{
		_el("page").value=1;
		_el("frmSearchBar").submit();
	}
	function mtPageLast()
	{
		_el("page").value=99999999;
		_el("frmSearchBar").submit();
	}
	function OnKeyDownWhenKeyWhat()
	{
		var keyChar = event.keyCode;
		if (keyChar=="13"){
			goToSearch();
		}
	}
	
	function addComment()
	{
		var tmp =_el("txtComTaste").value;
		var intS=parseInt(tmp);

		if (tmp!='')
		{
			if (isNaN(intS))
			{
				alert('请输入有效数字,评分范围1到5.');
				_el("txtComTaste").focus();
				return false;
			}
			if (intS<1 || intS>5)
			{
				alert('请输入有效数字,评分范围1到5.');
				d_el("txtComTaste").focus();
				return false;
			}
		}
		else
		{
			_el("txtComTaste").value='0';
		}
		

		tmp =_el("txtEnvironment").value;
		intS=parseInt(tmp);
		if (tmp != '')
		{
			if (isNaN(intS))
			{
				alert('请输入有效数字,评分范围1到5.');
				_el("txtEnvironment").focus();
				return false;
			}
			if (intS<1 || intS>5)
			{
				alert('请输入有效数字,评分范围1到5.');
				_el("txtEnvironment").focus();
				return false;
			}
		}
		else
		{
			_el("txtEnvironment").value='0';
		}

		
		
		tmp =_el("txtComService").value;
		intS=parseInt(tmp);
		if (tmp != '')
		{
			if (isNaN(intS))
			{
				alert('请输入有效数字,评分范围1到5.');
				_el("txtComService").focus();
				return false;
			}
			if (intS<1 || intS>5)
			{
				alert('请输入有效数字,评分范围1到5.');
				_el("txtComService").focus();
				return false;
			}
		}
		else
		{
			_el("txtComService").value='0';
		}
		
		
		tmp =_el("txtComPrice").value;
		intS=parseInt(tmp);
		if (tmp != '')
		{
			if (isNaN(intS))
			{
				alert('请输入有效数字,评分范围1到5.');
				_el("txtComPrice").focus();
				return false;
			}
			if (intS<1 || intS>5)
			{
				alert('请输入有效数字,评分范围1到5.');
				_el("txtComPrice").focus();
				return false;
			}
		}
		else
		{
			_el("txtComPrice").value='0';
		}

		tmp =_el("txtComment").value;
		if (tmp.trueLength() <1  || tmp.trueLength() >1023 )
		{
			alert('请填写有效的评论内容,请不要超过1024个字符!');
			_el("txtComment").focus();
			return false;
		}
	
		_el("frmSearchBar").action="finalPage.jsp";
		_el("oAction").value="2";
		_el("txtComTaste").value=_el("txtComTaste").value + ","+ _el("txtEnvironment").value + "," + _el("txtComService").value+ "," +_el("txtComPrice").value
		_el("frmSearchBar").submit();
	}
	
	function mtSeeComment()
	{
			_el("frmSearchBar").action="finalPage.jsp";
			_el("oAction").value="5";
			_el("frmSearchBar").submit();
	}
	
	function mtHotSearch(pHotName)
	{
			_el("keyWhat").value=pHotName;
			_el("frmSearchBar").action="searchPage.jsp";
			_el("oAction").value="2";
			_el("frmSearchBar").submit();
	}
	
	function mtHighLightOne(pDATAID)
	{
		highLight.submit(pDATAID);
	}
	
	function mtChangeAction(mAction)
	{
		_el("oAction").value=mAction;	
	}
	
	function _el(a){return document.getElementById(a)}