/**
* main script file
* @author		mac@zestedegenie.com
* @creationDate 2011-06-06
* @editDate		2011-06-06
*/


/** *******************************************************
 * open links with rel='external' in new tabs
 * @author http://www.456bereastreet.com/archive/200610/opening_new_windows_with_javascript_version_12/
 */
var JSTarget={init:function (att,val,warning) {if (document.getElementById&&document.createElement&&document.appendChild) {var strAtt=((typeof att==='undefined')||(att===null))?'class':att;var strVal=((typeof val==='undefined')||(val===null))?'non-html':val;var strWarning=((typeof warning==='undefined')||(warning===null))?' (opens in a new window)':warning;var oWarning;var arrLinks=document.getElementsByTagName('a');var oLink;var oRegExp=new RegExp("(^|\\s)"+strVal+"(\\s|$)");for(var i=0;i<arrLinks.length;i++) {oLink=arrLinks[i];if ((strAtt=='class')&&(oRegExp.test(oLink.className))||(oRegExp.test(oLink.getAttribute(strAtt)))) {oWarning=document.createElement("em");oWarning.appendChild(document.createTextNode(strWarning));oLink.appendChild(oWarning);oLink.onclick=JSTarget.openWin;}oWarning=null;}}},openWin:function (e) {var event=(!e)?window.event:e;if (event.shiftKey||event.altKey||event.ctrlKey||event.metaKey) {return true;} else {var oWin=window.open(this.getAttribute('href'),'_blank');if (oWin) {if (oWin.focus) {oWin.focus();}return false;}oWin=null;return true;}},addEvent:function (obj,type,fn) {if (obj.addEventListener) {obj.addEventListener(type,fn,false);}else if (obj.attachEvent) {obj["e"+type+fn]=fn;obj[type+fn]=function () {obj["e"+type+fn](window.event);};obj.attachEvent("on"+type,obj[type+fn]);}}};JSTarget.addEvent(window,'load',function () {JSTarget.init("rel","external","");});

/** *******************************************************
 * ColorBox v1.3.16 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
 * @author 2011 Jack Moore - jack@colorpowered.com Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
 */
(function (a,b,c) {function ba(b) {if (!T) {O=b,Z(a.extend(J,a.data(O,e))),x=a(O),P=0,J.rel!=="nofollow"&&(x=a("."+V).filter(function () {var b=a.data(this,e).rel||this.rel;return b===J.rel}),P=x.index(O),P===-1&&(x=x.add(O),P=x.length-1));if (!R) {R=S=!0,q.show();if (J.returnFocus)try{O.blur(),a(O).one(k,function () {try{this.focus()}catch(a) {}})}catch(c) {}p.css({opacity:+J.opacity,cursor:J.overlayClose?"pointer":"auto"}).show(),J.w=X(J.initialWidth,"x"),J.h=X(J.initialHeight,"y"),U.position(0),n&&y.bind("resize."+o+" scroll."+o,function () {p.css({width:y.width(),height:y.height(),top:y.scrollTop(),left:y.scrollLeft()})}).trigger("resize."+o),$(g,J.onOpen),I.add(C).hide(),H.html(J.close).show()}U.load(!0)}}function _() {var a,b=f+"Slideshow_",c="click."+f,d,e,g;J.slideshow&&x[1]&&(d=function () {E.text(J.slideshowStop).unbind(c).bind(i,function () {if (P<x.length-1||J.loop)a=setTimeout(U.next,J.slideshowSpeed)}).bind(h,function () {clearTimeout(a)}).one(c+" "+j,e),q.removeClass(b+"off").addClass(b+"on"),a=setTimeout(U.next,J.slideshowSpeed)},e=function () {clearTimeout(a),E.text(J.slideshowStart).unbind([i,h,j,c].join(" ")).one(c,d),q.removeClass(b+"on").addClass(b+"off")},J.slideshowAuto?d():e())}function $(b,c) {c&&c.call(O),a.event.trigger(b)}function Z(b) {for(var c in b)a.isfunction (b[c])&&c.substring(0,2)!=="on"&&(b[c]=b[c].call(O));b.rel=b.rel||O.rel||"nofollow",b.href=a.trim(b.href||a(O).attr("href")),b.title=b.title||O.title}function Y(a) {return J.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(a)}function X(a,b) {b=b==="x"?y.width():y.height();return typeof a=="string"?Math.round(/%/.test(a)?b/100*parseInt(a,10):parseInt(a,10)):a}function W(c,d) {var e=b.createElement("div");c&&(e.id=f+c),e.style.cssText=d||!1;return a(e)}var d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0},e="colorbox",f="cbox",g=f+"_open",h=f+"_load",i=f+"_complete",j=f+"_cleanup",k=f+"_closed",l=f+"_purge",m=a.browser.msie&&!a.support.opacity,n=m&&a.browser.version<7,o=f+"_IE6",p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J={},K,L,M,N,O,P,Q,R,S,T=!1,U,V=f+"Element";U=a.fn[e]=a[e]=function (b,c) {var f=this,g;if (!f[0]&&f.selector)return f;b=b||{},c&&(b.onComplete=c);if (!f[0]||f.selector===undefined)f=a("<a/>"),b.open=!0;f.each(function () {a.data(this,e,a.extend({},a.data(this,e)||d,b)),a(this).addClass(V)}),g=b.open,a.isfunction (g)&&(g=g.call(f)),g&&ba(f[0]);return f},U.init=function () {y=a(c),q=W().attr({id:e,"class":m?f+(n?"IE6":"IE"):""}),p=W("Overlay",n?"position:absolute":"").hide(),r=W("Wrapper"),s=W("Content").append(z=W("LoadedContent","width:0; height:0; overflow:hidden"),B=W("LoadingOverlay").add(W("LoadingGraphic")),C=W("Title"),D=W("Current"),F=W("Next"),G=W("Previous"),E=W("Slideshow").bind(g,_),H=W("Close")),r.append(W().append(W("TopLeft"),t=W("TopCenter"),W("TopRight")),W(!1,"clear:left").append(u=W("MiddleLeft"),s,v=W("MiddleRight")),W(!1,"clear:left").append(W("BottomLeft"),w=W("BottomCenter"),W("BottomRight"))).children().children().css({"float":"left"}),A=W(!1,"position:absolute; width:9999px; visibility:hidden; display:none"),a("body").prepend(p,q.append(r,A)),s.children().hover(function () {a(this).addClass("hover")},function () {a(this).removeClass("hover")}).addClass("hover"),K=t.height()+w.height()+s.outerHeight(!0)-s.height(),L=u.width()+v.width()+s.outerWidth(!0)-s.width(),M=z.outerHeight(!0),N=z.outerWidth(!0),q.css({"padding-bottom":K,"padding-right":L}).hide(),F.click(function () {U.next()}),G.click(function () {U.prev()}),H.click(function () {U.close()}),I=F.add(G).add(D).add(E),s.children().removeClass("hover"),a("."+V).live("click",function (a) {a.button!==0&&typeof a.button!="undefined"||a.ctrlKey||a.shiftKey||a.altKey||(a.preventDefault(),ba(this))}),p.click(function () {J.overlayClose&&U.close()}),a(b).bind("keydown."+f,function (a) {var b=a.keyCode;R&&J.escKey&&b===27&&(a.preventDefault(),U.close()),R&&J.arrowKey&&x[1]&&(b===37?(a.preventDefault(),G.click()):b===39&&(a.preventDefault(),F.click()))})},U.remove=function () {q.add(p).remove(),a("."+V).die("click").removeData(e).removeClass(V)},U.position=function (a,c) {function g(a) {t[0].style.width=w[0].style.width=s[0].style.width=a.style.width,B[0].style.height=B[1].style.height=s[0].style.height=u[0].style.height=v[0].style.height=a.style.height}var d,e=Math.max(b.documentElement.clientHeight-J.h-M-K,0)/2+y.scrollTop(),f=Math.max(y.width()-J.w-N-L,0)/2+y.scrollLeft();d=q.width()===J.w+N&&q.height()===J.h+M?0:a,r[0].style.width=r[0].style.height="9999px",q.dequeue().animate({width:J.w+N,height:J.h+M,top:e,left:f},{duration:d,complete:function () {g(this),S=!1,r[0].style.width=J.w+N+L+"px",r[0].style.height=J.h+M+K+"px",c&&c()},step:function () {g(this)}})},U.resize=function (a) {if (R) {a=a||{},a.width&&(J.w=X(a.width,"x")-N-L),a.innerWidth&&(J.w=X(a.innerWidth,"x")),z.css({width:J.w}),a.height&&(J.h=X(a.height,"y")-M-K),a.innerHeight&&(J.h=X(a.innerHeight,"y"));if (!a.innerHeight&&!a.height) {var b=z.wrapInner("<div style='overflow:auto'></div>").children();J.h=b.height(),b.replaceWith(b.children())}z.css({height:J.h}),U.position(J.transition==="none"?0:J.speed)}},U.prep=function (b) {function h(b) {U.position(b,function () {var b,d,g,h,j=x.length,k,n;!R||(n=function () {B.hide(),$(i,J.onComplete)},m&&Q&&z.fadeIn(100),C.html(J.title).add(z).show(),j>1?(typeof J.current=="string"&&D.html(J.current.replace(/\{current\}/,P+1).replace(/\{total\}/,j)).show(),F[J.loop||P<j-1?"show":"hide"]().html(J.next),G[J.loop||P?"show":"hide"]().html(J.previous),b=P?x[P-1]:x[j-1],g=P<j-1?x[P+1]:x[0],J.slideshow&&E.show(),J.preloading&&(h=a.data(g,e).href||g.href,d=a.data(b,e).href||b.href,h=a.isfunction (h)?h.call(g):h,d=a.isfunction (d)?d.call(b):d,Y(h)&&(a("<img/>")[0].src=h),Y(d)&&(a("<img/>")[0].src=d))):I.hide(),J.iframe?(k=a("<iframe/>").addClass(f+"Iframe")[0],J.fastIframe?n():a(k).load(n),k.name=f+ +(new Date),k.src=J.href,J.scrolling||(k.scrolling="no"),m&&(k.frameborder=0,k.allowTransparency="true"),a(k).appendTo(z).one(l,function () {k.src="//about:blank"})):n(),J.transition==="fade"?q.fadeTo(c,1,function () {q[0].style.filter=""}):q[0].style.filter="",y.bind("resize."+f,function () {U.position(0)}))})}function g() {J.h=J.h||z.height(),J.h=J.mh&&J.mh<J.h?J.mh:J.h;return J.h}function d() {J.w=J.w||z.width(),J.w=J.mw&&J.mw<J.w?J.mw:J.w;return J.w}if (!!R) {var c=J.transition==="none"?0:J.speed;y.unbind("resize."+f),z.remove(),z=W("LoadedContent").html(b),z.hide().appendTo(A.show()).css({width:d(),overflow:J.scrolling?"auto":"hidden"}).css({height:g()}).prependTo(s),A.hide(),a(Q).css({"float":"none"}),n&&a("select").not(q.find("select")).filter(function () {return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(j,function () {this.style.visibility="inherit"}),J.transition==="fade"?q.fadeTo(c,0,function () {h(0)}):h(c)}},U.load=function (b) {var c,d,g=U.prep;S=!0,Q=!1,O=x[P],b||Z(a.extend(J,a.data(O,e))),$(l),$(h,J.onLoad),J.h=J.height?X(J.height,"y")-M-K:J.innerHeight&&X(J.innerHeight,"y"),J.w=J.width?X(J.width,"x")-N-L:J.innerWidth&&X(J.innerWidth,"x"),J.mw=J.w,J.mh=J.h,J.maxWidth&&(J.mw=X(J.maxWidth,"x")-N-L,J.mw=J.w&&J.w<J.mw?J.w:J.mw),J.maxHeight&&(J.mh=X(J.maxHeight,"y")-M-K,J.mh=J.h&&J.h<J.mh?J.h:J.mh),c=J.href,B.show(),J.inline?(W().hide().insertBefore(a(c)[0]).one(l,function () {a(this).replaceWith(z.children())}),g(a(c))):J.iframe?g(" "):J.html?g(J.html):Y(c)?(a(Q=new Image).addClass(f+"Photo").error(function () {J.title=!1,g(W("Error").text("This image could not be loaded"))}).load(function () {var a;Q.onload=null,J.scalePhotos&&(d=function () {Q.height-=Q.height*a,Q.width-=Q.width*a},J.mw&&Q.width>J.mw&&(a=(Q.width-J.mw)/Q.width,d()),J.mh&&Q.height>J.mh&&(a=(Q.height-J.mh)/Q.height,d())),J.h&&(Q.style.marginTop=Math.max(J.h-Q.height,0)/2+"px"),x[1]&&(P<x.length-1||J.loop)&&(Q.style.cursor="pointer",Q.onclick=function () {U.next()}),m&&(Q.style.msInterpolationMode="bicubic"),setTimeout(function () {g(Q)},1)}),setTimeout(function () {Q.src=c},1)):c&&A.load(c,function (b,c,d) {g(c==="error"?W("Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},U.next=function () {!S&&x[1]&&(P<x.length-1||J.loop)&&(P=P<x.length-1?P+1:0,U.load())},U.prev=function () {!S&&x[1]&&(P||J.loop)&&(P=P?P-1:x.length-1,U.load())},U.close=function () {R&&!T&&(T=!0,R=!1,$(j,J.onCleanup),y.unbind("."+f+" ."+o),p.fadeTo(200,0),q.stop().fadeTo(300,0,function () {q.add(p).css({opacity:1,cursor:"auto"}).hide(),$(l),z.remove(),setTimeout(function () {T=!1,$(k,J.onClosed)},1)}))},U.element=function () {return a(O)},U.settings=d,a(U.init)})(jQuery,document,this);

/** *******************************************************
 * browser vars
 */

var isIe = false;
var isIe6 = false;
var isIe7 = false;

/**
 * Check if browser is IE
 */
if ($.browser.msie) {
	isIe = true;
}
/**
 * Check if browser is IE6 or less
 */
if (isIe === true && $.browser.version < 7) {
	isIe6 = true;
}
if (isIe === true && $.browser.version < 8) {
	isIe7 = true;
}


/** *******************************************************
 * contain text vars
 */
var vars = {
	init: function () {
		// site.root
		vars.root = "/";
	
		if ($('body.en')[0]) { // if site EN
			vars.lang = 'en';
			// colobox
			vars.current = "image {current} of {total}";
			vars.previous = "previous";
			vars.next = "next";
			vars.close = "Close";
		} else {
			vars.lang = 'fr';
			// colobox
			vars.current = "image {current} de {total}";
			vars.previous = "suivant";
			vars.next = "précédent";
			vars.close = "Fermer";
		}
	}
};


/** *******************************************************
 * Put elements at the same height
 */
var equalHeight = {
	/**
	 * init
	 * @param	jQuery $group	jQuery object of the elements to equalize
	 */
	init: function (group) {
		var tallest = 0;
		group.each(function () {
			var thisHeight = $(this).height();
			if (thisHeight > tallest) { // if curr height higher than tallest
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	}
};


/** *******************************************************
 * Generate a tooltip
 */
var tt = {
	/**
	 * init the tooltip
	 * @param	jQuery $ele jQuery object of the elements that need an tooltip
	 */
	init: function (ele) {
		ele.live('mouseover', tt.tipOver);
		ele.live('mouseout', tt.tipOut);
		
		if (!$("#tip")[0]) {
			var tip = '<span id="tip" class="none"></span>';
			$("#wrapper").append(tip);
			$("#tip").hide().removeClass('none');
			
			this.winWidth = $(window).width(); // curr window width
			this.pad = parseInt($("#tip").css('padding-left'), 10) + parseInt($("#tip").css('padding-right'), 10); // tooltip padding
			this.text = '';
		}
		
		$(window).resize(function () {
			tt.winWidth = $(window).width();
		});
	},
	/**
	 * hover of tooltip
	 * @param	jQuery $e	the mouseover event
	 */
	tipOver: function (e) {
				
		var tip = $("#tip");
		tip.hide();
		tt.text = '';
		tip.html('');
		tip.removeClass('tip-event');
				
		if ($(this).attr("title") !== "" && typeof ($(this).attr("title")) !== 'undefined') { // check if title attr present and not empty
			tip.append($(this).attr("title"));
			tt.text = $(this).attr("title"); // save current attr
			$(this).attr("title", ""); // remove current attr
		} else {
			if ($(this).attr("alt") !== "" && typeof ($(this).attr("alt")) !== 'undefined') { // check if alt attr present and not empty
				tip.append($(this).attr("alt"));
				tt.text = $(this).attr("alt"); // save current attr
				$(this).attr("alt", ""); // remove current attr
			} else {
				if ($(this).find('.tip')[0]) { // check if hover is on event
					var text = $(this).find('.tip').clone();
					tip.addClass('tip-event').append(text);
					tip.find('.tip>li:last').addClass('last');
				} else {
					return false;
				}
			}
		}
		
		tip.show();
		tip.css({
			'width': tip.width(),
			'display': 'block'
		});
		
		// while the mouse is in mouvement
		$(this).mousemove(function (e) {
			tip.css({
				'top': e.pageY + 20,
				'left': e.pageX - tip.width() / 2,
				'right': 'auto'
			});
								
			// if gets ouside to the right
			if ((parseInt(tip.css("left"), 10) + tip.width()) + tt.pad >= (tt.winWidth - 1)) {
				tip.css({
					'left': 'auto',
					'right': '5px',
					'left': 'auto'
				});
			}

			// if get outside to left
			if (parseInt(tip.css("left"), 10) <= 0) {
				tip.css("left", 1);
			}

			
		});
	
	},
	/**
	 * hover out of tooltip
	 */
	tipOut: function () {
		if (tt.text !== '') { // reset the starting attributes to the element
			$(this).attr("title", tt.text);
			$(this).attr("alt", tt.text);
		}
		$("#tip").width('auto').text('').hide();
	}
};


/** *******************************************************
 * remove and put back default values in field
 */
var inputLabel = {
	/**
	 * add events on field and set default value;
	 * @param	jQuery $targ	jquery selector of the field
	 */
	init: function (targ) {
			
		targ.each(function () {
			var targ = $(this);
			var val1 = '';
			$(this).focus(function () {
				if (val1 === '') { val1 = $(this).val(); }
				inputLabel.clear(targ, val1);
			}).blur(function () {
				inputLabel.blur(targ, val1);
			}).addClass("label-in");
		});
	},
	/**
	 * remove the field's default value
	 * @param	jQuery $targ		jquery selector of the field
	 * @param	string $startValue	default input text
	 */
	clear: function (targ, startValue) {
		if (targ.val() !== startValue) { // if value different from start value
			targ.val();
		} else {
			targ.val("").removeClass("label-in");
		}
	},
	/**
	 * put the default value back
	 * @param	jQuery $targ		jquery selector of the field
	 * @param	string $startValue	default input text
	 */
	blur: function (targ, startValue) {
		if (targ.val() !== "") { // if field not empty
			targ.val();
		} else {
			targ.val(startValue).addClass("label-in");
		}
	}
};


/** *******************************************************
 * fix lists by adding clearer
 */
var clearer = { 
	/**
	 * init clearer
	 * @param	string $ls	list element to clear
	 * @param	int $nb		nb of element before clear
	 * @param	int $exep	selector to ignore
	 */
	init: function (ls, nb, exep) {
		if (!exep) {
			$(ls + '>li').each(function () {
				if ($(this).index(ls + '>li') % nb === 0) {
					$(this).before('<span class="clearer"></span>');
				}
			});
		} else {
			$(ls + '>li:not(' + exep + ')').each(function () {
				if ($(this).index(ls + '>li:not(' + exep + ')') % nb === 0) {
					$(this).before('<span class="clearer"></span>');
				}
			});
		}
		
	}
};


/** *******************************************************
 * msg
 */
var msg = {
	/**
	 * init msg
	 */
	init: function () {
		this.html = $('<div class="alert-msg"><div class="w-inner"></div></div>');
		
		$('#tel').click(function () {
			msg.open($('#vpop'));
			return false;	
		});
	},
	/**
	 * show msg
	 * @param	jQuery $e		jquery selector of the content
	 */
	open: function (e) {
		if (!$('.alert-msg')[0]) {
			var eHtml = msg.html;
			eHtml.find('.w-inner').html(e.parent().html());
			
			$('#tel').addClass('open');
			$('#wrapper').prepend(eHtml);
			$('.alert-msg').hide().slideDown();
		} else {
			$('.alert-msg').slideUp(500, function () {
				$('#tel').removeClass('open');
				$(this).remove();
			});
		}
	},
	/**
	 * close msg
	 */
	close: function () {
		$(this).closest('.alert-msg').slideUp(500, function () {
			$(this).remove();
		});
		return false;
	}
};


/** *******************************************************
 * services
 */
var services = {
	init: function () {
		$('.ls-main h2 a').click(this.show);
	},
	show: function () {
		$(this).parent().toggleClass('selected');
		$(this).parent().next().slideToggle();
		return false;
	}
};

var contact = {
	send: function () {
		$.post(
				$("form#contactForm").attr('action'), 
				$("form#contactForm").serialize(),
				function(html)
				{
					$("#notification").html(html);
					
					/*var callbackFunction = $('#facebox input#callbackFunction').val();
					
					if(callbackFunction)
					{
						eval(callbackFunction);
					}*/
				}
		);
		return false;
	},
	support: function() {
		
		var dbug = "";
		jQuery.each(jQuery.browser, function(i, val) {
			dbug += i + " " +  val + " ";
		});
		$('#dbug').val(dbug);
	}
};

/** *******************************************************
 * realisations
 */
var realisations = {
	init: function () {
		$('#rea-opt #grid-open').live("click", function () {
			realisations.loadHtml($(this).attr("href")).show();
			return false;
		});
		
		$('#grid #grid-close').live("click", function () {
			realisations.hide();
			return false;
		});
		
		$("#grid.ajax .ls-pag a").live("click", function () {
			realisations.loadHtml($(this).attr("href"));
			return false;
		});
		
		if ($('#rea-infos #rea-nav')[0]) {
			realisations.nav();
		}
		
/*
		if ($("#rea-infos")[0]) {
			realisations.fadeTime(2000);
			$("#head, #rea-infos, #foot").hover(realisations.fadeBack, realisations.fadeTime);
		}
*/
				
	},
	loadHtml: function (url) {
		// add loading bg
		$("#box-realisations").css('background', 'url(' + vars.root + 'img/ajax-loader2.gif) center center no-repeat');
		// hide curr data
		$('#box-realisations #ls-realisations, #box-realisations .ls-pag').css('visibility', 'hidden');
		// load new data
		$.ajax({
			url: url,
			data: null,
			success: function (response) {
				$("#box-realisations").hide().html(response).css('background', '').fadeIn();
				$("#realisation-" + $(".ls-main").attr("id")).addClass("selected");
			},
			dataType: "html"
		});
		return this;
	},
	/**
	 * show the current gallery
	 */
	show: function () {
		tt.tipOut();
		$('#rea-infos').animate({
			top: -1000
		}, 500, function () {
			$('#rea-infos').hide();
			$('#grid').css({'top': '-1000px'}).show().animate({
				top: 0,
				zIndex: 19999
			}, 500, function () {
				if (isIe7 !== true) {
					$('#cboxOverlay').show();
				}
			});
		});
		return this;
	},
	/**
	 * hide the current gallery
	 */
	hide: function () {
		tt.tipOut();
		$('#cboxOverlay').hide();
		$('#grid').css({'z-index': 1}).animate({
			top: -1000
		}, 500, function () {
			$('#grid').hide();
			$('#rea-infos').css('top', '-1000px').show().animate({
				top: 0
			}, 500);
		});
		return this;
	},
	/**
	 * setup the fade timeout
	 * @param	int	time	time before fade begin
	 */
	fadeTime: function (e, time) {
		if (!time) {
			time = 5000;
		}
		realisations.time = setTimeout(realisations.fade, time);
	},
	/**
	 * fade extra elements
	 */
	fade: function () {
		if (!$("#grid:visible")[0]) {
			$("#head, #rea-infos, #foot").fadeTo(1000, 0.3);
		}
	},
	/**
	 * show back extra elements
	 */
	fadeBack: function () {
		clearTimeout(realisations.time);
		$("#head, #rea-infos, #foot").stop(false, false).fadeTo(500, 1);
	},
	/**
	 * init nav by keyboard
	 */
	nav: function () {
		$(document.documentElement).keyup(function (event) {
			switch (event.keyCode) {
			case 73:
				if (typeof ($('#rea-infos .ls-main h2 a')) !== 'undefined') {
					$('#rea-infos .ls-main h2 a').trigger('click');
				}
				break;
			case 74:
				if (typeof ($('#rea-prev').attr('href')) !== 'undefined') {
					window.location = $('#rea-prev').attr('href');
				}
				break;
				
			case 75:
				if (typeof ($('#rea-next').attr('href')) !== 'undefined') {
					window.location = $('#rea-next').attr('href');
				}
				break;
			}
		});
	}
};


/** *******************************************************
 * Fonction to relaunch after an ajax refresh
 */
var ajax = {
	init: function () {
		JSTarget.init("rel", "external", "");
	}
};


/** *******************************************************
 * Fonctions to call on DOM ready
 */

$(document).ready(function () {
	vars.init();
	msg.init();
	services.init();
	realisations.init();
	contact.support();
	
	if((!navigator.userAgent.match(/iPhone/i)) && (!navigator.userAgent.match(/iPod/i)) && (!navigator.userAgent.match(/iPad/i))) {
		tt.init($('.bt'));
		tt.init($('.ls-main h2 a'));
	}
	
	inputLabel.init($('#ls-con input, #ls-con textarea'));
	
	// messages box close link
	$('.msgbox .close').live('click', function () {
		$(this).closest('.msgbox').hide();
		return false;
	});
});


/** *******************************************************
 * Fonctions to call on window load
 */
$(window).load(function () {

});
