$(document).ready(function() {	

	$("div.post").hover(function() {
		//$(this).css({background: "#d4d2ba"});
	}, function() {
		//$(this).css({background: "#e3e1c9"});
	});
	
	
	$(".widget_extended-categories .children .children").hide();
	
	$(".widget_extended-categories .children li a:not(.widget_extended-categories .children .children li a)").click(function() {		
		$(this).toggleClass("active");
		$(this).parent("li").children(".children").toggle();
		return false;
	});
	
	// Open the menu that matches the url
	var currentURL = window.location;
	//alert(currentURL);
	
	$("a[href="+currentURL+"]").parent("li").parent("ul.children").show();
	$("a[href="+currentURL+"]").parent("li").parent("ul.children").prev("a").addClass("active");	
	
	// Populate the homepage with some random posts every few minutes
	function repopulate() {						
		setTimeout(repopulate, 10000);
		alert('7 seconds');
	}
	//var test = setTimeout(repopulate(), 10000);


	setTimeout(function() {	
		repopulate();		
	}, 10000);

	function repopulate() {
		
		// Hide the current posts
		$(".homepage div.hider").fadeOut(500, function() {
									
			// Send a post and grab
			$(".hider").load("http://www.ethicalfashion.ca?p=357&"+rnd(), function() {					
								
				$(".hider").fadeIn(500);								
				
				//alert('loaded');
			});			
		
		});
		
		setTimeout(repopulate, 10000);
	}
	
	function rnd(){ return String((new Date()).getTime()).replace(/\D/gi,'') }

});