$j(function(){
	$j('a[id^="popup_"], a[class^="popup_"], span.spanLink, span.spanImageLink').live("click", function (e) {
		e.preventDefault();

		var params = {};
		var tagName = $j(this).attr('tagName');
		var thishref = "";
		var classAttribute = $j(this).attr('class').toLowerCase();

		if (tagName == "A") {
			this.href.replace("&amp;","&").replace(/(?:&|\?)([^&=]*)=?([^&]*)/g, function($0,$1,$2){
				if($1){
					params[$1.toLowerCase()] = $2;
				}
			});

			thishref = this.href;
		} else if (tagName == "SPAN") {
			if (classAttribute.indexOf('spanlink') > -1) {
				thishref = location.protocol + '//' + location.host + $j(this).attr('href');
				thishref.replace("&amp;", "&").replace(/(?:&|\?)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {
					if ($1) {
						params[$1.toLowerCase()] = $2;
					}
				});
			} else {
				thishref = $j(this).attr('href');
				thishref.replace("&amp;", "&").replace(/(?:&|\?)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {
					if ($1) {
						params[$1.toLowerCase()] = $2;
					}
				});
			}
		}

		return window.open(
			thishref,
			params.wname || 'popup',
			'height=' + (params.h || 350) + ',' +
			'width=' + (params.w || 250) + ',' +
			'toolbar=' + (params.tbar || 'no') + ',' +
			'menubar=' + (params.mbar || 'no') + ',' +
			'scrollbars=' + (params.sbar || 'auto') + ',' +
			'resizable=' + (params.resize || 'auto') + ',' +
			'location=' + (params.lbar || 'no') + ',' +
			'directories=' + (params.dirs || 'no') + ',' +
			'status=' + (params.status || 'no')
		);
	});
});
