// JavaScript Document

function myFadeIn(object){
      object.fadeIn(200, function () {
		object.bind('click',displayLayer);
		if ( object.next().length )    {
			myFadeIn(object.next());
            }
      });
}

function displayLayer(){
	var $id = $(this).attr('id');
	if($.browser.msie)	{
		$id = $id.substring($id.lastIndexOf('/')+1);
	}

	$('#body').load('php/image.php?id=' + $id,null, function()	{
		$('#image').fadeIn(500);
		$('#layer .previous').bind('click',prevNextLayer);
		$('#layer .next').bind('click',prevNextLayer);
		$('#data #back').bind('click',Reload);
	});
	
	$('#title').css('display','none');
	$('#meta').css('display','none');
	$('#main').css('display','none');

}

function prevNextLayer()	{
	var $id = $(this).attr('id');

      if($.browser.msie)	{
		$id = $id.substring($id.lastIndexOf('/')+1);
	}
	
	$('#body').load('php/image.php?id=' + $id,null, function()	{
		$('#image').fadeIn(500);
		$('#layer .previous').bind('click',prevNextLayer);
		$('#layer .next').bind('click',prevNextLayer);
		$('#data #back').bind('click',Reload);
	});
	
	return false
}

function Reload() {
      location.reload();
      return false;
}

$(document).ready(function() {
  //if (navigator.appVersion.indexOf("MSIE 6.") == -1) {
      $('#body #main').load('php/images.php', null, function(){
            myFadeIn($('#main a:first'));
      });
      $("#body").ajaxStart(function(){
            $("#body").addClass('loading');
      });
      $("#body").ajaxStop(function(){
            $("#body").removeClass('loading');
      });
      $('#body #banner a').click(function(){
        $('#body #banner').remove();
      });
      $('#body #banner2 a').attr('target','_blank');
      $('#body #banner2 a').click(function(){
        $('#body #banner2').remove();
      });          
  //s}
});
