// JavaScript Document

function markActive() {

      //Take the current URL and split it into chunks at each slash
      var currentURL = window.location.toString().split("/"); //split url
	  var page = currentURL[currentURL.length-1].split("."); //split the last element (page) of url
	  
	  var pageName = page[0]; //get page name after .html or .php?foo=bar#blabla

	  //Returns all anchors within myElement, where href is starting with pageName.
	  
	  var activeLink = $('navi').getElements('a[href^='+pageName+']');
	  
	  //set link class to active
	  if(activeLink) {
		  activeLink.addClass('active');
	  }
};


/*
	
	Author:  		David Walsh
	Last Updated:  3/16/2008
	URL:				http://davidwalsh.name/mootools-12-openlinks-class
	
*/
// a lovely fast case-insensitive regexp build from file extensions




window.addEvent('domready', function() {
	
	markActive(); 
	
	if($chk(document.getElementById('ACS_Comments_Container'))) {
			ACS_init();
	}
	
	if($chk(document.getElementById('news'))) {
			$$('.newsArticle:odd').addClass('odd');
			$$('.newsArticle:even').addClass('even');
	}
	
	new SmoothScroll({ duration:600 }, window); //700 milliseconds to get there
	
	
	var ext	= $$('a.external');
	ext.each(function(e){
		e.addEvent('click', function(ev){
			ev	= new Event(ev).stop();
			window.open(e.getProperty('href'),'_blank');
		});
	});

	
	
	
});


