// JavaScript Document
window.addEvent('domready', configure);



function configure(){
	$$('img[act=zoom]').each(function(el){
		el.setStyle('cursor','pointer');
		el.setProperty('rel',"{ url:'"+el.get('src').split('reducImage.php')[1].split('img=')[1].split('&')[0]+"'}");							
	});
	$$('img[act=download]').each(function(el){
		el.setStyle('cursor','pointer');
		src = el.get('src').split('reducImage.php')[1].split('img=')[1].split('&')[0];
		el.addEvent('click', function(){ window.location.href='http://clients-cms.rhonalpcom.fr/CMS/download.php?file='+src });
	});
	$$('a[act=download]').each(function(el){
		el.setStyle('cursor','pointer');
		src = el.get('href');
		el.addEvent('click', function(){ window.location.href='http://clients-cms.rhonalpcom.fr/CMS/download.php?file='+src });
	});
	SqueezeBox.assign($$('img[act=zoom]'), { parse:'rel' } );
	$$('img[act=blank]').each(function(el){
		el.setStyle('cursor','pointer');
		el.setProperty('target',"_blank");
		el.addEvent('click', function(){ window.open(this.src); });
	});
	SqueezeBox.assign($$('a[rel=lightbox]'));
	SqueezeBox.assign($$('.lightbox'), { parse:'rel' } );
	//console.log($$('a[rel=lightbox]'));
	
	//data : [['download', 'Telecharger'],['wallpaper', 'Fond d\'ecran telechargeable']]
	
	$$('table.alternance_tableau').each(function(tab){
		$(tab).set('cellspacing', 0);
		$(tab).set('cellspadding', 0);
		$(tab).set('border', 0);
		$(tab).getElements('tr').each(function(el, index){
			if(index==0){
				el.addClass('enteteTab');
			}
			if(index>1){
				el.addClass('enteteLigne'+(index%2));
			}
		});
		
	});

}

function fix_inline_PNGs(){
	var images = $$('img'); // liste de tous les élément <img /> du document
	images.each(function(e){
		if (e.getParent().get('tag')=='a'){
			styleCursor = 'pointer';
		}else{
			styleCursor = '';
		}
	var this_src = e.getProperty('src');
	var this_height = e.height;
	var this_width = e.width;
	if (this_src.toUpperCase().contains('.PNG')){
	var this_new = new Element('span', {
	'styles': {
	 'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+this_src+'\', sizingMethod=\'scale\')',
	 'display': 'inline-block',
	 'height': this_height,
	 'width': this_width,
	 'cursor': styleCursor
	 }});
	 
	// e.replaces(this_new);
	this_new.replaces(e);
	 }
	 });
 }


 window.addEvent('load', function() { // Garantit l'exécution du la fonction au bon moment!
 //fix_inline_PNGs();
 });


