var overlay;
window.addEvent('domready', function() {
	
	if($E('div.tel span')){
		if($E('div.tel span').getText()=='work'){$E('div.tel span').setText('T.');}
		fax = $E('div.tel').getNext().getFirst();
		if(fax.getText()=='fax'){fax.setText('F.');}
	}
	
	if(window.ie){
		$$('img[src$=png]').each(function(el) {
			el.replaceWith(new Element('input', {
			'styles': {
			'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'crop\', src=\'' + el.getProperty('src') + '\')',
			'position': 'relative',
			'background': 'transparent'
			},
			'title': el.getProperty('alt')
			}).setStyles(el.getStyles('padding','margin','border','height','width','left','top')).setProperties(el.getProperties('id','class')).setProperty('disabled', 'true'));
			});
	}
	
	
	$ES('.roll a').each(function(e){
		
	full = new Element('span',{'class':'full'});full.injectBefore(e);
	faded = new Element('span',{'class':'faded'});faded.injectBefore(full);
	
	x = e.getPrevious();
	var fx = new Fx.Styles(x, {duration:400, wait:false});
	
	if(e.getProperty('sel')!='1')
	{
		e.addEvent('mouseenter',function(){
			
			fx.start({'opacity': [1,1]});
			//e.getFirst().setStyle('padding-left','15px');
		});
		
		e.addEvent('mouseleave',function(){
			
			fx.start({'opacity': [1,0]});
			//e.getFirst().setStyle('padding-left','12px');
		});
	}
	else{
		fx.start({'opacity': [0,1]});
		e.getFirst().setStyles({'color':'#ffffff'});
		
	}
	
	});
		
	$ES('.gall a').each(function(e){
		shadow = new Element('span',{'class':'shadow',styles:{'opacity':'0.45'}});
		thumb = e.getPrevious();
		img = thumb.getFirst();
		sh = shadow.injectInside(thumb);
		s = e.getFirst();
		var fx = new Fx.Styles(s, {duration:200, wait:false});
		
		if(e.getProperty('nobook')!=1)
		{
			if(!window.ie)
			{
				e.addEvent('mouseenter',function(){
				
					t = e.getPrevious().getLast().setStyle('opacity','0');		
					fx.start({'height': '0px'});	 
				});
			e.addEvent('mouseleave',function(){
	
					t = e.getPrevious().getLast().setStyle('opacity','0.45');
					fx.start({'height': '25px'});
				});
			}
			
		e.addEvent('click',function(c){
			var c = new Event(c);
			c.stop();
			overlay =  new Overlay({'colour':'#000000'});
			overlay.show();
			$('screencast').setStyle('display','block');
			
			var flashvars = {path:"/books/swf/main.swf",idBook: e.getProperty("bid")};
			var params = {scale: "noscale",quality: "best",allowScriptAccess: "always",allowFullScreen: "true",bgcolor:'#000000',wmode:"opaque"};
			var attributes = {id: "screencast",name: "screencast"};
			
			swfobject.embedSWF("/books/swf/main.swf", "screencast", "100%", "100%", "8.0.0","/books/js/expressInstall.swf", flashvars, params, attributes);
			
		});
		
		if(window.ie){
			img.addEvent('click',function(c){
			var c = new Event(c);
			c.stop();
			overlay =  new Overlay({'colour':'#000000'});
			overlay.show();
			$('screencast').setStyle('display','block');
			
			var flashvars = {path:"/books/swf/main.swf",idBook: e.getProperty("bid")};
			var params = {scale: "noscale",quality: "best",allowScriptAccess: "always",allowFullScreen: "true",bgcolor:'#000000',wmode:"opaque"};
			var attributes = {id: "screencast",name: "screencast"};
			
			swfobject.embedSWF("/books/swf/main.swf", "screencast", "100%", "100%", "8.0.0","/books/js/expressInstall.swf", flashvars, params, attributes);
			
			});
			
			e.addEvent('mouseenter',function(){
				
					t = e.getPrevious().getLast().setStyle('opacity','0');		
					fx.start({'height': '0px'});	 
				});
				
			img.addEvent('mouseleave',function(){
	
					t = e.getPrevious().getLast().setStyle('opacity','0.45');
					fx.start({'height': '25px'});
				});
		}
		
		}
		else{
			var s_o = new Array();
			e.addEvent('mouseenter',function(){
			s_o[e.getProperty('bid')] = e.getFirst().getFirst().getText();
			e.getFirst().getFirst().setText('Coming soon');
			});
			
			e.addEvent('mouseleave',function(){
			e.getFirst().getFirst().setText(s_o[e.getProperty('bid')]);
			});
			
			e.addEvent('click',function(c){
			var c = new Event(c);
			c.stop();
			});
			
		}
	});
	
	$ES(".btn-menu a").each(function(e){
		bg = new Element('span',{'class':'bg'});
		f = new Element('span',{'class':'faded'});
		f.injectBefore(e);bg.injectBefore(f);
		
		if(window.ie){
			img = f.getStyle('background-image');
			len = img.length;
			f.setStyles({
			'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', sizingMethod=\'crop\', src=\'' + img.substring(5,len-2) + '\')',
			'background':''
			});
		}
		
		b = e.getParent().getFirst();
		var fx = new Fx.Styles(b, {duration:300, wait:false});
		var fxa = new Fx.Styles(e, {duration:300, wait:false});	
		if(e.getParent().getProperty('class')!='btn-menu active')
		{
		e.addEvent('mouseenter',function(){		
			fx.start({'height': '44px','display':'block'});
			fxa.start({'opacity': [0.1,1]});
		});
		e.addEvent('mouseleave',function(){
			fx.start({'height': '21px','display':'block'});
			fxa.start({'opacity': [1,0.1]});
		});
		}
	});
	
	if($('email')){
	$('email').addEvent('focus',function(){
		if($(this).getProperty('value')=='votre adresse e-mail'){
			$(this).setProperty('value','');
		}
	});
	
	$('email').addEvent('blur',function(){
		if($(this).getProperty('value')==''){
			$(this).setProperty('value','votre adresse e-mail');
		}
	});}
	
	// Gab's class
	
	flashLaunch = {
		lanchflash:function(){
			if($('thisisthebook')){
				var bid = $('thisisthebook').getProperty('bid');
				overlay =  new Overlay({'colour':'#000000'});
				overlay.show();
				$('screencast').setStyle('display','block');
				var flashvars = {path:"/books/swf/main.swf",idBook: bid};
				var params = {scale: "noscale",quality: "best",allowScriptAccess: "always",allowFullScreen: "true",bgcolor:'#000000'};
				var attributes = {id: "screencast",name: "screencast"};
			
				swfobject.embedSWF("/books/swf/main.swf", "screencast", "100%", "100%", "8.0.0","/books/js/expressInstall.swf", flashvars, params, attributes);	
			}
		}
	}
	// Launch
	flashLaunch.lanchflash();
	
	//legal
	$('legal').addEvent('click',function(e){
		//new Event(e).stop();
		var legalsfade = new Element('div',
				{ 
				'styles':{
						'background':'#000',
						'height':$E('.body').getStyle('height'),
						'width':$E('.body').getStyle('width'),
						'position':'absolute',
						'top':'0px',
						'left':'0px',
						'z-index':'9999',
						'display':'block',
						'overflow':'hidden',
						'opacity':'0.5'
				 	},
				 'id':'legalfade'
				}
			);
			
		var legals = new Element('div',
				{ 
				'styles':{
						'height':'600px',
						'width':'933px',
						'position':'absolute',
						'top':'0px',
						'margin':'0px auto',
						'z-index':'99999',
						'display':'block',
						'overflow':'hidden'
				 	},
				 'id':'legal_mention'
				}
			);
			
			var legalEffects = new Fx.Styles(legalsfade, {duration: 300, transition: Fx.Transitions.linear});
			var legals_text = '<p class="legaltext"><br/>MENTIONS LEGALES<br/><br/>'+
					   'Creasenso.fr est un site de la société CREASENSO™, SARL au capital de 7500 &euro;, dont le siège social est 21, rue de Trévise ; 75009 PARIS, immatriculé au Registre du Commerces et des Sociétés de Paris sous le numéro B 447 652 249'+
					    '<br/><br/>'+
					    'Gérant : Cédric BORDERIE'+
					    '<br/><br/>'+
					    'Le site web est hébergé par la société Typhon™ SAS au capital de 100 100 &euro; - 17 rue Réaumur, 75003 Paris - RCS PARIS B 480 288 97'+
					    '<br/><br/><a href="#">Retour</a></p>';
			legals.setHTML(legals_text);
			legalsfade.injectInside($E('.body'));
			legals.injectInside($('size'));
			legalEffects.start({'opacity': [0.5,0.8]});
			legalsfade.addEvent('click',function(){legals.remove();legalsfade.remove();});
			legals.addEvent('click',function(){legals.remove();legalsfade.remove();});
		});
	
});





