/*\------------------------------------------------------------------------

	>> souroti.gr
	>> 29/09/06				
	>> Kostis Sakkas				
		
------------------------------------------------------------------------\*/

window.onload	= function() {emailCloak(); bannerCloak();}




/*\------------------------------------------------------------------------
	
	Replaces the flash banner with a packshot for the drop down menu 
	to work properly
	
------------------------------------------------------------------------\*/

bannerCloak	=function(){
	if (document.getElementById){
		var el = document.getElementById("nav");
		var flashDiv = document.getElementById("flashbanner");
		var noflashDiv = document.getElementById("noflashbanner");
		if(el && flashDiv && noflashDiv){
			el.onmouseover=function(){flashDiv.style.display = 'none';	noflashDiv.style.display = 'block';}
			el.onmouseout=function(){flashDiv.style.display = 'block';	noflashDiv.style.display = 'none';}
			noflashDiv.onmouseover=function(){flashDiv.style.display = 'none';noflashDiv.style.display = 'block';}
			noflashDiv.onmouseout=function(){flashDiv.style.display = 'block';noflashDiv.style.display = 'none';}
		}
	}
}



/*\------------------------------------------------------------------------
	
	This function is used for the Suckerfish (flyout) menus
	Author : http://bmb.cameronmoll.be/
	
------------------------------------------------------------------------\*/


sfHover	=	function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


/*\------------------------------------------------------------------------
	
	menuExpandable.js - implements an expandable menu based on a HTML list
	Author: Dave Lindquist (http://www.gazingus.org)
	
------------------------------------------------------------------------\*/


if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    //if (window.opera) return; // I'm too tired

	actuator.parentNode.style.background = "url(../img/arrow-down-sm.gif) 90% 10px no-repeat";
    actuator.onclick = function() {
        var display = menu.style.display;
        this.parentNode.style.background =
            (display == "block") ? "url(../img/arrow-down-sm.gif) 90% 10px no-repeat" : "url(../img/arrow-up-sm.gif) 90% 10px no-repeat";
        menu.style.background = "url(/images/square.gif)";
        menu.style.display = (display == "block") ? "none" : "block";

        return false;
    }
}



/*\------------------------------------------------------------------------
	
	Opens new windows via rel="external"
	url : http://www.brucelawson.co.uk/index.php/2005/opening-links-in-new-windows-in-xhtml-strict/
	
------------------------------------------------------------------------\*/

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.target = "_blank";
			anchor.title = (anchor.title != "") ? anchor.title+" (Ανοίγει σε νέο παράθυρο)" : "Ανοίγει σε νέο παράθυρο";
			anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
		}
	}
}


/*\------------------------------------------------------------------------
	
	Replaces email addresses with the title attr.
	credits : initial idea from http://www.badboy.ro/articles/2005-01-25/index.php
	
------------------------------------------------------------------------\*/

emailCloak = function() {
	if (document.getElementById) {
		var alltags = document.all? document.all : document.getElementsByTagName("*");
		for (i=0; i < alltags.length; i++) {
			if (alltags[i].className == "emailCloak") {
				var oldText = alltags[i].firstChild;
				var emailAddress = alltags[i].firstChild.nodeValue;
				var user = emailAddress.substring(0, emailAddress.indexOf("("));
				var website = emailAddress.substring(emailAddress.indexOf(")")+1, emailAddress.length);
				var newText = user+"@"+website;
			  	var a = document.createElement("a");
			  	a.href = "mailto:"+newText;
				var address = document.createTextNode(newText);
				a.appendChild(address);
				alltags[i].replaceChild(a,oldText);
			}
		}
	}
}

