function addEvent(o,ev,fn){
	(o.attachEvent) ? o.attachEvent("on"+ev, fn) : o.addEventListener(ev, fn, false);
} 
function removeEvent(o,ev,fn,flag){
	(o.removeEvent) ? o.removeEvent("on"+ev, fn) : o.removeEventListener(ev, fn, false);
} 

function getCssProperty(o,property){
	var computedStyle;
	if (typeof o.currentStyle != 'undefined'){
		computedStyle = o.currentStyle;
	} else {
		computedStyle = document.defaultView.getComputedStyle(o, null);
	}
	if(property=="float")
		return computedStyle["styleFloat"] || computedStyle["cssFloat"] 
	return computedStyle[property];
}

ExternalLinkMarker=new function(){
	var createExternalLinkMarker=function(){
		var img=(img)?img:document.createElement("img");
		img.className="externalLinkMarker";
		img.src=window.backendContextPath+"/frontend/images/0.gif";
		img.style.backgroundImage="url("+window.backendContextPath+"/frontend/images/ico-external-link.gif"+")";
		img.style.backgroundRepeat="no-repeat";
		img.style.backgroundPosition="center center";
		img.style.height="9px";
		img.style.width="12px";
		img.style.margin="0 0 0 2px";
		img.style.border="0 none #fff";
		img.style.verticalAlign="middle";
		return img;
	}
	var addExternalLinkMarker=function(o,img){
		var img=(img)?img:createExternalLinkMarker();
		if(getCssProperty(o,"display")!="block" || getCssProperty(o,"float")!="none"){
			if(getCssProperty(o,"lineHeight")!="normal" && getCssProperty(o,"lineHeight")!="auto"){
				img.style.height=getCssProperty(o,"lineHeight");
			}
			img.style.position="static";
			o.appendChild(img);
		}else{
			if(getCssProperty(o,"position")!="absolute"){
				o.style.position="relative"
			}
			img.style.position="absolute";
			img.style.top="0";
			img.style.right="0";
			img.style.bottom="auto";
			img.style.left="auto";

			o.appendChild(img);
		}
	};
	this.addClassToExternalUrl=function() {
		var links = document.getElementsByTagName("A");
		var currentDomain = document.location.href.match(/:\/\/(.[^/]+)/)[1];
		for (var i = 0; i < links.length; i++){
			var mch = links[i].href.match(/:\/\/(.[^/]+)/);
			if (mch && mch[1] != currentDomain) {
				if(links[i].className != "") {
					links[i].className = links[i].className + " " + "externalURL";
				} else {
					links[i].className = "externalURL";
				}
				addExternalLinkMarker(links[i]);
			}
		}
	};
}();
addEvent(window,"load",ExternalLinkMarker.addClassToExternalUrl);

