$(function(){
	// $("a").bind("focus",function(){if(this.blur)this.blur();});
 
	$("#menu > li:first-child.current_page_item, #menu > li:first-child.current-cat").addClass("first_menu_active");
	$("#menu > li:last-child.current_page_item, #menu > li:last-child.current-cat").addClass("last_menu_active");
	$("#menu li ul li:has(ul)").addClass("parent_menu");

	$("#right_col ul > li:last-child").css({marginBottom:"0"});

	$("#comment_area ol > li:even").addClass("even_comment");
	$("#comment_area ol > li:odd").addClass("odd_comment");
	$(".even_comment > .children > li").addClass("even_comment_children");
	$(".odd_comment > .children > li").addClass("odd_comment_children");
	$(".even_comment_children > .children > li").addClass("odd_comment_children");
	$(".odd_comment_children > .children > li").addClass("even_comment_children");
	$(".even_comment_children > .children > li").addClass("odd_comment_children");
	$(".odd_comment_children > .children > li").addClass("even_comment_children");
	$("#trackback_url").click(function(){this.select();});

	$("#guest_info input,#comment_textarea textarea")
    .focus( function () { $(this).css({borderColor:"#33a8e5"}) } )
    .blur( function () { $(this).css({borderColor:"#ccc"}) } );

	$("blockquote").append('<div class="quote_bottom"></div>');

	$(".side_box:first").addClass("first_side_box");
	$(".search_input").val("Recherche");
	$(".search_input").focus(function(){$(".search_input").val("");});
	$(".displaynone").removeClass("displaynone");
});

$(document).ready(function(){
	
	/** Check Comment Submit **/
	$('#commentform').submit(function(){
		testret = 0;
		verifmail = new RegExp(/^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,4}$/);
		name = $("#author").val();
		mail = $("#email").val();
		text = $("#comment").val();
		if(name == "") { $("#author").animate({opacity: 0}, 200, '', function(){$("#author").css({ backgroundColor: "#f77" });$("#author").css({color:"#fff"})}); $("#author").animate({opacity: 1}, 200); testret = 1; }
		else { $("#author").css({ backgroundColor: "#fff" });  $("#author").css({color:"#666"}); }
		
		if(mail == "" || verifmail.test(mail) == false) { $("#email").animate({opacity: 0}, 200, '', function(){$("#email").css({ backgroundColor: "#f77" });$("#email").css({color:"#fff"})}); $("#email").animate({opacity: 1}, 200); testret = 1; }
		else { $("#email").css({ backgroundColor: "#fff" });  $("#email").css({color:"#666"}); }
		
		if(text == "") { $("#comment").animate({opacity: 0}, 200, '', function(){$("#comment").css({ backgroundColor: "#f77" });$("#comment").css({color:"#fff"})}); $("#comment").animate({opacity: 1}, 200); testret = 1; }
		else { $("#comment").css({ backgroundColor: "#fff" });  $("#comment").css({color:"#666"}); }
		
		if(testret == 1)
			return false;
		else
			return true;
	});
	/***********************/
	
	/** Scroll function. Any link with a hash (#) will scroll to that id on the page. **/
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
	/***********************/
});
