// JavaScript Document

function init(){
	
	//handle first set of accordions
	var stretchers = document.getElementsByClassName('stretcher'); //div that stretches
	var toggles = document.getElementsByClassName('display'); //where I click on
	
	//accordion effect
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: true, duration: 400}
	);
	
	myIMG = new fx.Opacity('boxy', {opacity:true, duration: 400});
	
	$up = 0;
	loadMe('home');
	$('content').style.display = "none";
	//$('section').style.visibility = "hidden";
	$('hometext').style.display = "block";
	
}


function loadMe(url){
	//change title text
	if ($up == 0) {
		myIMG.toggle(); //hide old pic
		$up = 1;
	}
	if (url != "home") {
		setTimeout(function() {$('hometext').style.display = "none"}, 700);
		setTimeout(function() {$('content').style.display = "block"}, 700);
		//setTimeout(function() {$('section').style.visibility = "visible"}, 900);
	} else {
		setTimeout(function() {$('hometext').style.display = "block"}, 700);
		setTimeout(function() {$('content').style.display = "none"}, 700);
		//setTimeout(function() {$('section').style.visibility = "hidden"}, 100);
	}
	setTimeout(function() {$('boxy').style.backgroundImage = "url(images/" + url + "_pic.jpg)"}, 1000); //change pic
	if ($up == 1) {
		setTimeout("myIMG.toggle()",1600); //show new pic
		$up = 0;
	}
	
	//load url into content DIV
	if (url != "home") {
		setTimeout(function() {new ajax(url + '.htm', {update: $('right'), method: 'get'})}, 1600);
	} else {
		setTimeout(function() {new ajax(url + '.htm', {update: $('right'), method: 'get'})}, 1600);
	}
	
	
}


window.onload = function(){
	
	$S('#menus li a').action({
		
		onclick: function(){
			var llabel = this.innerHTML;
			$S('#menus li a').each(function(element){
				element.style.backgroundPosition = '';
			});
			this.style.backgroundPosition = 'bottom';
		}
	});
	
	$S('#submenu li a').action({
		
		onclick: function(){
			var sllabel = this.innerHTML;
			$S('#submenu li a').each(function(element){
				element.style.backgroundPosition = '';
			});
			this.style.backgroundPosition = 'bottom';

		}
	});
	
	$S('#newbuttons li a').action({
		
		onclick: function(){
			var sllabel = this.innerHTML;
			$S('#newbuttons li a').each(function(element){
				element.style.backgroundPosition = '';
			});
			this.style.backgroundPosition = 'bottom';

		}
	});
	
	$S('#menus li a').action({
		onmouseover: function(){
			var llabel = this.innerHTML;
			
			$S('#label').each(function(element){				
				element.innerHTML = llabel;
			});
		}
	});
	
	$S('#submenu li a').action({
		onmouseover: function(){
			var sllabel = this.innerHTML;
			
			$S('#label').each(function(element){				
				element.innerHTML = sllabel;
			});
		}
	});
	
	$S('#newbuttons li a').action({
		onmouseover: function(){
			var nllabel = this.innerHTML;
			
			$S('#label').each(function(element){				
				element.innerHTML = nllabel;
			});
		}
	});
}
	