/**
 * Flex interfaces
 */
function menuCallASHTML(op,user,id,firstName,name,prefix) {
  switch(op) {
  case "loginSession":
    document.getElementById('bar_content').innerHTML = prefix+"<strong><a href=\"/auteur-"+id+"-"+firstName+"-"+name+"\">"+user+"</a></strong> | <strong><a href=\"javascript:submitLogout(true)\">Se d&eacute;connecter</a></strong>";
  break;
  case "gotoPage":
    document.location.href = "/auteur-"+id+"-"+firstName+"-"+name;
  break;
  }
}

function submitLogout(isphp) {
  // php or flex login
  document.getElementById("logoutForm").php.value = isphp;
  // call logout.php via AJAX
  document.getElementById("submitButton").click();
  // update Flex
  //movie.menuCallHTMLAS("logoutSession");
}

function getFlashMovieObject(movieName)
{
  if (document.embeds[movieName]) return document.embeds[movieName];
  if (window.document[movieName]) return window.document[movieName];
  if (window[movieName]) return window[movieName];
  if (document[movieName]) return document[movieName];
  return null;
}

function goToComment(val) {
  getFlashMovieObject("Alex").goToComment(val);
}

function toggleDebug(show) {
	getFlashMovieObject("Alex").toggleDebug(show);
}

var firstComment;
function addComment(a) {
	firstComment = a.first;
	$('#hiddendiv').load("/rate.php",a,callbackf);
}

function deleteComment(a) {
	$('#'+a.uid).remove();
	if ($('.comment').length == 0) {
		$('#comments').remove();
	}
}

function callbackf(responseText, textStatus, XMLHttpRequest) {
	if (textStatus=="success") {
		if (firstComment) $('#comments_content').html(responseText);
		else $('.comment:first').before(responseText);
		$('#hiddendiv').html("").hide();
	}
}

function showNotesFromAuthor(authorId) {
	getFlashMovieObject("Alex").showNote(authorId);
}

function createPresentationFromLiveRecord(filename) {
	$('#liveName').val(filename);
	$('#part_3').toggle();
	$('#addVideoForm').submit();
}

function cancelLiveRecord() {
	$('#camRecorderContain').remove();
	$('#part_3').toggle();
	$('#part_2').toggle();
}

