window.onload = function() {
		 
		 //height effects
		 myHeight = new fx.Height('slide',{wait:false});
		 myHeight.show();

		 new Insertion.Top('slide', '<p id="mainAreaLoading" style="display:none"><img src="http://www.manicmelon.com/wp-content/themes/ManicMelon/img/ajax-loader.gif" alt="Loading..." /></p>');

new Insertion.Top($('c_life'), '<a href="#show_tags" title="Show tags" id="lifestyle"><img src="http://www.manicmelon.com/wp-content/themes/ManicMelon/img/show.gif" class="tags_overlay" alt="Show tags" id="lifestyle_overlay" /></a>');

		new Insertion.Top($('c_bus'), '<a href="#show_tags" title="Show tags" id="business"><img src="http://www.manicmelon.com/wp-content/themes/ManicMelon/img/show.gif" class="tags_overlay" alt="Show tags" id="business_overlay"  /></a>');

		new Insertion.Top($('c_web'), '<a href="#show_tags" title="Show tags" id="web"><img src="http://www.manicmelon.com/wp-content/themes/ManicMelon/img/show.gif" class="tags_overlay" alt="Show tags" id="web_overlay"  /></a>');


		 // Clicks
		 $('lifestyle').onclick = function() {
				loadContent(1);
				return false;
		 };
		$('business').onclick = function() {
				loadContent(2);
				return false;
		};
		$('web').onclick = function() {
				loadContent(3);
				return false;
		};
		refresh = new fx.Height('slide',{wait:false,onComplete:function(){Element.show($('tagcontent'));myHeight.toggle();}});
		
		//Element.hide($('tagcontent'));
		first = true;		
		marginChange = new Fx.Style('mainAreaLoading', 'margin-top');
		//myHeight.toggle();
};


function startLoading() {
		Element.hide($('tagcontent'));
		margintop = Element.getHeight($('tagsinner'));
		margintop = (margintop/2)-20;
		if (margintop<5) margintop = 0;
		marginChange.set(margintop);
		Element.show($('mainAreaLoading'));	
		if (first) {
			if (Element.getHeight($('slide'))=="") {
				myHeight.toggle();
			}
			first=false;
			new Insertion.Bottom('tags', "<span class='center'><img class='toggle' src='http://www.manicmelon.com/wp-content/themes/ManicMelon/img/toggle.gif' onclick='javascript:myHeight.toggle();' alt='toggle'/></span>");
		} else if (Element.getHeight($('slide'))==0) {
			myHeight.toggle();
		}
}

function finishLoading() {
	  Element.hide('mainAreaLoading');
	  marginChange.set(0);
	  refresh.toggle();
}

function loadContent(id) {
	  startLoading();
	  // Request the content and update the 'div' area (i'll explain this in more detail later).
	  new Ajax.Updater('tagcontent', 'http://www.manicmelon.com/wp-content/themes/ManicMelon/tags.php', {method: 'post', postBody:'content='+ id +'&cats='+ cats +'', onComplete:function(){ finishLoading();}});			  
}