function init() {
	$('#tabs li a').click(function() {
	 	$(this).each(function() {
	 		$('#tabs li a').removeClass('on');
	 		$('#video-tabs div').each(function() {
	 			$(this).hide();
	 		});
	 	});
	 	var tab = '#' + $(this).attr("id") + '-tab'; 
	 	// alert(tab); 
	 	$(this).addClass('on');
	 	$(tab).fadeIn('slow');
	});
	$.ajax({
		type: "GET",
		url: "xml/topvideos.xml",
		dataType: "xml",
		success: function(xmlData) {
			xmlTopVideo = xmlData;
			buildTopVideo();
		}
	});
	$.ajax({
		type: "GET",
		url: "xml/sessions-home.xml",
		dataType: "xml",
		success: function(xmlData) {
			xmlSessions = xmlData;
			buildSessions();
		}
	});
	$.ajax({
		type: "GET",
		url: "xml/lighterside.xml",
		dataType: "xml",
		success: function(xmlData) {
			xmlLighterSide = xmlData;
			buildLighterSide();
		}
	});
}
function loadClip(num,segment) {
	$('#clip').hide();
	var movie = $('#movie-' + segment + num).text()
	setTimeout(function () {
		$('#clip').show();
	}, 500);
	$('#clip').media({
		width: 320, 
		height: 260, 
		src: 'fla/flvplayer.swf?file=../flv/' + movie + '.flv',
		autoplay: true
	}); 		
}
function loadMenu(num) {
	num = Number(num);
	var numb = num + 1;
	$('#clipDesc').hide();
	$.ajax({
		type: "GET",
		url: "../xml/artist0" + numb + ".xml",
		dataType: "xml",
		success: function(xmlDat) {
			xmlArtistSet = xmlDat;
			browseContent();
			var title = "";
			var movie = "";
			var description = "";
    		$(xmlArtistSet).find('item').each(function(i){
				title = $('title:eq(0)', xmlArtistSet).text();
				movie = $('movie:eq(0)',xmlArtistSet).text()
				newArtist = $('#artist' + num).text();
				newDescription = $('#description' + num).text();
				$('#clip').quicktime({
    				src: '../mov/' + movie + '.mov',
					attrs: {autoplay: false},
					caption:  false 
				}); 		
			});
				$('#clipDesc').fadeIn('slow');
				$('#video-column h4').empty().append(newArtist);
				$('#video-column p').empty().append(newDescription);
				$('#artisthead').empty().append(newArtist);
				$("#subClips").fadeIn('slow');
		}
	});
}
function buildMenu() {
	var selectText = 'STORYline Quick Selection...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	$(xmlArtistSets).find("item").each(function(i) {
		clipmenu += "<option value=\"" + i + "\">" + $("movie:eq(" + i + ")",xmlArtistSets).text() + "</option>";
	});
	// $("#sessionmenu").html(clipmenu);	
}
function buildTopVideo() {
	var color = "blue";
	var alt = "";
	var clipList = "";
	clipList += "<ol>";
	$(xmlTopVideo).find("item").each(function(i) {
		i % 2 == 0 ? alt = " class=\"alt\"" : alt = "";
		i % 2 == 0 ? thumb = "-alt" : thumb = "";
		clipList += "<li" + alt + "><a href=\"#\" onclick=\"loadClip('" + i + "','tv');return false;\"><img src=\"thumbs/videothumb_tv_" + (i+1) + ".gif\" width=\"75\" height=\"60\" alt=\"[movie]\"/></a>";
		// clipList += "<li" + alt + "><a href=\"#\" onclick=\"loadClip('" + i + "');return false;\"><img src=\"imgs/vidthumb_" + color + thumb + ".gif\" width=\"75\" height=\"60\" alt=\"[movie]\"/></a>";
		clipList += "<span id=\"title" + i + "\"><a href=\"#\" onclick=\"loadClip('" + i + "', 'tv');return false;\">" + $("title:eq(" + i + ")",xmlTopVideo).text()  + "</a></span><br />";
		clipList += "<span id=\"movie-tv" + i + "\"class=\"fragment\">" + $("movie:eq(" + i + ")",xmlTopVideo).text() + "</span>";
		clipList += "<span id=\"length" + i + "\">| " + $("length:eq(" + i + ")",xmlTopVideo).text() + " |</span>";
		clipList += "<span id=\"copy" + i + "\" class=\"fragment\">" + $("copy:eq(" + i + ")",xmlTopVideo).text() + "</span>";
		clipList += "</li>";
	});
	clipList += "</ol>";
	$("#topvideos-tab").html(clipList);
}
function buildSessions() {
	var color = "blue";
	var alt = "";
	var clipList = "";
	clipList += "<ol>";
	$(xmlSessions).find("item").each(function(i) {
		i % 2 == 0 ? alt = " class=\"alt\"" : alt = "";
		i % 2 == 0 ? thumb = "-alt" : thumb = "";
		clipList += "<li" + alt + "><a href=\"#\" onclick=\"loadClip('" + i + "','se');return false;\"><img src=\"thumbs/videothumb_se_" + (i+1) + ".gif\" width=\"75\" height=\"60\" alt=\"[movie]\"/></a>";
		clipList += "<span id=\"title" + i + "\"><a href=\"#\" onclick=\"loadClip('" + i + "','se');return false;\">" + $("title:eq(" + i + ")",xmlSessions).text()  + "</a></span><br />";
		clipList += "<span id=\"movie-se" + i + "\"class=\"fragment\">" + $("movie:eq(" + i + ")",xmlSessions).text() + "</span>";
		clipList += "<span id=\"length" + i + "\">| " + $("length:eq(" + i + ")",xmlSessions).text() + " |</span>";
		clipList += "<span id=\"copy" + i + "\" class=\"fragment\">" + $("copy:eq(" + i + ")",xmlSessions).text() + "</span>";
		clipList += "</li>";
	});
	clipList += "</ol>";
	$("#sessions-tab").html(clipList);
}
function buildLighterSide() {
	var color = "blue";
	var alt = "";
	var clipList = "";
	clipList += "<ol>";
	$(xmlLighterSide).find("item").each(function(i) {
		i % 2 == 0 ? alt = " class=\"alt\"" : alt = "";
		i % 2 == 0 ? thumb = "-alt" : thumb = "";
		clipList += "<li" + alt + "><a href=\"#\" onclick=\"loadClip('" + i + "','ls');return false;\"><img src=\"thumbs/videothumb_lsh_" + (i+1) + ".gif\" width=\"75\" height=\"60\" alt=\"[movie]\"/></a>";
		clipList += "<span id=\"title" + i + "\"><a href=\"#\" onclick=\"loadClip('" + i + "','ls');return false;\">" + $("title:eq(" + i + ")",xmlLighterSide).text()  + "</a></span><br />";
		clipList += "<span id=\"movie-ls" + i + "\"class=\"fragment\">" + $("movie:eq(" + i + ")",xmlLighterSide).text() + "</span>";
		clipList += "<span id=\"length" + i + "\">| " + $("length:eq(" + i + ")",xmlLighterSide).text() + " |</span>";
		clipList += "<span id=\"copy" + i + "\" class=\"fragment\">" + $("copy:eq(" + i + ")",xmlLighterSide).text() + "</span>";
		clipList += "</li>";
	});
	clipList += "</ol>";
	$("#lighterside-tab").html(clipList);
}

