// JavaScript Document

function Init(slide)
{
 document.PictPropertiesForm.caption.value = unescape(slide.caption); 
 if (slide.pictdate == 0)
   document.PictPropertiesForm.picturedate.value = ''
 else
   document.PictPropertiesForm.picturedate.value = slide.pictdate; 
 document.PictPropertiesForm.keywords.value = unescape(slide.tags); 
 document.PictPropertiesForm.pictid.value = slide.pictid; 
 document.PictPropertiesForm.ndx.value = slide.ndx; 
 var elem;
 if (slide.isprivate)
 {
   elem = document.getElementById("PrivateFld");
   elem.checked = true;
   elem = document.getElementById("PublicFld");
   elem.checked = false;
 }
 else
 {
   elem = document.getElementById("PrivateFld");
   elem.checked = false;
   elem = document.getElementById("PublicFld");
   elem.checked = true;
 }

 if ((slide.parent.isGuest) && ((slide.allowGuestEdit == 'ynYes') || (slide.allowGuestEdit == 'ynYesPwd')))
 {
    var DivElem = document.getElementById('PictPropsSecurity');
    DivElem.style.display = 'none';   
 }
 showPPButtons();
   
}

function showpictproptiesDialog(slide) {
  if ((!slide.parent.isGuest) || (slide.allowGuestEdit))
  {
    Init(slide);
    YAHOO.ft.pictpropertiesDlg.hideEvent.subscribe(pictpropertiesShowVideo, this)
    try {slideshow.hideMusicPlayer();	} catch(e) {};			
    dialogShowing = true;	
    YAHOO.ft.pictpropertiesDlg.configFixedCenter("fixedcenter", false);		
    YAHOO.ft.pictpropertiesDlg.show();		
  }
}

var pictpropertiesShowVideo = function()
{
  var Vp = document.getElementById("videoplayer");
  if (Vp) Vp.style.visibility = "visible";
}


function showPPButtons() {
  document.getElementById("ppWait").style.display = "none";
  document.getElementById("ppButtons").style.display = "block";
}


function showPPWait() {
  document.getElementById("ppButtons").style.display = "none";
  document.getElementById("ppWait").style.display = "block";
}

function SelectFld(elem) 
{
  elem.select();
}

function pictpropertiesCancelClick() {
  YAHOO.ft.pictpropertiesDlg.hide();
  var Vp = document.getElementById("videoplayer");
  if (Vp) Vp.style.visibility = "visible";
  try {slideshow.showMusicPlayer();	} catch(e) {};	
  dialogShowing = false;
}

function SaveProperties() {
  showPPWait();
  var sUrl = '/ftweb/bin/ft.dll/detailfs?editmode=t&slideshow=0&justdata=1';
  YAHOO.util.Connect.setForm("PictPropertiesForm", false, false);
  callbackSaveProperties.argument = slideshow.slides[slideshow.curIndex];
  YAHOO.util.Connect.asyncRequest("POST", sUrl, callbackSaveProperties); 
}

var handleSavePropertiesFailure = function(o){
  alert("Saving Picture Properties failed");
}


var handleSavePropertiesSuccess = function(o){
  if(o.responseText != undefined){
    if (!verifySessionOk(o.responseText,false)) return;
    var aslide = o.argument;
    var SecElem = document.getElementById('PublicFld');
    if (SecElem.checked) aslide.isprivate = false; else aslide.isprivate = true;
    aslide.caption = document.PictPropertiesForm.caption.value;
    aslide.pictdate = document.PictPropertiesForm.picturedate.value;
    aslide.tags = document.PictPropertiesForm.keywords.value; 
    aslide.calculatedCaptions = false;
    YAHOO.ft.pictpropertiesDlg.hide();
    document.getElementById("msgcaption").innerHTML = aslide.captionHtml();
    document.getElementById("msgpictdate").innerHTML = aslide.pictdatefilenameStr();
    dialogShowing = false;		
    try {slideshow.showMusicPlayer();	} catch(e) {};			
  } 
}

var callbackSaveProperties =
{
  success:handleSavePropertiesSuccess,
  failure:handleSavePropertiesFailure
};

function showTagsMsgDialog()
{
  var Msg = "Tags or keywords can be used to categorize your photos and videos.  If you have opted-in to the";
  Msg += " <a href='javascript:showgalleryoptinDialog();' class=bluelinkdlg>public gallery</a>,"
  Msg += " your photos can be searched using your tags.  To enter multiple tags, separate each tag with a comma.";
  showMessageDialog("What are Tags?", Msg);
}

function showSecurityInfo()
{
  var Msg = "Each photo and video has its own security setting, public or private.<br><br>";
  Msg += "<b>Public Photos and Videos</b><br><br>";
  Msg += "Public photos and videos can be viewed by all guests (users who enter your email";
  Msg += " address in the guest login field on the FotoTime home page).";
  Msg += "  If you are opted-in to the <a href='showgalleryoptinDialog();' class=bluelinkdlg>public gallery</a>";
  Msg += " your public photos and videos can be browsed/searched by the general public.<br><br>";
  Msg += "<b>Private Photos and Videos</b><br><br>";
  Msg += "A private picture can only be viewed by you (a user who enters both an email";
  Msg += " address and password in the login/password field on the FotoTime home page).";
  Msg += "  You can also send an invitation to a specific user which gives access to a specific";
  Msg += " album, as well as access to Private pictures.  Finally, you can turn off all guest";
  Msg += " logins by going to Admin Options -> Edit Preferences and uncheck the ";
  Msg += "'Allow guests to login from home page' checkbox.";  
  showMessageDialog("Security Information", Msg, 'righttextdlg');
}

function showpictTags()
{
  showpicttagsDialog(document.PictPropertiesForm.pictid.value);
}
