var current = 0, over = true;

function ExternalLinks() {
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
            anchor.onclick = function(x) {
                var p = x;
                return function() {
                    over = false;
                    Hide();
                    var w = window.open(p); 
                    if(!w)
                        alert("אנא וודא שחוסם הפופ אפים אינו מופעל");
                    return false;
                }
            }(anchor.getAttribute("href"));
    }
}

function Show(id) {
    if ( current > 0 && current != id)
        document.getElementById("sub" + current).style.display = "none";
		
    current = id;
	
	if (document.getElementById("sub" + current).style.display == "block")
		document.getElementById("sub" + current).style.display = "none"
	else
		document.getElementById("sub" + current).style.display = "block";
}

function Hide() {
    if(!over && current > 0)
        document.getElementById("sub" + current).style.display = "none";
    over = true;
}

function Over() {
    over = true;
}

function Out() {
    over = false;
}

window.onload = ExternalLinks;
window.document.onclick = Hide;
