$(document).ready(function(){
    $('a[rel="external"]').click(function() {
        window.open($(this).attr('href'));
        return false;
    });
    
    PrinterTool = {};
    PrinterTool.windowSettings = 'toolbar=no,location=no,' + 'status=no,menu=no,scrollbars=yes,width=650,height=400';
    PrinterTool.print = function (tagID,docTitle) {
        var target = document.getElementById(tagID);
        var title = document.title;
        if (docTitle!=null) title = docTitle;
        if (!target || target.childNodes.length === 0) {
            alert("Il n'y a rien à imprimer!");
            return;
        }
        var content = target.innerHTML;
        var text = '<html><head><title>' + title + '</title></head><body>' + content + '</body></html>';
        printerWindow = window.open('','',PrinterTool.windowSettings);
        printerWindow.document.open();
        printerWindow.document.write(text);
        printerWindow.document.close();
        printerWindow.print();
    };
    
    $.extend({
        getUrlVars: function(){
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for(var i = 0; i < hashes.length; i++)
            {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        },
        getUrlVar: function(name){
            return $.getUrlVars()[name];
        }
    });
})
