// ======================================================================================
// PBTSGalPlus, a PBTSGallery extentsion 
// Courts Carter, pizzabytheslice.com, v1.0.0 (1999-2005)
// Use, distribute, modify (improve. please?) according to Creative Commons agreement:
// http://creativecommons.org/licenses/by-nc/2.0/
// ======================================================================================
// 
//      DO NOT DIRECTLY ACCESS ANY VARIABLE
//      USE "GETTER" OR "SETTER" FUNCTIONS
// ---------------------------------------------------
// Favorites vars
var g_aryFavs      = new Array(0),
    g_thisFav      =    -1,// points to current fav
    g_FavSshowIntId=  null,// timer interval id/handle
    g_isFavSshow   = false;// state: is the slideshow currently running?

// ====================================================================================================
//     P U B L I C
// ====================================================================================================
function addFav(){// already in the list, add anyway?
	if (arguments.length > 0)
		g_aryFavs[g_aryFavs.length]=arguments[0];
	else
		g_aryFavs[g_aryFavs.length]=g_thisImg;
	g_thisFav=g_aryFavs.length-1;
	} // addFav

function clearFav(){
	g_aryFavs=null;
	g_aryFavs= new Array(0);
	stopFavSlideshow();
	}

function nextFav(){
	if (g_aryFavs.length > 0) {
		if (g_thisFav < (g_aryFavs.length-1))
			g_thisFav++;
		else
		  g_thisFav=0;
		switchPic( g_aryFavs[g_thisFav] );
		} else {
  		alert( "You must first add a favorite to your list.");
		}
} // nextFav

function prevFav(){
	if (g_aryFavs.length > 0) {
		if (g_thisFav > 1)
			g_thisFav--;
		else
		  g_thisFav=g_aryFavs.length-1;
		switchPic( g_aryFavs[g_thisFav] );
		} else {
  		alert( "You must first add a favorite to your list.");
		}
} // nextFav

function startFavSlideshow() { // check length > 1
  stopFavSlideshow();
	if (g_aryFavs.length < 2) {
 		alert( "You need at least two images in your favorites list for a slideshow.");
	} else {
	  g_FavSshowIntId= window.setInterval( "nextFav()", g_SshowDelay );
  	g_isFavSshow= true;
	}
  } // startFavSlideshow

function stopFavSlideshow() {
  if (g_isFavSshow) {
    g_isFavSshow= false;
    clearInterval(g_FavSshowIntId);
    }
  } // stopFavSlideshow

// ==================================================================
// FUNCTION: getters (returns values of stuff)
// USE:      PUBLIC
// ==================================================================
function getFavList() { return g_aryFavs.toString();}
function getFavCount(){	return g_aryFavs.length;}


