var searchType = "";
jQuery(window).bind("load",function(){
	jQuery("#cmb_category").bind("change",function(){
	    searchType  = "category";
		sort();
	});
	
	jQuery("#cmb_sort").bind("change",function(){
		sort();
	});
	
	jQuery("#cmb_order").bind("change",function(){
		sort();
	});
	
	jQuery("#cmb_manufacturer").bind("change",function(){
		sort();
	});
	
	jQuery("#symptomId").bind("change",function(){
		 searchType  = "symptoms";
		sort();
	});
});	

function sort()
{
	
	sortfld="";
	order="";
	manufacturerId="";
	
	categoryId = jQuery("#cmb_category").attr("value");
	symptId = jQuery("#symptomId").attr("value");

	/*
	sortfld = jQuery("#cmb_sort").attr("value");
	order = jQuery("#cmb_order").attr("value");
	manufacturerId = jQuery("#cmb_manufacturer").attr("value");
	*/	
	
	url="/equipment/index";
	if(categoryId!=''){
		url+="/categoryId/"+categoryId;
	}
	if(manufacturerId!=''){
		url+="/manufacturerId/"+manufacturerId;
	}
	if(symptId!=''){
		url+="/symptomId/"+symptId;
	}

	if(sortfld!=''){
		url+="/sort/"+sortfld;
	}
	if(order!=''){
		url+="/order/"+order;
	}
	document.location.href=url +"/?searchby="+ searchType;	
}

function changePaging(recordPerPage)
{
   document.location.href="/equipment/index/recordPerPage/"+recordPerPage+" ";
   
}

jQuery(window).bind("load",function(){
	jQuery("#equipment_advanced_search").bind("click",function(){
		jQuery("#equipment_search_container").hide();
		jQuery("#equipment_advanced_search_container").show();

		jQuery("#cmb_category").attr("value","");
		
		jQuery("#li_search").removeClass("tab_active_left");
		jQuery("#li_search span:first").removeClass("tab_active_right");		
		
		jQuery("#li_advanced_search").addClass("tab_active_left ");
		jQuery("#li_advanced_search span:first").addClass("tab_active_right");
		
	});
	
	jQuery("#equipment_search").bind("click",function(){
		jQuery("#equipment_advanced_search_container").hide();
		jQuery("#equipment_search_container").show();
		
		jQuery("#symptomId").attr("value","");
		
		jQuery("#li_advanced_search").removeClass("tab_active_left");
		jQuery("#li_advanced_search span:first").removeClass("tab_active_right");		
		
		jQuery("#li_search").addClass("tab_active_left ");
		jQuery("#li_search span:first").addClass("tab_active_right");
		
		/*		
		jQuery("#li_search").removeClass("class","tab_active_left margin-left-off");
		jQuery("#li_search span:first").attr("class","tab_active_right");
		
		jQuery("#li_advanced_search").remove("class");
		jQuery("#li_advanced_search span:first").removeAttr("class");
		*/
		
	});
	
});
