/**
 * @author juego
 */

function layout(){

	// Typography mod on H1 titles.
	$('h1').each(function() {
		var str = $(this).text(); // get text inside H1
		var strLeng = str.length;
		var color = $(this).css('color'); // get color of H1.
		var letterHeightStr = $(this).css('font-size'); //get font-size of H1
		var taille = 106 //parseInt(letterHeightStr);

		$(this).html('').css({
			height: taille
		});

		for (i = 0; i < strLeng; i++) {
			$(this).append('<div id="id-' + i + '" width="' + taille + 'px" height="' + taille + 'px" style="float: left; position: relative; display:inline-block; width:' + taille + 'px; height:' + taille + 'px; margin: 0px; padding: 0px;"></div>');
			drawALetter(str.charAt(i), $(this).children('#id-' + i), taille, taille, taille / 3, color);
		};
	});
	
	// Typography mod on H2 titles.
	$('h2').each(function() {
		var str = $(this).text(); // get text inside H2
		var strLeng = str.length;
		var color = $(this).css('color'); // get color of H1.
		var letterHeightStr = $(this).css('font-size'); //get font-size of H1
		var taille = 36 //parseInt(letterHeightStr);

		$(this).html('').css({
			height: taille
		});

		for (i = 0; i < strLeng; i++) {
			$(this).append('<div id="id-' + i + '" width="' + taille + 'px" height="' + taille + 'px" style="float: left; position: relative; display:inline-block; width:' + taille + 'px; height:' + taille + 'px; margin: 0 2px 2px 0; padding: 0px;"></div>');
			drawALetter(str.charAt(i), $(this).children('#id-' + i), taille, taille, 14, color);
		};
	});	
	
	// Typography mod on Menu H3 titles.
	/*
	$('.sidebar > ul > li > a').each(function() {
		var str = $(this).text(); // get text inside H2
		var strLeng = str.length;
		var color = $(this).css('color'); // get color of H1.
		var letterHeightStr = $(this).css('font-size'); //get font-size of H1
		var taille = 14 //parseInt(letterHeightStr);

		$(this).html('').css({
			height: taille
		});

		for (i = 0; i < strLeng; i++) {
			$(this).append('<div id="id-' + i + '" width="' + taille + 'px" height="' + taille + 'px" style="float: left; position: relative; display:inline-block; width:' + taille + 'px; height:' + taille + 'px; margin: 0 2px 5px 0; padding: 0px;"></div>');
			drawALetter(str.charAt(i), $(this).children('#id-' + i), taille, taille, 1, '#000000');
		};
	});	
	
	// mouse events on the typo mod menu.
	$('.sidebar > ul > li > a').each(function() {
		$(this).mouseover(function() {
			$(this).children().children().css({
				backgroundColor : '#990000'
			});
		});
		$(this).mouseout(function() {
			$(this).children().children().css({
				backgroundColor : '#000000'
			});
		});
	});
	*/
	
	/*
	//image layout
	var iFr = 0; // indice <p> french
	var iEn = 0; // indice <p> english
	lesPfr = $('.french > p'); // les <p> francophones
	lesPen = $('.english > p'); // les <p> anglais
	
	if (lesPen.length) {
	
		lesPfr.each(function(){
			var images = $(this).children('img');
			// si le <p> contient des images
			if (images.length) {
				// pour chaque image
				var hauteur = 0;
				images.each(function(){
					var h = $(this).height();
					hauteur += (h - (h % 18)) + 18;
				});

				var fullHtml = '<div class="span-9 img-holder" style="text-align: center; height:' + hauteur + 'px;">' + $(this).html() + '</div>';
				lesPfr.eq(iFr).after(fullHtml);
				lesPen.eq(iEn).before('<div class="span-9 temp" style="height:' + hauteur + 'px;">&nbsp;</div>');
				$(this).remove(); // enlever le <p> contenant les images
				iEn--;
			}
			iFr++;
			iEn++;
		});
		
		$('.french > div > img').css({
			marginTop: "0",
			marginRight: "-80px",
			marginBottom:  "0em",
			marginLeft: "80px",
			float: "right",
			position: "relative"
		}); // equivalent au .push-3 sans la marge de dessous.
		
	}
	*/
	$(".fbox").fancybox({
		"titlePosition": "inside",
		"cyclic" : "true",
		"overlayOpacity" : "0.3"
	});

}

