//
//  JS for Flash FTP object
//
//  Clio Soleil (clio@PrettyGetter.TV)
//  PrettyGetter Productions (http://PrettyGetter.TV) 
//  

///////////////////////////////////////////////
// these functions are called from the flash object
///////////////////////////////////////////////

//--------------------------------------------------------------------------------------------------------------------------------------------
function FTP_flashReady(objName)
// called by MP3Player swf when fully loaded and initialized
// this is the first point we can interact with the flash movie
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  //alert("JS:"+objName);
}

//--------------------------------------------------------------------------------------------------------------------------------------------
function FTP_begin(objName, js)
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  document.getElementById("FTP_status_"+objName).style.display = "";
  document.getElementById("FTP_status_"+objName).style.width = "0px";
  
  // call custom begin function if defined
  if ((js != "FTP") && window["FTP_status_"+js+"_begin"])
    window["FTP_status_"+js+"_begin"]();
}

//--------------------------------------------------------------------------------------------------------------------------------------------
function FTP_progress(percent, objName, js)
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  document.getElementById("FTP_status_"+objName).innerHTML = percent+"%";
  document.getElementById("FTP_status_"+objName).style.width = percent+"%";
  
  // call custom progress function if defined
  if ((js != "FTP") && window["FTP_status_"+js+"_progress"])
    window["FTP_status_"+js+"_progress"](percent);
}

//--------------------------------------------------------------------------------------------------------------------------------------------
function FTP_completed(filename, objName, js)
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  //document.getElementById("FTP_status_"+objName).innerHTML = "<a target='_blank' href='/tmp/"+filename+"'>"+filename+"</a>";
  document.getElementById("FTP_status_"+objName).innerHTML = filename;
  document.getElementById("FTP_status_"+objName).style.width = "100%";
  
  // call custom completed function if defined
  if ((js != "FTP") && window["FTP_status_"+js+"_completed"])
    window["FTP_status_"+js+"_completed"](filename);
}

//--------------------------------------------------------------------------------------------------------------------------------------------
function FTP_cancel(objName, js)
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  //alert("Cancelled by user!");
  
  // call custom cancel function if defined
  if ((js != "FTP") && window["FTP_status_"+js+"_cancel"])
    window["FTP_status_"+js+"_cancel"]();
}

//--------------------------------------------------------------------------------------------------------------------------------------------
function FTP_error(msg, objName, js)
//--------------------------------------------------------------------------------------------------------------------------------------------
{
  //alert("Error uploading file!");
  document.getElementById("FTP_status_"+objName).style.width = "100%";
  
  // call custom error function if defined
  if ((js != "FTP") && window["FTP_status_"+js+"_error"])
    window["FTP_status_"+js+"_error"](msg);
}

