$(document).ready(function() {
	window.makeMailLinks?makeMailLinks():null;
	//window.highlightIncomplete?highlightIncomplete():null;
});
/* <span class="email">x (at) x.com</span> becomes <a href="x@x.com">x@x.com</a> 
* this is an anti-spam measure
*/
function makeMailLinks(){
		$('span.email').each(function(){
			var theAddress = $(this).text().replace(/ \(at\) /, "@");
			$(this).replaceWith($('<a href="mailto:'+theAddress+'">'+theAddress+'</a>'));
			});
	}
function highlightIncomplete(){
	$('form').submit(function(){
		$('.fail').removeClass('fail');
		$('input.required,textarea.required').each(function(){
			if($(this).val()==''){
				$(this).addClass('fail');
				}
			});
		$('div.checkboxgroup.required,tr.checkboxgroup.required').each(function(){
			if($(this).find('input[type=checkbox]:checked,input[type=radio]:checked').size()==0)
				{
					$(this).addClass('fail');
					/* exception in case there's a text field in there */
					$(this).find('input[type=text]').each(
						function(){
						if($(this).val()!=''){
								$(this).parents().removeClass('fail');
								}
							}
						);
				}
			});
		/*$('tr.checkboxgroup.required').each(function(){
			console.log('tr.checkboxgroup.required');
			});*/
			if($('.fail').size()>0) {
				if($('body').hasClass('fr')){
					window.alert('voeuillez completer tous les champs, svp');
					}else{
					window.alert('please fill in all fields');
					}
				return false;
				}
			/*return true;*/
		});
	/*var failfields = $('#failfields li');
	if(failfields.size()>0){
		failfields.each(function(){
			console.log($(this).text());
			$('input[name='+$(this).text()+']').parent().addClass('fail');
			});
		}*/
	}

