window.addEvent('domready', function(){
	
	var activeSection = $('activeSection').value;
	if (activeSection == "default") {activeSection = 0;}
	if (activeSection == "financial") {activeSection = 1;}
	if (activeSection == "office") {activeSection = 2;}
	if (activeSection == "healthcare") {activeSection = 3;}
	if (activeSection == "scientific") {activeSection = 4;}
	if (activeSection == "technical") {activeSection = 5;}
	if (activeSection == "industrial") {activeSection = 6;}
	if (activeSection == "group") {activeSection = 7;}
	
	var myAccordion = new Accordion($('#sidebar'), '#sidebar>ul>li.pagenav>h2', '#sidebar>ul>li.pagenav>ul', {
		opacity: true,
		alwaysHide: true,
		show: activeSection
	});
	
	new SlideList($('header-submenu').getElement('ul'));
	
	var items = $$('#sidebar>ul>li.pagenav>h2');
	var fx = new Fx.Elements(items, {wait: false, duration: 300});
	
	items.each(function(item, i){
		item.addEvents({
			mouseleave: function(){
				this.highlight('#fff', '#e7ebee');
			fx.start();
				
			}
		});
	});
	
	
});

window.addEvent('load', function() {
	if (document.getElementById("services")) {
		$('video').addEvent('click', function() { Mediabox.open('/wp-content/themes/alliance/video.html', 'Welcome to Alliance Staffing Solutions', '640 360'); } );
		
		$('service-financial').addEvent('click', function() { location.href='/businesses/alliance-financial/home/' } );
		$('service-office').addEvent('click', function() { location.href='/businesses/alliance-office/home/' } );
		$('service-healthcare').addEvent('click', function() { location.href='/businesses/alliance-healthcare/home/' } );
		$('service-scientific').addEvent('click', function() { location.href='/businesses/alliance-scientific/home/' } );
		$('service-technical').addEvent('click', function() { location.href='/businesses/alliance-technical/home/' } );
		$('service-industrial').addEvent('click', function() { location.href='/businesses/alliance-industrial/home/' } );
		$('service-group').addEvent('click', function() { location.href='/businesses/alliance-search/home/' } );
	}
	
	if (document.getElementById("rsslink")) {
		var rsslink = $('rsslink');
		var fx = new Fx.Elements(rsslink, {wait: false, duration: 400});
		
		$('rsslink').addEvents({
			mouseleave: function(){
				this.highlight('#73b7b2', '#008d86');
			fx.start();
				
			}
		});
	}
	
	if (Browser.Engine.name == 'trident' && Browser.Engine.version == 4) {var isIE6 = "true";} else {var isIE6 = "false";}
	
	if ($$(".danSlide-visible") && isIE6 == "false") {
		var links = $$('div.danSlide-visible');
		var contents = $$('div.danSlide-hidden');
	   
	    //Crashes IE for some reason...
		//contents.set('slide',{
		//	duration:600,
		//	transition:Fx.Transitions.Back.easeIn
		//});
	   
		contents.slide('hide');
	 
		links.addEvent('click',function(e){
			e.stop();
			var index = links.indexOf(this);
			if(!contents.some(function(content,i){
				var slide = content.get('slide');
				if(slide.open && i != index){
					slide.slideOut().chain(function(){contents[index].slide('in')});
                	return true;
				}
				else if(i != index)
					slide.slideOut();
			})){
				var slide = contents[index].get('slide');
				contents[index].slide((slide.open) ? 'out' : 'in');
			}
		});
	}
	
	if (document.getElementById("slideshow")) {
		new Slideshow('slideshow', ['photo-home.jpg', 'photo-financial.jpg', 'photo-office.jpg', 'photo-healthcare.jpg', 'photo-scientific.jpg', 'photo-technical.jpg', 'photo-industrial.jpg', 'photo-group.jpg'], { controller: false, thumbnails: false, height: 265, width: 580, duration: 1100, delay: 4000, hu: '/wp-content/themes/alliance/images/' });
		new Slideshow('logoslideshow', ['logo-home.jpg', 'logo-financial.jpg', 'logo-office.jpg', 'logo-healthcare.jpg', 'logo-scientific.jpg', 'logo-technical.jpg', 'logo-industrial.jpg', 'logo-group.jpg'], { controller: false, thumbnails: false, height: 265, width: 327, duration: 1100, delay: 4000, hu: '/wp-content/themes/alliance/images/' });
	}
});