function choose_keywordnew()
{
	var scobj = document.getElementById('search_input');
	var scvalue = scobj.getAttribute('value');
	var width_page;
	if(scvalue == "请输入关键字")
	{
		scobj.setAttribute('value',"");
		scobj.style.color="#222";
	}
	var width=screen.width;
	if(width<=1152){
		width_page = 990;
	}else{
		width_page = 1200;
	}
	document.getElementById('hide_search_div').style.display = 'none';
	document.getElementById('hide_search_div').style.left = 0+'px';
	document.getElementById('hide_search_div').style.top = 0+'px';
//	document.getElementById('hide_search_div').style.width = document.documentElement.clientWidth+'px';
	document.getElementById('hide_search_div').style.width = (document.documentElement.clientWidth - (document.documentElement.clientWidth - width_page)/2)+'px';
	document.getElementById('hide_search_div').style.height = document.documentElement.scrollHeight+'px';
	
}


function show_choose_id(id){
	//show_search_1();
	
	var search_choose_obj = document.getElementById('search_choose');
	var attribute = document.getElementById(id); 
	var atrrvalnew = $("#search_input").val();	
	if(attribute.style.display == "none" && atrrvalnew!="" && atrrvalnew != "请输入关键字"){
		attribute.style.display="";
	}
	
	if(atrrvalnew!="" && atrrvalnew != "请输入关键字" && attribute.style.display == "" ){
			$("#bbs_js").html("<span>帖子</span>搜索："+atrrvalnew);
			$("#video_js").html("<span>视频</span>搜索："+atrrvalnew);
			$("#blog_js").html("<span>日志</span>搜索："+atrrvalnew);
			$("#album_js").html("<span>相册</span>搜索："+atrrvalnew);
			$("#user_js").html("<span>成员</span>搜索："+atrrvalnew);	
	}
	
	if(atrrvalnew==""){
		attribute.style.display="none";
	}
}

function show_id(id){
	var attribute = document.getElementById(id).style.display; 
	if(attribute == "none"){
		document.getElementById(id).style.display="";
	}
}
function hide_id(id){
	var attribute = document.getElementById(id).style.display; 
	if(attribute == ""){
		document.getElementById(id).style.display="none";
	}
}


var isIE = navigator.userAgent.indexOf("MSIE")>0;
//创建事件的通用函数
var EventUtil = function(){};
EventUtil.winWidth   = 0;
EventUtil.winHeight = 0;
EventUtil.addEventHandler = function(obj,EventType,Handler)
{
	//如果是FF
	if(obj.addEventListener)
	{
	   obj.addEventListener(EventType,Handler,false);
	}
	//如果是IE
	else if(obj.attachEvent)
	{
	   obj.attachEvent('on'+EventType,Handler);
	}
	else
	{
	   obj['on'+EventType] = Handler;
	}
}

/**
* @deprecated 获取浏览器 Event 事件
* @return evt
*
*/
EventUtil.getEvent = function (evt)
{
	return (evt ? evt : (window.event ? window.event : EventUtil.getEvent.caller.arguments[0]));
}

$(document).keydown(function(){
	var num = $("#search_ul").find("li").length;
	var j;
	var nameOfArray;
	var searchtype;
	if(document.getElementById('search_choose').style.display==""){
		if (window.attachEvent)
		{
			for(var i=0; i<num; i++){
				 if($("#search_ul").find("li").get(i).style.backgroundColor=='#dcdcdc' || $("#search_ul").find("li").get(0).getAttribute("id")=="search_ulone"){  
					 switch(window.event.keyCode){  
						 case 38 :  
							 if(i-1>=0){ 
								j = i-1;
							   $("#search_ul").find("li").get(i-1).style.backgroundColor = '#dcdcdc';   
							   $("#search_ul").find("li").get(i).style.backgroundColor = "";
							 }  
							 break;  
						 case 40 :  
							 if(i==0 && $("#search_ul").find("li").get(0).getAttribute("id")=="search_ulone"){
								  $("#search_ul").find("li").get(0).style.backgroundColor = '#dcdcdc';   
								  $("#search_ul").find("li").get(0).setAttribute("id","");
							 }else{
								 if(i+1<=num-1){  
									 j = i+1;
									 $("#search_ul").find("li").get(j).style.backgroundColor = '#dcdcdc';   
									 $("#search_ul").find("li").get(i).style.backgroundColor = "";
								 }  
							 }
							 
							 break;  
						  case 13 :
							nameOfArray = new Array('bbs','video','blog','album','user');
							searchtype = nameOfArray[i];
							$("#search").attr("action",'javascript:search_submit("'+searchtype+'")');
							//search_submit('blog');
						}  
						 break;  
				 }   
			}
		}
		else
		{
			//EventUtil.addEventHandler(document,"keydown",notifyKeyDown); //FF
			var eventnew = EventUtil.getEvent(eventnew);
				var num = $("#search_ul").find("li").length;
				var j;
				var i;
				var nameOfArray;
				var searchtype;	
					for(i=0; i<5; i++){
						 if($("#search_ul").find("li").get(i).style.backgroundColor=='rgb(220, 220, 220)' || $("#search_ul").find("li").get(0).getAttribute("id")=="search_ulone"){  
							 switch(eventnew.keyCode){  
								 case 38 :  
									 if(i-1>=0){ 
										j = i-1;
									   $("#search_ul").find("li").get(j).style.backgroundColor = '#dcdcdc';   
									   $("#search_ul").find("li").get(i).style.backgroundColor = "";
									 }  
									 break;  
								 case 40 : 
									 if(i==0 && $("#search_ul").find("li").get(0).getAttribute("id")=="search_ulone"){
										   $("#search_ul").find("li").get(0).style.backgroundColor = '#dcdcdc';
										   $("#search_ul").find("li").get(0).setAttribute("id","");
									 }else{
										 if(i+1<=num-1){ 
											 j = i+1;
											 $("#search_ul").find("li").get(j).style.backgroundColor = '#dcdcdc';   
											 $("#search_ul").find("li").get(i).style.backgroundColor = "";
										 }  
									 }
									 
									 break;  
								  case 13 :
									nameOfArray = new Array('bbs','video','blog','album','user');
									searchtype = nameOfArray[i];
									$("#search").attr("action",'javascript:search_submit("'+searchtype+'")');
							  }  
								 break;  
							}   
					}
			
		}
		
	}
	
})