if(jQuery)
(function($){
	//cookies plugins
	jQuery.cookie = function(name, value, options) {
		if (typeof value != 'undefined') { // name and value given, set cookie
			options = options || {};
			if (value === null) {
				value = '';
				options.expires = -1;
			}
			var expires = '';
			if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
				var date;
				if (typeof options.expires == 'number') {
					date = new Date();
					date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
				} else {
					date = options.expires;
				}
				expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
			}
			// CAUTION: Needed to parenthesize options.path and options.domain
			// in the following expressions, otherwise they evaluate to undefined
			// in the packed version for some reason...
			var path = options.path ? '; path=' + (options.path) : '';
			var domain = options.domain ? '; domain=' + (options.domain) : '';
			var secure = options.secure ? '; secure' : '';
			document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
		} else { // only name given, get cookie
			var cookieValue = null;
			if (document.cookie && document.cookie != '') {
				var cookies = document.cookie.split(';');
				for (var i = 0; i < cookies.length; i++) {
					var cookie = jQuery.trim(cookies[i]);
					// Does this cookie string begin with the name we want?
					if (cookie.substring(0, name.length + 1) == (name + '=')) {
						cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
						break;
					}
				}
			}
			return cookieValue;
		}
	};
	
	//TUNNEL
	if($.cookie("age"))
	{
		var vars = {swfToLoad:'website.swf'};
		var params = { menu:'true', allowfullscreen:'true', allowscriptaccess:'always'};
		var attributes = { id:'faith_full', name:'FaithFul' }; 
		
    	swfobject.embedSWF("preloader.swf", "flashContent", "100%", "100%", "10.0.0", "javascript/express_install.swf", vars, params, attributes);
		swfobject.registerObject("preloader", "10.0.0", "javascript/express_install.swf");
		
		if (swfmacmousewheel) {
			swfmacmousewheel.registerObject(attributes.id);
		}
		return;
	}
	$("body").hide();
	jQuery(function($){
		$("body").hide();
		var bgcolor=$("body").css("background-color");
		if(bgcolor=="transparent" || bgcolor=="")
			bgcolor=$("html").css("background-color");
		if(bgcolor=="transparent" || bgcolor=="")
			bgcolor="#000000";
		var css={
			cideo_tunnel_overall:{
		
				position:"fixed",
				'z-index':9999,
				display:"block",
				"overflow-y":"auto",
				top:0,
				left:0,
				right:0,
				bottom:0,
				width:"100%",
				"background-color":bgcolor
			},
			cideo_tunnel_all:{
				display:"table",
				"overflow":"visible",
				"text-align":'center',
				width:"100%",
				height:"100%"
			},
			cideo_tunnel_page:{
				display:'table-cell',
				"overflow":"visible",
				"vertical-align":"middle"
			},
			cideo_tunnel_logo:{
				"margin":"20px 0"
			},
			cideo_tunnel_texte:{
				"width":300,
				"text-align":"justify",
				"margin":"40px auto"
			},

		}
		var template=$("<div id='cideo_tunnel_overall'>\
		<div id='cideo_tunnel_all'>\
			<div id='cideo_tunnel_page'>\
				<div id='cideo_tunnel_logo'><img src='images/logo.png'></div>\
				<div id='cideo_tunnel_texte'><p class='texte'>Commencée au 16ème siècle, l’histoire de la famille prend un tournant en 1808 avec Honoré Legras qui développe alors l’un des plus beaux vignobles de la Côte des Blancs. Cette région de Champagne est ainsi nommée en raison du Chardonnay, l’un des plus fins de tous les cépages blancs et qui règne ici en maître...</p><p>Pour visiter le site <span id='cideo_tunnel_titre'></span>, vous certifiez être majeur et avoir connaissance de la règlementation en vigueur dans votre pays relative à l'information sur les boissons alcoolisées diffusée sur Internet.</p></div>\
				<div id='cideo_tunnel_form'>\
					<p><label><input type='checkbox' id='cideo_tunnel_checkbox'> J'ai l'âge légal dans mon pays.</label></p>\
					<button id='cideo_tunnel_button'>Entrer</button>\
				</div>\
			</div>\
		</div>\
	</div>");
		var bodyContent=$("body>*").each(function(){
			$this=$(this);
			$this.data("cideo_tunnel_display",$this.css('display'));
			$this.css('display','none');
		});
		$("body").prepend(template);
		var templateAll=$("*",template).add(template);
		var elms={};
		templateAll.filter('[id]').each(function(){
			$this=$(this);
			var id=this.id;
			elms[id]=$this;
			try{
			if(css[id])
				$this.css(css[id]);
			}catch(e){
				
			}
			/*$this.mousedown(function(){
				console.log(id);
			});*/
		});
		elms.cideo_tunnel_titre.text($.trim(document.title.split(' - ')[0]));
		elms.cideo_tunnel_button.click(function(){
			if(elms.cideo_tunnel_checkbox.is(":checked"))
			{
				$.cookie("age",true);
				bodyContent.each(function(){
					$this=$(this);
					$this.css('display',$this.data("cideo_tunnel_display"));
				});
				template.fadeOut(function(){$(this).remove()});
				
						var vars = {swfToLoad:'website.swf'};
		var params = { menu:'true', allowfullscreen:'true', allowscriptaccess:'always'};
		var attributes = { id:'faith_full', name:'FaithFul' }; 
		
    	swfobject.embedSWF("preloader.swf", "flashContent", "100%", "100%", "10.0.0", "javascript/express_install.swf", vars, params, attributes);
		swfobject.registerObject("preloader", "10.0.0", "javascript/express_install.swf");
		
		if (swfmacmousewheel) {
			swfmacmousewheel.registerObject(attributes.id);
		}
			}
		});
		$("body").show();

	});
})(jQuery);
