// JavaScript Document
var id_global=1;
$(document).ready(function() { 
    var effect = function(el, n, o, i) {
		
		$.extend(o, {
			easing: "easeOutQuint"
		});
		
		$(el).bind("click", function() {
			
			$("#overlay #text #info").addClass("current").hide(n, o, 1000, function() {
				var self = $("#overlay #text #info");
				  //id=$("#arrow-right").attr("rel")-1;
				  
          //if(id==0) id=43;
				  //alert(id);
          $.ajax({
            type: "GET",
            url: "page.php",
            data: "id="+id_global+"&action=2",
            success: function(html){
              $("#overlay #text #info #o-content").html(html);
                }
            });
          $.ajax({
            type: "GET",
            url: "page.php",
            data: "id="+id_global+"&action=1",
            success: function(html){
              $("#overlay #text h1").fadeOut("slow", function() {$("#overlay #text h1").html(html); $("#overlay #text h1").fadeIn("slow");});
                }
            });
				window.setTimeout(function() {
					if(i==1 )$(self).show(n, { direction: "right" }, 1000, function() { $("#overlay #text #info").removeClass("current");});
	        else $(self).show(n, { direction: "left" }, 1000, function() { $("#overlay #text").removeClass("current");});
				},500);
			});
		});
		
	};
	
	effect("#arrow-left", "slide", { direction: "right" }, 2);
	effect("#arrow-right", "slide", { direction: "left" }, 1);
	
	var effect2 = function(el, n, o) {
		
		$.extend(o, {
			easing: "easeOutQuint"
		});
		
		$(el).bind("click", function() {
			
			$("#overlay #text #info").addClass("current").hide(n, o, 1000, function() {
				var self = $("#overlay #text #info");
				  $("#arrow-left").hide();
				  $("#arrow-right").hide();
				  //alert(id);
          $.ajax({
            type: "GET",
            url: "page.php",
            data: "id="+id_global+"&action=2",
            success: function(html){
              $("#overlay #text #info #o-content").html(html);
                }
            });
          $.ajax({
            type: "GET",
            url: "page.php",
            data: "id="+id_global+"&action=1",
            success: function(html){
              $("#overlay #text h1").fadeOut("slow", function() {$("#overlay #text h1").html(html); $("#overlay #text h1").fadeIn("slow");});
                }
            });
				window.setTimeout(function() {
					$(self).show(n, o, 1000, function() { $("#overlay #text #info").removeClass("current");});
				},500);
			});
		});
		
	};
	//effect2("#o-content #books", "slide", { direction: "down" });
  effect2("#overlay .nav", "slide", { direction: "down" });
	});
  
    function fadeout(param, callObj)
    {
      $.ajax({
            type: "GET",
            url: "page.php",
            data: "id="+id_global+"&action=2",
            success: function(html){
                $("#overlay #text #info #o-content").html(html);
                }
            });
          $.ajax({
            type: "GET",
            url: "page.php",
            data: "id="+id_global+"&action=1",
            success: function(html){
              $("#overlay #text h1").html(html);
                }
            });
             $("#arrow-left").hide();
				  $("#arrow-right").hide();
         $("#logo").fadeOut("slow");
        $("#main").fadeOut("slow", function() { 
         $("#overlay").fadeIn("slow");      });
    }
    
    function setId(param)
    {
      if(param==0) id_global=43;
      else if(param==44) id_global=1;
      else id_global=param;
    }
    
    function display_book(param)
    {
      $.ajax({
            type: "GET",
            url: "page.php",
            data: "id="+id_global+"&action=2",
            success: function(html){
                $("#overlay #text #info #o-content").fadeOut("slow", function() {$("#overlay #text #info #o-content").html(html); $("#overlay #text #info #o-content").fadeIn("slow");});
                }
            });
          $.ajax({
            type: "GET",
            url: "page.php",
            data: "id="+id_global+"&action=1",
            success: function(html){
              $("#overlay #text h1").fadeOut("slow", function() {if(param!=1) {$("#arrow-left").show();$("#arrow-right").show();} $("#overlay #text h1").html(html); $("#overlay #text h1").fadeIn("slow");});
                }
            });      
    }

