/* ------------------------------------------------------------------------
 * get_tweets.js
 * ------------------------------------------------------------------------ */     

$(document).ready(function(){
	$("#tweets-list").tweet({
      	username: ["NicholasTheWord"],
		avatar_size: 32,
		count: 3
	});
});     

/*
var tweetsCount = 3;

function getLatestTweets(){     
	var url = "http://search.twitter.com/search.atom?q=from%3ANicholasTheWord";
	jQuery.getFeed({
       url: url,
       success: function(feed) { 
	alert("success");
           buildLatestTweets(feed);
       }
   });  
}
    
function buildLatestTweets(feed){   
	var list = $("#tweets");
	for(var i=0; i<tweetsCount; i++){
		var date = feed.item[i].updated;
		var link = feed.item[i].link;
		var description = feed.item[i].description;
		list.append("<li>" + description + "</li>");
	} 
	
}

$(document).ready(function(){
	getLatestTweets();
}) 
*/

/* ------------------------------------------------------------------------
 * panels.js
 * ------------------------------------------------------------------------ */     

var currentPanelId;
        
function setupPanelsMenu(){
	$("#archive-menu a").unbind("click").bind("click", {id: "archive"}, function(e){
		e.preventDefault();
		showPanel(e.data.id);
	}).html("Browse archive");
	$("#tags-menu a").unbind("click").bind("click", {id: "tags"}, function(e){
		e.preventDefault();
		showPanel(e.data.id);
	}).html("Browse tags");
}

function showPanel(id){
	hidePanels();
	/*
	if(currentPanelId){
		$("#" + currentPanelId + "-panel").slideUp();
    	setupPanelsMenu();   
	}  
	*/
	currentPanelId = id;
	$("#" + id + "-panel").slideDown("slow", function(){  
		$.scrollTo($("#" + id + "-panel"), 150);  
	});  
	$("#" + id + "-menu").addClass("active");
	$("#" + id + "-menu a").unbind("click").bind("click", function(e){
		e.preventDefault();
	   	hidePanels();
	}).html("Close " + id); 
}      

function hidePanels(){
	$(".footer-panel").css("display", "none"); 
	$(".panel-menu").removeClass("active");
    setupPanelsMenu();    
} 

$(document).ready(function(){
	setupPanelsMenu();
})



/* ------------------------------------------------------------------------
 * basicform.js
 * ------------------------------------------------------------------------ */      

/*
 *	PLACE HOLDER: Display text on empty input
 *  The text is taken from the "placeholder" attribute
 *  This is not needed for Safari had this browser already manage this function itself
 */
      
$(document).ready(function(){ 
	$("input[type=text]").example(function() {
		return $(this).attr('placeholder');
	}, 
	{className: 'example_text'}
	);
	$("input[type=password]").example(function() {
		return $(this).attr('placeholder');
	}, 
	{className: 'example_text'}
	);
	$("textarea").example(function() {
		return $(this).attr('placeholder');
	}, 
	{className: 'example_text'}
	);
});        


/*
 * SPREAD THE WORD: Display and hide the block with same name
 */
    
$(document).ready(function(){ 
	$("#wysd > a").bind("click", function(event){
		event.preventDefault();
	});
	$("#wysd").bind("mouseenter", function(event){
		$("#wysd > .content").slideDown();
	});
	$("#wysd").bind("mouseleave", function(event){   
		$("#wysd > .content").slideUp("fast");
	});
});