function showMoreSite()
{
	var divMoreCites=document.getElementById("moreCites");

	if(divMoreCites != null){
		divMoreCites.style.display="block";
	}
}

function getElement(objId)
{
	return document.getElementById(objId);
}

function showLocSelect(obj)
{
	var locdiv=getElement("locListDiv");

	if(locdiv.style.display=="block"){
		locdiv.style.display="none";
		return;
	}
	locdiv.style.display="block";
	var locs=locdiv.getElementsByTagName("li");
	for(var i=0;i<locs.length;i++)
	{
		var theloc=locs[i];
			theloc.onmouseover=function(){
				this.style.backgroundColor="#E0E5DF"
			}
			theloc.onmouseout=function(){
				this.style.backgroundColor="#E6F3C8"
			}
			theloc.onclick=function(){
				var locstr=this.innerHTML;
				if (locstr.indexOf(" ")!=-1)
				locstr=locstr.substr(0,locstr.indexOf(" ")); //fixbug 在IE下多出一个空格
				SetCookie("NTES_LocNewsAddr",locstr,365);
				setLocNews(locstr);
				hideLocSelect();
				var l=getElement("locbar");
				loadAJAXTab(l.getAttribute("urn"),l.getAttribute("rel"));			
			}
	}
}

function IsChild(cNode,pNode)
{
	while(cNode!=null){
		cNode=cNode.parentNode;
		if(cNode==pNode) return true; 
	}
	return false;
}

function hideLocSelect()
{
	getElement("locListDiv").style.display="none";
}

function hideCitySelect()
{
	getElement("cityListDiv").style.display="none";
}

document.onmousedown=function(aEvent)
{
	var myEvent = window.event ? window.event : aEvent;
	var lo=getElement("locListDiv");
	var city=getElement("cityListDiv");
	if(!IsChild(myEvent.srcElement,lo))hideLocSelect();
	if(!IsChild(myEvent.srcElement,city))hideCitySelect();
}

function selectAll(objSelf)
{
  selectSite(objSelf.checked);
}

function selectSite(val){
	var sites=document.all("postcode");
//	alert(sites.length);
	if(sites !=null){
		for(i=0;i<sites.length;i++){
			sites[i].checked=val;
	 	}
	}
}

function siteClick(objSelf){
	if(objSelf.checked){
		checkSel();
	}else{
		var siteAll=getElement("siteAll");
		siteAll.checked=false;
	}
}

/**
检查是否选择了所有城市，如果选择了所有城市，则将“全部”置为选中状态。
*/
function checkSel(){
	var sites=document.all("postcode");
	var selAll=true;
	if(sites !=null){
		for(i=0;i<sites.length;i++){
			if(!sites[i].checked){
				selAll=false;
				break;
			}
		}
	}  
	getElement("siteAll").checked=selAll;
}

function before_search(){
//	alert("before_search");
	if(document.all("searchword").value==""){
		 alert("请输入检索词！");
		 document.all("searchword").focus();
		 return false;
	}
	setSearchChannel();
//	alert(document.all("channelid").value);
	return true;
}

function setSearchChannel(){
	var allSrh=getElement("siteAll");
	if(allSrh.checked){
		document.all("channelid").value=allSrh.value;
  }else{
  	var sites=document.all("postcode");
  	var searhcchannels="";
  	for(i=0;i<sites.length;i++){
  		if(sites[i].checked){
  			if(searhcchannels==""){
  				searhcchannels=sites[i].value;
  			}else{
  				searhcchannels= searhcchannels +"," + sites[i].value;
	 	  	}
  		}
  	} 
	 if(searhcchannels !=""){ document.all("channelid").value=searhcchannels};	  
  }
}
