// =========================
//
// PageBrowserButton Class
// Controls the Button that Opens/Closes Page Browser
//
// =========================

var pageBrowserButtonCurrentState = "pause";
var pageBrowserButtonIsMouseOver = false;
var pageBrowserButtonIsMouseDown = false;
function enterPageBrowserButton (s,e)
{
	var over = wpfe.findName(pageBrowserButtonCurrentState + "_over");
	var normal = wpfe.findName(pageBrowserButtonCurrentState + "_normal");
    var down = wpfe.findName(pageBrowserButtonCurrentState + "_down");
    
	if (pageBrowserButtonIsMouseDown == true)
	{
	  normal.opacity = 0;
 	  over.opacity = 0;
 	  down.opacity = 1;
	}
	else
	{
	  normal.opacity = 0;
 	  over.opacity = 1;
	}
	
	pageBrowserButtonIsMouseOver = true;
}

function leavePageBrowserButton (s,e)
{
	var over = wpfe.findName(pageBrowserButtonCurrentState + "_over");
	var normal = wpfe.findName(pageBrowserButtonCurrentState + "_normal");
	var down = wpfe.findName(pageBrowserButtonCurrentState + "_down");
	
	if (pageBrowserButtonIsMouseDown == true)
	{
	  normal.opacity = 0;
 	  over.opacity = 1;
 	  down.opacity = 0;
	}
	else
	{
      normal.opacity = 1;
 	  over.opacity = 0;
	}
	
	pageBrowserButtonIsMouseOver = false;
}

function downPageBrowserButton (s,e)
{
	var over = wpfe.findName(pageBrowserButtonCurrentState + "_over");
	var down = wpfe.findName(pageBrowserButtonCurrentState + "_down");
	
    down.opacity = 1;
    over.opacity = 0;
    
    pageBrowserButtonIsMouseDown = true;
    wpfe.findName("pageBrowserButton").captureMouse();
}

function upPageBrowserButton (s,e)
{
 	var over = wpfe.findName(pageBrowserButtonCurrentState + "_over");
	var normal = wpfe.findName(pageBrowserButtonCurrentState + "_normal");
	var down = wpfe.findName(pageBrowserButtonCurrentState + "_down");
    var _sb = wpfe.findName("openPageBrowserSB");
	
	if (pageBrowserButtonIsMouseOver == true)
	{
	  // change button state
	  if (pageBrowserButtonCurrentState == "pause")
	  {
	    pageBrowserButtonCurrentState = "play";
	    // Begin animation
	    _sb.begin();
	  }
	  else
	  {
	    pageBrowserButtonCurrentState = "pause";
	    // Stop animation
	    _sb.stop();
	  }
	  
	  newover = wpfe.findName(pageBrowserButtonCurrentState + "_over");
	  
	  newover.opacity = 1;
	  down.opacity = 0;
	}
	else
	{
      normal.opacity = 1;
	  down.opacity = 0;
	  over.opacity = 0;
	}
	
	pageBrowserButtonIsMouseDown = false;
	wpfe.findName("pageBrowserButton").releaseMouseCapture();

}