

Cufon.replace('.LucidaSans, #hp_greybox_inner_title, #hp_greybox_inner_title, .testimonyListing_Elem_place, .testimonyListing_Elem_title, #help_title, #footer li, #footer #right', {
	fontFamily: 'LucidaSans',
	hover: true
});
Cufon.replace('#menu UL', { 
	fontFamily: 'LucidaSans', 
	hover: true,
	textShadow: "1px 1px #EEE",
	hover: {
		textShadow: "1px 1px #FFF"
	}
});
Cufon.replace('.UI_Button_Blue a', { 
	fontFamily: 'LucidaSans', 
	textShadow: "1px 1px #006"
});
Cufon.replace('#support #support_phone, .UI_Button_Orange a, .UI_Button_Green a, .UI_Button_Blue.current a', { 
	fontFamily: 'LucidaSans', 
	textShadow: "1px 1px #930"
});

$(function(){
	$(".defaultValue").defaultValue();
	
	$("#banner_elems").cycle({
		fx: 'scrollLeft',
		pager: '#bannerSwitch',
		activePagerClass: 'current',
		easing: 'easeOutQuart',
		timeout: 10 * 1000
	});
	$("#bannerFrame").click(function(){
		window.location.href = $("#banner_elems img:visible").attr("url");
	});
	
	$(".gallery").prettyPhoto();
});

/* GOFORM */

/* VALIDATION */

jQuery.validator.addMethod("enum", function(value, element, params) { 
 return listFind(params,value) >= 0; 
}, jQuery.format("Please enter a value which is in the list : {0}"));


function initGOFormValidation(index,item,settings){
	settings = $.extend({
		submitHandler: function(){}
	},settings);
	
	if( $(item).attr("validation") && $(item).attr("validation") == "false" ) {
		return false;
	}
	
	if( $("textarea.GOForm_ExtendValidation",item).size() ) {
		var ExtendValidation = structKeyLCase($.parseJSON( $("textarea.GOForm_ExtendValidation",item).val() ),true);
	} else {
		var ExtendValidation = {};
	}
	
	var baseValidation = structKeyLCase({"messages":{"name":{"maxlength":"Le nom doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre nom.","minlength":"Le nom doit comporter au minimum {0} caract&egrave;res."},"confirm":{"maxlength":"Le mot de passe de confirmation doit comporter au maximum {0} caract&egrave;res.","equalto":"Veuillez saisir le m&ecirc;me mot de passe.","required":"Veuillez saisir le mot de passe de confirmation.","minlength":"Le mot de passe de confirmation doit comporter au minimum {0} caract&egrave;res."},"captcha":{"required":"Veuillez recopier le code de s&eacute;curit&eacute;","invalid":"Le code de s&eacute;curit&eacute; n'est pas correct."},"address":{"maxlength":"L'adresse doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre adresse.","minlength":"L'adresse doit comporter au minimum {0} caract&egrave;res."},"oldpassword":{"maxlength":"L'ancien mot de passe doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre ancien mot de passe.","minlength":"L'ancien mot de passe doit comporter au minimum {0} caract&egrave;res."},"phone":{"maxlength":"Le t&eacute;l&eacute;phone doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre num&eacute;ro de t&eacute;l&eacute;phone."},"firstname":{"maxlength":"Le pr&eacute;nom doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre pr&eacute;nom.","minlength":"Le pr&eacute;nom doit comporter au minimum {0} caract&egrave;res."},"message":{"maxlength":"Le message doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre message.","minlength":"Le message doit comporter au minimum {0} caract&egrave;res."},"zip":{"maxlength":"Le code postal doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre code postal.","rangelength":"Le code postal doit comporter {0} chiffres.","minlength":"Le code postal doit comporter au minimum {0} caract&egrave;res.","digits":"Le code postal ne doit comporter que des chiffres."},"gender":{"required":"Veuillez saisir votre titre."},"email":{"maxlength":"L'email doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre email.","minlength":"L'email doit comporter au minimum {0} caract&egrave;res.","email":"Votre email n'est pas valide.","duplicate":"Cette email est d&eacute;j&agrave; utilis&eacute;e."},"city":{"maxlength":"La ville doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre ville.","minlength":"La ville doit comporter au minimum {0} caract&egrave;res."},"password":{"maxlength":"Le mot de passe doit comporter au maximum {0} caract&egrave;res.","required":"Veuillez saisir votre mot de passe.","minlength":"Le mot de passe doit comporter au minimum {0} caract&egrave;res."}},"rules":{"phone":{"maxlength":20.0},"firstname":{"maxlength":30.0,"minlength":2.0},"message":{"maxlength":1000.0,"minlength":10.0},"confirm":{"maxlength":20.0,"equalto":"[name=password]","minlength":4.0},"zip":{"rangelength":[1.0,5.0],"digits":true},"name":{"maxlength":30.0,"minlength":2.0},"gender":{"enum":"M1,F1,F2"},"oldpassword":{"maxlength":20.0,"minlength":4.0},"address":{"maxlength":150.0,"minlength":6.0},"email":{"maxlength":150.0,"minlength":6.0,"email":true},"city":{"maxlength":30.0,"minlength":3.0},"password":{"maxlength":20.0,"minlength":4.0}}},true);
	
	var validationRules = $.extend(true,{},baseValidation,ExtendValidation);
	
	var validation = $.extend(validationRules,{
		showErrors: function(errorMap, errorList) {
			$.each(errorList,function(index,item){
				var inputName = $(item.element).attr("name");
				var formParent = $(item.element).parents("form");
				$("th[rel="+inputName+"],label[for="+inputName+"]",formParent).addClass("error");
			});
			this.defaultShowErrors();
		},
		success: function(label) {
			var inputName = label.attr("for");
			var formParent = label.parents("form");
			$("th[rel="+inputName+"],label[for="+inputName+"]",formParent).removeClass("error");
			label.remove();
			$("li",this.errorLabelContainer).each(function(index,item){
				if( $.trim($(item).html()).length == 0 ) $(item).remove();
			});
		},
		submitHandler: function(form) {
			var $form = $(form);
			var self = this;
			
			var errorLabelContainer = this.settings.errorLabelContainer;
			var errorContainer = this.settings.errorContainer;
			
			if( $(".GOFormSubmit",$form).hasClass("UI_Disabled") )
				return false;
				
			$(".GOFormSubmit",$form).addClass("UI_Disabled");
			
			if( typeof $form.attr("ajax") == "undefined" ) {
				form.submit();
				return;
			}
			
			var values = $(form).serialize();
			
			$("input,select,textarea",$form).attr("disabled","disabled");
			
			$.ajax({
				url: $form.attr("ajax"),
				cache: false,
				data: {
					values: values
				},
				type: "POST",
				dataType: "json",
				success: function(data , textStatus , XMLHttpRequest){
					var enabledInputs = true;
					
					data = structKeyLCase(data,true);
					
					if( data.code != 200 ) {
						$(errorLabelContainer).empty();
						$.each(data.messages,function(index,item){
							$("<li />").html(item.message).appendTo(errorLabelContainer);
						});
						$(errorLabelContainer).show();
						$(errorContainer).show();
					} else {
						if( "redirect" in data ) {
							window.location.href = data.redirect;
							enabledInputs = false;
						}
						$form.prev(".GOFormSuccess").show();
						if( $form.prev(".GOFormSuccess").size() ) $form.hide();
					}
					
					$(".GOFormSubmit",$form).removeClass("UI_Disabled");
					if( enabledInputs ) $("input,select,textarea",$form).removeAttr("disabled");
					
					settings.submitHandler( $form , data );
				},
				error: function(){
					$(".GOFormSubmit",$form).removeClass("UI_Disabled");
					$("input,select,textarea",$form).removeAttr("disabled");
				}
			});
			
			return false;
		}
	});
	
	if( $(".GOFormErrorContainer",item).size() ) {
		if( $(".GOFormErrorContainer",item).attr("id") == "" ) {
			$(".GOFormErrorContainer",item).attr("id",Math.uuid(11));
		}
		validation.errorContainer = "#" + $(".GOFormErrorContainer",item).attr("id");
	}
	
	if( $(".GOFormErrorList",item).size() ) {
		if( $(".GOFormErrorList",item).attr("id") == "" ) {
			$(".GOFormErrorList",item).attr("id",Math.uuid(11));
		}
		validation.errorLabelContainer = "#" + $(".GOFormErrorList",item).attr("id");
		validation.wrapper = "li";
	}
	
	$(item).validate(validation);
}
/* / VALIDATION */

$(function(){
	$(".GOFormSubmit",".GOForm").live('click',function(e){
		e.preventDefault();
		$(this).parents("form").trigger("submit");
		return false;
	});
	
	/* CAPTCHA REFRESH */
	$(".GOFormCaptchaRefresh",".GOForm").live("click",function(e){
		e.preventDefault();
		
		var $parentContainer = $(this).parents(".GOFormCaptcha");
		
		var $captchaImg = $("img.GOFormCaptchaImg:last",$parentContainer);
		$("img.GOFormCaptchaImg:last",$parentContainer).not($captchaImg).remove();
		var $captchaKeyInput = $("input.GOFormCaptchaKey",$parentContainer);
		
		$.ajax({
			url: "/modules/GOForm.cfc?lang=fr&wsdl&method=getNewCaptcha",
			cache: false, data: {}, type: "POST", dataType: "json",
			success: function(data){
				$captchaImg.attr('src',data.CAPTCHA.IMGSRC);
				$captchaKeyInput.val(data.CAPTCHAKEY);
				
				/*$('<img />')
					.attr('src',data.CAPTCHA.IMGSRC)
					.addClass('GOFormCaptchaImg')
					.load(function(){
						$captchaImg.css({"zIndex":10}).after(this);
						$captchaImg.fadeOut(750,function(){
							$(this).remove();
						});
						///$captchaImg.attr("src",data.CAPTCHA.IMGSRC);
						$captchaKeyInput.val(data.CAPTCHAKEY);
					});*/
				
			}
		});
	});
	/* / CAPTCHA REFRESH */
	
	// INIT VALIDATION
	$("form.GOForm").each(initGOFormValidation);
	
	$("input,textarea",".GOForm").keyup(function(){
		if( $(".GOFormErrorContainer ul li",$(this).parents("form:first")).size() ){
			$(".GOFormErrorContainer , .GOFormErrorContainer ul",$(this).parents("form:first")).show();
		} else {
			$(".GOFormErrorContainer , .GOFormErrorContainer ul",$(this).parents("form:first")).hide();
		}
	});
});

/* / GOFORM */




