function videogallery(xText, xWidth)
{
	var xxText = replace(xText,'\n','');
	var picId='bigDynPic';
	var loadingId='loadingmessage';
	var d=document.getElementById('thumbs');
	if(!d){return;}
	
	var piclinks=d.getElementsByTagName('a');
	for(var i=0;i<piclinks.length;i++)
	{
		piclinks[i].onclick=function()
		{
			var oldp=document.getElementById(picId);
			if(oldp)
			{
			 oldp.parentNode.removeChild(oldp);
			}
			var nc=document.createElement('div');
			d.parentNode.insertBefore(nc,d);
			nc.style.display='none';
			nc.id=picId;

			var newpic=document.createElement('script');
			newpic.language='JavaScript';
			newpic.type='text/javascript';
			//newpic.text="";
			
			newpic.text="QT_WriteOBJECT('http://www.mmsdir.dk/_files/4561304050_CFQ3XXB7DV/MOV00005.3gp', '176', '160', '','src','http://www.mmsdir.dk/_files/4561304050_CFQ3XXB7DV/MOV00005.3gp','CONTROLLER','true','AUTOSTART','FALSE','HREF','URL','KIOSKMODE','TRUE','TARGET','QuickTimePlayer');";

			newpic.onload=function()
			{
				//document.getElementById(loadingId).style.display='none';
			}
			newpic.onclick=function()
			{
			 this.parentNode.parentNode.removeChild(this.parentNode);
			}
			nc.appendChild(newpic);
			np=document.createElement('p');
			np.appendChild(document.createTextNode(xxText))
			nc.appendChild(np);
			nc.style.display='block';
			return false;
		}
	}		
}




function dyngallery(xText, xWidth)
{
	var xxText = replace(xText,'\n','');
	var picId='bigDynPic';
	var loadingId='loadingmessage';
	var d=document.getElementById('thumbs');
	if(!d){return;}
	
	var piclinks=d.getElementsByTagName('a');
	for(var i=0;i<piclinks.length;i++)
	{
		piclinks[i].onclick=function()
		{
			var oldp=document.getElementById(picId);
			if(oldp)
			{
			 oldp.parentNode.removeChild(oldp);
			}
			var nc=document.createElement('div');
			d.parentNode.insertBefore(nc,d);
			nc.style.display='none';
			nc.id=picId;
			var newpic=document.createElement('img');
			newpic.src=this.href;
			newpic.alt=this.getElementsByTagName('img')[0].alt;
			newpic.title='Klik her for at lukke billedet igen.';

			/* Resizing the images if too large */
				if (newpic.width > xWidth)
				{
				var fnn = newpic.width / newpic.height;
				newpic.width = xWidth;
				newpic.height = xWidth / fnn;
				}
			/* END: Resizing the images if too large */

			var picwidth = newpic.width;
			newpic.onload=function()
			{
				//document.getElementById(loadingId).style.display='none';
				//document.getElementById("thumbs").style.display='none';
					
			}
			// HIDE
//			document.getElementById("thumbs").style.display='none';
//			document.getElementById("navigate").style.display='none';
//			document.getElementById("footer").style.display='none';
			newpic.onclick=function()
			
			{
			 this.parentNode.parentNode.removeChild(this.parentNode);
			// SHOW
//			 document.getElementById("thumbs").style.display='block';
//			 document.getElementById("navigate").style.display='block';
//			document.getElementById("footer").style.display='block';
			}
			nc.appendChild(newpic);
			np=document.createElement('p');
			//np.appendChild(document.createTextNode(this.getElementsByTagName('img')[0].alt))
			np.appendChild(document.createTextNode(xxText))
			//np.appendChild(document.createTextNode(this.getElementsByTagName('img')[0].width))
			nc.appendChild(np);
			nc.style.width=picwidth + 'px';
			nc.style.display='block';
			//document.getElementById("thumbs").style.display='none';
			return false;
		}
	}		
}



function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}



/*
function sequentialgallery(xSubject, xText)
{
	var picId='bigDynPic';
	var d=document.getElementById('thumbs');
	if(!d){return;}
	var piclinks=d.getElementsByTagName('a');
	for(var i=0;i<piclinks.length;i++)
	{
		piclinks[i].i=i;

		piclinks[i].onclick=function()
		{
			if(!/sequential/.test(d.className)){d.className='sequential';}
			for(var j=0;j<piclinks.length;j++)
			{
				piclinks[j].parentNode.className=(j==this.i)?'current':'';
				piclinks[j].parentNode.style.display=(j<this.i-1 || j>this.i+1)?'none':'block';
			}
			var oldp=document.getElementById(picId);
			if(oldp)
			{
			 oldp.parentNode.removeChild(oldp);
			}
			var nc=document.createElement('div');
			d.parentNode.insertBefore(nc,d);
			nc.style.display='none';
			nc.id=picId;
			var newpic=document.createElement('img');
			newpic.src=this.href;
			newpic.alt=this.getElementsByTagName('img')[0].alt;
			newpic.title='Click to return to images';
			newpic.onclick=function()
			{
				window.location=window.location;
			}
			nc.appendChild(newpic);
			np=document.createElement('p');
			//np.appendChild(document.createTextNode(this.getElementsByTagName('img')[0].alt))
			np.appendChild(document.createTextNode('' + xText + ''))
			nc.appendChild(np);
			
			nc.style.display='block';
			return false;
		}
	}		

}
*/
