// CHECK VERSION NAVIGATEUR
// ------------------------
var IE6 = (navigator.appVersion.indexOf("MSIE 6.")==-1) ? false : true;
if (IE6) {
	window.location.replace("./proposition_navigateur.php");
}

// EFFET EN "ENTRÉE DE PAGE"
// -------------------------

var gspeed = 300;
var timer, timer_addthis;

// EFFET "TYPEWRITER"
$.fn.typewriter = function(opt,callback) {
	var i=0;
	var typeone = function(self, text, content) {
		if (text.length > 0) {
			i=i+1;
			var next = text.match(/(\s*(<[^>]*>)?)*(&.*?;|.?)/)[0];
			text = text.substr(next.length);
			$(self).html(content+next);
			setTimeout(function(){
				typeone(self, text, content+next);
			}, opt['delay']);
			if(text.length==0) if (callback!=null) callback();
		}
	}
	this.each(function() {
		opt = opt || { 'delay': 1 };
		typeone(this, $(this).html(), '');
	});
	return this;
}

// ARRIVÉE
var special, specialContent, lock_infos_pratiques = false, lock_content_comm = false;
function getIn(bool) {
	special = bool;
	$("#screen").stop().scrollTo(0, gspeed);
	// génération d'une nvlle matrice...
	$("#global").css("width","10000px");
	$("#global").css("height","auto");

	// récupération du titre...
	var titre = document.title;	
	var stock = '';
	stock += '<span class="lightblue">Teleportation status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><strong>ok</strong>';
	stock += '<br /><span class="lightblue">New place&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><strong>'+titre+'</strong><br /><br /><br /><br />';		
	$("#cible").before('<div class="box" id="box0" ><div id="global_header"><div class="header" style="background:#fff;"></div></div><div id="console_init"><div id="titre_init"><span id="message">'+stock+'</span> |</div></div>');	
	$("#message").typewriter(null,function(){
		// Quand "typewriter" se termine, on lance...
		timer = setTimeout("scroll()",gspeed);
	});

}

function scroll() {
	$("#titre").css("display","none");
	// nettoie le timer (sécurité)
	clearTimeout(timer);
	// scrolling
	var dist = 1000;
	$("#screen").stop().scrollTo(
		dist, gspeed,{
						axis:'x',
						easing:'jswing',
						onAfter:function() {
									$("#console_init").css("display","none");
									$("#titre").css("display","block");
									$("#titre").typewriter({ 'delay': 20 });
									if (special) {
										timer = setTimeout("header(1)",1500);
									}
								}
		});
}

function getInContent(dest, bool) {
	specialContent = bool;
	$("#screen").stop().scrollTo(0, gspeed);
	// génération d'une nvlle matrice...
	$("#global").css("width","10000px");
	$("#global").css("height","auto");

	// récupération du titre...
	var titre = document.title;	
	var stock = '';
	stock += '<span class="lightblue">Teleportation status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><strong>ok</strong>';
	stock += '<br /><span class="lightblue">New place&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><strong>'+titre+'</strong><br /><br /><br /><br />';		
	$("#cible").before('<div class="box" id="box0" ><div id="global_header"><div class="header" style="background:#fff;"></div></div><div id="console_init"><div id="titre_init"><span id="message">'+stock+'</span> |</div></div>');
	
	
	$("#message").typewriter(null,function(){
			timer = setTimeout("scrollContent(\'"+dest+"\')");
	});

}

function scrollContent(dest){
	$("a.bt_menu_s").addClass("bt_menu");
	$("a.bt_menu_s").removeClass("bt_menu_s");
	var children = $("#menu_top").children();
	
	var child = $(children[dest]);
	
	var petitChild = child.children();
	
	var dist = 1000;
	var d = dest*1000;
	$("#screen_content").scrollTo(d,0);
	
	$("#titre").css("display","none");
	$("#screen").stop().scrollTo(1000,gspeed,{onAfter:function() {
			$("#console_init").css("display","none");
			$("#titre").css("display","block");	
			$(petitChild[0]).click();
			
			if (specialContent) {
				timer = setTimeout("header(1)",1500);
			}
		}});
}

function scrollContentSpecial(dest){
	var dist = 1000;
	var d = dest*1000;
	$("#screen_content").scrollTo(d,0);
	$("#screen").stop().scrollTo(1000,gspeed);
}

// EFFET EN "SORTIE DE PAGE"
// -------------------------

var url = "";
var dest = "";

function memURL(obj) {
	var bg = obj.css("background-color");
	url = obj.attr("href");
	obj.removeAttr("href");
	obj.css("background-color",bg);
	$(obj).fadeOut(60, function() { $(obj).attr("href", url); }).fadeIn(60).fadeOut(50).fadeIn(50).fadeOut(40).fadeIn(40).fadeOut(30).fadeIn(30).fadeOut(20).fadeIn(20).fadeOut(10).fadeIn(10, function() {
		document.location = url;
	});
}

function init() {
	
	//generateBG();
	
	$("#bt_next").hover(function() {
		$("a.bt_menu_small", this).stop().fadeTo(150, 0.75, 'jswing');
	}, function() {
		$("a.bt_menu_small", this).stop().fadeTo(150, 1, 'jswing');
	});

	// CSS des boutons / position en bas
	var tab_bt = $("span.in_bt");
	for (a = 0; a< tab_bt.length; a++) {
		$(tab_bt[a]).css("margin-top", 80-$(tab_bt[a]).height()+"px");
	}
	var tab_bt_s = $("span.in_bt_small");
	for (a = 0; a< tab_bt_s.length; a++) {
		$(tab_bt_s[a]).css("margin-top", 40-$(tab_bt_s[a]).height()+"px");
	}

	// Survol du menu
	$('div.bt_menu').hover(function(){
		$("a.bt_menu, a.bt_menu_m, a.bt_menu_n, a.bt_fleche", this).stop().fadeTo(150, 0.75, 'jswing');
	}, function() {  
		$("a.bt_menu, a.bt_menu_m, a.bt_menu_n, a.bt_fleche", this).stop().fadeTo(150, 1, 'jswing');
	});
	$('div#menu_back').hover(function(){
		$("a.bt_special, a.bt_special_small", this).stop().fadeTo(150, 0.75, 'jswing');
	}, function() {  
		$("a.bt_special, a.bt_special_small", this).stop().fadeTo(150, 1, 'jswing');
	});
	$('div.bt_menu_expo').hover(function(){
		$("a.bt_menu_expo, a.bt_menu_imgs, a.bt_menu_video, a.bt_menu_download", this).stop().fadeTo(150, 0.75, 'jswing');
	}, function() {  
		$("a.bt_menu_expo, a.bt_menu_imgs, a.bt_menu_video, a.bt_menu_download", this).stop().fadeTo(150, 1, 'jswing');
	});
	// Survol du menu small
	$('div.bt_menu_small').hover(function(){
		$("a.bt_menu_small", this).stop().fadeTo(150, 0.75, 'jswing');
		$("a.bt_menu_expo", this).stop().fadeTo(150, 0.75, 'jswing');
	}, function() {  
		$("a.bt_menu_small", this).stop().fadeTo(150, 1, 'jswing');
		$("a.bt_menu_expo", this).stop().fadeTo(150, 1, 'jswing');
	});
	
	// Click du menu
	$('div.bt_menu a').click(function() {
		$("#cible div.bt_menu a.bt_menu_s").addClass("bt_menu");
		$("#cible div.bt_menu a.bt_menu_s").removeClass("bt_menu_s");
		$(this).removeClass("bt_menu");
		$(this).addClass("bt_menu_s");
		$(this).fadeTo(0,1);
	});

	// Survol du menu footer
	$('a.enter').hover(function(){
		$(this).stop().fadeTo(150, 0.75, 'jswing');
	}, function() {  
		$(this).stop().fadeTo(150, 1, 'jswing');
	});
	
	// SURVOL DIV MEDIAS
	$(".media").hover(function() {
		$("span.media_in", this).stop().animate({bottom:0},gspeed/2,"jswing");
	},function() {
		$("span.media_in", this).stop().animate({bottom:-20},gspeed/2,"jswing");
	})
	
	// Menu "cxExpos"
	
	// Survol
	$('a.cxExpos, a.cxExpos_S').hover(function(){
		$(this).stop().animate({marginTop:0,height:25},gspeed/2,'jswing');
	}, function() {  
		$(this).stop().animate({marginTop:10,height:15},gspeed/2,'jswing');
	});
	$('a.cxExpos, a.cxExpos_S').click(function(){
		$("a.cxExpos_S").addClass("cxExpos");
		$("a.cxExpos_S").removeClass("cxExpos_S");
		$(this).addClass("cxExpos_S");
		$(this).removeClass("cxExpos");
	});
	// Animations des volets
	var style_in = 'jswing';
	var style_out = 'jswing';
	var speed_in = 200;
	var speed_out = 200;		
	$('.item').hover(function(){
		var h = $(this).height()*-1;
		$(".itemImg", this).stop().animate({top:h+'px'}, speed_in, style_in);
		$(".underItem", this).stop().animate({top:h+'px'}, speed_in, style_in, function() {
			$("a.in_item, a.in_item_pink, a.in_item_punk", this).stop().fadeTo(100,0.4, "jswing").fadeTo(100,0.85, "jswing")
		});	
	}, function() {  
		$(".itemImg", this).stop().animate({top:'0px'}, speed_out, style_out); 
		$(".underItem", this).stop().animate({top:'0px'}, speed_out, style_out); 
	});
	$(".underItem, .underItemIntro, .underItemIntroCarre").click(function() {
		var obj = $("a.in_item, a.in_item_pink, a.in_itemIntro, a.in_item_punk, a.in_itemIntroCarre, a.in_itemIntroLight", this);
		memURL(obj);
	})
	
	// Eclairage des vignettes
	$("img.vignet").mouseover( function() {
		$(this).stop().animate({opacity: 0.7}, gspeed);
	} );
	$("img.vignet").mouseout( function() {
		$(this).stop().animate({opacity:1}, gspeed);
	} );	
	$('a.in_item, a.in_item_pink, a.in_itemIntro, a.simple_bt, a.simple_bt_nf, a.mail_bt, a.bt_next, a.bt_retour, a.download_bt').hover(function(){
		$(this).stop().fadeTo(100,0.4, "jswing").fadeTo(100,0.85, "jswing")
	}, function() {  
		$(this).stop().fadeTo(500,0.85);
	});

	$('.itemIntro').hover(function(){
		var h = $(this).height()*-1;
		$(".itemImgIntro", this).stop().animate({top:h+'px'}, speed_in, style_in);
		$(".underItemIntro", this).stop().animate({top:h+'px'}, speed_in, style_in, function() {
			$("a.in_itemIntro, a.in_itemIntroLight", this).stop().fadeTo(100,0.4, "jswing").fadeTo(100,0.85, "jswing")
		});	
	}, function() {  
		$(".itemImgIntro", this).stop().animate({top:'0px'}, speed_out, style_out); 
		$(".underItemIntro", this).stop().animate({top:'0px'}, speed_out, style_out); 
	});
	
	$('.itemIntroCarre').hover(function(){
		var h = $(this).height()*-1;
		$(".itemImgIntroCarre", this).stop().animate({top:h+'px'}, speed_in, style_in);
		$(".underItemIntroCarre", this).stop().animate({top:h+'px'}, speed_in, style_in, function() {
			$("a.in_itemIntroCarre", this).stop().fadeTo(100,0.4, "jswing").fadeTo(100,0.85, "jswing")
		});	
	}, function() {  
		$(".itemImgIntroCarre", this).stop().animate({top:'0px'}, speed_out, style_out); 
		$(".underItemIntroCarre", this).stop().animate({top:'0px'}, speed_out, style_out); 
	});
	
	// ZOOMIN
	zoomIn($('#zoomplace'),50);
		
	// PARTAGER / SHARE
	
	$("#partage").click(function(){
		var op_menu = $(".menu_addthis").css("display","block");
		$(".menu_addthis").stop().animate({
opacity: '1',
left: 380
		},250, function(){
			timer_addthis = setTimeout("close_addthis()",1500);
		});
	});
	
	$(".menu_addthis").mouseover(function(){
		clearTimeout(timer_addthis);
		$(".menu_addthis").stop().animate({
opacity: '1'
		},100);
	});
	$(".menu_addthis").stop().mouseout(function(){

			timer_addthis = setTimeout("close_addthis()",250);
		});


}

function close_addthis(){
		$(".menu_addthis").stop().animate({
opacity: '0', left:1000
		},250, function(){
			$(".menu_addthis").css("display","none");
			$(".menu_addthis").animate({
left: 1000
			},100);
			clearTimeout(timer_addthis);
		});
	}

function header(d) {
	var distance = d*1000;
	$("body").stop().scrollTo(0,50,{onAfter:function() {
			$("#screen_header").stop().scrollTo(distance,gspeed, {onAfter:function() {
					$("#num_h_g, #num_h_d").html(d+1);
				}});
		}});
	special = false;
}

function content(d, mess, intext) {

	if (intext) {
	
		var children = $("#menu_top").children();
		var child = $(children[d]);
		var petitChild = child.children();
		$(petitChild[0]).click();
		
	} else {
	
		if (mess != null) {
			$("#titre").html(mess);
			$("#titre").typewriter({ 'delay': 20 });
		}
		var distance = d*1000;
		$("body").stop().scrollTo(0,0);
		$("#screen_content").stop().scrollTo({top:0,left:distance},gspeed, function() {
			var tabContent = $('.content');
			var h = $(tabContent[d]).height();

			$("#screen_content").css("height",h+80);
		});
		
		if (d == 8 && !lock_content_comm) {
			$("#video").load("./videos/videoplayer_home.php");
		} else {
			$("#video").html("");
		}
	}
}

function contentIntro(dest) {
	var children = $("#menu_top").children();
	var child = $(children[dest]);
	var petitChild = child.children();
	$(petitChild[0]).click();
}

// -------------------------------
// ----------------------- GALERIE
var path = "";
var nb = 0;
var pic = 1;
var num_pic=0;
var loading = false;
var destination;
var thumbState = false;

function initGallery(my_path, my_nb) {
	$("#legende").css("width",(920-$("#galerie").width())+"px");
	$(".bt_menu_imgs span.in_bt_expo").html(my_nb + " images");
	
	path = my_path;
	nb = my_nb;
	getLegende();
	allPic();
}
function initLegend() {
	$("#legende").css("width",(920-$("#galerie").width())+"px");
}
function getGallery(dest1,dest2) {
	destination=dest2;
	if (destination == 3000) {
		thumbState = true;
		var hs = $("#stock").height();
		$("#screen_content").css("height",hs+80);
	}
	clearTimeout(timer);
	
	$("#numero").css("display","block");
	$("#numero").html("Image "+pic+" sur "+nb);
	$("#numero").css("width",(920-$("#galerie").width())+"px");

	$("#galerie").click( function(){nextPic();});
	$("#galerie").hover( function(){
		$(this).css("cursor", "pointer");
	},
	function(){
		$("#bt_next").stop().fadeTo(150, 1, 'jswing');
	});
	$("body").stop().scrollTo(0,50,{onAfter:function() {
			$("#screen_header").stop().scrollTo({top:0,left:dest1},gspeed, {onAfter:function() {
					$("#num_h_g, #num_h_d").html("+");
					$("#screen_content").stop().scrollTo({top:0,left:dest2},gspeed, {onAfter:function() {					
							$(".header").stop().animate({height:"50px"},gspeed,"jswing");
							$("#console").stop().animate({height:"0px"},gspeed,"jswing");
							

						}});
				}});
		}});
	
}

function closeGallery(dest1,dest2) {
	thumbState = false;
	$("body").stop().scrollTo(0,50,{onAfter:function() {
			$("#console").stop().animate({height:"115px"},gspeed,"jswing");
			$(".header").stop().animate({height:"90px"},gspeed,"jswing",function() {
				$("#num_h_g, #num_h_d").html("2");
				$("#screen_header").stop().scrollTo({top:0,left:dest1},gspeed, {onAfter:function() {
						//$("#screen_content").stop().scrollTo({top:0,left:dest2},gspeed);
						content(0);
					}});
			});
		}});
}

function nextPic() {
	if (!loading) {
		thumbState = false;		
		loading = true;
		if (pic<nb) {
			pic ++;
		} else {
			pic = 1;
		}
		$("#screen_content").stop().scrollTo({top:0,left:2000},gspeed/2,{onAfter:function() {
				$("#galerie").html('<img src="./images/expos/'+path+'/'+path+eval(pic)+'.jpg" onload="javascript:reloadGallery();" />');
			}});
	}
}
function prevPic() {
	if (!loading) {
		thumbState = false;
		loading = true;
		if (pic>1) {
			pic --;
		} else {
			pic = nb;
		}
		$("#screen_content").stop().scrollTo({top:0,left:2000},gspeed/2,{onAfter:function() {
				$("#galerie").html('<img src="./images/expos/'+path+'/'+path+eval(pic)+'.jpg" onload="javascript:reloadGallery();" />');
			}});
		
	}
}

// ------------------ AFFICHER L'IMAGE CHOISIE PARMIS LES VIGNETTES
function switchPic() {
	if (!loading) {	
		loading = true;
		$("body").scrollTo(0,gspeed);
		$("#screen_content").stop().scrollTo({top:0,left:2000},gspeed/2,{onAfter:function() {			
				$("#galerie").empty();			
				getLegende();
				$("#galerie").html('<img src="./images/expos/'+path+'/'+path+eval(pic)+'.jpg" onload="javascript:reloadGallery();" />');
			}});
	}
}

// ------------------ AFFICHER TOUTES LES VIGNETTES
function allPic() {	
	// --------------- crŽer des div dynamiquement dans la div galerie
	$("#stock").html("");
	for(ex=1;ex<=nb;ex++){
		$("#stock").append('<div class="vignette" id="'+eval(ex)+'" ><img src="./images/expos/'+path+'/vignette/'+path+eval(ex)+'.jpg" class="vignette_img" /></div>');
	}
	// --------------- hover sur vignettes
	$('div.vignette').hover(function(){
		$(this).stop().fadeTo(150, 0.50, 'jswing');
	}, function() {  
		$(this).stop().fadeTo(150, 1, 'jswing');
	});		
	// --------------- clique sur vignettes
	$("div.vignette").click( function() {
		thumbState = false;
		pic=this.id
		switchPic();			
	} );
}

function getLegende() {
	
	$("#legende").css("display","block");
	$("#legende").html("loading...");
	var pointer = "./datas/data_"+path+".php";
	var ajaxLGD = $.ajax({
type: "POST",
url: pointer,
data: "id="+pic,
success: function(msg){
			$("#legende").html(ajaxLGD.responseText);
		}
	});
}

function reloadGallery() {
	loading = false;
	// --------------- afficher le numéro de l'image si les vignettes ne sont pas affichées
	$("#numero").css("display","block");
	$("#numero").html("Image "+pic+" sur "+nb);
	$("#numero").css("width",(920-$("#galerie").width())+"px");
	$("#legende").css("width",(920-$("#galerie").width())+"px");
	$("#screen_content").scrollTo({top:0,left:1000}, gspeed/2, function() {
			var hl = $("#legende").height();
			var hi = $("#galerie").height();
			if (hl >= hi) {
				$("#screen_content").css("height", hl+100);
			} else {
				$("#screen_content").css("height", hi+80);
			}
			getLegende();
		// var himg = $("#galerie").height();
		// $("#screen_content").css("height",himg+80);
	});
	// getLegende();
}

function openThumbs() {
	if (!thumbState) {
		content((1000/1000)+2);
	} else {
		content(1000/1000);
	}
	thumbState = !thumbState;
}

// In "LIEUX" fonctionnement du plan
//----------------------------------

function map(obj, img) {
	$("#reti_plan").css("left",1000);
	//var nb= n-1;
	//var selContent = $("div.content").children(".item:eq("+nb+")").children(".itemImg").css("background");
	
	obj.css("color","#27276f");
	
	$("#reti_plan").css("display","block");
	var t = obj.css("top");
	var l = obj.css("left");
	var s = obj.width();
	l2 = l.substring(0,l.length-2);
	l3 = parseFloat(l2)+s+5;
	
	$("#reti_plan").css("top",t);
	//$("#reti_plan").css("left",l3);
	$("#reti_plan").css("width",150);
	$("#reti_plan").stop().fadeTo(0,0);

	$("#reti_plan").stop().animate({left:l3,opacity:1},gspeed/2,"jswing");
	var n = obj.attr("name");	
	$("#reti_plan").html("<a class='reti_plan' href='"+obj.attr("href")+"' onclick='planURL($(this));'>"+n+"</a><img src='./images/expositions/"+img+".jpg' style='width:150px;margin-top:5px;' />");
	// !!!!!!!!!!!!!!
	//$("#reti_info").css("background",selContent);
	// !!!!!!!!!!!!!!
	//$("#reti_plan").css("opacity",0.15);
}
function mapOut() {
	$("#reti_plan").stop().animate({left:1000,opacity:0},gspeed/2,"jswing");
	$("a.num_plan").css("color","#fff");
}

function planURL(obj) {
	url = obj.attr("href");
	obj.removeAttr("href");
	$(obj).fadeOut(60, function() { $(obj).attr("href", url); }).fadeIn(60).fadeOut(50).fadeIn(50).fadeOut(40).fadeIn(40).fadeOut(30).fadeIn(30).fadeOut(20).fadeIn(20).fadeOut(10).fadeIn(10, 		function() {
		document.location = url;
	});
}

function zoomIn(obj, val) {
	var myImg = $(obj).children().children(".zoom");
	var imgW = myImg.width();
	var imgH = myImg.height();
	
	$(obj).css("overflow","hidden");

	
	var zoom = 250+val;
	var zoomR = 250;
	$(obj).hover(function() {
		$(myImg).stop().animate({width:zoom+"px",marginLeft:(val/2)*-1,marginTop:(val/2)*-1},gspeed,"jswing");	
	},function(){
		$(myImg).stop().animate({width:zoomR+"px",marginLeft:0,marginTop:0},gspeed,"jswing");
	});
}		

var trajet1 = new Array(35,15,15,70,170,150);
var termes1 = new Array("3h05","26,3 Euros*","15 Kg","5h05","240,00 Euros**","100 Kg");
var trajet2 = new Array(100,60,14,100,120,120);
var termes2 = new Array("1h05","11,4 Euros*","2 Kg","1h05","25,0 Euros**","12 Kg");
var trajet3 = new Array(120,75,15,75,140,130);
var termes3 = new Array("3h10","22,8 Euros*","4 Kg","1h40","80,0 Euros**","30 Kg");
var trajet4 = new Array(100,80,20,70,130,130);
var termes4 = new Array("2h20","22,5 Euros*","4 Kg","1h50","80,0 Euros**","30 Kg");
var trajet5 = new Array(55,45,15,60,130,110);
var termes5 = new Array("3h05","32,3 Euros*","9 Kg","3h15","150,0 Euros**","65 Kg");
var trajet6 = new Array(100,40,15,75,130,110);
var termes6 = new Array("3h05","26,3 Euros*","9 Kg","2h30","100,0 Euros**","40 Kg");

function scrollTrajet(val, obj) {
	test = val;
	val = (val-1)*188;
	$("#comparateur").stop().scrollTo(val,gspeed);
	//
	$("a.comparateur_selected").addClass("comparateur");
	$("a.comparateur_selected").removeClass("comparateur_selected");
	
	$(obj).addClass("comparateur_selected");
	$(obj).removeClass("comparateur");
	
	var trajet = eval("trajet"+test);
	var termes = eval("termes"+test);
	$("#A1").stop().animate({width:trajet[0]+"px"},gspeed,"jswing");
	$("#lineA1").html(termes[0]);
	$("#A2").stop().animate({width:trajet[1]+"px"},gspeed,"jswing");
	$("#lineA2").html(termes[1]);
	$("#A3").stop().animate({width:trajet[2]+"px"},gspeed,"jswing");
	$("#lineA3").html(termes[2]);
	$("#B1").stop().animate({width:trajet[3]+"px"},gspeed,"jswing");
	$("#lineB1").html(termes[3]);
	$("#B2").stop().animate({width:trajet[4]+"px"},gspeed,"jswing");
	$("#lineB2").html(termes[4]);
	$("#B3").stop().animate({width:trajet[5]+"px"},gspeed,"jswing");
	$("#lineB3").html(termes[5]);
}

function initInfos() {
	// GESTION MAP LIEUX
	
	$("a#cite").hover(function() {
		$("span",this).css("display","block");
	}, function() {
		$("span",this).css("display","none");
	});
	
	$("a.map_logo, a.map_logo_s").hover(function() {
		$("a.map_logo_s").addClass("map_logo");
		var toblue = $("a.map_logo_s").attr("id");
		var tobluepic = "./images/infos_pratiques/"+toblue+"_blue.gif";
		$("a.map_logo_s").children("img").attr("src",tobluepic);
		$("a.map_logo_s").removeClass("map_logo_s");
		
		var me = $(this).attr("id");
		var new_pic = "./images/infos_pratiques/"+me+"_orange.gif";
		$(this).children("img").attr("src",new_pic);
		
		$(this).addClass("map_logo_s");
		$(this).removeClass("map_logo");
		
		$("#map_infos").scrollTo("#cartouche_"+me,250);
	});
	

}

function letShow(color){
	if (color != "all") {
		$('.item[name!="comm"][name!='+color+']').stop().animate({width:"0px"},gspeed,"jswing", function() {
			$('.item[name!="comm"][name!='+color+']').css("display","none");
			$('.item[name='+color+']').stop().animate({width:"230px"},gspeed,"jswing");
		});
		
	} else {
		$('.item[name=blue]').stop().animate({width:"230px"},gspeed,"jswing");
		$('.item[name=black]').stop().animate({width:"230px"},gspeed,"jswing");
		$('.item[name=green]').stop().animate({width:"230px"},gspeed,"jswing");
	}
}

function switchLanguage() {
	var reg1 = new RegExp("GB_","g");;
	var myHost = location.host;
	var myPage = location.pathname;
	var mySearch = location.search;
	
	if (myPage.length == 1) {
		var GB = "http://"+myHost+"/GB_index.php";
		document.location = GB;
	} else {
		if (myPage.length > 3 && myPage.match(reg1)) {
			var newPage = myPage.replace(reg1,'');
			var FR = "http://"+myHost+newPage+mySearch;
			document.location = FR;
		} else {
			var newPage = location.pathname.substr(1,location.pathname.length);
			var GB = "http://"+myHost+"/GB_"+newPage+mySearch;
			document.location = GB;
		}
	}
}

var newsLen, newsTimer, news = 0;
function initIndex() {

	// INITIALISATION DU NEWSER
	newsLen = $("#newser_road").children().length;
	$("#newser_road").css("width",632*newsLen);
	
	launchNews();
	
	$("a.newser").click(function() {
		clearTimeout(newsTimer);
	})
	$("a.newser").mouseout(function() {
		clearTimeout(newsTimer);
		newsTimer = setTimeout("changeNews()",4000);
	})
	
	// INITIALISATION DES ONGLETS EXPOS
	$(".item[name=black]").css("display","none");
	$(".item[name=green]").css("display","none");
}

function launchNews() {
	newsTimer = setTimeout("changeNews()",1000);
}

function changeNews() {
	news ++;
	if (news == newsLen+1) {
		news = 1
	}
	newser(news);
	newsTimer = setTimeout("changeNews()",4000);
}

function newser(n) {
	news = n;
	var d = (n-1)*632;
	var dp = (n-1)*50+20;
	$("#newser_win").scrollTo({top:0,left:d},gspeed,"jswing");
	$("#newser_pointer").animate({left:dp},gspeed,"jswing");
}

function myLocalScroll(ancre,t) {
	$("body").scrollTo($("#"+ancre+""),t,"jswing");
}

// *****************
// SCRIPT SNCF / TER
// *****************
$.fn.regex = function(pattern) { 
	return ($(this[0]).val().match(pattern)) ? true : false; 
} 

var regN = /^[^\sÀÂÇÈÉÊËÎÔÙÛàâçèéêëîôùû\\\.\$\[\]\(\)\{\}\^\?\*\+\-\&@]+$/;
var regM = /^[a-zA-Z0-9\-_]+[a-zA-Z0-9\.\-_]*@[a-zA-Z0-9\-_]+\.[a-zA-Z\.\-_]{1,}[a-zA-Z\-_]+/;

function verif(don){

	if($.trim($(don).val())==""){
		return oble(don);
	}else{
		if($(don).regex(regN)==true){
			return true;
		}else{
			return reg(don);
		}
	}
}

function oble(don){
	$(don).val("Champ obligatoire");
	$(don).css('color','red');
}

function reg(don){
	$(don).val("pas d'accent ni caractères spéciaux");
	$(don).css('color','red');
}

function verifM(don){
	if($.trim($(don).val())==""){
		return oble(don);
	}else{
		if( $(don).regex(regM)==true ){
			return true;
		}else{
			$(don).val("Email non valide");
			$(don).css('color','red');
		}
	}
}

function edit_pdf() {
	var n = $("input[name=nom]");
	var p = $("input[name=prenom]");
	var m = $("input[name=email]");
	var ok = $("input[name=ok]");
	$(n).val($(n).val().replace(/ /g, '_'));
	$(p).val($(p).val().replace(/ /g, '_'));
	
	verif(p);
	verif(n);
	verifM(m);
	if(verif(p)==true && verif(n)==true && verifM(m)==true){
		window.open("generatepdf/ter_reduc.php?nom="+n.val()+"&prenom="+p.val()+"&email="+m.val()+"&ok="+ok.val());
		$("input[name=nom]").val("");
		$("input[name=prenom]").val("");
		$("input[name=email]").val("");
	}
}

function rebootCss(don){
	$("input[name="+don+"]").val("");
	$("input[name="+don+"]").css('color','black');
}

var vidPos;
function launchVid(cible) {
	vidPos = $("#screen_content").scrollLeft();
	if (vidPos != 0) {
		vidPos = vidPos/1000;
	}
	$("#screen_content").scrollTo($("#video"),250, {onAfter:function() {
			if (cible != null) {
				cible = "./videos/videoplayer"+cible+".php";
				$("#video").load(cible);
				$("#screen_content").css("height","500px");
			}
		}});
}

function closeVideo() {
	$("#video").html("");
	$("#screen_content").scrollTo({top:0,left:vidPos*1000}, gspeed, "jswing");
	var tabContent = $('.content');
	var h = $(tabContent[vidPos]).height();
	$("#screen_content").css("height",h+80);
}


// ******************
// GESTION DES "OFFS"
// ******************

var posOff;
var memOff;
var categorieOff = "normal";
var repertoire = "off";
var recal = 213;

function initOff() {
	$(".off_bt").mouseover( function() {
		$(this).css("border","1px solid #27276f");
	} );
	$(".off_bt").mouseout( function() {
		$(this).css("border","1px solid #ccc");
	} );
	
	$(".off_bt").css("display","none");
	$(".off_bt[name=normal]").css("display","block");
}

function initEcoles() {
	repertoire = "off";
	categorieOff = "ecole";
	recal = 235;
	
	$(".off_bt").mouseover( function() {
		$(this).css("border","1px solid #27276f");
	} );
	$(".off_bt").mouseout( function() {
		$(this).css("border","1px solid #ccc");
	} );
	
	$(".off_bt").css("display","none");
	$(".off_bt[name=ecole]").css("display","block");
	//
	$("#screen_content").css("height","1000px");
}

function initDS() {
	repertoire = "design_and_shop";
	categorieOff = "p1";
	recal = 311;
	
	$(".off_bt").mouseover( function() {
		$(this).css("border","1px solid #27276f");
	} );
	$(".off_bt").mouseout( function() {
		$(this).css("border","1px solid #ccc");
	} );
	
	$(".off_bt").css("display","none");
	$(".off_bt[name=p1]").css("display","block");
	//
	$("#screen_content").css("height","1000px");
}

function launchOff(obj) {
	$(".content").css("height",1098);
	var checkElu = $("#elu").length;

	if (checkElu == 0) {
		var elu = obj.parent();
		var position = $(elu).position();
		posOff = position;

		$(elu).css("position","absolute");
		$(elu).css("left",position.left);
		$(elu).css("top",position.top);
		
		$(elu).attr("id", "elu");
		$("div.off_bt:not(#elu)").css("display","none");
		
		$(elu).animate({left:20},gspeed/2,"jswing",function() {

			$(elu).animate({top:recal},gspeed/2,"jswing", function() {
				memOff = $("#elu a span.off_bt_titre").html();
				$("#elu a span.off_bt_titre").html("<span style='display:block;text-align:left;padding-top:6px;'>FERMER</span>");
				$("#elu").animate({height:25},gspeed/2,"jswing");
				$("#elu a img").css("display","none");
				getOffContent(elu);
			});
		});
	} else {
		$("#temp").remove();
		$("#elu a span.off_bt_titre").html(memOff);
		$("#elu").height("112px");
		
		$("#elu a img").css("display","block");
		$("#elu").animate({top:posOff.top},gspeed/2,"jswing",function() {
			$("#elu").animate({left:posOff.left},gspeed/2,"jswing",function() {
				$("#elu").css("position","static");
				$("#elu").removeAttr("id");
				
				if (categorieOff != "all") {
					$("div.off_bt[name="+categorieOff+"]").css("display","block");
				} else {
					$("div.off_bt").css("display","block");
				}
			});
		});
	}
}

function getOffContent(elu) {
	var total = $(".off_bt").length;
	var nbNextBro = elu.nextAll(".off_bt").length;
	var pos = total - nbNextBro;

	var tabOffCont = $(".off_content");
	var selOffCont = $(tabOffCont[pos-1]).clone();
	
	$(elu).after("<div id='temp'></div>");

	$("#temp").css("margin-left","130px");
	$("#temp").append(selOffCont);
	$("#temp .off_img").append("<img src='./images/expos/"+repertoire+"/"+pos+".jpg' />");
}

function letShowOff(categorie){
	//$("body").scrollTo(350,gspeed/1.5,"jswing");
	categorieOff = categorie;
	$("#temp").remove();
	$("#elu a span.off_bt_titre").html(memOff);
	$("#elu").css("position","static");
	$("#elu").height("112px");
	$("#elu a img").css("display","block");
	
	if (categorie != "all") {
			$('.off_bt[name!='+categorie+']').css("display","none");
			$('.off_bt[name='+categorie+']').css("display","block");		
		} else {
			$('.off_bt[name=normal]').css("display","block");
			$('.off_bt[name=public]').css("display","block");
			$('.off_bt[name=ecole]').css("display","block");
			$('.off_bt[name=autour]').css("display","block");
			
			$('.off_bt[name=p1]').css("display","block");
			$('.off_bt[name=p2]').css("display","block");
			$('.off_bt[name=p3]').css("display","block");
			$('.off_bt[name=p4]').css("display","block");
			$('.off_bt[name=p5]').css("display","block");
	}
}

// ********************
// BT "RANDOM" IN EXPOS
// ********************

var tabExpos = new Array(
'expo_100_chairs.php',
'expo_acteurs_et_institutions.php',
'expo_between_reality_and_the_impossible.php',
'expo_couriot.php',
'expo_demain_c-est_aujourd-hui.php',
'expo_design_and_shop.php',
'expo_international.php',
'expo_interware.php',
'expo_la_ville_mobile.php',
'expo_l-entreprise.php',
'expo_lumieres.php',
'expo_n-1_2.php',
'expo_off.php',
'expo_prediction.php',
'expo_process_design.php',
'expo_teleport_a_visual_confrontation.php',
'expo_transparences.php',
'expo_ubiquite-aura.php'
)

function randomExpo(obj) {
	var sExpo = Math.round(Math.random()*17);
	$(obj).fadeOut(100).fadeIn(100).fadeOut(80).fadeIn(80).fadeOut(60).fadeIn(60).fadeOut(40).fadeIn(40).fadeOut(20).fadeIn(20, function() {
		document.location = tabExpos[sExpo];
	});
}

// ****************
// BG GENERATOR (?)
// ****************
/*function generateBG() {
	var nb = 200;
	var i = 0;
	for (var a=0; a<nb; a++) {
		var op = Math.random()*.8+.2;
		i += .05;
		var ht = Math.sin(i)*50+150;
		var erase = Math.round(Math.random()*3);
		if (erase == 1) {
		//	op = 0;
		}
		var myDiv = "<div class='test' style='background:#27276f;width:"+ht+"px;position:absolute;top:"+a*5+"px;left:0;height:5px;opacity:"+op+"'></div>";
		$("#screen").before(myDiv);
	}
	$(".test").hover(function() {
			var myW = $(this).width()+Math.random()*20-20;
			$(this).css("width",myW+"px");
		})
}
*/
