jQuery.fn.htmlBranding = function(settings) {
		settings = jQuery.extend({
		htmlTpl : '<div class="blockmarque"><a href="#BLOCKLINK#" class="hoverglobal"></a><div class="blockimg" style="background-image:url(#BLOCKIMG#)"></div><div class="blockinfo"><span class="blockmarque-title">#BLOCKTITLE#</span><span class="blockmarque-text">#BLOCKTEXT#</span></div></div>'
		}, settings);
	
	/*Fonction permettant de remplacer plusieurs éléments dans un String*/	
	function replaceAll(txt, replace, with_this) {
		return txt.replace(new RegExp(replace, 'g'),with_this);
		}		
				
	/*Pour chaque élément Marque*/
	$(".brandlayout").each(function(){ 
	
			/*On Stocke un template temporaire et on remplace tous les liens*/			
			var htmlTplTemp = settings.htmlTpl ;			
			if( $(this).find("a").attr('href') == '' ){	htmlTplTemp = replaceAll(htmlTplTemp,'#BLOCKLINK#','#');}
			else{htmlTplTemp = replaceAll(htmlTplTemp,'#BLOCKLINK#',$(this).find("a").attr('href'));}				
			htmlTplTemp = replaceAll(htmlTplTemp,'#BLOCKIMG#',$(this).find("img").attr('src'));
			htmlTplTemp = replaceAll(htmlTplTemp,'#BLOCKTITLE#',$(this).find(".PBMainTxt").text());
			htmlTplTemp = replaceAll(htmlTplTemp,'#BLOCKTEXT#',$(this).find(".PBLongTxt").text());			
					
			/*Méthode d'inclusion*/		
			$('.view').append(htmlTplTemp)	;
			}
		)
		
	/*On supprime le viewtbl*/	
	$(".brands .viewtbl").remove();		

};

$('.brands').htmlBranding();
