// Source: http://scott.yang.id.au/2003/06/obfuscate-email-address-with-javascript-rot13/
Rot13 = {
    map: null,

    convert: function(a) {
        Rot13.init();

        var s = "";
        for (i=0; i < a.length; i++) {
            var b = a.charAt(i);
            s += ((b>='A' && b<='Z') || (b>='a' && b<='z') ? Rot13.map[b] : b);
        }
        return s;
    },

    init: function() {
        if (Rot13.map != null)
            return;
              
        var map = new Array();
        var s   = "abcdefghijklmnopqrstuvwxyz";

        for (i=0; i<s.length; i++)
            map[s.charAt(i)] = s.charAt((i+13)%26);
        for (i=0; i<s.length; i++)
            map[s.charAt(i).toUpperCase()] = s.charAt((i+13)%26).toUpperCase();

        Rot13.map = map;
    },

    write: function(a) {
        document.write(Rot13.convert(a));
    }
}


	
window.addEvent('domready', function() {
	
	var adminbar = $('adminbar');
	try {	

		adminbar.addEvent('mouseenter', adminbar.fade.bind(adminbar, [1]));
		adminbar.addEvent('mouseleave', adminbar.fade.bind(adminbar, [0.2]));

		var fx = new Fx.Tween(adminbar, { link: "chain", duration: "2000" });
		fx.start('opacity', 1, 1); // essentially wait
		fx.start('opacity', 1, 0.2);
	} catch (e) { // adminbar is not set b/c we are not admin
	}
});

function dialog (id, header, text, choices, options) {
	var content = '<div id="'+id+'_dialog" class="dialog"><h5>'+header+'</h5><div>'+text+'</div><ul>';
	for (button in choices) {
		content += '<a href="javascript:'+choices[button]+'">'+button+'</a>';
	}
	content += '</ul></div>';

	var dialog = new StickyWin.Modal({
		content: content,
		closeOnClickOut: true,
		closeOnEsc: true,
		showNow: true,
		timeout: 0,
		modalOptions: {
			modalStyle: {
				'background-color': 'white',
				'opacity': '.6'
			}
		}
	});
}
