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

// Author : Guillaume Quimper
// Influenza marketing http://www.influenza.ca
// Version 1.0
// Created: Septembre 2010

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


//---------------------------------------------------------------------------------------------------------
// Disable some default browser behavior on imgages and links -  e.g. alt & title attributes from showing
//---------------------------------------------------------------------------------------------------------

$(function() {
	$('img, a').removeAttr('title');
	$('img').removeAttr('alt');
}); 


//------------------------------------------------------------------------
// Main Navigation Effects
//------------------------------------------------------------------------

$(function() {

  $("#siteNav li.parent a").next("#siteNav li ul").hide();
  $("#siteNav li.parent a").click( function () {  
        if($(this).next("#siteNav li.parent ul").is(":hidden")){
         $("#siteNav li.parent a").next("#siteNav li.parent ul:visible").slideUp();
         $(this).next("#siteNav li.parent ul").slideDown();
		 $("#siteNav li.parent a").removeClass("active");
		 $(this).addClass("active");
		 return(false);
       }
        else($(this).next("#siteNav li ul").slideUp());

          }); 
   $("#siteNav li.current-menu-ancestor a").next("#siteNav li ul").show();
   $(".strategie li.strategie a").next("#siteNav li ul").show();
   $(".design li.design a").next("#siteNav li ul").show();
   $(".web li.web a").next("#siteNav li ul").show();
   $(".influence li.influence a").next("#siteNav li ul").show()
   
}); 




//---------------------------------------------------------------------------
// Effect for CSS3 Transition Non Supporting Browsers
//---------------------------------------------------------------------------
$(function() { 
 	if ($.browser.msie == true) { var css3 = "unsupported"; } 
	  else if ($.browser.mozilla == true) { var css3 = "unsupported"; }
	  else { var css3 = "supported"; }
	
	if(css3 == "unsupported") {
		
		//Homepage Portfolio
		$('span.itemDescription').css({"top": "250px"});
		$("#itemsPortfolio li a").hover(
			function(){
				$('span.itemDescription',this).stop().animate({"top": "150px"}, "normal");
			},
			function() {
				$('span.itemDescription',this).stop().animate({"top": "250px"}, "fast");
			}
		);
		
		//Design & Web Portfolio
		$('#detailContainer').css({"left": "680px"});
		$("#itemWrapper").hover(
			function(){
				$('#detailContainer').stop().animate({"left": "480px"}, "normal");
			},
			function() {
				$('#detailContainer').stop().animate({"left": "680px"}, "fast");
			}
		);
	}
});

//------------------------------------------------------------------------
// Portfolio Navigation Tabs
//------------------------------------------------------------------------
$(function() {
	var tabContainers = $('div#panels > div');
	
	$('ul#categoryTabs a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        $('ul#categoryTabs a').removeClass('active');
        $(this).addClass('active');
        return false;
    }).filter('ul#categoryTabs a.active').click();
}); 

//------------------------------------------------------------------------
// Portfolio Navigation Tabs
//------------------------------------------------------------------------
$(function() {
	$('#imageContainer').cycle({ 
			requeueOnImageNotLoaded: true,
			fx: 'scrollHorz',
			timeout:  5000,
			pager:  '#pager'
    });
});

//------------------------------------------------------------------------
// Content H1 styling
//------------------------------------------------------------------------
$(function() {
	$('#pageContent h1, #newsSection h1, #featuredPortfolio h1').wrapInner('<span class="background"></span>');
	$('#pageContent h1, #newsSection h1, #featuredPortfolio h1').append('<span class="shadow"></span>');
}); 


//------------------------------------------------------------------------
// Standard post style p
//------------------------------------------------------------------------
$(function() {
	$('.post p:first').addClass('intro'); 	
}); 

//------------------------------------------------------------------------
// Clients List Accordions
//------------------------------------------------------------------------
$(function(){   
	$('#clients h4:last').css("border-bottom","1px solid #CDCDCE");
	$("#clients h4 a:first").addClass("aktif-liens");  
      
	$("#clients h4").click(function () {   
		$("#clients h4 a.aktif-liens").removeClass("aktif-liens");
		$("#clients h4:last").css("border-bottom","1px solid #CDCDCE"); 
		$(this).addClass("aktif-liens");
		$(this).next("div.slide").slideToggle("slow").siblings("div.slide:visible").slideUp("slow");
		return false;
	});
	
	$("#clients h4:last").click(function () {    
		$("#clients h4").css("border-bottom","none");
		return false;
	});
}); 

//------------------------------------------------------------------------
// Team Caroussel - Roundabout plugin 
//------------------------------------------------------------------------
$(function(){  
   
   //Set Team Caroussel for Modern Browsers
	  if ($.browser.msie && $.browser.version < 9) { var browser = "unsupported"; }
	  else { var browser = "supported"; }
	  
	  //Write Flash if Unsupported Browser
	  if (browser == "supported" ) {
		   $('<div id="teamDescription"></div>').insertAfter('#team');
		   
		   $('#team').roundabout({
				childSelector: 'div.teamMember',
				minOpacity : 0.05,
				reflect : true,
				duration : 400
			});
		   
		   
			$('#team div.teamMember').click(function () {
				var useText = $('div.teamDetails', this).html();
				$('#teamDescription').empty();
				$('#teamDescription').html(useText).fadeIn();
			}).filter('#team div:first').click();
		}
		if (browser == "unsupported" ) {
			$('div.teamMember img').wrap('<div class="thumbTeam" />');
		}
});




//------------------------------------------------------------------------
// Mailto links rewriting
//------------------------------------------------------------------------

jQuery.fn.mailto = function() {
	return this.each(function(){
		var email = $(this).html().replace(/\s*\(.+\)\s*/, "@");
		$(this).before('<a href="mailto:' + email + '" rel="nofollow" title="Email ' + email + '">' + email + '</a>').remove();
	});
};

$(function(){
	$('.courriel').mailto();
});

//------------------------------------------------------------------------
// Footer Clearing DIV
//------------------------------------------------------------------------
$(function(){
	$('<div class="vclear"></div>').insertAfter('#contactInformation');
});


//------------------------------------------------------------------------
// Client Zone Modal Box
//------------------------------------------------------------------------
$(function() {    
   
     //select all the a tag with name equal to modal  
     $('a[rel=modal]').click(function(e) {  
		 
		 //Cancel the link behavior  
         e.preventDefault();  
         
		 //Build variables form trigger link  
         var iframe = $(this).attr('href');
		 var closeLang = $(this).attr('lang');
		 if (closeLang == 'fr') { var closeTag = "Fermer"; }
		 else { var closeTag = "Close"; }

		 
		 // Add transparent Outer Mask
		 $('body').append('<div id="mask"></div>');
		 
		 // Build div containing iframe
		 $('body').append('<div id="zoneClient"></div>');
		 $('#zoneClient').html('<a href="#" class="close">'+ closeTag +'</a><iframe src="'+ iframe +'" frameborder="0" width="720" height=" 480" scrolling="auto"></iframe>')
       
         //Get the screen height and width  
         var maskHeight = $(document).height();  
         var maskWidth = $(window).width();  
       
         //Set height and width to mask to fill up the whole screen  
         $('#mask').css({'width':maskWidth,'height':maskHeight});  
         
         //transition effect       
         //$('#mask').fadeIn(1000);
		 $('#mask').fadeTo("fast",0.25); 
       
         //Get the window height and width  
         var winH = $(window).height();  
         var winW = $(window).width();  
                 
         //Set the popup window to center  
         $('#zoneClient').css('top',  winH/2-$('#zoneClient').height()/2);  
         $('#zoneClient').css('left', winW/2-$('#zoneClient').width()/2);  
       
         //transition effect  
         $('#zoneClient').fadeIn(200);
		 
		 //if close button is clicked  
		 $('a.close').click(function () {   
			 $('#mask, #zoneClient').fadeOut(200);
			 return false;
		 });       
		   
		 //if mask is clicked  
		 $('#mask').click(function () {  
			 $(this).fadeOut();  
			 $('#zoneClient').fadeOut(200);
		 });    
       
     });  
       
            
       
});


//------------------------------------------------------------------------
// Single page strategie
//------------------------------------------------------------------------

$(function(){  	
  $(".strategyItem p").before('<div id="img">');  
  $("#img").append($(".strategyItem img"));  
  var taille=$(".strategyItem img").attr("width");
  $(".strategyItem p").css("padding-right", taille);
});
