var SMP = Aris.extend({
	maxItems: 7,
	pageReady: function() {
		var $ = DOM.get;
		
		//show our flash movie if we can
		if ( typeof SWFObject == 'function' && $('images') ) {
			var so = new SWFObject("/flash/SlideShow.swf", "flashHeader", "607", "376", "8", "#ffffff", true);
			so.addParam("wmode", "transparent");
			so.addParam("flashvars", "xmlfile=/flash/SlideShow.xml");
			so.addParam("useExpressInstall", "/playerProductInstall.swf");
			so.write("images");
		    var so = new SWFObject("/!images/flash/mp_flash_sparkles_2008.swf", "flashHeader", "960", "273", "8", "#ffffff", true);
			so.addParam("wmode", "transparent");
			so.write("promos");
		}
		//show photo gallery
		if ( typeof SWFObject == 'function' && $('photogallery') ) {
			var so = new SWFObject("/!UserFiles/photo-gallery/Album.swf", "flashHeader", "620", "400", "8", "#ffffff", true);
			so.addParam("wmode", "transparent");
			so.addParam("flashvars", "xmlfile=/!UserFiles/photo-gallery/PhotoAlbum.xml");
			so.addParam("useExpressInstall", "/playerProductInstall.swf");
			so.write("photogallery");
		}
		//show snow gallery
		if ( typeof SWFObject == 'function' && $('snowgallery') ) {
			var so = new SWFObject("/!UserFiles/snow-photos/Album.swf", "flashHeader", "691", "400", "8", "#ffffff", true);
			so.addParam("wmode", "transparent");
			so.addParam("flashvars", "xmlfile=/!UserFiles/snow-photos/PhotoAlbum.xml");
			so.addParam("useExpressInstall", "/playerProductInstall.swf");
			so.write("snowgallery");
		}
		
		//set up our nav menu
		var navRoot = $('nav');
		if ( !navRoot ) return;
		
		// cutoff point at which to split the menus
		var max = this.maxItems;
		//go through all the uls
		Array.from(navRoot.getElementsByTagName('ul')).forEach( function(ul, idx) {
			var lis = ul.getElementsByTagName('li');
			var liCount = lis.length
			//exit if we are dealing with less than our max
			if ( liCount <= max ) {
				if ( window.ActiveXObject ) { 
					DOM.setStyle(ul, 'width', DOM.getDim(ul).width + 'px');
				}
				return;
			};
			
			//divide up the content into two halves
			liCount = liCount / 2;
			
			//create a container to put our splits into
			var menuCont = document.createElement('div');
			ul.parentNode.appendChild(menuCont);
			
			//clone the current dropdown (but not children)
			var ul2 = ul.cloneNode(false);
			DOM.addClass(ul, 'menu col0');
			DOM.addClass(ul2, 'menu col1');
			
			//move the current menu into our container along with the new one
			DOM.adopt(menuCont, ul);
			menuCont.appendChild(ul2);
			
			//divide up the items
			Array.from(lis).forEach(function(li,idx2) {
				if ( idx2 >= liCount )
					DOM.adopt(ul2,li);
			});
			
			//now work out height so that both menu's appear the same; make sure the fist menu is wide enough;
			var d1 = DOM.getDim(ul);
			var d2 = DOM.getDim(ul2);
			if ( d1.width < 160 )
				d1.width = 160;			
			if ( d1.height > d2.height )
				d2.height = d1.height;
			else
				d1.height = d2.height;
			d2.left = (d1.width-1);
			forEach(d1, function(val, idx, obj) { obj[idx] = val +'px'; });
			forEach(d2, function(val, idx, obj) { obj[idx] = val +'px'; });
			DOM.setStyle(ul, d1);
			DOM.setStyle(ul2, d2);
			
			// attach the sucker-fish programing in IE
			if (!window.attachEvent) return;
			var sfEls = DOM.get('nav').getElementsByTagName("dd");
			forEach(sfEls, function(sfEl) {
				sfEl.onmouseover=function() {
					DOM.addClass(this,"IEhover");
				}
				sfEl.onmouseout=function() {
					DOM.removeClass(this,"IEhover");
				}
			});

		});
	}
});
