/**
function IEHoverPseudo()
{

	var navItems = document.getElementById("nav").getElementsByTagName("li");
	
	for (var i=0; i<navItems.length; i++)
	{
		if(navItems[i].className == "menuparent")
		{
			navItems[i].onclick=function() { 
			     
				 if (this.className.indexOf('over') < 0) {
				   this.className += " over";
				 } else {
				   this.className = "menuparent";				 
				 }
				 
			   }
			//navItems[i].onmouseout=function() { this.className = "menuparent"; }
		}
	}

}
window.onload = IEHoverPseudo;

**/

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function showSubMenu(el) {

	return function() {
	  
	  /** 
	  alert(is_visible(el));
	  
	  if (is_visible(el)) {
	  	el.style.display = 'block'
	  } else {
	  	el.style.display = 'none';
	  }
	  
	  alert(is_visible(el));
	  
	  **/
	  
	  alert(el.getAttribute("id"));
	  
	  if (el.style.display != 'block') {
	    el.style.display = 'block';
	  } else {
	  	el.style.display = 'none';
	  }
	  
	  //Element.toggle(el);
	  
	}

}

function hideSubMenu(el) {

	return function() {
	  el.style.display = 'none';
	}

}

function set_parent_links() {

	parent_links = document.getElementsByClassName("parentlink");
	
	
	for(i=0;i<parent_links.length;i++) {
	  //alert(parent_links[i].tagName);
	  
	  parent_links[i].href="#";
	}

}

function is_visible(el) {

	if (el.style.display == 'none') {
		return false;
	} else {
		return true;
	}

}

function toggleSubMenu(subMenu) {


	  el = document.getElementById(subMenu);

	 
	 
	  if (!el) {
	  	alert("Element not found");
		return false;
	  }

	  if (subMenu == 'facilities_submenu') {
	    if (Element.hasClassName(document.getElementById('facilities_link'), 'current')) {
		  Element.removeClassName(document.getElementById('facilities_link'), 'current');
		  Element.removeClassName(document.getElementById('facilities_parent_link'), 'current');		
		} else {
 	      Element.addClassName(document.getElementById('facilities_link'), 'current');
		  Element.addClassName(document.getElementById('facilities_parent_link'), 'current');
		}
		
	  }
	  
	  if (subMenu == 'contact_submenu') {
	    if (Element.hasClassName(document.getElementById('contact_link'), 'current')) {
		  Element.removeClassName(document.getElementById('contact_link'), 'current');
		  Element.removeClassName(document.getElementById('contact_parent_link'), 'current');		
		} else {
 	      Element.addClassName(document.getElementById('contact_link'), 'current');
		  Element.addClassName(document.getElementById('contact_parent_link'), 'current');
		}
		
	  }
	  
	  if (el.style.display != 'block') {
	    el.style.display = 'block';
	  } else {
	  	el.style.display = 'none';
	  }

}

/**
function IEHoverPseudo()
{

	var navItems = document.getElementById("nav").getElementsByTagName("li");
	
	set_parent_links();
				
	for (var i=0; i<navItems.length; i++)
	{
		
		hasSubMenu = navItems[i].getElementsByTagName("ul");
		
		alert(hasSubMenu.length);
		
		//alert(hasSubMenu.length);
	
		//if(navItems[i].className == "menuparent")
		if (hasSubMenu.length > 0) {
			alert(hasSubMenu.length);
			navItems[i].onclick=showSubMenu(hasSubMenu[0]);
		}
	}

}
**/



var ScrollLinks = {
	currentHash: false,
	start: function(){
		this.scroll = new fx.Scroll({duration: 1500, transition: fx.sineOut, onComplete: function(){this.end();}.bind(this)});
		this.allinks = $c(document.getElementsByTagName('a'));
		this.allinks.each(function(lnk){
			if ((lnk.href && lnk.href.indexOf('#') != -1) && ( (lnk.pathname == location.pathname) 
				|| ('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) {
				lnk.onclick = function(){
					ScrollLinks.scroll.clearTimer();
					this.initialHref = this.href;
					this.initialHash = this.hash;
					this.href = "javascript:void(0)";
					setTimeout(function(){this.href = this.initialHref;}.bind(this), 200);
					ScrollLinks.go(this);
				}
			}
		});
	},

	go: function(link){
		this.currentHash = link.initialHash.slice(1);
		if (this.currentHash) {
			this.allinks.each(function(lnk){
				if (lnk.id == ScrollLinks.currentHash){
					if (window.opera) lnk =  [lnk].find('parentNode');
					ScrollLinks.scroll.scrollTo(lnk);
					return;
				}
			});
		}
	},

	end: function(){
		if (!/Konqueror|Safari|KHTML/.test(navigator.userAgent)) window.location.hash = "#"+this.currentHash;
		this.currentHash = false;
	}
}


addLoadEvent(set_parent_links);


