
var oldId = 0;

function updateTab(tab,defaultId,indent) {
	// Find id of old and new tabs
	var newId;
	if (tab != undefined)  {
		if (tab.id) newId = tab.id;
		else if (tab.indexOf('#') > 0) newId = 'tab_' + tab.substring(tab.indexOf('#')+1);
		else if (defaultId != undefined) newId = defaultId;
		else newId = tab;
	}
	if (indent == undefined) indent = 32;

	if (oldId == newId) return;

	// Change tab class
	if (oldId) document.getElementById(oldId).className = "";
	document.getElementById(newId).className = "selected";	

	// Fade out old app and fade in new one	
	if (oldId) {
		Effect.Fade(oldId+'_div', { duration: 0.5, afterFinish: function (obj) { 
			new Effect.Appear(newId+'_div', { duration: 0.5 });
		}});
	}
	else {
		new Effect.Appear(newId+'_div', { duration: 0.5 });
	}

	// Slide old tab in and new tab out	
	if (oldId) {
		new Effect.Morph(oldId, {
			style: 'margin-left:'+indent+'px;', // CSS Properties
			duration: 0.25,
			queue: 'test'
		});
	}
	new Effect.Morph(newId, {
		style: 'margin-left:0px;', // CSS Properties
		duration: 0.25,
		queue: 'test'
	});
	oldId = newId;
}

function updateVideo(tab,url) {
	// Find id of old and new tabs
	var newId;
	if (tab != undefined)  {
		if (tab.id) newId = tab.id;
		else if (tab.indexOf('#') > 0) newId = 'tab_' + tab.substring(tab.indexOf('#')+1);
		else newId = tab;
	}

	if (oldId == newId) return;

	// Change tab class
	if (oldId) document.getElementById(oldId).className = "";
	document.getElementById(newId).className = "selected";	

	var html = '<object width="640" height="505"><param name="bgcolor" value="#000000"></param><param name="wmode" value="transparent"></param><param name="movie" value="'+url+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+url+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505" wmode="transparent" bgcolor="#000000"></embed></object>';

	$('content').innerHTML = html;

	// Slide old tab in and new tab out	
	if (oldId) {
		new Effect.Morph(oldId, {
			style: 'margin-left:32px;', // CSS Properties
			duration: 0.25,
			queue: 'test'
		});
	}
	new Effect.Morph(newId, {
		style: 'margin-left:0px;', // CSS Properties
		duration: 0.25,
		queue: 'test'
	});
	oldId = newId;
}
