/**
* project customfuncs
*
* @author		Frank Schnappenberger
* @copyright	triple-i new media system design gmbh
* @version		0.0.1
*/

var gActiveSub = new Array();

/**
* init function after page load
*/
function InitPage()
{
	// adjust footer pos
	var body_height = Element.getHeight(document.body);
	var header_height = Element.getHeight('header');
	var viewport_height = GetViewportHeight();
	
	if(body_height<viewport_height-2){
		$('desk').style.height = (viewport_height-header_height-145)+'px';
	}
	
	DropdownEffect();
	
}

/**
* get viewport height
*/
function GetViewportHeight()
{
	if (window.innerHeight) return window.innerHeight;
	if (window.opera) return document.body.clientHeight;
	return document.documentElement.clientHeight;
}

/**
* simulates target blank in an accessible way
*
* use links: <a href="http://www.triple-i.de" onclick="return TargetBlank(this.href)">Link</a>
*
* @param	string		url
* @return	boolean		always false
*/
function TargetBlank (url) {
	var newwindow	= window.open(url, "newwindow"+Math.random(),"menubar=yes,location=yes,status=yes,scrollbars=yes,toolbar=yes,resizable=yes");
	newwindow.focus();
	return false;
}

/**
 * dropdown menue mit effekten
 */
function DropdownEffect() 
{
	var nav_root = $("nav");

	for (i=0; i<nav_root.childNodes.length; i++) {
		var node = nav_root.childNodes[i];
	
		if (node.nodeName=="LI") {
			var my_id = node.getElementsByTagName('a');
			if($(my_id[0].id+'sub')){
								
				$(my_id[0].id+'sub').style.display = 'none';

				node.onmouseover=function(){
					var my_id = this.getElementsByTagName('a');
					
					var queue = Effect.Queues.get(my_id[0].id);
					queue.each(function(e) { e.cancel() });

					new Effect.Appear(my_id[0].id+'sub',{ duration: 0.5, queue: {position: 'end',scope: my_id[0].id,limit:1}});
				}
				
				node.onmouseout=function(){
					var my_id = this.getElementsByTagName('a');
					
					new Effect.Fade(my_id[0].id+'sub',{ duration: 0.5, queue: {position: 'end',scope: my_id[0].id,limit:1}});
					gActiveSub[my_id[0].id+'sub'] = 'closing';
				}
				
				new Effect.Fade(my_id[0].id+'sub',{ duration: 0.0 });
			}
		}
	}
}
