function addPhoto(x,name,legend)
{ 
// <!-- <div><a href="" onclick='open("slideshow.php?jpg=n")'> <img src="x.jpg"/> <a/>#Namnet</div>  -->  
// create needed elements
    var picDiv = document.createElement('div'); 
    var a= document.createElement('a');
    var p= document.createElement('p');
    var photo = document.createElement('img');
    var br = document.createElement('br');
    var txt = document.createTextNode(name);
    var story = document.createTextNode(legend);
//build picture and element specific strings
    var source = smallPath + name;
    var id = 'jpg=' + x;

//setting values to the nodes
    a.id = id;
    a.href="";
    a.onclick = function(){var w = open("slideshow.php?" + this.id,"slideshow","menubar=no, toolbar=no, resizable=yes, scrollbars=yes");w.focus();return false;};
    photo.src = source;
    picDiv.className = "picture";
    p.className = "pictxt";
    
//build DOM structure
    a.appendChild(photo);
    p.appendChild(a);
    p.appendChild(txt);
    p.appendChild(br);
    p.appendChild(story);
    picDiv.appendChild(p);
    document.getElementById("gallery").appendChild(picDiv);
 
}
