//*************************************************************************

//** Author : Guillaume Quimper - Influenza marketing **

//** Created : March 2009 **	

//*************************************************************************

$(document).ready(function(){

//Page Flip on hover

	$("#pageflip").hover(function() {
		$("#pageflip img , .msg_block").stop()
			.animate({
				width: '307px', 
				height: '306px'
			}, 250); 
		} , function() {
		$("#pageflip img").stop() 
			.animate({
				//width: '100px', 
				//height: '102px'
				width: '160px', 
				height: '162px'
			}, 220);
		$(".msg_block").stop() 
			.animate({
				width: '160px', 
				height: '160px'
			}, 200);
	});

});

// ***************
// Main Navigation
// ***************

$(function() {
	
	$('#mainNav li a:has(span.text)').append('<div class="light"></div>');
	
	$('#mainNav li.menu').hover(
		function() {
			$('ul', this).slideDown('normal');
		}, function() {
			$('ul', this).fadeTo(450, 1).slideUp('fast');
		}
	);
	
	
	$('#mainNav li').hover(
		function() {
			//$(this).append('<div class="light"></div>');
			$('div.light', this).fadeIn('normal');
		}, function() {
			$('a:not(.active) div.light', this).fadeOut('fast');
			//$('<div class="light"></div>').remove();
		}
	);
	
	$("#mainNav li ul li a").hover(
		function() {
			$("span", this).fadeIn("normal");
		}, function() {
			$("span", this).fadeOut("normal");
		}
	);
	
	
});

// ***********
// JScrollPane
// ***********
$(function() {
	$('.scroll-pane').jScrollPane({showArrows:true, scrollbarWidth: 18, arrowSize: 14, dragMinHeight: 18, dragMaxHeight: 18 });
});

// *********
// News Tabs
// *********	
$(function () {
	var tabContainers = $('#news > div');
	tabContainers.hide().filter(':first').show();
	
	$('div#news ul#newsTabs li a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).fadeIn("normal");
		$('div#news ul#newsTabs li a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').click();
});

// **************
// Adding Classes
// **************
$(function () {
	$("#aquapipe h5:first-child").addClass("first");
	$("#industry h5:first-child").addClass("first");
	$("#credits li:last-child").addClass("last");
	$("#content p:first-child").addClass("first");
	$("#content h5 + p").addClass("first");
	$("#content div.steps:first").addClass("first");
	$("#content div.steps:last").addClass("last");
	$("#content h6.news:last").addClass("last");
});

// **************
// Stripes Tables
// **************

$(function() {			   
	//$("table#specs tr:even").addClass("alt");
	//$("ol li:even").addClass("alt");
});

// *************
// Calling Flash
// *************
$(function(){
	$('.preview').flash({
  	 src: 'library/video/video-player.swf',
   	 width: 270,
   	 height: 215,
	 flashvars: {films: 'pete14.flv'}
	});
});

// *******
// Lighbox
// *******
$(function(){
	$("a[@rel*=lightbox]").lightBox();	   
});

// *******
// Mail To
// *******

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(){
	$('.mailto').mailto();
});