function get_firstchild(n)
{
	x=n.firstChild;
	while (x.nodeType!=1)
	{
		x=x.nextSibling;
	}
	return x;
}


domready=function()
{
	var browser;
	if (window.ActiveXObject)  
	{
		browser="ie";
	}
	else
	{
		browser="ff";
	}

	if (document.getElementById('sample') != null) {
	
	var gal = document.getElementById('gallery');

	
	var nb;
	var t = new Array ();
	var i;
	
		if (browser=="ie") {
			nb = gal.childNodes.length;
			for (i=0; i <nb; i++) {
				var img = gal.childNodes[i].childNodes[0].childNodes[0].childNodes[0].childNodes[0];
				t[i]=img.src;
			}
			for (i=0; i <nb; i++){
				gal.removeChild(gal.childNodes[0]);	
			}	
		}
		
		else if (browser=="ff") {
			var comp = 0;
			for (var j=0; j<gal.childNodes.length; j++) {
				if (gal.childNodes[j].nodeType != 3) {
					var var1 = gal.childNodes[j];
					var var2 = get_firstchild(var1);
					var var3 = get_firstchild(var2);
					var var4 = get_firstchild(var3);
					var img = get_firstchild(var4);
					t[comp]=img.src;
					comp = comp + 1;
				}
			}
			
			nb = comp;

			for (var j=nb; j>=0; j--) {
				if (gal.childNodes[j].nodeType != 3) {
					gal.removeChild(gal.childNodes[j]);
				}								
			} 
		}	
		
		
		
		var sample = document.getElementById('sample');		
		
		var mask6 = document.createElement('div');
		mask6.setAttribute("id","mask6");
		sample.appendChild(mask6);
		
		var box7 = document.createElement('div');
		box7.setAttribute("id","box7");
		mask6.appendChild(box7);
		
		for (i=0; i <nb; i++){
			var span1 = document.createElement('span');
			box7.appendChild(span1);
			var img = document.createElement('img');
			span1.appendChild(img);
			img.src=t[i];
			img.alt="Photo";
		}		
		
		var thumbs7 = document.createElement('div');
		thumbs7.setAttribute("id","thumbs7");
		sample.appendChild(thumbs7);

		var thumbs = document.createElement('div');
		thumbs.setAttribute("id","thumbs");
		thumbs7.appendChild(thumbs);

		for (i=0; i <nb; i++){
			var div1 = document.createElement('div');
			thumbs.appendChild(div1);
			var img = document.createElement('img');
			div1.appendChild(img);
			img.src=t[i];
			img.alt="Photo Thumb";
		}			

		var thumbs_mask7 = document.createElement('div');
		thumbs_mask7.setAttribute("id","thumbs_mask7");
		thumbs7.appendChild(thumbs_mask7);

		var thumbs_handles7 = document.createElement('p');
		thumbs_handles7.setAttribute("id","thumbs_handles7");
		thumbs7.appendChild(thumbs_handles7);

		for (i=0; i <nb; i++){
			var span2 = document.createElement('span');
			thumbs_handles7.appendChild(span2);
		}		

	  	var startItem = 0; 
		var thumbs_mask7 = $('thumbs_mask7').setStyle('left',(startItem*60-568)+'px').set('opacity',0);
		var fxOptions7 = {property:'left',duration:0, transition:Fx.Transitions.Back.easeOut, wait:false}
		var thumbsFx = new Fx.Tween(thumbs_mask7,fxOptions7);
		var nS7 = new noobSlide({
			box: $('box7'),
			items: [0,1,2,3,4,5,6,7],
			handles: $$('#thumbs_handles7 span'),
			fxOptions: fxOptions7,
			onWalk: function(currentItem){
				thumbsFx.start(currentItem*60-568);
			},
			startItem: startItem
		});

		nS7.walk(0);
	
	}	
	
}

addLoadAction(domready);
