// array of links (you should add your link)
links = [
["http://www.net-security.org/insecuremag.php","<b>Download the new issue of (IN)SECURE Magazine today!</b>"],
];

// insert link
function insertRandomLink(class_name){
	var r = Math.floor(Math.random()*links.length);
	document.write("<a "+((class_name)?"class = '"+class_name+"'":"")+" href='"+links[r][0]+"'>"+links[r][1]+"</a>");
}

// show popup layer
function showPopup(o,file){
		var d;
		if (document.getElementById("_temp_popup")){
			d = document.getElementById("_temp_popup");
		} else {
			d = document.createElement("div");
			d.id = "_temp_popup";
			d.className="popup";
			d.innerHTML = '<iframe src="'+file+'" width="100%" height="100%" scrolling="no" frameborder="no" ></iframe>';
		}
		d.style.left = getLeftPos(o);
		d.style.top = getTopPos(o);
		document.body.appendChild(d);
		d.style.visibility="visible";
		d.onmouseout = function(event){
			var d = document.getElementById("_temp_popup");
			var e = event || window.event;
		    var target = e.relatedTarget || e.toElement;
			if(!isParent(target, d)) {
				d.style.visibility="hidden";
			}
		};
}

/* is parent have child? */
function isParent(child, parent) {
    if (!child || !parent) {
        return false;
    }
    while (true) {
        if (child == parent) {
            return true;
        }
        if (child.parentElement) {
            child = child.parentElement;
        } else if (child.parentNode) {
            child = child.parentNode;
        } else {
            return false;
        }
    }
}

// get left position of element
function getLeftPos(e)
{
	var nLeftPos = e.offsetLeft;
	var eParElement = e.offsetParent;
	while (eParElement != null) {
		nLeftPos += eParElement.offsetLeft;
		eParElement = eParElement.offsetParent;
	}
	return nLeftPos;
};

// get top position of element
function getTopPos(e)
{
	var nTopPos = e.offsetTop;
	var eParElement = e.offsetParent;
	while (eParElement != null) {
		nTopPos += eParElement.offsetTop;
		eParElement = eParElement.offsetParent;
	}
	return nTopPos;
};
