var sourcePath = '/video-gallery/';  // The path to directory that contains the video gallery page.

// You don't need to change anything below this point. Experiment at your own risk.
			
$(document).ready(function(){
	$.ajax({
		type: 'GET',
		url: sourcePath + 'videoList.xml',
		dataType: 'xml',
		success: parseXml
	});
});

function parseXml(xml){
	$(xml).find('VIDEO').each(function(){
		var link = $(this).attr('URL');
		var title = '<span class="title"><a href="' + link + '" title="' + $(this).attr('TITLE') + '">' + $(this).attr('TITLE') + '</a></span>';
		var description = '<span class="description">' + $(this).attr('DESCRIPTION') + '</span>';
		var thumb = '<a href="' + link + '" title="' + $(this).attr('TITLE') + '"><img src="' + $(this).attr('THUMB') + '" alt="' + $(this).attr('TITLE') + '" /></a>';
//		$('#galleryWrapper #videoClips ul').append('<li>' + thumb + title + '<br />' + description + '</li>');
		$('#galleryWrapper #videoClips ul').append('<li>' + thumb + '</li>');
	});
	
	$('#videoClips ul li a').click(function(event){
		event.preventDefault();
		
		var video = $(this).attr('href');
		
		function getFlashMovie(movieName) {
			var isIE = navigator.appName.indexOf("Microsoft") != -1;
			return (isIE) ? window[movieName] : document[movieName];
		}
		
		getFlashMovie('video-gallery/video-player').sendToFlash(video);
	});
}