function validate_form()
{
	var validators = new Array('email','location','title','description','howto');
	var errors = 0;
	var agreed = 1;
	var error_message = 'Please ';
	if ($F('agree') != 'YES') agreed = 0;
	
	for (var x=0;x<validators.length;x++)
	{
		if ($(validators[x]).hasClassName('incomplete')) $(validators[x]).removeClassName('incomplete');
		if ($F(validators[x]).length < 1)
		{
			errors = 1;
			$(validators[x]).addClassName('incomplete');
		}
	}
	
	if ($('website').hasClassName('incomplete')) $('website').removeClassName('incomplete');
	if (($F('website').length < 1) || ($F('website') == 'http://'))
	{
		errors = 1;
		$('website').addClassName('incomplete');
	}
	
	
	if (errors==1)
	{
		error_message = error_message + 'complete the fields in red';
	}
	if (agreed==0) 
	{
		if (error_message.length > 8) error_message = error_message + ' and ';
		error_message = error_message + 'accept the terms before posting';
	}
	error_message = error_message + '.'
	
	if ((errors==0) && (agreed==1))
	{
		$('post_form').submit();
	}
	else
	{
		Effect.Appear('error');
		Element.update('error',error_message);
	}
}

function filter($type)
{
	$sel_type = 'all';
	$category = '';
	if ($type.substring(0,1) != 'd')
	{
		if (Element.hasClassName('all', 'active'))
			Element.removeClassName('all', 'active');
		if (Element.hasClassName('freelance', 'active'))
			Element.removeClassName('freelance', 'active');
		if (Element.hasClassName('full-time', 'active'))
			Element.removeClassName('full-time', 'active');
		Element.addClassName($type, 'active');
		$sel_type = $type;
	} else
	{
		if (Element.hasClassName($type, 'active'))
		{
			Element.removeClassName($type, 'active');
		} else {
			Element.addClassName($type, 'active');
			$other_type = ($type=='design')?'development':'design';
			Element.removeClassName($other_type, 'active');
			$category = $type;
		}
		
		if (Element.hasClassName('all', 'active'))
			$sel_type = 'all';
		else if (Element.hasClassName('freelance', 'active'))
			$sel_type = 'freelance';
		else if (Element.hasClassName('full-time', 'active'))
			$sel_type = 'full-time';
	}
	$url = '/post/filter/'+$sel_type+'/'+$category;
	new Ajax.Updater('job_list', $url, {asynchronous:true});
}