var clickedLk;

window.onload = function onsenfou ()
	{
	clickedLk = document.getElementById("firstImg");
	clickedLk.style.borderColor = "#FFFFFF";
	}

function updateImg(oLk, url, newWidth, newHeight)
	{
	if (clickedLk != null)
		clickedLk.style.borderColor = "#000000";

	clickedLk = oLk;

	var oContent = document.getElementById("globalContent");
	oContent.innerHTML = "";

	var marginImg = ((oContent.offsetHeight/10) - newHeight)/2;
	
	var oLoader = NodeCreator(oContent,'img');
	oLoader.src = "imgs/ajax-loader.gif";
	oLoader.className = "imgLoader";

	var oImg = NodeCreator(oContent,'img');
	oImg.src = url;
	oImg.style.display = "none";
	oImg.style.marginTop = marginImg + "em";
	oImg.style.width = newWidth + "em";
	oImg.style.height = newHeight + "em";

	oImg.onload = function onsenfou ()
		{
		oContent.removeChild(oLoader);
		oImg.style.display = "block";
		};
	}

//creation de noeuds (XML et Html)
//d = objet de destination (id de la div...)
//t = type
//a = attributs exemple: ((attName1,attVal1),(attName2,attVal2),(...),...)
//v = value
function NodeCreator(d,t,a,v){
	
	//création de la nouvelle balise
	var ce = document.createElement(t);
	
	//init des valeurs
	var cv;
	
	//si valeurs
	if (v != null && v != "" && v != "undefined")
		{
		//création de la valeure (txt)
		var cv = document.createTextNode(v);
		//assignation de la valeure
		ce.appendChild(cv);
		}
	
	if (a != null && typeof(a) == "object" && a[0] != null)
		{
		//assignation des attributs
		for (var i=0; i<a.length; i++)
			{
			if (a[i][0] != null || a[i][0] != "")
				{
				var tmpAttName = a[i][0];
				var tmpAttVal = a[i][1];

				var ca = document.createAttribute(tmpAttName);
				ca.nodeValue = tmpAttVal;
				ce.setAttributeNode(ca);
				}
			}
		}
	
	if (d != null)
		{
		if (typeof(d) != "object")
			{
			d = document.getElementById(d);
			}

		//assignation du champ
		d.appendChild(ce);
		}
	
	return ce;
	}
