/*\------------------------------------------------------------------------

	>> sync.gr
	>> 17/08/06				
	>> Kostis Sakkas				
		
------------------------------------------------------------------------\*/


window.onload	= function() { setFooter();}
window.onresize = function() { setFooter();}
		



function addTag(tag) {
    var taginput = document.getElementById("tagInput");
    if (taginput.value.length > 1) taginput.value = taginput.value + ', ';
    taginput.value = taginput.value + tag;
}

/*\------------------------------------------------------------------------
	
	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';
		}
	}
}



/*\------------------------------------------------------------------------
	
	Position footer div at the bottom of the page using DOM
	
	Source from the precious AListApart.com
	Article : Exploring Footers
	URL : http://www.alistapart.com/articles/footers/

------------------------------------------------------------------------\*/

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
		
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var menuHeight = $('menu').offsetHeight;
			var membersHeight = $('members-module').offsetHeight;
			var headerHeight = $('header').offsetHeight;
			var contentHeight = $('content').offsetHeight;
			var footerElement = $('footer');
			var footerHeight  = footerElement.offsetHeight;
			var c = (menuHeight + membersHeight + headerHeight + contentHeight);
			/*
			alert(" MENU : " + menuHeight
				  + "\r\nMEMBER : " + membersHeight
				  + "\r\nHEADER : " + headerHeight
				  + "\r\nCONTENT : " + contentHeight
				  + "\r\nWRAPPER : " + c
				  + "\r\nFOOTER : " + footerHeight
				  + "\r\nWINDOW : " + windowHeight);
			*/
			if (windowHeight - (c + footerHeight) >= 0) 
				footerElement.style.height = (windowHeight - c - 20) + 'px';
			return null;
		}
	}
}
