Event.observe(window, 'load', function() {
	// do some CSS magic for no javascript version
	Element.addClassName('swapnav', 'hasjs');


	//-------- SWAPPER ----------
	
	// some DOM stuff
	var triggers = $$('#swapnav .swapnav');
	var contents = $$('#swapnav .swapcontent');

	// all the important stuff
	if (triggers.length>0 && contents.length>0) {
		
		var swapper = new FadeSwap(triggers, contents, 'click');

		// fix the local nav
		var localnav = $$('#swapnav #localnav ul li a');
		if (localnav.length>0) {
			for (var i=0; i<localnav.length; i++) {
				var section = document.location.toString().match(/(.*)#/);
				section = (section) ? section[1] : document.location.toString();
				if (localnav[i].href.match(section)) localnav[i].href += '#overview';
			}
		}

		// fix the anchor links for Safari
		// and make anchor links fade and swap instead of browser default
		var anchors = new AnchorFix(triggers, contents, swapper);
		
		// find the default
		var id = 0;
		if (document.location.hash) {
			var initial = document.location.hash;
			initial = initial.match(/#(.*)/)[1];
			var doesContentExist = anchors.doesContentExist(initial)
			if (doesContentExist) {
				id = doesContentExist.index;
			}
		}

		// swap to the default
		swapper.swapContent(null, id);
	}
	
	//-------- SOLUTIONS PROFILES ----------
	if($('profiles')) new ShowProfiles($('profiles'));


	
	//-------- PROFILES IMAGE/MOVIE POPUPS ----------
	
	// image gallery overlay
    var images = $$('#swapnav .sidebar .box.gallery li a.overlaythumb');
    imageGallery = (images.length>0) ? new AC.ImageOverlay(images) : false;

	Event.onDOMReady(function() {
		var movies = $$('.watchvideo');
		if (movies.length > 0) var overlays = new AC.MovieOverlay(movies, { moviewidth:640, movieheight:360 });
		if (overlays) AC.OverlayInit(overlays);
	});


}, false); 