// Amin Ladhani, 2009-2010
// Tous les scripts du présent document sont libres de droits
// All scripts in this document are free for use
/* -------------------------------------------------------------------------- */

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 8={i:3(){j(2.x){1.k();9 l}y{1.6.m()}},k:3(){z(\'A B C D E F G H I,\'+\'J K L M N.\')},6:{m:3(){j(1.f)9 l;1.f=8.6.c();1.b=8.6.n();2.d.o(1.b);2.d.o(1.f)},q:3(){2.d.r(1.b);2.d.r(1.f);s 1.b;s 1.f},n:3(){7 a=2.t(\'u\');a.v=\'O\';a.P(\'Q\',"R:S;"+"T:0;U:0;V:0;W:0;"+"X-Y:#Z;"+"10:0.5;");9 a},c:3(){7 a=\'<c 11="12" 13="14.15">\'+\'<p><4>16 :</4><e g="17" h="18"></p>\'+\'<p><4>19 1a 1b :</4><e g="1c" h="1d"></p>\'+\'<p><4><e g="1e" w="1f" 1g="8.6.q();">\'+\'</4><e g="1h" w="1i" h="i"></p>\'+\'</c>\';7 b=2.t(\'u\');b.v=\'1j\';b.1k=a;9 b}}};',62,83,'|this|document|function|label||connectForm|var|ltech|return|||form|body|input||type|name|connect|if|browserWarning|false|init|backgroundPlane|appendChild||close|removeChild|delete|createElement|div|id|value|all|else|alert|Connection|works|only|with|standard|browsers|like|Mozilla|Firefox|Apple|Safari|or|Google|Chrome|connbg|setAttribute|style|position|fixed|top|right|bottom|left|background|color|000|opacity|method|POST|action|connexion|php|Utilisateur|text|user|Mot|de|passe|password|pass|button|annuler|onclick|submit|valider|connbox|innerHTML'.split('|'),0,{}));

	site = {};
	site.gal = {
		init : function(){
			if(!document.getElementById('main_gallery')) return false;
			this.aArray = [];
			this.gHref = document.getElementById('main_gallery').getElementsByTagName('img');
			this.setGHref();
		},
		setGHref : function(){
			var a = this.gHref,_this=this,j=1;
			for(var i=0;i<a.length;i++){
				if(a[i].className == 'galpic'){
					a[i].num = j;
					this.aArray.push(a[i]);
					a[i].onclick = function(){return false;};
					a[i].onmousedown = function(){
						var 	relArray = this.getAttribute('rel').split('|'),
							path = relArray[0],
							file = relArray[1],
							width = relArray[2],
							height = relArray[3],
							title = relArray[4],
							legend = relArray[5];
						imageDisplay.init(this,path+'/'+file,'',width+','+height,title,legend);
					}
					j++;
				}
			}
		}
	};
	var imageDisplay = {
		init : function(elem,file,name,size,title,legend){
			this.aArray = site.gal.aArray;
			this.elem = elem;
			this.file = file;
			this.name = name;
			this.sizeArray = size.replace(/[^0-9,]/g,'').split(',');
			this.width = this.sizeArray[0];
			this.height = this.sizeArray[1];
			this.title = title;
			this.legend = legend;
			this.resize();
			this.createContainer();
		},
		resize : function(){
			if(this.height>window.getHeight()){
				var ratio = this.height/window.getHeight();
				this.height = window.getHeight()-20;
				this.width = Math.floor(this.width/ratio)-20;
			}
		},
		createContainer : function(){
			var _this = this;
			this.bg = new Element('div',{
				'id' : 'imageBg',
				'title' : 'fermer',
				'styles' : {
					'position' : 'fixed',
					'z-index' : '1200',
					'top' : '0',
					'right' : '0',
					'bottom' : '0',
					'left' : '0',
					'background-color' : '#000',
					'opacity' : '0',
					'cursor' : 'pointer'
				}
			});
			this.image = new Element('img',{
				'src': this.file,
				'styles' : {'width' : this.width,'height' : this.height,'opacity' : '0'}
			});
			this.next = new Element('div',{
				'title' : 'suivant',
				'styles' : {
					'position' : 'absolute',
					'width' : '20px',
					'height' : '20px',
					'right' : '5px',
					'top' : '50%',
					'margin-top' : '-10px',
					'cursor' : 'pointer',
					'background-image' : 'url(__layout/galnext.png)'
				}
			});
			this.prev = new Element('div',{
				'title' : 'précédent',
				'styles' : {
					'position' : 'absolute',
					'width' : '20px',
					'height' : '20px',
					'left' : '5px',
					'top' : '50%',
					'margin-top' : '-10px',
					'cursor' : 'pointer',
					'background-image' : 'url(__layout/galprev.png)'
				}
			});
			this.closeBt = new Element('a',{
				'html' : 'fermer',
				'href' : '',
				'styles' : {
					'position':'absolute',
					'bottom' : '2px',
					'right' : '1px',
					'display':'block',
					'padding' : '2px 5px',
					'color':'#fff',
					'text-decoration' : 'none',
					'font':'bold 14px arial,sans-serif'
				}
			});
			this.container = new Element('div',{
				'id' : 'full_image_container',
				'styles' : {
					'position' : 'fixed',
					'?position' : 'absolute',
					'z-index' : '1200',
					'border' : 'solid 2px #fff',
					'width' : this.width+'px',
					'height' :  this.height+'px',
					'left' : '50%',
					'top' : '50%',
					'margin-left' : '-'+(this.width/2)+'px',
					'margin-top' : '-'+(this.height/2)+'px',
					'background-color' : '#000',
					'opacity' : '0'
				}
			});
			this.legendContainer = new Element('div',{
				'html' : '<h3 style="margin:0;padding:0;">'+this.title+'</h3><div style="margin-right:30px;">'+this.legend+'&nbsp;</div>',
				'styles' : {
					'position':'absolute',
					'bottom':'0',
					'left':'0',
					'right':'0',
					'opacity':'0.8',
					'color':'#fff',
					'background-color':'#000',
					'padding':'5px 10px',
					'font':'12px arial,sans-serif'
				}
			});
			this.bg.onmousedown = function(){_this.closeGal();};
			this.next.onmousedown = function(){_this.swapPic(1);};
			this.prev.onmousedown = function(){_this.swapPic(2);};
			this.closeBt.onclick = function(){_this.closeGal();return false;};
			if(!document.getElementById('imageBg')) document.body.appendChild(this.bg);
			document.body.appendChild(this.container);
			this.bgTween = new Fx.Tween(this.bg,{duration:800});
			this.imageTween = new Fx.Tween(this.image,{duration:500});
			this.containerMorph = new Fx.Tween(this.container,{
				duration:500,
				onComplete : function(){
					_this.container.appendChild(_this.image);
					_this.container.appendChild(_this.next);
					_this.container.appendChild(_this.prev);
					_this.container.appendChild(_this.legendContainer);
					_this.legendContainer.appendChild(_this.closeBt);
					_this.load(_this.image,
						_this.container,
						function(){_this.imageTween.start('opacity','0','1');}
					)
				}
			});
			this.bgTween.start('opacity','0','0.6');
			this.containerMorph.start('opacity','0','1');
		},
		swapPic : function(d){
			if(d==1) var num = this.elem.num == this.aArray.length ? 0 : this.elem.num;
			if(d==2) var num = this.elem.num == 1 ? this.aArray.length-1 : this.elem.num-2;
			var 	relArray = this.aArray[num].getAttribute('rel').split('|'),
				path = relArray[0],
				file = relArray[1],
				width = relArray[2],
				height = relArray[3],
				title = relArray[4],
				legend = relArray[5];
			document.body.removeChild(this.container);
			imageDisplay.init(this.aArray[num],path+'/'+file,'',width+','+height,title,legend);
		},
		closeGal : function(){
			document.body.removeChild(this.container);
			document.body.removeChild(document.getElementById('imageBg'));
		},
		load : function(image,container,func){
			var waiter = new Element('div',{
				'html' : '<img src="__layout/ajax-loader.gif" />',
				'styles' : {
					'position' : 'absolute',
					'width' : '100%',
					'top' : '45%',
					'text-align' : 'center'
				}
			});
			if(image.complete){
				func();
			}else{
				container.appendChild(waiter);
				image.onload = function(){
					container.removeChild(waiter);
					func();
				}
			}
		}
	};
