/**
 * @author oliviermaghe
 */
$(document).ready(function() {

	// if the href sends the surfer outside my site, pop up a new window 
	
	$("a[href^=\"http\"]").each(function(i){
		$(this).not("[href*=\""+document.domain+"\"]").click(function(){
			window.open($(this).attr("href"));
			return false;
		});
	});
	
	// surround all images from the inside with a thickbox type anchor
	// to only affect wanted images, use ./ instead of / in the src path
	
	$("img[src^=\"./data/images/\"]").each(function(i){
		destination = $(this).attr("src").replace(".tb","");
		$(this).wrapAll("<a class='thickbox' title='Cliquez pour agrandir' href='"+destination+"'></a>");
	});

	// Click on a <code> tag and its content will be selected and ready to copy/paste 
	
	var toSelect = "<div class='codeclick'>Cliquez pour sélectionner</div>";
	
	$("code").after(toSelect).click(function(){
		/* replacement in code content */
		content = $(this).html().replace(/n/ig,'').replace(/<br>/ig, '\n').replace(/<br\//ig, '\n');
		/* build the text area */
		textarea ='<textarea rows="5" cols="80">'+content+'</textarea>';
		
		/* hide the code, append the textarea after, focus on it, select the content, remove the tip*/
		$(this).hide().after(textarea).next().focus().select().next().hide();
	});
		
}); 


