	$(document).ready(function(){
			    /** [JTR] Drink form, call checkfields function on submit **/
			    if(jQuery('#drinkform')){
			    	jQuery('#drinkform').bind('submit', function(e) {
			    		e.preventDefault();
			    		if(verifFields('drinkform')) {
			    			$(this).unbind('submit');
			    			jQuery('#drinkform').submit();
			    		}
			    	});
			    }
			    /** [/JTR] **/


			});
	

	    /** [/JTR] **/




	/** [JTR] **
	 * This function check if the form with it id in param is valid
	 *
	 * To use it, you must give an id to all your form element,
	 * and create a hidden div or span near each element with as id your
	 * id element and _err at the end like : description_err for the textarea with id : description
	 *
	 * Now you can add many validator to the classes of your form element :
	 * vf_notempty, vf_numeric, vf_name, vf_email, vf_textonly, vf_notnumeric, vf_nottext, vf_phone
	 *
	 * @example for example for an email input which is an obligatory field you must set it like :
	 * 		<input type="text" id="email" class="vf_notempty vf_email" />
	 * 		<span id="email_err" style="display:none"></span>
	 *
	 * if you want to personalize error message, simply create a span or div like this anywhere inside the form:
	 * <span style="display:none;" id="form_err-vf_notempty">Ce champ est obligatoire</span>
	 *
	 * @name verifFields
	 * @uses jQuery
	 * @author Jeremy TRUFIER <jeremy.trufier@gmail.com>
	 * @description used to check if a form is valid or not
	 * @params formId [, printError=true]
	 */
	function verifFields(formId) {
		if(arguments.length<=1 || arguments[1])
			var printError=true;
		else
			var printError=false;

		var regexpCheck={
				'notempty':["^.+$","You have to fill this field"],
				'numeric':["^[-+]?\d*\.?\d*$","This field must be numeric"],
				'name':["^([a-zA-Z '-]*)$","Not a valid name"],
				'email':["^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\.\\-]+)\\.([a-zA-Z]{2,5})$","Not a valid email"],
				'phone':["^((\\+([1-9][0-9] *)*(\\(?[0-9]*\\)? *|\\.\\- [0-9]*\\.\\- ))?[0]?[1-9][0-9\\.\\- ]*)?$","Not a valid phone number"],
				'textonly':["^([a-zA-Z ]*)$","Only text in this field"],
				'notnumeric':["^([^0-9]*)$","This field don't allow numeric caracters"],
				'nottext':["^([^a-zA-Z]*)$","This field don't allow text"]
			}

		var result=true;
		jQuery('#'+formId).find('*[class*="vf_"]').each(function() {
			var err='';

			if (this.type == 'radio') {
				if ((!document.getElementById('isStudentYes').checked)&&(!document.getElementById('isStudentNo').checked) ) {
					result=false;
					err=jQuery('#'+formId).find('#form_err-vf_notempty').html();
				}
			}
			if (this.type == 'select-one') {
				if ((document.getElementById('isStudentYes').checked)&&(this.value == 'Choisir') ) {
					result=false;
					err=jQuery('#'+formId).find('#form_err-vf_notempty').html();
				}
			}
			if (this.type == 'hidden') {
				if ( !$('input:checkbox:checked').length ) {
					result=false;
					err=jQuery('#'+formId).find('#form_err-vf_notempty').html();
				}
			}
			if ((this.type == 'text')&&(this.name == 'job')&&(document.getElementById('isStudentNo').checked)) {
				var ok = true;
				if ((!document.getElementById('isStudentNo').checked)&&(jQuery(this).val() == '') ) {
					ok = false;
					result=false;
					err=jQuery('#'+formId).find('#form_err-vf_notempty').html();
				}
				if (ok == true) {
					for(key in regexpCheck){
						if(err=='' && jQuery(this).is('.vf_'+key)) {
							var reg = new RegExp(eval('regexpCheck.'+key+'[0]'));
							if(!reg.test(jQuery(this).val())){
								result=false;
								err=((jQuery('#'+formId).find('#form_err-vf_'+key).length>0)?jQuery('#'+formId).find('#form_err-vf_'+key).html():eval('regexpCheck.'+key+'[1]'));
							}
						}
					}
				}
			}
			if ((this.type == 'text')&&(this.name == 'school_other')&&(document.getElementById('isStudentYes').checked)&&(document.getElementById('school').options[document.getElementById('school').selectedIndex].value == 'Autre')) {
				var ok = true;
				if (jQuery(this).val() == '') {
					ok = false;
					result=false;
					err=jQuery('#'+formId).find('#form_err-vf_notempty').html();
				}
				if (ok == true) {
					for(key in regexpCheck){
						if(err=='' && jQuery(this).is('.vf_'+key)) {
							var reg = new RegExp(eval('regexpCheck.'+key+'[0]'));
							if(!reg.test(jQuery(this).val())){
								result=false;
								err=((jQuery('#'+formId).find('#form_err-vf_'+key).length>0)?jQuery('#'+formId).find('#form_err-vf_'+key).html():eval('regexpCheck.'+key+'[1]'));
							}
						}
					}
				}
			}
			if ((this.type == 'text')&&(this.name != 'job')&&(this.name != 'school_other')&&(this.type != 'hidden')) {
				for(key in regexpCheck){
					if(err=='' && jQuery(this).is('.vf_'+key)) {
						var reg = new RegExp(eval('regexpCheck.'+key+'[0]'));
						if(!reg.test(jQuery(this).val())){
							result=false;
							err=((jQuery('#'+formId).find('#form_err-vf_'+key).length>0)?jQuery('#'+formId).find('#form_err-vf_'+key).html():eval('regexpCheck.'+key+'[1]'));
						}
					}
				}
			}

			if(printError)
				if(jQuery('#'+formId).find('#'+jQuery(this).attr('id')+'_err')){
					jQuery('#'+formId).find('#'+jQuery(this).attr('id')+'_err').html(err);
					if(err!='')
						jQuery('#'+formId).find('#'+jQuery(this).attr('id')+'_err').fadeIn(300);
					else
						jQuery('#'+formId).find('#'+jQuery(this).attr('id')+'_err').fadeOut(200);
				}
		});

		return result;
	}
	/** [/JTR] **/
	
	// tente de basculer les div sur les boutons radio
	$( function(){
		$("input[name='isStudent']").click(function(){
			//console.dir(this);
			 if ($(this).val() == 1) {
				 if ($('#drink_job').css('display')!='none') {
					 $('#drink_job').fadeOut('300', function (){
						 $('#drink_school_content').fadeIn();
						 $('#drink_job').val('');
						 $('#drink_school_other').fadeOut();
					 });
				 }
				 else {
					 $('#drink_school_content').fadeIn();
					 $('#drink_school_other').fadeOut();
				 }
			 } else {
				 if ($('#drink_school_content').css('display')!='none') {
					 $('#drink_school_content').fadeOut('300', function (){
						 $('#drink_job').fadeIn();
						 $('#school').val('Choisir');
					 });
				 }
				 else {
					 $('#drink_job').fadeIn();
					 $('#school').val('Choisir');
				 }
			 }		
		});
		
		$('#school').change(function(){			
			 if ($(this).val() == "Autre") {
				 $('#drink_school_other').fadeIn();
			 } else {
				 $('#drink_school_other').fadeOut('300');
			 }		
		});

	} );
	
    window.onload = function() {
	    	$('#drink_school_content').hide();
	    	$('#drink_job').hide();
	    	$('#drink_school_other').hide();
        }

	
	


