var century = { src: base_url + 'libraries/img/century_gothic.swf' };
sIFR.activate(century);
sIFR.replace(century, {
  selector: '.title_flash',
  wmode: 'transparent',
  css: '.sIFR-root { color: #FBC8FB; }'
});



$(document).ready(function()
{
	$(document).pngFix(); 
	$('.guestbook_content').jScrollPane();
	$('.onglet_scroll').jScrollPane();
	

/* ///////////////// LIGHTBOX ////////////////////// */
	$(".media_content a").fancybox({
		'overlayOpacity' :	0.8
	});
	

/* ///////////////// GUESTBOOK ////////////////////// */
	$("#add_guestbook").hide();
	
	$("#guestbook_go").click(function(){
		$.post(base_url + "index.php/blog/guestbook_insert/", { 
			name: $("#guestName").val(), 
			body: $("#guestBody").val() 
		},
		  function(data){
		    $(".guestbook_content").html(data);
		    $('.guestbook_content').jScrollPane();
		    $("#add_guestbook").fadeOut("normal", function(){
				$("#unlock-bottom").fadeIn();
				$("#guestBody").val("");
				$("#guestName").val("");
			});
		});
		return false;
	});

/* ///////////////// COMMENTS ////////////////////// */	
	$(".comments_container").hide();
	
	$(".commentaire a").toggle(function(){
		var this_id = this.id;
		$("#ajax_load_title_" + this_id ).show();
		$.post(base_url + "index.php/blog/comments_get/" + this_id, function(data){
  			$("#comments_message_" + this_id).html(data);
  			$("#comment_" + this_id).slideDown("normal", function(){
  				$("#ajax_load_title_" + this_id ).hide();
  			});
		}, "html");
		return false;
	},function(){
		$("#comment_" + this.id).slideUp();
		return false;
	});
	
	
	$(".comment_go").click(function(){
		//var this_id = (this).attr("comentGoId");
		var this_id = $(this).attr("commentGoId");
		$("#ajax_load_title_" + this_id ).show();
		$.post(base_url + "index.php/blog/comments_insert/", { 
			entry_id: this_id, 
			body: $(this).parent().prev().val(),
			autor: $(this).parent().prev().prev().prev().val() 
		},
		  function(data){
		    $.post(base_url + "index.php/blog/comments_get/" + this_id, function(data){
  				$("#comments_message_" + this_id).html(data);
  				$(".ajax_load_title").hide();
  				$("#ajax_load_title_" + this_id ).hide();
			});
		});
		return false;
	});
	
	
/* ///////////////// BOTTOM ////////////////////// */	

	$("#savoir_plus a").toggle(function(){
		$("#bottom").animate({ 
        height: "375px"
      }, 500 );
		return false;
	},function(){
		
		$("#bottom").animate({ 
        		height: "0px"
      			}, 500 );
      	
      return false;
	});
	
	
	$('.onglet_bottom').click(function(){
		$('.onglet_bottom').removeClass('selected');
		$(this).addClass('selected');
		
		$('.onglet_body').fadeOut();
		$('#onglet_body_' + $(this).next().html()).fadeIn();
		
	
	});
 


	
/* ///////////////// IPHONE ////////////////////// */		
	
	// Set the slider to be sliding
	$("#unlock-slider").slider({
		handle: "#unlock-handle",
		animate:true,
		slide: function(e,ui)
		{
			$("#slide-to-unlock").css("opacity", 1-(parseInt($("#unlock-handle").css("left"))/120));
		},
		stop: function(e,ui)
		{
			if($("#unlock-handle").position().left == 182)
			{
				unlock();
			}
			else
			{
				$("#unlock-handle").animate({left: 0}, 182 );
				$("#slide-to-unlock").animate({opacity: 1}, 182 );
			}
		}
	});
	
	var unlock = function()
	{
			
		$("#unlock-bottom").fadeOut("normal", function(){
			$("#add_guestbook").fadeIn();
			$("#unlock-handle").animate({left: 0}, 182 );
			$("#slide-to-unlock").animate({opacity: 1}, 182 );
		});

	}
	
	
});