var $j = jQuery.noConflict();
// Use jQuery via $j(...)
$j(document).ready(function(){
	$j("a[rel=example_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleShow'		: false,
		'padding': 0
	});
	
	$j("#map_europe area").mouseenter(function(){ var zone=$j(this).attr("alt"); $j("#lazone img").attr("src","cartes/" + zone + ".gif"); }).mouseleave(function(){ $j("#lazone img").attr("src","cartes/vide.gif"); });

});

window.addEvent('domready', function() {

	$$('img').each(function(img){
		img.setProperty('galleryimg','no');
		// var myDrag = new Drag(img);
		img.addEvents({
			'contextmenu': function(event){
				return false;
			}
		});
	});
	
	if ($('Header').getHeight()+$('Content').getHeight()+$('Footer').getHeight() < window.getHeight()){
		$('Content').setStyles({'height': window.getHeight()-($('Header').getHeight()+$('Footer').getHeight()+90) });
	}
	
	function GreyBackground(){
		$('GreyBackground').empty();
		$$('.GreyBackground').each(function(obj){
			var bgr = new Element('div',{
				'class':'BackgroundGrey',
				'styles':{
					'top':obj.getCoordinates().top-(obj.getHeight()/10)+(obj.getParents('.GreyBackground').length*2),
					'left':obj.getCoordinates().left-(obj.getWidth()/10)+(obj.getParents('.GreyBackground').length*10)+(obj.getChildren().length),
					'height':obj.getHeight()+(obj.getHeight()/5),
					'width':obj.getWidth()+(obj.getWidth()/15),
					'opacity': 0.3,
					'z-index': 1
				}
			}).injectInside($('GreyBackground'));
		})
	}
	
	GreyBackground();
	
	$('FooterRightBackground').setStyles({
		'opacity': 0.3
	});
	
	window.addEvents({'resize': function(){
		GreyBackground();
	}});
	window.addEvents({'load': function(){
		GreyBackground();
	}});
	
	$$('.ReadMoreLink').each(function(bt){
		var text = bt.get('text');
		var alt = bt.get('alt');
		var rel = bt.get('rel');
		bt.addEvents({
			'click': function(){
				if ($(rel).getStyle('display') == 'none'){
					$(rel).setStyles({'display':'block'});
					bt.set({'text':alt});
				} else {
					$(rel).setStyles({'display':'none'});
					bt.set({'text':text});
				}
			}
		})
	});

});


function setLink(){
	var javascriptLink = document.getElements('a.javascript');
	javascriptLink.each(function(link){
		link.set({
			'href':link.get('alt'),
			'alt': ''
			});
		link.removeClass('javascript');
	});
}

// Tab

function loadUrlIn(url,target,fade){
	if ((target.getCoordinates().top-window.getScroll().y > 0)){
		loadUrl(url,target,fade);
	} else {
		var myFx = new Fx.Scroll(window, {
		    offset: {
		        'x': 0,
		        'y': -100
		    },
		onComplete: function(){
			loadUrl(url,target,fade);
			}}).start(0,target.getCoordinates().top)
	}
}

function loadUrl(url,target,fade){
	if (fade){ var myFx2 = new Fx.Tween(target,{duration: 800, link: 'chain',transition: Fx.Transitions.Quad.easeIn}).set('opacity',0); }
	var myHTMLRequest = new Request.HTML({
		url: url+'&lng='+lng,
		update: target,
		onComplete: function(){
			if (fade){ myFx2.start('opacity',1); }
			setLink();
		}}).get();
}

function show(id){
	$('show'+id).setStyles({'display':'none'});
	$('content'+id).setStyles({'display':'block'});
}

function hide(id){
	$('show'+id).setStyles({'display':'inline'});
	$('content'+id).setStyles({'display':'none'});
}

function toggleDiv(id){
	
}
