$(function(){
	$("a.fancybox").fancybox({
		'frameWidth': 500,
		'frameHeight': 450,
		'hideOnContentClick': false 
	});
	
	$('#comments').live('click',function(){
		$(this).parent().children('textarea').slideToggle();
		$(this).parent().children('textarea').focus();
	});
	
	// 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");
        }
    }
   
   
    $("a.jqbookmark").click(function(event){
        event.preventDefault(); // prevent the anchor tag from sending the user off to the link
        var url = "http://www.jobskebek.ca/";
        var title = "JobsKebek - Le moteur de recherche de l'emploi au Québec";
       
        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)
            jAlert('Votre navigateur ne support pas cette action');
        }
    });
	
	$('form[name=alert]').live('submit',function(){
		var container = $(this).parent(':first');
		$.ajax({
			type: "post",
			url: "mail/alert",
			data: "to=" + container.find('input[name=to]').val(),
			success: function(msg){
				$('#loader').remove();
				container.html(msg);
			}
		});
		$(this).remove();
		container.html('<img src="/images/load.gif" id="loader" />');
		return false;
	});
	
	$('.error, .good').live('click',function(){
		$(this).fadeOut('slow');
	});
	
	$('form[name=rechercherTop], form[name=rechercherBottom], form[name=rechercher]').submit(function(){
		var query 		= $(this).find('input[name=q]').val();
		if(query == ''){
			jAlert("<strong>Vous devez saisir un métier.</strong>");
			return false;
		}
		return true;
	});
	
	$(".fList li").click(function(){
		if($(this).children('a').attr('href') != null){
			location = $(this).children('a').attr('href');
		}
	});
});
