function voir_exemple()
{
	var nb_div = document.getElementsByTagName('div').length;
	for (i=0; i<nb_div; i++)
	{
		var sous_partie = document.getElementsByTagName('div').item(i);
		if (sous_partie.className == 'sous_partie')
		{
			// recupere l'url du lien à l'intérieur de la balise h3
			var url = sous_partie.getElementsByTagName('h3')[0].getElementsByTagName('a')[0].getAttribute('href');

			/***********************************************************
			/ 			EFFET DE SURVOL SUR LA SOUS PARTIE 
			/***********************************************************/			

				sous_partie.onmouseover = function() {
					this.className = "sous_partie sp_hover";
				}
	
				sous_partie.onmouseout = function()	{
					this.className = "sous_partie";
				}
	
				sous_partie.onclick = function()	{
					window.location = this.getElementsByTagName('h3')[0].getElementsByTagName('a')[0].getAttribute('href');;
				}

			/***********************************************************
			/ 						PHOTO 
			/***********************************************************/			

				// recupere la bonne photo
				var nb_img = sous_partie.getElementsByTagName('img').length;
				for (x=0; x<nb_img; x++)
				{
					if (sous_partie.getElementsByTagName('img')[x].parentNode.className == 'photo')
					{
						var photo = sous_partie.getElementsByTagName('img')[x];
						//var src_photo = photo.getAttribute('src');
						break;
					}
				}
				
				// création du lien sur la photo avec ses attributs
				var newLinkPhoto = document.createElement('a');
				newLinkPhoto.setAttribute('href', url);
				newLinkPhoto.className = 'photo';
	
				// remplace la photo simple par la meme photo en lien
				sous_partie.replaceChild(newLinkPhoto, photo.parentNode);

			/***********************************************************
			/ 						LIEN "EN SAVOIR PLUS" 
			/***********************************************************/			

				// création de la balise lien "en savoir plus " avec ses attributs
				var newLink = document.createElement('a');
				newLink.setAttribute('href', url);
				newLink.className = 'exemple';
			
				// assigner un texte à l'intérieur du lien
				var linkText = document.createTextNode('voir des exemples');
				newLink.appendChild(linkText);
	
				// ajout du lien
				sous_partie.appendChild(newLink);
		}
	}
}
function contact()
{
	var contact = document.getElementById('contact');
	var img_contact = contact.getAttribute('src');
	
	// création de la balise lien
	var newLink = document.createElement('a');
	newLink.setAttribute('href', 'contact.html');
	newLink.setAttribute('id', 'contact');


	//assigner un texte à l'intérieur du lien
	var img = document.createElement('img');
	img.setAttribute('src', img_contact);
	newLink.appendChild(img);
	
	contact.parentNode.replaceChild(newLink, contact);
}

window.onload = function(){
	voir_exemple();
	contact();
}
