
	function recreateNode(id) {
		node = document.getElementById(id);
		
		p = node.parentNode;
	//	p.removeChild(node);
		
//	recreate the node
		new_node = document.createElement('div');
//		p.appendChild(node);
		p.replaceChild(new_node, node);
		new_node.setAttribute('id', id);
//		alert('done');
	}
	
	
	function displayVideo(src, thumbnail, title, video_target, w, h) {
		if ( ! video_target ) {
			recreateNode(target);
			video_target = target;
		}

		if ( (src.toLowerCase().indexOf('.mpg') > 0) || (src.toLowerCase().indexOf('.mov') > 0)) {
			displayVideoQT(src, thumbnail, title, video_target, w, h);
		} else if ( (src.toLowerCase().indexOf('.mp4') > 0) || (src.toLowerCase().indexOf('.flv') > 0) || (src.toLowerCase().indexOf('.m4v') > 0)) {
			displayVideoJW(src, thumbnail, title, video_target, w, h);
		} else {
			alert("No plug-in found for " + src);
		}
	}
	

	function displayVideoQT(src, thumbnail, title, video_target, w, h) {
			var myQTObject = new QTObject(thumbnail, "video", "512", "302");
			myQTObject.addParam("href", src);
			myQTObject.addParam("target", "myself");
			myQTObject.addParam("controller", "true");
			myQTObject.addParam("kioskmode", "true");			
			myQTObject.addParam("scale", "tofit");			
			myQTObject.write(video_target);
	}
	
	
	function displayVideoJW(src, thumbnail, title, video_target, w, h) {
		var s1 = new SWFObject(player, video_target + '_video',max_width,max_height,'8','#000000');
		s1.addParam('allowfullscreen', 'true');

		s1.addVariable('file', src);
//	display height equal or greater than the height of the swf ( above ) 
//	causes the control bar to float on the video play area
		s1.addVariable("displayheight", display_height);
		s1.addVariable("controlbar", "bottom");
		s1.addVariable("backcolor", "0x000000");
		s1.addVariable("frontcolor", "0x666666");
		s1.addVariable("lightcolor", "0xffffff");
		if ( thumbnail )
			s1.addVariable('image', thumbnail);
		s1.write(video_target);
			
	}
	
	
	function next(p_id) {
		gallery_nav(p_id, 1);
	}
	
	
	function previous(p_id) {
		gallery_nav(p_id, -1);
	}
	
	
	function gallery_nav(p_id, incr) {
//	all nodes in the gallery
		nodes = $j('div.gallery_content');

//	increment the current object counter
		current_obj += incr;
		if ( current_obj >= nodes.length )
			current_obj = 0;
		else if ( current_obj < 0 )
			current_obj = nodes.length - 1;

//	turn all nodes display off
		$j('div.gallery_content').hide();
//	turn display on for the current object
		$j('div.gallery_content:eq(' + current_obj +')').show();
//	try to use the a title as the title for the nav
//		if ( $j('div.gallery_content:eq(' + current_obj +') > a').attr('title') )
//			title = $j('div.gallery_content:eq(' + current_obj +') > a').attr('title');
//	we're not doing titles anymore
		title = '';

//	update the nav info
		$j('div#nav_info').text(current_obj + 1 + "/" + nodes.length);
		$j('div#nav_content').text(title);

//	if its a video check whether the video has loaded
		if ( $j('div.gallery_content:eq(' + current_obj +')') ) {
			elem = $j('div.gallery_content:eq(' + current_obj +')');

//	first video should have loaded already
			if ( elem.hasClass('video') && ! elem.hasClass('loaded') && ! elem.hasClass('first') ) {
				id = elem.attr('id');
				if ( videos[id] ) {
					v = videos[id];
					displayVideo(v['src'], v['poster'], v['title'], v['id'], max_width, max_height); 
					elem.addClass('loaded');
				}
			}
		}
	}	
