/*
 * Wraps quicklink boxes with anchors. 
 * Href, target, title and onclick attributes are taken from the first 
 * link of the link list in the quicklink box 
 * 
 * Requires: jquery.js
 *
 */
$(document).ready(function() {
	$('.Box, .OnlineDateItemHomepage').each(function() {
		var jqa = $('ul.Links li a', $(this));
		if (jqa.length == 1) {
			var jsa = jqa.get(0);
			var oca = '';
			if (jsa.getAttribute('onclick') != undefined) {
				var r = jsa.getAttribute('onclick').toString().match(/\(([^\(\)]+)\)/);
				if (r.length > 0) {
					oca = RegExp.$1;
				}
			}			
			attribs = [
				['href',    jqa.attr('href')],
				['target',  jqa.attr('target')],
				['title',   jqa.attr('title')],
				['onclick', oca]
			];
			a = $(this).wrap('<a></a>').parent();
			a.css({
				'text-decoration': 'none',
				'cursor': 'pointer'
			});
			for (i = 0; i < attribs.length; i++) {
				if (attribs[i][1] != undefined && attribs[i][1] != '') {
					if (attribs[i][0] == 'onclick') {
						var s = attribs[i][1];
						a.bind('click', function() {
							var es = 'window.open(' + s.toString() + ');';
							eval(es);
						});
					} else {
						a.attr(attribs[i][0], attribs[i][1]);
					}
				}
			}
			jqa.replaceWith('<span class="FakeLink">' + jqa.html() + '</span>');
		}
	});
});

