var popinOverlay = { 
	expose: { 
	color: '#000', 
	loadSpeed: 200, 
	opacity: 0.5, 
	onLoad: function(){$('input').blur();$('select').hide()}, //IE6 trick to hide/show select input
	onClose: function() {$('select').show()} 
	},
	closeOnEsc: true,
	closeOnClick: false 
};

var popinOverlayForQuestion = { 
	expose: { 
	color: '#000', 
	loadSpeed: 200, 
	opacity: 0.5, 
	onLoad: function(){$('input').blur();$('select').hide()}, //IE6 trick to hide/show select input
	onClose: function() {$('select').show()} 
	},
	closeOnEsc: false,
	closeOnClick: false 
};

$(document).ready(function() { 
	$(".modalInput").overlay({ 
		expose: { 
		color: '#000', 
		loadSpeed: 200, 
		opacity: 0.5, 
		onLoad: function(){$('select').hide();$('.modal select').show()}, //IE6 trick to hide/show select input
		onClose: function() {$('select').show()} 
		}, 						 
		closeOnClick: true 
	});
	
	// re-initialise le scroll dans la popin
	$(".modalInput").click(function() {
		$('.modal .scrollbar').jScrollPane({showArrows:true});
	});
	
	//affichage texte dans structure
	$(".zone .moreInfo").click(function() {
		$(this).parents(".zone").find(".text").show();
		try {
			// for IE6: use a js function in order to display the text above the "select" element (IE6 bug)
			if (typeof(window['autoRepair']) != "undefined") {
				autoRepair();
			}
		} catch (e) {}
		return false;
	})

	var timeoutID;
	var myElement;
	
	//affichage texte dans structure
	$(".zone .moreInfo, .zone .title h1").mouseover(function() {
		myElement = $(this);
		timeoutID = window.setTimeout(function() {
			myElement.parents(".zoneMain").find(".text").show();	
		try {
			// for IE6: use a js function in order to display the text above the "select" element (IE6 bug)
			if (typeof(window['autoRepair']) != "undefined") {
				autoRepair();
			}
		} catch (e) {}
		return false;}, 300);
	})

	//masquage texte dans structure
	$(".zoneMain .title").mouseout(function() {
		window.clearTimeout(timeoutID);
		$(this).parents(".zoneMain").find(".text").hide();
		$(".zoneMain .text").mouseout(function() {
			$(this).hide();	
		});			
		return false;
	})	

	$(".popinLoading").overlay({ 
		expose: { 
		color: '#fff', 
		loadSpeed: 200, 
		opacity: 0.7, 
		onLoad: function(){$('select').hide()}, //IE6 trick to hide/show select input
		onClose: function() {$('select').show()} 
		},
		top:"center",
		closeOnEsc: false,
		closeOnClick: false 
	});
	
	$(".popinError").overlay(popinOverlay);	
	$(".popinQuestion").overlay(popinOverlayForQuestion);	

	//thx IE
	$("#header .links").css("zoom",1);
	$("#header .cart").css("zoom",1);
	
	var popin = $(".modal").detach();
	popin.appendTo("body");
	
});	
