


$.easy.popup();
$.easy.tooltip("a[title]");

/* VERTICAL ALIGN */

function align()
{
	var lmt = document.getElementById('containers');
	var container = document.documentElement;
	
	if(lmt && container)
	{
	    var containerHeight;
	    if (container.innerWidth)
	    {
            containerHeight = container.innerHeight;
		}
		else
		{
            containerHeight = container.clientHeight;
		}
	    var lmtHeight;
	    if (lmt.innerWidth)
	    {
            lmtHeight = lmt.innerHeight;
		}
		else
		{
            lmtHeight = lmt.offsetHeight;
		}
		var y = Math.ceil((containerHeight - lmtHeight) / 2);
		if(y < 0)
		{
			y = 0;
		}
		lmt.style.position = "relative";
		lmt.style.top = y + "px";
	}

}

function addevent(obj,evt,fn,capt){
	if(obj.addEventListener)
	{
		obj.addEventListener(evt, fn, capt);
		return true;
	}
	else if(obj.attachEvent)
	{
		obj.attachEvent('on'+evt, fn);
		return true;
	}
	else return false;
}

if (document.getElementById && document.getElementsByTagName)
{
	addevent(window, 'load', align, false);
	addevent(window, 'resize', align, false);
}

/* JQUERY */

$(document).ready(function() {
    $('#images').cycle({
		fx:			'fade',
		timeout:	7000
	});
	//$('a[href*="contact"]').addClass("colorbox");
	$(".colorbox").colorbox({width:"750px", height:"600px", iframe:true});
	
	$("#containers").vAlign();
	$("#containers").hAlign();
	
	
	$(".ssmenu-1").each(
		function(){
			$(this).css("width", $(this).prev("a").outerWidth() + "px");
		}
	);
	
	if ( $('#legals').length ) {
		$('body').css('background-position', '0px 260px');
	}
	
	if ( $('#contact').length ) {
		$('body').css('background-position', '0px 260px');
	}
	
	if ( $('#tarifs').length ) {
		$('body').css('background-position', '0px 260px');
		$('#content').css('padding', '20px 0 0 0');
	}
	
	$('#tarifs').tabs();
	
});


(function ($) {
$.fn.vAlign = function() {
	return this.each(function(i){
		var container = document.documentElement;
		var ch;
		if (container.innerWidth){ch = container.innerHeight;}
			else{ch = container.clientHeight;}
		var h = $(this).height();
		var oh = $(this).outerHeight();
		
		if (oh < ch){
			var mt = (h + (oh - h)) / 2;	
			$(this).css("margin-top", "-" + mt + "px");	
			$(this).css("top", "50%");
			$(this).css("position", "absolute");	
		}
	});	
};
})(jQuery);

(function ($) {
$.fn.hAlign = function() {
	return this.each(function(i){
		var container = document.documentElement;
		var cw;
		if (container.innerWidth){cw = container.innerWidth;}
			else{cw = container.clientWidth;}
		var w = $(this).width();
		var ow = $(this).outerWidth();	
		
		if (ow < cw){
			var ml = (w + (ow - w)) / 2;	
			$(this).css("margin-left", "-" + ml + "px");
			$(this).css("left", "50%");
			$(this).css("position", "absolute");
		}
	});
};
})(jQuery);

