var prevSearchCond = '';
function searchProduct(searchRequest){
	var catIds = '';
	//var theQuery = {'catchall':searchTerm, 'name':searchTerm+'^10', 'description':searchTerm+'^9'};
	//var theQuery = {};

	//theQuery.category_id = '('+searchRequest.category_ids+')';
	
	//if we search for new conditions, need to init the solr search object again
	//var searchCond = searchRequest.category_ids;
	var searchCond = searchRequest.query;
	//alert(searchCond);
	//alert(prevSearchCond);
	if(searchCond != prevSearchCond){
		jQuery('#content').data('solrsearch',null);
	}
	
	
	var urlType = isStaticLinking?'static_url':'dynamic_url';
	var artistUrl = isStaticLinking?'static_artist_url':'dynamic_artist_url';
	var template_jst = isStaticLinking?'itemtemplate.jst':'itemtemplate_dynamic.jst';
	
	if(!searchRequest.sort_by){
		searchRequest.sort_by = '';
	}
	jQuery('#content').solrsearch({
		query_url: "/kidrobot_search/?wt=json",
		query_sort: searchRequest.sort_by,
	    query: searchRequest.query,
	    paging_prev_code: '<a href="#" class="arr">&lt;</a>',
	    paging_next_code: '<a href="#" class="arr">&gt;</a>',
	    facets: {items:[]},
	    facets_to: '',
	    per_page: 30,
	    results_per_line: 3,
	    rt_fields: 'id,name,image_url,brand,price,list_price,artist_status,product_tag,'+urlType+','+artistUrl,
		item_node_html: staticPath+'/js/'+template_jst,
		item_trans: {price:'p', list_price:'p'},
		show_sort_by: {items:[]},
		product_listing: '#prod-list',
		paging_to: '.pagination-wrapper',
	    view_all_code: 'View All'
	});

	var solrsearch = jQuery('#content').data('solrsearch');
	solrsearch.load_page();

	prevSearchCond = searchCond;
	
	return solrsearch;

}

