function initDebug(){
	$('#debug .action a.switchview').toggle(
		function() {
			$("#debug .view").hide();
			//$("#debug .action a.switchview").html("show");
			$("#debug .action a.switchview").removeClass("switch-show");
			$("#debug .action a.switchview").addClass("switch-hide");
		},
		function() {
			$("#debug .view").show();
			//$("#debug .action a.switchview").html("hide");
			$("#debug .action a.switchview").removeClass("switch-hide");
			$("#debug .action a.switchview").addClass("switch-show");
		});
	$('#debug .action a.movetop').click(
		function() {
			$('#debug').removeClass("bottom");
			$('#debug').addClass("top");
			$('a.button-debug').removeClass("bottom");
			$('a.button-debug').addClass("top");
			$('#debug .action a.movebottom').removeClass('activated');
			$('#debug .action a.movetop').addClass('activated');
	});
	$('#debug .action a.movebottom').click(
		function() {
			$('#debug').removeClass("top");
			$('#debug').addClass("bottom");
			$('a.button-debug').removeClass("top");
			$('a.button-debug').addClass("bottom");
			$('#debug .action a.movetop').removeClass('activated');
			$('#debug .action a.movebottom').addClass('activated');
	});
	
	$('#debug .action a.close').click(
			function() {
				$('#debug').hide();
		});
	
	$('a.button-debug').toggle(
		function() {
			$('#debug').show();
		},
		function() {
			$('#debug').hide();
		});
	
	$('#debug .action a.add').click(
		function() {
			$('#debug .view').height(eval($('#debug .view').height()+48));
	});
	
	$('#debug .action a.reduce').click(
		function() {
			$('#debug .view').height($('#debug .view').height()-48);
	});
	
	$("#debug .view").hide();
	//$("#debug").draggable({ snap: 'body', snapMode: 'outer' });
	//$("#debug").resizable({ grid:50 });
}/**
 * Non obstrusive javascript intialization
 */
$(document).ready(function(){

	// Search textbox
	$('#search').focus(function(){
		$(this).addClass("active");
		if(this.value=="input your search"){
			this.value="";
		}
	});
	$('#search').blur(function(){
		$(this).removeClass("active");
		if(this.value==""){
			this.value="input your search";
		}else{
			$('#formsearch').submit();
		}
	});
	// JQuery Lightbox plugin initialisation
	$(function() {
		// Select all links that contains lightbox in the attribute rel
		$('.smart-gallery a').lightBox();
	});

	// Initialize onclick action on .block to display articles
	$(".block").each(function(){
		var url="'/#/read/"+this.id+"'";
		$(this).onclick="window.url="+url;
	});
	initDebug();
});
