function buildPopups(sw) {
	var d = document;
	if (d.getElementById && d.getElementsByTagName) {
		for (var i = 0; i < d.getElementsByTagName('a').length; i++) {
			var this_link = d.getElementsByTagName('a')[i];
			var this_href = this_link.getAttribute('href');
			var rel = this_link.getAttribute('rel');
			if (this_href && rel) {
				rel = rel.split(' ');
				if (rel && rel[0] == sw) {
					var w = (rel[1]) ? rel[1] : 640;
					var h = (rel[2]) ? rel[2] : 480;
					this_link.setAttribute('onclick', 'window.open(\'' + this_href + '\', \'win-' + this_href + '\', \'width=' + w + ',height=' + h + ',toolbar=no,menubar=no,resizable=yes\')\; return false\;');
				}
			}
		}
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

addLoadEvent(function() {
	buildPopups('image')
});
