﻿//¤¤¤ ON LOAD EVENTS ¤¤¤

$(document).ready(function() {

    //Load Roll overs effects
    RollHoverEffects();
    
    //Used in the product template
    VerticalCenteringForIE();

    //Forms - Validation
  $("form").validity(function() {
       $(".textbox.require").require();
      $(".txtemail").require().match("email");
       $(".txttelephone").require().match("phone");
   });

   $("#ctl00_lnkAlertes").attr('href', $("#ctl00_lnkAlertes").attr('href') + "#result")
   $("#ctl00_lnkAlertes2").attr('href', $("#ctl00_lnkAlertes2").attr('href') + "#result")

    //Forms - French Language Pack for jValidity
    if (ReturnLanguage() == "fr") { $.extend($.validity.messages, { require: "Ce champ est requis.", phone: "Ce champ doit être de format ###-###-####", email: "Ce champ doit être un adresse courriel" }); }

    //Forms - Add effect when you just sent an form request. 
    $(".form-confirmation").effect("pulsate", { times: 3 }, 1000);

    //Add hint to Textboxes [jquery.hint.js]
    $(":text").hint();


    //Make some input controls pretty. All those with the class .uniform
    //$(".uniform").uniform();


    //¤¤ NOW WEBSITE CUSTOM ¤¤¤¤¤¤¤¤¤¤

    //Load client ribbon carousel : jquery.jcarousel.pack.js
    //jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) { if ((t /= d) < (1 / 2.75)) { return c * (7.5625 * t * t) + b; } else if (t < (2 / 2.75)) { return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b; } else if (t < (2.5 / 2.75)) { return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b; } else { return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b; } };
    //$('#ribboncarousel').jcarousel({ auto: 5, easing: 'BounceEaseOut', animation: 1000, wrap: 'last' });

    $(document).ready(function () {
        $('#header')
            .before('<div id="nav">')
            .cycle({
                fx: 'fade',
                delay: 10000,
                timeout: 5000,
                pause: 1
            });
    });
	
	//Hide banner & carousel for inner pages
	if ($("body").hasClass("nothomepage")) {
		$("#header").css("display","none");
		$("#ctl00_Categories").css("display","none");
	}
});




function RollHoverEffects()
{

    //.simplehover - Rollover effect on links
    $("div.simplehover").mouseover(function() {
        $(this).attr("style", $(this).attr("style").replace("-off.", "-on."));
    }).mouseout(function() {
        $(this).attr("style", $(this).attr("style").replace("-on.", "-off."));
    });


    //.fadehover - Rollover effect on links and images with FADE
    $("a.fadehover img, img.fadehover").mouseover(function() {
        $(this).stop(true, true).fadeTo(0, 0.5, function() {
            $(this).attr("src", $(this).attr("src").replace("-off.", "-on.")).fadeTo(500, 1);
        });
    }).mouseout(function() {
        $(this).stop(true, true).fadeTo(50, 0.5, function() {
            $(this).attr("src", $(this).attr("src").replace("-on.", "-off.")).fadeTo(50, 1);
        });
    });

    //Effect on thumbnails images.
    $("a.imagehover img, img.imagehover").mouseover(function() {
        $(this).stop().fadeTo(0, 0.35);
        $(this).stop().fadeTo(500, 1);
    });


}


//¤¤¤ FUNCTIONS & UTILITIES ¤¤¤

function ReturnLanguage() {
    language = $(location).attr('href').substr($(location).attr('href').indexOf('/', 7) + 1, 2);
    return language;
}

function VerticalCenteringForIE() {
    $(".category-image").load(function() {
        $(this).css("top", ($(this).parent().height() - $(this).height()) / 2);
    }).each(function() {
        if (this.complete) $(this).trigger("load"); //Patch for IE cached images
    });
}

//parse URL to get values  - To retrieve example : var i = getUrlVars()["i"];
function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
