var notifyOn = 0;
var uname;
var cur_location;

function lightboxInfo(someInfo)
{
   $('#insideLightbox').empty();
   $('#insideLightbox').append(someInfo);
   toggleBox("insideLightbox", 23);
}

function register()
{
   x_registerUser("getForm", lightboxInfo);
}

function toggleBox(box, onOff)
{
   $('#fade').slideToggle("fast");
   if(onOff === 23)
   {
      $('#fade').fadeTo("slow", .6);
      $('#'+box).fadeTo("slow", 1);
      setTimeout('toggleDiv(\''+box+'\')', 1050);
   }
   else
   {
      $('#fade').fadeTo("slow", .0);
      $('#'+box).fadeTo("slow", .0);
      toggleDiv(box);
   }
}

function replaceDiv(someData)
{
   cur_location = location.hash;
   $("#pagedata").fadeTo("slow", 0, function(){
      $('#pagedata').empty();
      $('#pagedata').append(someData);
      $("#pagedata").fadeTo("slow", 1);
   });
}

function toggleDiv(divName)
{$('#' +divName).slideToggle("slow");}

function logOutButton()
{
   var button = '<input type="button" value="Log Out" class="btn" onclick="logout()" onmouseover="this.className=\'btn btnhov\'" onmouseout="this.className=\'btn\'">';
   return button;
}

function getNewPage(pagename, link_cat)
{
   x_getNewPage(pagename, link_cat, location.hash, replaceDiv);
}

function handle_photos(someData)
{
   $("#pagedata").fadeTo("slow", 0, function(){
      $('#pagedata').empty();
      $('#pagedata').append(someData);
      $("#pagedata").fadeTo("slow", 1, function(){
         jQuery.Lightbox.relify();
         $("#lightbox-close-button").empty();
         $("#lightbox-close-button").append("<img src='./images/close.png' />");
      });
   });
}

function getGalPhotos(id)
{
   x_getGalPhotos(id, handle_photos);
}

function checkLocation()
{
   if(cur_location!=location.hash)
   {
      var new_location = location.hash;
      //alert(cur_location+" is the current location. This is the new location "+new_location);
      new_location = new_location.split("||");
      cur_location = location.hash;
      //alert(new_location[0]+" and "+new_location[1]);
      getNewPage(new_location[0].replace(/#/, ''), new_location[1]);
   }
}

$(function(){
   if(location.hash!='#Home'){location.hash='#Home';}
   cur_location = location.hash;
   setInterval("checkLocation()", 500);
});