jQuery(function($) {
	
	//IE fixes
	if ($.browser.msie) {
		
		//All IE
		$('#top5 li:first-child').addClass('first-child');
		
		//IE6
		if ($.browser.version <= 6){
		}
	}
	
	
	//emptyOnFocus
	$('#newsletter form').emptyOnFocus();
		
	//Dialogs
	//Help Dialog (register)
	$('button.help').click(function(){
		$('#help').dialog({
			bgiframe: true,
			draggable: false,
			resizable: false,
			width: 400,
			close: function(event, ui) {
				$(this).dialog('destroy');
			}

		});
		return false;
	});
	
	
	//Add Comment Dialog
	$('#add-comment').click(function(){
		$('#add-comment-dialog').dialog({
			bgiframe: true,
			draggable: false,
			resizable: false,
			width: 500,
			modal: true,
			close: function(event, ui) {
				$(this).dialog('destroy');
			}

		});
		return false;
	});
	
	//Add Comment Dialog
	$('div.more a[href="#details"]').click(function(){
		$('#detail').dialog({
			bgiframe: true,
			draggable: false,
			resizable: false,
			width: 400,
			close: function(event, ui) {
				$(this).dialog('destroy');
			}

		});
		return false;
	});
	
	//Envoyer à un ami dialog
	$('#envoi-ami').click(function(){
		$('#add-comment-dialog').dialog({
			bgiframe: true,
			draggable: false,
			resizable: false,
			width: 500,
			modal: true,
			close: function(event, ui) {
				$(this).dialog('destroy');
			}

		});
		return false;
	});	
	
	// Menu
	$(".rollover").hover( function() {
		$(this).children("img").attr("src", "http://www.plusduntourdanslamanche.com/img/fleche_menu_hover.jpg");
	}, function() {
		$(this).children("img").attr("src", "http://www.plusduntourdanslamanche.com/img/fleche_menu.jpg");
	});
	
	// BOOKMARK
  $("a.jqbookmark").click(function(event){
		// add a "rel" attrib if Opera 7+
		if(window.opera) {
			if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
				$("a.jqbookmark").attr("rel","sidebar");
			}
		}  	
    event.preventDefault(); // prevent the anchor tag from sending the user off to the link
    var url = this.href;
    var title = this.title;
   
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url, "");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite( url, title);
    } else if(window.opera) { // Opera 7+
        return false; // do nothing - the rel="sidebar" should do the trick
    } else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
        alert('Malheureusement, votre navigateur ne supporte pas cette action, merci d\'ajouter ce site manuellement.');
    }
  });
  
  // Header slider
  $("div.scrollable").scrollable({ size: 1, loop:true }).autoscroll({autoplay: true, steps:1, interval:3000});
  
  $("#EndroitDetailFermer").click(function() { 
  	$("#EndroitDetail").fadeOut(800).hide(); 
  });
});