$(document).ready(function() {
	
	var options = { path: '/'};//, expires: 365 
	
	$('#header').find('a[class!="active"]').append('<span class="hover"></span>').each(function () {
			var $span = $('> span.hover', this).css('opacity', 0);
			
			$(this).hover(function () {
					
					$span.stop().fadeTo(200, 1);
			}, function () {
					
					$span.stop().fadeTo(500, 0);
			});
	});
	
	$('#aside').find('li[class!="active"]').each(function () {
			
			
			$(this).append('<span class="hover"></span>');
			
			var $span = $(this).children('span.hover').css('opacity', 0);
			
			$(this).hover(function () {
					
					$span.stop().fadeTo(200, 1);
					
			}, function () {
					
					$span.stop().fadeTo(500, 0);
					
			});
	});
	
	$('.box3').find('img[class="fade"]').each(function () {
			
			$(this).click(function () { 
				var target = $(this).prev("a").attr("href");
				self.location.href = target;
			});
	});
	
	$('.post').find('.src').each(function () {
			
			$(this).click(function () { 
				var target = $(this).parent(".image").prev("h2").children("a");
				target.trigger("click");
				self.location.href = target.attr("href");
			});
	});
	
	$('.post').find('a.blog_more').append('<span class="hover"></span>').each(function () {
			
			
			var $span = $('> span.hover', this).css('opacity', 0);
			
			$(this).hover(function () {
					
					$span.stop().fadeTo(200, 1);
					
			}, function () {
					
					$span.stop().fadeTo(500, 0);
					
			});
	});
	
	$("#toggle_head").click(function(){
		
		if($(this).hasClass("closed"))
		{
			$(this).removeClass("closed").attr("title","Masquer le haut");
			$("#header").animate({height:'576'},1000);
			
			$.cookie("toggle_head","opened", options);
			
		}
		else
		{
			$(this).addClass("closed").attr("title","Montrer le haut");
			$("#header").animate({height:'375'},1000);
			$.cookie("toggle_head","closed", options);
			
		}
		
		return false;
	});
	
	$("a.tags").click(function(){
		
		var span = $("#ariane").find("span.italic");
		
		$.cookie("blo_tag",span.text(), options);
		//return true;
		//alert(span.text());
	});
	
	$('#devis').find('a[class!="active"]').each(function () {
			
		$(this).append('<span class="hover"></span>');
		
		var $span = $(this).children('span.hover').css('opacity', 0);
		
		$(this).hover(function () {
				
				$span.stop().fadeTo(200, 1);
				
		}, function () {
				
				$span.stop().fadeTo(500, 0);
				
		});
		
		
	});
	
	$('input.button-hover').wrap('<div class="button-wrap"></div>');
		$('input.button-hover').hover(function() {
			$(this).stop().animate({'opacity': 0}, 200)
		}, function() {
			$(this).stop().animate({'opacity': 1}, 500)
	});
	
	
});
function scrollToo(target)
{
		var targetOffset = $(target).offset().top;
      	$('html,body').animate({scrollTop: targetOffset}, 1000);
}
jQuery.cookie = function (key, value, options) {
    
    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
        
        value = String(value);
        
        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
