
var xmlHttp;

function surportOrOpp(id,type){
	
		createXMLHttpRequest();
		var url="/news/supportOrOpp.do?newsId="+id+"&type="+type;
		
		xmlHttp.open("GET", url, true);
		
		xmlHttp.onreadystatechange = handleSurpotOrOpp;
   	
		xmlHttp.send(null);
	
	
}


function handleSurpotOrOpp(){

if(xmlHttp.readyState == 4) {
        	if(xmlHttp.status == 200) {
       	
        		var xmlDoc=xmlHttp.responseXML;
				      			
        		var resluts=xmlDoc.getElementsByTagName("result");
        		  
        		
        		
        		if(resluts.length!=0){
        	
        			var surportCount=resluts[0].getAttribute("surportCount");
        			
        			var oppCount=resluts[0].getAttribute("oppCount");
        			
        			
        			document.getElementById("surportCount1").innerHTML=surportCount;
        			document.getElementById("oppCount1").innerHTML=oppCount;
        			
        			document.getElementById("surportCount2").innerHTML=surportCount;
        			document.getElementById("oppCount2").innerHTML=oppCount;
        			
        			
        		}
        	}
        }
}

//搜索类型变更时，更改分类列表
function conTypeChange(){
	
	var conType=document.getElementsByName("conType")[0];
	
	var typeId=document.getElementsByName("typeId")[0];
	
	
	if(conType.value=='news'){
		typeId.length=0;
		addNewsItem(typeId);

	}
	
	else if(conType.value=='product'){
		typeId.length=0;
		
		addProduct(typeId);
	
	}
	else if(conType.value=='project'){
	
		typeId.length=0;
	
		addProject(typeId);

	}
	
}

function addProject(typeId){
	   	var op=document.createElement('option');
			
		op.text="工程案例";
		
		op.value="37";
		try
   		 {
    		typeId.add(op,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op);
   		 }
}

function addProduct(typeId){
		var op=document.createElement('option');
			
		op.text="所有分类";
		
		op.value="0";
		try
   		 {
    		typeId.add(op,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op);
   		 }
	
	
		var op1=document.createElement('option');
			
		op1.text="配管配线工程";
		
		op1.value="71";
		try
   		 {
    		typeId.add(op1,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op1);
   		 }
   		 
   		 var op2=document.createElement('option');
			
		op2.text="通信、计算机网络系统设备安装工程";
		
		op2.value="72";
		try
   		 {
    		typeId.add(op2,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op2);
   		 }
   		 
   		 var op3=document.createElement('option');
			
		op3.text="建筑设备监控系统安装工程";
		
		op3.value="73";
		try
   		 {
    		typeId.add(op3,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op3);
   		 }
   		 
   		 var op4=document.createElement('option');
			
		op4.text="有线、卫星电视接收系统设备安装工程";
		
		op4.value="74";
		try
   		 {
    		typeId.add(op4,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op4);
   		 }
   		 
   		 var op5=document.createElement('option');
			
		op5.text="音响、会议系统设备安装工程";
		
		op5.value="75";
		try
   		 {
    		typeId.add(op5,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op5);
   		 }
   		 
   		 var op6=document.createElement('option');
			
		op6.text="电源与电子设备防雷接地装置安装";
		
		op6.value="76";
		try
   		 {
    		typeId.add(op6,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op6);
   		 }
   		 
   		 var op7=document.createElement('option');
			
		op7.text="智能识别管理系统设备安装工程";
		
		op7.value="77";
		try
   		 {
    		typeId.add(op7,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op7);
   		 }
   		 
   		 var op8=document.createElement('option');
			
		op8.text="安全防范系统设备安装工程";
		
		op8.value="78";
		try
   		 {
    		typeId.add(op8,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op8);
   		 }
   		 
   		 var op9=document.createElement('option');
			
		op9.text="综合设备安装工程";
		
		op9.value="79";
		try
   		 {
    		typeId.add(op9,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op9);
   		 }
}


//添加新闻的元素
function addNewsItem(typeId){

		var op=document.createElement('option');
			
		op.text="所有分类";
		
		op.value="0";
		try
   		 {
    		typeId.add(op,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op);
   		 }

		var op1=document.createElement('option');
			
		op1.text="人物专访";
		
		op1.value="31";
		try
   		 {
    		typeId.add(op1,null);
   		 }
  		catch(ex)
   		 {
    		typeId.add(op1);
   		 }
		
		
		
		var op2=document.createElement('option');
		op2.text="行业新闻";
		op2.value="32";
		try{
			typeId.add(op2,null);
		}
		catch(ex){
			typeId.add(op2);
		}
		
		var op3=document.createElement('option');
		op3.text="会展培训";
		op3.value="33";
		try{
			typeId.add(op3,null);
		}
		catch(ex){
			typeId.add(op3);
		}
		
		var op4=document.createElement('option');
		op4.text="人才招聘";
		op4.value="34";
		try{
			typeId.add(op4,null);
		}
		catch(ex){
			typeId.add(op4);
		}
		
		var op5=document.createElement('option');
		op5.text="企业管理";
		op5.value="35";
		try{
			typeId.add(op5,null);
		}
		catch(ex){
			typeId.add(op5);
		}
		
		var op6=document.createElement('option');
		op6.text="市场营销";
		op6.value="36";
		try{
			typeId.add(op6,null);
		}
		catch(ex){
			typeId.add(op6);
		}
		
		var op7=document.createElement('option');
		op7.text="产品·技术";
		op7.value="38";
		try{
			typeId.add(op7,null);
		}
		catch(ex){
			typeId.add(op7);
		}
		
		var op8=document.createElement('option');
		op8.text="闲情雅趣";
		op8.value="39";
		try{
			typeId.add(op8,null);
		}
		catch(ex){
			typeId.add(op8);
		}
}

	/*获取对象*/
	function getObj(id)
{
	if(document.getElementById)
	{
		return document.getElementById(id);
	}
	else if(document.all)
	{
		return document.all[id];
	}
	else if(document.layers)
	{
		return document.layers[id];
	}
}
function cm( vVar)
{
	var mObj = getObj("m"+vVar);

	if(mObj.style.display=="none")
	{
		mObj.style.display = "block";
		
	}
	else
	{
		mObj.style.display = "none";
	
	}
	return true;
}




var blnCanShow=true;

var KeyStoryId=0;			//上一次显示的id

var blnFirstClickKey=true;		//关键字框是否为第一次点击


function keyInputClick(){
alert();
 if(blnFirstClickKey){
 
 	blnFirstClickKey=false;
 	
 	var key=document.getElementsByName("key")[0];
 	
 	key.value="";
 }
}

function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}


function sendKeyByGet(){

		createXMLHttpRequest();

		var searchType=document.getElementsByName("searchType")[0];
		
		var key=document.getElementsByName("key")[0];

		//alert(key.value);

		var url = "/news/getSearchKey.do?" ;
	
		if(key.value!=''){	
			hiddenKeyWin();
			
			if(blnCanShow){	//如果允许显示联想提示框
			
				url=url+"key="+encodeURI(key.value)+"&searchType="+encodeURI(searchType.value);
		
    		//alert(url);
   				 xmlHttp.onreadystatechange = handleKeyList;
   		 		 xmlHttp.open("GET", url, true);
				xmlHttp.send(null);
			}
	}
}

function handleKeyList(){
    	if(xmlHttp.readyState == 4) {
        	if(xmlHttp.status == 200) {
       		
        		var xmlDoc=xmlHttp.responseXML;

        		var titles=xmlDoc.getElementsByTagName("title");
        		
        		var htmlValue="";
        		
        		if(titles.length!=0){
        			var keyTitle=document.getElementById("keyTitle");
					
					
					keyTitle.style.display="block";

					for(var i=0;i<titles.length;i=i+1){
				
						var id=titles[i].getAttribute("id");
					
						var title=titles[i].getAttribute("title");
					
						var count=titles[i].getAttribute("count");
					
						
						htmlValue+='<div id="ktw'+id+'" onmouseover="keyMouseOn('+id+')" '+'" style="width:100%;cursor:default"> ';
						htmlValue+='<div title="搜索此关键字" id="ktwt'+id+'" onclick="keyClick('+id+')" '+' style="float:left; width:100%; text-align:left; padding:1px 2px; height:17px; overflow:hidden;" >'+title+'</div>';
						htmlValue+='</div>';
				
					}
					
					//	htmlValue+='<div style="width:100%;cursor:hand"> ';
					//	htmlValue+='<div style="float:left; width:99%; text-align:left; padding:1px 2px; height:15px; overflow:hidden;color:#ff0000;">[本联想提示只显示标题符合关键字的内容]</div>';
						//htmlValue+='<div onclick="colseTip()" style="float:right; width:19%; text-align:right; color:#000000;padding:1px 2px;">关闭</div>';
					//	htmlValue+='</div>';
					
     				keyTitle.innerHTML=htmlValue;
     				}
        			else{
        				hiddenKeyWin();
        			}
       	 	}
    
    　　
    	}
}

function colseTip(){

	blnCanShow=false;
	hiddenKeyWin();
}

//用户点击联想提示框
function keyClick(id){

var key=document.getElementById("key");
var titleVaue=document.getElementById("ktwt"+id);
key.value=titleVaue.innerText;


var keyForm=document.getElementById("keyForm");

if(keyForm!=null){
	
	keyForm.submit();
}

}



//鼠标移过联想提示框
function keyMouseOn(id){
	
	if(KeyStoryId!=0){
		var titleVauePri=document.getElementById("ktw"+KeyStoryId);
		
		if(titleVauePri!=null)
			titleVauePri.style.backgroundColor="#FFFFFF";
	}
	
	KeyStoryId=id;

	var titleVaue=document.getElementById("ktw"+id);
	
	titleVaue.style.backgroundColor="#3366CC";
	
	
}


document.onclick=hiddenKeyWin;
function hiddenKeyWin(){
	var keyTitle=document.getElementById("keyTitle");
	keyTitle.style.display="none";
}

function showKeyWin(){
	var keyTitle=document.getElementById("keyTitle");
	keyTitle.style.display="block";
}
