//	Main javascript module

function doSearch(f){
	var obj = $("div#body div.content");
	obj.hide();
	$('div#loading').show();
	if (!obj) return false;
	$.post('search',{ajax:1, str:f.str.value, state:f.state.value},function(data){
		alert(data);
		obj.html(data);
		showStep(2);
		$('div#loading').hide();
		obj.fadeIn('slow');
	});
}

var expandedRow = null;
function expand(id){
	var show = false;
	if (expandedRow!=id){
		show = true;
	}
	$('#row-'+expandedRow).hide();
	expandedRow = id;
	if (show){
		$('#row-'+id).fadeIn('slow');
		showStep(3);
	} else {
		expandedRow = null;
		showStep(2);
	}
}

function showStep(s){
	var obj = $('div#step'+s);
	if (!obj) return false;
	$('div.note div.selected').each(function(){
		$(this).removeClass('selected');
	});
	obj.addClass('selected');
	return true;
}

function rules(){
	if ($('#rules').css('display')=='block') $('#rules').hide('slow'); else $('#rules').show('slow');
}