// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

Event.observe(window, 'load', function() {
	var $j = jQuery.noConflict();
	
	$$('.round').each(function(element) {
		$j(element).corner();
	})
	
	$$('.flash').each(function(element) {
		element.visualEffect('shake');
		element.visualEffect('fade', {delay: 5});
	});
	
	Event.observe('email', 'focus', function(){Field.clear(this);});
});

// To fetch the newest news and write it into the homepage
var NewsBoy = Class.create({
  initialize: function(tumblr_json) {
		this.json = tumblr_json;		
		this.posts = this.json['posts'];
		this.insertPost('blog-content', this.formatPost(this.posts[0], 1111));
  },
  
	formatPost: function(post, max_length) {
		var string = '<h3>' + post['regular-title'] + ' (<a href="http://mfm.tumblr.com/">More News</a>)</h3>';
		string    +=  post['regular-body'];
		return string;
	},
	
	insertPost: function(destination, html) {
		$(destination).update(html);
	}
});
