// (C) Stanis Latrekc, 2005
oldLinksFunc = OnLoadHitchs;
OnLoadHitchs = function() {
	if(typeof oldLinksFunc == 'function') {
		oldLinksFunc();
	}

	as = ArrayFromCollection(document.getElementsByTagName('a'));

	for(i in as) {
		if(typeof as[i] === 'object') {
			a = as[i];

			if(a.href && a.protocol === 'http:' && a.hostname != window.location.host && !a.target.length) {
				a.setAttribute('target', '_blank');
			}

			a.popup = a.getAttribute('popup');

			if(a.protocol === 'http:' && a.popup != null && a.popup != '') {
				a.onclick = function(e) {
					var popup = this.popup.split(' ');

					var w = popup[0];
					var h = typeof popup[1] != 'undefined' ? popup[1] : popup[0];
					if(typeof popup[2] != 'undefined') {
						switch(popup[2]) {
							case 'image':
								return openImagePopupWindow(this.href, w, h);
								break;
						}
					} else {
						return openPopupWindow(this.href, w, h);
					}
				}
			}
		}
	}
}

function openPopupWindow(url, width, height) {
	var w = window.open(url,'_blank','toolbar=no,status=no,location=no,menubar=no,resizable=yes,scrollbars=yes,width='+width+',height='+height);
	w.focus();
	return false;
}

function openImagePopupWindow(url, width, height) {
	var w = window.open(url, null, 'width='+width+', height='+height+', toolbar=no, status=no, location=no, menubar=no, resizable=yes, scrollbars=no');
	w.document.open();
	w.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'+"\n"+'<HTML><HEAD><TITLE>'+url+'</TITLE><STYLE>HTML, BODY { padding: 0; margin: 0; background: #000000;  height: 100%;}</STYLE></HEAD><BODY onclick="window.close();"><IMG src="'+url+'" width="'+width+'" height="'+height+'" border="0"></BODY></HTML>');
	w.document.close();
	w.focus();
	return false;
}