var oCalendarChs=new PopupCalendar("oCalendarChs"); //初始化控件时,请给出实例名称:oCalendarChs   
oCalendarChs.weekDaySting=new Array("日","一","二","三","四","五","六");   
oCalendarChs.monthSting=new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");   
oCalendarChs.oBtnTodayTitle="今天";   
oCalendarChs.oBtnCancelTitle="取消";   
oCalendarChs.Init();   

function highSearchTipe(){
	var hst=document.getElementById('highLevelTip')
	
	if(hst.style.display=="none")
		hst.style.display="block";
	else
		hst.style.display="none";
}

function dateClear(){

	document.getElementsByName("startDate")[0].value="";
	
	document.getElementsByName("endDate")[0].value="";
}

 function userLogin(){
	if(document.loginForm.userName.value=="" || document.loginForm.userPass.value==""){
		alert("用户名密码不能为空");
		return false;
	}
	 else{
	 	return true;
	 }
 }
 
function formKeyKown(){
  if   (event.keyCode   ==   13) {
  }
}

function addFav(){
	window.external.AddFavorite(window.location.href,document.title);
}




var xmlHttp;


var lastSurportCount="0";
var lastOppCount="0";

function surportOrOpp(id,type){


		if(lastSurportCount!="0"){
        				
        		alert("重复投票将无效!");
        		return;
       }
	
		if(lastOppCount!="0"){
        				
        		alert("重复投票将无效!");
        		return;
        }
	
		createXMLHttpRequest();
		var url="/mats/supportOrOpp.do?matId="+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");
        			
        			if(lastSurportCount=="0"){
        				lastSurportCount=surportCount;
        				document.getElementById("surportCount1").innerHTML="次数:"+surportCount;
        			}
        			else if(lastSurportCount!="0"){
        				
        				alert("重复投票将无效!");
        				return;
        			}
        			
        			if(lastOppCount=="0"){
        				lastOppCount=oppCount;
        				document.getElementById("oppCount1").innerHTML="次数:"+oppCount;
        			}
        			else if(lastOppCount!="0"){
        				
        				alert("重复投票将无效!");
        			}
        			
        			
        			
        			
        			
        			
        			
        			
        		}
        	}
        }
}

//搜索类型变更时，更改分类列表
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 = "/mats/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";
}


function inputKeyDown(name)   
  {   
    if   (event.keyCode   ==   13)   //   keyCode   ==   13   说明按下的是回车键   
    {   
    		
    		pagiationText(name);
            //ButtonId.click();   //   提交按钮的ID号   
    }   
  }  
  
  
    /*获取单个cookies*/
function getck(sname){
  var acookie=document.cookie.split("; ");
  for(var i=0;i<acookie.length;i++){
       var arr=acookie[i].split("=");
       if(sname==arr[0]){
         if(arr.length>1)
            return unescape(arr[1]);
         else
            return "";
       }
    }
  return "";
} 
	
function validReview(){

	var rand=document.getElementsByName("rand")[0];
	
	var revUserName=document.getElementsByName("revUserName")[0];
	
	var revText=document.getElementsByName("revText")[0];

	if(rand.value==""){
		alert("校验码不能为空!");
		return false;
	}
	
	if(revUserName.value==""){
	
		alert("作者不能为空!")
		return false;
	}
	
	if(revText.value==""){
	
		alert("评论正文不能为空!");
		return false;
	}
	
	if(revUserName.value.length>30){
	
		alert("作者的长度不能大于30!")
		return false;
	}
	
	if(revText.value.length>500){
	
		alert("评论正文字数不能大于500!");
		return false;
	}

	if(rand.value!=getck("rand")){
    	alert("校验码不正确,请重新输入!");
    	return false;
  }
  
  
  return true;
}

function randnumchange(){
	
  	var checkNumPic=document.getElementById("checkNumPic");
	
	checkNumPic.src="/imageRandServlet.do?aaa="+Math.random();

	
}
