/**
 * Author:殘雪易冷 | E-mail: xueruos520@163.com                   
 * Copyright (c) 版权所有 无锡君通软件                                   
 * 2010.9.25
 * blog.csnowy.com
 */
 
/**
 * 普通搜索
 */

function drop_mouseover(pos){
	try{window.clearTimeout(timer);}catch(e){}
}
function drop_mouseout(pos){
	var posSel=document.getElementById(pos+"Sel").style.display;
	if(posSel=="block"){
		timer = setTimeout("drop_hide('"+pos+"')", 1000);
	}
}
function drop_hide(pos){
	document.getElementById(pos+"Sel").style.display="none";
}
function search_show(pos,searchType,href){
    document.getElementById(pos+"SearchType").value=searchType;
    document.getElementById(pos+"Sel").style.display="none";
    document.getElementById(pos+"Slected").innerHTML=href.innerHTML;
    document.getElementById(pos+'q').focus();
    var sE = document.getElementById("searchExtend");
    if(sE != undefined && searchType == "bar"){
    	sE.style.display="block";
    }else if(sE != undefined){
    	sE.style.display="none";
    }
	try{window.clearTimeout(timer);}catch(e){}
	return false;
}

function focusbar(ob){
	ob.value = '';
	document.onkeydown=function(e){
		var e=e?e:window.event;
		if(e.keyCode=="13"){
		
		}
	}
}
//所搜条结束

/* 普通搜索 */
function do_search(){
  type = $('#headSearchType').val();
  key = $('#headq').val();
  CX.getInfo('search.php','POST',"app",'action=common_search&type='+type+'&key='+key,_common_search);
}

function do_search_ajax(ob){
  var id = ob.id;
  var page = ob.name;
  CX.getInfo('search.php','POST',"app",'action=common_search&type='+type+'&key='+key+'&page='+page,_common_search);
}
function _common_search(ret){
  keyword = $('#headq').val();
  commonsearch_div(ret);
  //$ret_arr = ret.split('###');	
  //$('#index-body').html($ret_arr[0]);
  //$('#info_pages').text($ret_arr[1]);
  //$('#headq').attr("value", keyword);
}

//列表页筛选
function js_do_view_choice(){
  $('#do_choice_item').css('display', '');
  $('#view_cho').remove();
  $('#this_af').after('<input id="close_cho" name="button" type="button" class="but" style="width:110px" value="关闭筛选选项"  onclick="js_do_close_choice()"/>');
}

function js_do_close_choice(){
  $('#do_choice_item').css('display', 'none');
  $('#close_cho').remove();
  $('#this_af').after('<input id="view_cho" name="button" type="button" class="but" style="width:110px" value="显示筛选选项"  onclick="js_do_view_choice()"/>');
}

//筛选开始
function shaixuan(){
  //获取所有的筛选选项
  var sx_catid_c = $('#sx_catid').val();
  var sx_lis_str = '';
  var $sx_lis_arr = [];
  $sx_lis = $('#cx_sx > li');
  if($sx_lis.length == '2'){
	  alert('请选择筛选项！'); 
	  return false;}
  //获取筛选项的ID
  for(i=0; i<($sx_lis.length-2); i++){
	  cx_num = i+2;
	  sx_lis_id = $sx_lis[cx_num].id;
	  if(sx_lis_str == ''){
	    sx_lis_str = sx_lis_id;
	  }else{
	    sx_lis_str = sx_lis_str+','+sx_lis_id;
	  }
  }
  CX.getInfo('search.php','POST',"app",'action=detail_search&key='+sx_lis_str+'&cat_id='+sx_catid_c,_detail_search);	
}

function _detail_search(ret){
	$_ret_arr = ret.split('###');
	$('ol').html($_ret_arr[0]);
	$('#info_pages').text($_ret_arr[1]);
	$('#remove_search').css('display', 'none');
	$('#badoo').css('display', 'none')
	//alert($_ret_arr[0]);
}

function do_search_ajax_de(ob){
  var id = ob.id;
  var page = ob.name;
  var sx_catid_c = $('#sx_catid').val();
  var sx_lis_str = '';
  var $sx_lis_arr = [];
  $sx_lis = $('#cx_sx > li');
  //获取筛选项的ID
  for(i=0; i<($sx_lis.length-2); i++){
	  cx_num = i+2;
	  sx_lis_id = $sx_lis[cx_num].id;
	  if(sx_lis_str == ''){
	    sx_lis_str = sx_lis_id;
	  }else{
	    sx_lis_str = sx_lis_str+','+sx_lis_id;
	  }
  }
  CX.getInfo('search.php','POST',"app",'action=detail_search&key='+sx_lis_str+'&cat_id='+sx_catid_c+'&page='+page,_detail_search);	
}
