function submitForm(){
	$(this).parents("form").submit();
}
function getLabel(obj){
	return $(obj).siblings("label").text();
}
function uncheckAll(){
	uncheck("#category_all");
	if(!$(this).attr("checked"))
		uncheck(this);
	else
		check(this);
}
function uncheck(obj){
	$(obj).attr("checked",false);
	var _text = getLabel(obj);
	$("div.module_search p:contains('"+_text+"')").remove();
}
function check(obj){
	$(obj).attr("checked",true);
	var _text = getLabel(obj);
	$("div.module_search").append("<p>");
	$("div.module_search p:last").addClass("text_selected");
	$("div.module_search p.text_selected:last").text(_text);
}
function resetCheckbox(){
	$("form#form_search input[type='checkbox']").each(function(){
		uncheck(this);
	});
	check(this);
}
function checkCheckboxes(){
	$.each($.globals.categories,function(e){
		check("#form_search input[value="+$.globals.categories[e]+"]");
	});
}
$(document).ready(function(){
	$("div.button a").click(submitForm);
	$("form#form_search input[type='checkbox']").click(uncheckAll);
	$("#category_all").click(resetCheckbox);
	checkCheckboxes();
});
