// JavaScript Document

$("document").ready(function(){
					
	$(".submit").click(function(event){
		event.preventDefault();	
		$(this).parents("form").submit();
	});
	
	$("div#header div.content ul#m_0 li").hover(function(){
		$("div.dropdown").hide();
		var id = $(this).attr("id");
		$("div.dropdown#" + id).fadeIn(500);				 
	});

	$("div#header div.content").hover(function(){

	}, function(){
		$("div.dropdown").hide();
	});

	$("div.thumbs a.thumb img").hide();
	fadeInThumb();
	
	$("#footer #m_0 li:first").addClass("first");
	$("div.news_item:last").addClass("last");

	$("div.slideshow div.slide:first").fadeIn(500);
	countproj = $("div.slideshow div.slide").length-1;
	projslideshow = setInterval("next_project()", 3000);
	$("ul.dots li:eq("+curproj+")").addClass("active");

	$("ul.dots li").click(function(event){
	 $("div.slideshow div.slide:eq("+curproj+")").fadeOut(500);
	 $("ul.dots li:eq("+curproj+")").removeClass("active");
	 curproj = $("ul.dots li").index(this);
	 $("div.slideshow div.slide:eq("+curproj+")").fadeIn(500);
	 $("ul.dots li:eq("+curproj+")").addClass("active");
	});

	$("div.slideshow").hover(function(){
	 clearInterval(projslideshow);
	 $("img#pause").fadeIn(500);
	}, function(){
	 projslideshow = setInterval("next_project()", 3000);
	 $("img#pause").fadeOut(500);
	});
});

	function fadeInThumb(){
	 $("div.thumbs a.thumb img:hidden:first").fadeIn(600, function(){
	  if ( $("div.thumbs a.thumb img:hidden").length != 0) {
	   fadeInThumb();
	  }
	 });
	}
	var projslideshow;
	var curproj = 0;
	var countproj = 0;

	function next_project() {
 	 $("div.slideshow div.slide:eq("+curproj+")").fadeOut(500);
	 $("ul.dots li:eq("+curproj+")").removeClass("active");
	 curproj = next_project_id();
 	 $("div.slideshow div.slide:eq("+curproj+")").fadeIn(500);
	 $("ul.dots li:eq("+curproj+")").addClass("active");
	}

	function next_project_id() {
	 if (curproj == countproj) { return 0; }
	 curproj++;
	 return curproj;
	}

