YAHOO.namespace("example.container");

function init() 
   {
// Build overlay1 based on markup, initially hidden, fixed to the center of the viewport, and 300px wide
//   YAHOO.example.container.overlay1 = new YAHOO.widget.Overlay("overlay1", { fixedcenter:true, visible:false, width:"300px" } );
//   YAHOO.example.container.overlay1.render();
//   YAHOO.log("Overlay1 rendered.", "info", "example");

// Build overlay2 dynamically, initially hidden, at position x:400,y:500, and 300px wide
//   YAHOO.example.container.overlay2 = new YAHOO.widget.Overlay("overlay2", { xy:[600,200], visible:false, width:"300px" } );
//   YAHOO.example.container.overlay2.setHeader("Overlay #2 from Script");
//   YAHOO.example.container.overlay2.setBody("This is a dynamically generated Overlay.");
//   YAHOO.example.container.overlay2.setFooter("End of Overlay #2");
//   YAHOO.example.container.overlay2.render(document.body);
//   YAHOO.log("Overlay2 rendered.", "info", "example");

// Build overlay3 dynamically, initially hidden, aligned to context element "context", and 200px wide

// Re-align just before the overlay is shown and whenever the window is resized to account for changes in the position  
// of the context element after the initial context alignment 
//   YAHOO.example.container.overlay3 = new YAHOO.widget.Overlay("overlay3", { context:["ctx","tl","bl", ["beforeShow", "windowResize"]], visible:false, width:"200px" } );
//   YAHOO.example.container.overlay3.setHeader("Overlay #3 from Script");
//   YAHOO.example.container.overlay3.setBody("Test Content");
//   YAHOO.example.container.overlay3.setFooter("End of Overlay #3");
//   YAHOO.example.container.overlay3.render(document.body);
//   YAHOO.log("Overlay3 rendered.", "info", "example");

//   YAHOO.util.Event.addListener("show1", "click", YAHOO.example.container.overlay1.show, YAHOO.example.container.overlay1, true);
//   YAHOO.util.Event.addListener("hide1", "click", YAHOO.example.container.overlay1.hide, YAHOO.example.container.overlay1, true);

//   YAHOO.util.Event.addListener("show2", "click", YAHOO.example.container.overlay2.show, YAHOO.example.container.overlay2, true);
//   YAHOO.util.Event.addListener("hide2", "click", YAHOO.example.container.overlay2.hide, YAHOO.example.container.overlay2, true);

//   YAHOO.util.Event.addListener("PresentPanel", "click", YAHOO.example.container.overlay3.show, YAHOO.example.container.overlay3, true);
//   YAHOO.util.Event.addListener("CancelPanel", "click", YAHOO.example.container.overlay3.hide, YAHOO.example.container.overlay3, true);
   }

YAHOO.util.Event.addListener(window, "load", init);

function PresentPanel(ContentText, LLink, RLink, Width, Anchor)
   {
   var myObj;
   var myId;
   var myOut;
   if ( loggedin == 1 ) /* They are logged in */
      {
      location.href = LLink;
      }
   else
      {
       YAHOO.example.container.overlay3 = new YAHOO.widget.Overlay("overlay3", { context:[Anchor,"tl","bl", ["beforeShow", "windowResize"]], visible:false, width:Width } );

       myOut = ContentText + '<div class="overlaybuttons">'
       myOut = myOut + '<button onClick="javascript:location.href=\'' + LLink + '\';" id="LButton">Login</button>';
       myOut = myOut + '<button onClick="javascript:location.href=\'' + RLink + '\';" id="RButton">Register</button>';
       myOut = myOut + '<button onClick="javascript:ClosePanel();" id="CancelPanel">Cancel</button>';
       myOut = myOut + '</div>';

       YAHOO.example.container.overlay3.setHeader("");
       YAHOO.example.container.overlay3.setBody(myOut);
       YAHOO.example.container.overlay3.setFooter("");
       YAHOO.example.container.overlay3.render(document.body);

       YAHOO.example.container.overlay3.show();

        myId = 'overlay3';
        if ( document.getElementById ) { myObj = document.getElementById(myId); }
        else { if ( document.all )     { myObj = document.all[myId]; } }

        myObj.style.borderWidth = '1px';
        myObj.style.borderColor = 'black';
       }
   }
function ClosePanel()
   {
   YAHOO.example.container.overlay3.hide();
   YAHOO.example.container.overlay3.destroy();
   }
