var ajaxLoader = function(srcUrl, targetEl) {	// ~=### AJAX Function ###=~
	var ajaxGet = new Request.HTML({				//	set new request
		method: 'get',								//	set request type
		url: srcUrl,								//	set source url on server
		evalScripts: false,							//	don't process page scripts
		data: { 'do' : '1' },						// dummy to fill server call
	/*	onRequest: function() {alert(srcEl)},			//	function to perform on start of request		*/
		update: $(targetEl),								// element to update with 'response'
		onComplete: function(response) {catchLinks.delay(500)}	//	function to perform on completion of request
	}).send();												//	confirm and process request
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var catchLinks = function() {		// ~=### Catch New Links from AJAX pages ###=~
	$('main').getElements('a.ajaxMe').addEvent('click', function(event) {	// get links that need ajax
		event.stop();									// prevent browser from processing link
		ajaxLoader(this.get('href'), $('main'));		// get ajax to process link
		window.scroll(0, 0);						// scroll to top of window (ref = coords)
	});
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var changeMenu = function(oldMenu,newMenu,pos) {	// ~=### Change Active Sub Menu ###=~
	$(oldMenu).tween('height', '28px');					// shrink current active menu
	$(oldMenu).removeClass('activeSubMenu');			// remove active class
	$(newMenu).addClass('activeSubMenu');				// add active class
	$(newMenu).tween('height', pos+45);					// expand new menu to past the last link
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var doDate = function() {			// ~=### Print Date Stamp ###=~
	var dNow = new Date().format("%A %d%o %b, %Y"); 	//	Get Current Date & Time -> convert to local string
	$('timeDate').set('text', dNow);			//	Put Date in page element
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var setLinks = function() {		// ~=### Set Links Events ###=~	(instead of using css)
//~~~~~### Header Links ###~~~~~
	$$('a.mainLink').setStyles({
		'color': '#EEE',
		'text-decoration': 'none'
	});
	
	$$('a.mainLink').addEvent('mouseenter', function() {
		this.setStyle('color', 'maroon');
	});
	
	$$('a.mainLink').addEvent('mouseleave', function() {
		this.setStyle('color', '#EEE');
	});
	
	$$('a.mainLink').addEvent('click', function(event) {
		event.stop();
		ajaxLoader(this.get('href'), $('main'));
	});

//~~~~~### Sub Menu Links ###~~~~~
	$$('a.subLink').setStyles({
		'color': 'white',
		'text-decoration': 'none'
	});
	
	$$('a.subLink').addEvent('mouseenter', function() {
		this.setStyle('color', 'fuchsia');
	});
	
	$$('a.subLink').addEvent('mouseleave', function() {
		this.setStyle('color', 'white');
	});
	
	$$('a.subLink').addEvent('click', function(event) {	// ~=# Submenu Link calls AJAX and Changes Menu #=~
		event.stop();										//	stop browser from following links href
		ajaxLoader(this.get('href'), $('main'));			//	use ajax function to process links href
		
		var thisMenu = this.getParent('div.subMenu').get('id');		// get clicked link's sub menu ID
		
		if($(thisMenu).hasClass('activeSubMenu')!==true) {		//	check not active sub menu
			var activeMenu = $('sidebar').getElement('.activeSubMenu').get('id');		// get active sub menu's ID
			var toHere = $(thisMenu).getLast('a').getPosition($(thisMenu));	//	get position of last link in new menu
			changeMenu(activeMenu,thisMenu,toHere.y);		// call to 'changeMenu' sub routine
		}
	});
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var setSubMenus = function() {		// ~=### Sub Menu Events ###=~

	$$('div.subMenu').addEvent('mouseenter', function() {	// ~=# Mouse Enter #=~
		if(this.hasClass('activeSubMenu')!==true) {				//	if not active menu
			var toHere = this.getLast('a').getPosition(this);	//	get position of last link in sub menu
			this.tween('height', toHere.y+45); 					//	grow height to 30px past the last link
		}
	});
	
	$$('div.subMenu').addEvent('mouseleave', function() {	// ~=# Mouse Leave #=~
		if(this.hasClass('activeSubMenu')!==true) {				//	if not active menu
			this.tween('height', '28px');						//	shrink height back to 28px
		}
	});
	
	$$('div.subMenu').addEvent('click', function() {		// ~=# Mouse Click #=~
		if(this.hasClass('activeSubMenu')!==true) {				//	if not active menu
			var thisMenu = this.get('id');						// get this menu's ID
			var activeMenu = $('sidebar').getElement('.activeSubMenu').get('id');		//	get active menu's ID
			var toHere = this.getLast('a').getPosition(this);		//	get position of last link in sub menu
			changeMenu(activeMenu,thisMenu,toHere.y);		// call to 'changeMenu' sub routine
		}
	});
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		//~~~### END OF FILE ###~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~