$(document).ready(function() {
// FallBack Select Navigation
$('#NavigationSelect').change(function() {
location.href = $(this).val();
});
// Champ e-mail
$('input[type=email]').on('blur', function() {
var _id = $(this).attr('id');
$(this).mailcheck({
suggested: function(element, suggestion) {
$('#'+_id+"_suggestion").html("La syntaxe de l'adresse ne serait pas plutôt " + suggestion.full + " ?" ).show();
},
empty: function(element) {
$('#'+_id+"_suggestion").hide();
}
});
});
$('.email_suggeree').die().live('click', function() {
$('#'+$(this).attr('rel')).val($(this).html());
$('#'+$(this).attr('rel')+'_suggestion').html('').hide();
});
// Label : CheckBox / Radio
InitLabel();
// Initialisation de l'UI
InitUI();
// Recherche Lieu (PreFooter)
if ($("#RechercheLieuPrefooter").length > 0) {
// centers
var RechercheLieuPrefooter = document.getElementById('RechercheLieuPrefooter');
var AutocompleteLieuPrefooter = new google.maps.places.Autocomplete(RechercheLieuPrefooter, {componentRestrictions: {country: "us"}});
google.maps.event.addListener(AutocompleteLieuPrefooter, 'place_changed', function() {
var PlaceResult = AutocompleteLieuPrefooter.getPlace();
if(PlaceResult)
var Hash = (PlaceResult.formatted_address) ? PlaceResult.formatted_address : PlaceResult.name;
else
var Hash = $('#RechercheLieuPrefooter').val();
location.href = "http://www.carboncleaningusa.com/centers#"+Hash;
});
$('#BtnRechercheLieuPrefooter').click(function(){
google.maps.event.trigger(AutocompleteLieuPrefooter, 'place_changed');
});
}
// ------//
// Child //
// ------//
// Truc pour le dernier sous menu
$('.Navigation div.MainLink:last-child').addClass('last-child');
// ---------- //
// Navigation //
// ---------- //
$(window).load(function(){
$.browser.chrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
// Position par défaut (Rubrique en cours, classe 'On')
var curseur = $('.Navigation .Curseur');
if ($('.Navigation .MainLink a.Main.On').length > 0)
{
var curseur_defaut = NavPosition($('.Navigation .MainLink a.Main.On').parent());
}
else
{
var curseur_defaut = curseur.css('left');
}
curseur.css('left', curseur_defaut).show();
// Over
function NavigationOver(){
var _obj = $(this);
$('a.Main', _obj).addClass('Hovered');
$('ul', _obj).slideDown('fast');
curseur.animate({ left: NavPosition($(this)) }, 500, 'easeInOutExpo', function() {});
}
// Out, on vérifie si on quitte carrément la navigation
function NavigationOut(){
var _obj = $(this);
$('a.Main', _obj).removeClass('Hovered');
$('ul', _obj).slideUp('fast');
var hoverNav = ($('.Navigation').is(':hover'));
if (hoverNav == false) {
curseur.animate({ left: curseur_defaut }, 500, 'easeInOutExpo', function() {});
}
}
// Calcul pour la position du curseur sur l'élément survolé
function NavPosition(obj)
{
/* if (obj.parent().hasClass('WithSub')) {
var obj = obj.parent();
var pos = obj.position();
var lar = obj.width()+10;
} else {
var pos = obj.position();
var lar = obj.width()+30;
} */
var pos = obj.position();
var lar = obj.outerWidth();
var margin = (obj.outerWidth(true) - obj.innerWidth());
if(typeof pos != 'undefined') var curseur_pos = pos.left + margin + (lar / 2) - Math.round((curseur.width() / 2))+3;
return curseur_pos;
}
// Configuration du hoverIntent
var config = {
sensitivity: 2,
interval: 50,
over: NavigationOver,
timeout: 500,
out: NavigationOut
};
$('.Navigation div.MainLink').hoverIntent(config);
});
/* Scroll to top */
var rootObj = $('html, body');
var speedScrollTo = 800;
$(window).scroll(function(){
var posScroll = $(document).scrollTop();
var _Hoteur = 0;
_Hoteur += $('.Header').height();
_Hoteur += $('.Navigation').height();
_Hoteur += $('.Droite').height();
if ((posScroll >= _Hoteur) && ($(document).height() > _Hoteur)) { $('a.GoToTop').css('visibility', 'visible').fadeIn(300); }
else { $('a.GoToTop').fadeOut(300, function() { $(this).css('visibility', 'hidden') }); }
});
$('a.GoToTop').click(function() {
$(this).hide();
rootObj.animate({
scrollTop: 0
}, speedScrollTo, 'easeOutExpo');
return false;
});
$('.NavigationBlocs li a').click(function() {
var _href = $(this).attr('href');
rootObj.animate({
scrollTop: $( $.attr(this, 'href') ).offset().top
}, speedScrollTo, 'easeOutExpo');
return false;
});
/* $('.LienIdentificationPro, .ConnexionProRequise').click(function() {
Sessionize('ShowToolTipConnexion', '1', '', function() { location.href = 'http://www.carboncleaningusa.com/start-your-own-business'; });
});
$('.ConnexionProRequise').bind('click', false); */
if (navigator.geolocation)
{
$('.PreFooter .Localisation').addClass('GeolocalisationActivee');
$('.PreFooter .Localisation .BtnMaPosition').show();
}
});
//////////////////////////////////
// QUESTIONNAIRE -- START //
//////////////////////////////////
function AfficherQuestionnaire()
{
if(arguments.length == 3)
{
var type_moteur = arguments[0];
var id_marque = arguments[1];
var id_modele = arguments[2];
if(type_moteur != '')
{
EnregistrerValeurQuestionnaire('type_moteur', type_moteur, function(){
if(id_marque != '')
{
EnregistrerValeurQuestionnaire('id_marque', id_marque, function(){
if(id_modele != '')
{
EnregistrerValeurQuestionnaire('id_modele', id_modele, AfficherQuestionnairePrivate);
}
else
AfficherQuestionnairePrivate();
});
}
else
AfficherQuestionnairePrivate();
});
}
else
AfficherQuestionnairePrivate();
}
else
AfficherQuestionnairePrivate();
}
function AfficherQuestionnairePrivate()
{
$.fancybox.open([
{
href : './op_questionnaire_diagnostic.php?Action=Questionnaire'
}
], {
padding : 0 ,
type:'ajax' ,
minWidth : 270,
maxWidth : 650,
maxHeight : 650,
wrapCSS : 'BoxyQuestionnaire',
scrolling : 'visible',
autoResize : true,
autoCenter : true,
afterShow : function(){
AfterShow();
}
});
}
var ListeEnregistrerValeurQuestionnaireAjax = {};
function EnregistrerValeurQuestionnaire(Clef, Valeur, callBack)
{
// Dans le tableau
if(ListeEnregistrerValeurQuestionnaireAjax[Clef] && ListeEnregistrerValeurQuestionnaireAjax[Clef] != null)
ListeEnregistrerValeurQuestionnaireAjax[Clef].abort();
ListeEnregistrerValeurQuestionnaireAjax[Clef] = $.ajax({
type: "POST",
url: "./op_questionnaire_diagnostic.php",
data: "Action=EnregistrerValeurQuestionnaire&Clef="+Clef+"&Valeur="+Valeur,
dataType : 'html',
cache: false,
async: true,
success: function(data) { eval(data); if(callBack && $.isFunction(callBack)) callBack(); /* console.log(ListeClefs); */ return(false); },
error: function() {}
});
return false;
}
function QuestionSuivante(Etape)
{
return Action('Action=QuestionSuivante', 'op_questionnaire_diagnostic.php');
}
function AfficherEtapeQuestionnaire(Etape)
{
return Action('Action=AfficherEtapeQuestionnaire&Etape='+Etape, 'op_questionnaire_diagnostic.php');
}
//////////////////////////////////
// QUESTIONNAIRE -- END //
//////////////////////////////////
//////////////////////////////
// Les labels -- START //
//////////////////////////////
function InitLabel()
{
$('body').addClass('has-js');
$('.label_check, .label_radio, .cssLabelPointure, .cssLabelCouleur').click(function(){
setupLabel();
});
setupLabel();
}
function setupLabel() {
if ($('.label_check input').length)
{
$('.label_check').each(function(){
$(this).removeClass('c_on');
});
$('.label_check input:checked').each(function(){
$(this).parent('label').addClass('c_on');
});
$('.label_check input:disabled').each(function(){
$(this).parent('label').addClass('c_disabled');
});
}
if ($('.label_radio input').length)
{
$('.label_radio').each(function(){
$(this).removeClass('r_on');
});
$('.label_radio input:checked').each(function(){
$(this).parent('label').addClass('r_on');
});
$('.label_radio input:disabled').each(function(){
$(this).parent('label').addClass('r_disabled');
});
}
}
//////////////////////////////
// Les labels -- END //
//////////////////////////////
function Action(dataString, urldest, callback, beforeSend)
{
// Execution du formulaire
$.ajax({
type: "POST",
url: urldest,
beforeSend: beforeSend,
data: dataString,
dataType : 'html',
cache: false,
async: true,
success: function(data) { eval(data); if($.isFunction(callback)) callback(); return(false); },
error: function() { Boxy.alert('Une erreur est survenue. Veuillez réessayer à nouveau.
Si le problème persiste veuillez contacter l\'administrateur du système.', null, {title: 'Information'}); }
});
return false;
}
/* ---------------- */
/* --- INIT. UI --- */
/* ---------------- */
function InitUI() {
// Initialisation des onglets
$('.tabs').tabs();
// Initialisation des champs d'erreur pour les formulaires
if($('form input[type=text], form input[type=password], form textarea').length) $('form input[type=text], form input[type=password], form textarea').focus(function() { $('#'+$(this).attr('id')+"_Err").slideUp('fast'); });
// Initialisation des boutons
//if($("button:not(.NojQuery), a.uiButton").length) $("button:not(.NojQuery), a.uiButton").button().mouseout(function() { $(this).removeClass('ui-state-focus'); });
if($(".uiIconConnexion").length) $('.uiIconConnexion').button({icons: { primary: "ui-icon-locked" }});
if($(".uiIconDefaut").length) $('.uiIconDefaut').button({icons: { primary: "ui-icon-heart" }});
if($(".uiIconModifier").length) $('.uiIconModifier').button({icons: { primary: "ui-icon-pencil" }});
if($(".uiIconSupprimer").length) $('.uiIconSupprimer').button({icons: { primary: "ui-icon-circle-close" }});
if($(".uiIconEnvoyer").length) $('.uiIconEnvoyer').button({icons: { primary: "ui-icon-play" }});
// Initialisation des radios & checkbox
$('input[type=checkbox]').checkBox();
if($(".RadioSet").length) $(".RadioSet").buttonset();
// Masques de saisie (meioMask)
// $('.maskTelephone').setMask({mask : '99 99 99 99 99', autoTab: false});
// $('.maskHeure').setMask({mask : '24:59', autoTab: false});
// $('.maskDate').setMask({mask : '39/19/9999', autoTab: false});
// $('.maskNumber').setMask({mask : '999999', autoTab: false});
// DatePicker en Français
$.datepicker.setDefaults($.datepicker.regional['fr']);
$.datepicker.setDefaults({showWeek: true, dateFormat: 'dd/mm/yy', constrainInput: true});
if($(".DDChosen").length && ! /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent))
$('.DDChosen').each(function() {
var _obj = $(this);
disable_search_threshold_value = 9999;
if (_obj.attr('enable_search') == 'on') disable_search_threshold_value = 0;
_obj.chosen({ disable_search_threshold: disable_search_threshold_value });
});
// Initialisation des tooltips
if($(".tipsy").length) $('.tipsy').remove();
if($(".tooltip").length) $('.tooltip').tipsy({title: 'alt', gravity: 's'});
if($(".tooltip-s").length) $('.tooltip-s').tipsy({title: 'alt', gravity: 's'});
if($(".tooltip-n").length) $('.tooltip-n').tipsy({title: 'alt', gravity: 'n'});
if($(".tooltip-w").length) $('.tooltip-w').tipsy({title: 'alt', gravity: 'w'});
if($(".tooltip-e").length) $('.tooltip-e').tipsy({title: 'alt', gravity: 'e'});
if($(".tooltip-ne").length) $('.tooltip-ne').tipsy({title: 'alt', gravity: 'ne'});
if($(".tooltip-nw").length) $('.tooltip-nw').tipsy({title: 'alt', gravity: 'nw'});
if($(".tooltip-se").length) $('.tooltip-se').tipsy({title: 'alt', gravity: 'se'});
if($(".tooltip-sw").length) $('.tooltip-sw').tipsy({title: 'alt', gravity: 'sw'});
if($(".tooltipT").length) $('.tooltipT').tipsy({gravity: 's'});
if($(".tooltipT-s").length) $('.tooltipT-s').tipsy({gravity: 's'});
if($(".tooltipT-n").length) $('.tooltipT-n').tipsy({gravity: 'n'});
if($(".tooltipT-w").length) $('.tooltipT-w').tipsy({gravity: 'w'});
if($(".tooltipT-e").length) $('.tooltipT-e').tipsy({gravity: 'e'});
if($(".tooltipT-ne").length) $('.tooltipT-ne').tipsy({gravity: 'ne'});
if($(".tooltipT-nw").length) $('.tooltipT-nw').tipsy({gravity: 'nw'});
if($(".tooltipT-se").length) $('.tooltipT-se').tipsy({gravity: 'se'});
if($(".tooltipT-sw").length) $('.tooltipT-sw').tipsy({gravity: 'sw'});
// Initialisation des fancy
if($(".fancybox").length)
$('.fancybox').fancybox({
helpers : {
overlay : {
locked : false // try changing to true and scrolling around the page
}
}
});
if($("img.fancy").length)
$('img.fancy').each(function() {
var _alt = $(this).attr('alt');
if (_alt != '') {
var _position = $(this).position();
var _width = $(this).width();
var _height = $(this).height();
$(this).after('