//----------------------------------------------------------------------------------------

// Authors : Melissa Maheux & Nadia HADJI, Influenza marketing http://www.influenza.ca
// Version 1.0
// Created: July 2011

//----------------------------------------------------------------------------------------


//------------------------------------------------------------------------
// Font Replacement - Cufon
//------------------------------------------------------------------------
 
Cufon.set('fontFamily', 'gotham');
Cufon.replace('#footer p.btncontact, #header ul li a, #homeC #solutionsbox a.btn, #homeC #processbox a.btn, #homeC #customersbox a.btn, #subtnav ul li, #subnav ul li a, #subnav h2 a, #subnav h2, .mainnav li a, .mainnav li', {
	hover: true
});
Cufon.replace('#footer #address h1, #footer #address p, #homeC h2');


//------------------------------------------------------------------------
// Process Tabs
//------------------------------------------------------------------------

$(function() {
	$('#coda-slider-8').codaSlider({
		crossLinking: false,
		firstPanelToLoad: 1
	});
});

//------------------------------------------------------------------------
// Sticky Footer
//------------------------------------------------------------------------

$(function(){

	var contentHeight = $('#sitewrapper').height();
	var windowHeight = $(window).height();
	
	if(contentHeight > windowHeight) {
	  $('#footerwrapper').addClass('sticky');
	}
});


//------------------------------------------------------------------------
// Slideshow
//------------------------------------------------------------------------
$(function() {

$('#ss01') 

	.before('<div id="cycleNav">')
	.cycle({ 
		fx:      'scrollRight', 
		speed:    1000, 
		timeout:  4000,
		pager:  '#cycleNav',
		pause:   1
	});
	
});


//------------------------------------------------------------------------
// Add Css
//------------------------------------------------------------------------

$(function(){
	$("#subnav ul li:first").addClass("first");
	$(".testimonialsbox:even").addClass("bgBeige");	
	$(".testimonialsbox:first").addClass("first");	
	$(".cases:even").addClass("bgbeige");	

});


//------------------------------------------------------------------------
// Contact Drawer
//------------------------------------------------------------------------

$(function() {
	
	$('a#panelButtonContact').click(function () {
		$('#contact').slideToggle(300);
		$(this).toggleClass('active');
		return false;
	});

	// Close button
	$("a.closePanel").click(function () {
		$('#contact').slideToggle(300);
		$("#panelButtons ul li a").removeClass("active");
		$("label.error").remove();
		return false;
	});
	
});


//------------------------------------------------------------------------
// Formulaire Contact EN
//------------------------------------------------------------------------
$(document).ready(function() {
						 
	jQuery.validator.addMethod("phone", function (value, el, params) {
	return this.optional(el) || /^[01]?[- .]?\(?[2-9]\d{2}\)?[- .]?\d{3}[- .]?\d{4}$/.test(value);
	}, "Veuillez entrer un numéro téléphone valide.");

      
    var validator = $("#contactF").bind("invalid-form.validate", function() {
		
	}).validate({
            
            rules: {
        		phone: {
        				phone: true
        			}
        		},
            messages: {
			firstname: "Required field",
			lastname: "Required field",
			email: {
            required: 'Required field',
            email: 'Invalid address'
            },
            phone: {
            required: 'Required field',
			phone: 'Invalid number'
            },
              message: "Required field"
            },
              submitHandler: function(form) {
              jQuery(form).ajaxSubmit({
              target: "#contactF",
                  success: function() {
                  $("#contactF").html("<div id=\"reponse\"></div>");
                  $("#reponse").html("<p>Votre message a &eacute;t&eacute; envoy&eacute; avec succ&egrave;s! Un membre de notre &eacute;quipe communiquera avec vous sous peu...</p>")
                  //.append("<p></p>")
                  .hide()
                  .fadeIn(1500, function() {
                  $("#reponse");
                  });
                  }
              });
              }
	});
});



//------------------------------------------------------------------------
// Accordeon Team
//------------------------------------------------------------------------

$(function() {

	//jQuery('.accordeon h5').addClass("alt");
	//jQuery('.accordeon h5').addClass("last");
		
	//jQuery(".accordeon h5:first").addClass("active");
	jQuery(".accordeon div.details").hide();
	
	jQuery(".accordeon h5").click(function(){
	
	jQuery(this).next("div.details").slideToggle("fast")
	
	.siblings("div.details:visible").slideUp("fast");
	
	jQuery(this).toggleClass("active");
	
	jQuery(this).siblings("h5").removeClass("active");
	
	});

});


