/****************************************************************************
 *** clickable_box JS FILE
 ***
 *** This file contains:
 *** 	- Function to transform the "rel" attribute of DIV's, to a
 ***      global link on the DIV, in function of the type of target
 ***
 *** Author: Thierry Brodard <t.brodard@accessible.ch>
 *** Copyright: accessible Sàrl
 ***
 *****************************************************************************/

window.addEvent('domready', function() {

	var clickables = $$('.clickable');
	
	clickables.each(function(item) {
		// Reprendre la propriété "rel" du DIV
		var link = item.getProperty('rel').split(';');
		var target = link.length>1?link[1]:'';
		link = link[0];
		item.removeProperty('rel');
		
		// Rajouter un click global sur le DIV, en fonction du type de lien
		if(link){
			item.addEvent('click', function(el) {
				linkString = new String(link);
				
				if(target=='_blank'){
					window.open('/'+link);
				}else{
					document.location.href = link;
				}		
				
				/**
				 * Old version
				if (linkString.contains('html')  && (!linkString.contains('www')) && (!linkString.contains('http'))) {
					document.location.href = link;
				}else{
					window.open('/' + link);
				}
				
				*/
			});
		}
	});
});
