$(document).ready(function(){
	
	/* carousel pic */
	$(".carousel img").hide().eq(0).show();
	
	setInterval(randPic, 5000);
	
	var prevRand = 0;
	function randPic(){
		var rand = Math.floor(Math.random()*3+1);
		while (prevRand == rand) {
			rand = Math.floor(Math.random()*3+1);
		}
		prevRand = rand;
		$(".carousel img").hide();
		$(".carousel img").eq(rand).fadeIn(2000);
	}
	
	/* sidebar menu scripts */
	$("#sidebarMenu .submenu").slideUp(1);
	$("#sidebarMenu a.active").next("ul").slideDown(200);
	/*$("#sidebarMenu li").not($(".submenu li")).children("a").not($(".directLink")).click(function(e){
		e.preventDefault();
	})*/
	
	var oversubmenu = 0;
	$("#sidebarMenu .submenu").hover(function(){
		oversubmenu = 1;
	},function(){
		oversubmenu = 0;
	})
	
	/*
	$("#sidebarMenu").children("li").not($(".submenu li")).click(function(e){
		if (oversubmenu == 0 && !$(this).children(".directLink").length){
			$("#sidebarMenu").children("li").removeClass("active");
			$("#sidebarMenu .submenu").slideUp(1);
			$(this).addClass("active");
			if ($(this).children("ul").length) {
				$(this).children("ul").slideDown(300);
			}
		}
	});
	*/
	
	var defaultText = "Sogeord";
	$("#s").blur(function(){
		if ($(this).val().length < 1) {
			$(this).val(defaultText);
		};
	});
	
	$("#s").focus(function(){
		if ($(this).val() == defaultText) {
			$(this).val('');
		};
	});
	
})
