// JavaScript code for link.php. Include in <head> of pages using link.php.
// -----------------------------------------------------------------------------
// $Revision: 188 $ $Date: 2005-05-23 20:59:36 +0200 (ma, 23 mai 2005) $
// -----------------------------------------------------------------------------
// Copyright 2002-2005 Daniel Schlyder.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)



function bb_make_popup_image_link(src, width, height, window_name, window_title)
{
    if (navigator.userAgent.indexOf("Mozilla") != -1)
    {
        // Work-around making Mozilla not display scrollbars.
        // (Tested with 1.4.0)
        window_attributes = "width=" + (width + 5) + ",height=" + (height + 5);
    }
    else
    {
        window_attributes = "width=" + width + ",height=" + height;
    }
    
    // Position window in centre of screen. Skipped for Opera because it
    // centres relative to page window by default, and I could neither get it
    // to centre relative to screen, nor make up my mind whether that would be
    // desirable. (Tested with Opera 7.11)
    if (navigator.userAgent.indexOf("Opera") == -1)
    {
        offset_x = (screen.width - width) / 2;
        offset_y = (screen.height - height) / 2;
        
        window_attributes += ",left=" + offset_x + ",top=" + offset_y;
    }

    window_handle = window.open(src, window_name, window_attributes);
    window_handle.document.open();

    window_handle.document.write('<!DOCTYPE html'
        + ' PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n'
        + '\t"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n');
    window_handle.document.write('<html'
        + ' xmlns="http://www.w3.org/1999/xhtml"'
        + ' xml:lang="en" lang="en">\n');
    window_handle.document.write('<head>\n');

    window_handle.document.write('\t<title>' + window_title + '</title>\n');

    window_handle.document.write('</head>\n');
    window_handle.document.write('<body style="background-color: #000000;'
        + ' margin: 0; padding: 0">\n\n');

    window_handle.document.write('<div style="text-align: center">\n');
    window_handle.document.write('<a href="javascript:window.close()"'
        + '><img\n'
        + '\tsrc="' + src + '"\n'
        + '\twidth="' + width + '" height="' + height + '"\n'
        + '\talt="" title="<<" style="border: 0" /></a>\n');
    window_handle.document.write('</div>\n\n');

    window_handle.document.write('</body>\n</html>\n');
    window_handle.document.close();
}



function bb_replace_email_span()
{
	if (document.getElementsByTagName)
	{
		var elements = document.getElementsByTagName('span');

		for (i = 0;
			i < elements.length;
			++i)
		{
			if (elements[i].getAttribute('title'))
			{
				var value = elements[i].getAttribute('title');
				if (value.substring(0, 8) == 'bb:email')
				{
					var parts = elements[i].firstChild.nodeValue.split(' at ');
					var address = parts[0] + '@' + parts[1];

					var el = document.createElement('a');
					el.setAttribute('href', 'mailto:' + address);
					
					if (value.length > 9)
					{
						var text_node
							= document.createTextNode(value.substring(9));
					}
					else
					{
						var text_node = document.createTextNode(address);
					}
					el.appendChild(text_node);
					
					elements[i].parentNode.replaceChild(el, elements[i]);
					i--;
				}
			}
		}
	}
}



old_onload = window.onload;
if (old_onload)
{
	new_onload = function ()
	{
		old_onload();
		bb_replace_email_span();
	}
}
else
{
	new_onload = function ()
	{
		bb_replace_email_span();
	}
}
window.onload = new_onload;

