
MooTools.More={version:"1.2.4.4",build:"6f6057dc645fdb7547689183b2311063bd653ddf"};Fx.Scroll=new Class({Extends:Fx,options:{offset:{x:0,y:0},wheelStops:true},initialize:function(b,a){this.element=this.subject=document.id(b);
this.parent(a);var d=this.cancel.bind(this,false);if($type(this.element)!="element"){this.element=document.id(this.element.getDocument().body);}var c=this.element;
if(this.options.wheelStops){this.addEvent("start",function(){c.addEvent("mousewheel",d);},true);this.addEvent("complete",function(){c.removeEvent("mousewheel",d);
},true);}},set:function(){var a=Array.flatten(arguments);if(Browser.Engine.gecko){a=[Math.round(a[0]),Math.round(a[1])];}this.element.scrollTo(a[0],a[1]);
},compute:function(c,b,a){return[0,1].map(function(d){return Fx.compute(c[d],b[d],a);});},start:function(c,g){if(!this.check(c,g)){return this;}var e=this.element.getScrollSize(),b=this.element.getScroll(),d={x:c,y:g};
for(var f in d){var a=e[f];if($chk(d[f])){d[f]=($type(d[f])=="number")?d[f]:a;}else{d[f]=b[f];}d[f]+=this.options.offset[f];}return this.parent([b.x,b.y],[d.x,d.y]);
},toTop:function(){return this.start(false,0);},toLeft:function(){return this.start(0,false);},toRight:function(){return this.start("right",false);},toBottom:function(){return this.start(false,"bottom");
},toElement:function(b){var a=document.id(b).getPosition(this.element);return this.start(a.x,a.y);},scrollIntoView:function(c,e,d){e=e?$splat(e):["x","y"];
var h={};c=document.id(c);var f=c.getPosition(this.element);var i=c.getSize();var g=this.element.getScroll();var a=this.element.getSize();var b={x:f.x+i.x,y:f.y+i.y};
["x","y"].each(function(j){if(e.contains(j)){if(b[j]>g[j]+a[j]){h[j]=b[j]-a[j];}if(f[j]<g[j]){h[j]=f[j];}}if(h[j]==null){h[j]=g[j];}if(d&&d[j]){h[j]=h[j]+d[j];
}},this);if(h.x!=g.x||h.y!=g.y){this.start(h.x,h.y);}return this;},scrollToCenter:function(c,e,d){e=e?$splat(e):["x","y"];c=$(c);var h={},f=c.getPosition(this.element),i=c.getSize(),g=this.element.getScroll(),a=this.element.getSize(),b={x:f.x+i.x,y:f.y+i.y};
["x","y"].each(function(j){if(e.contains(j)){h[j]=f[j]-(a[j]-i[j])/2;}if(h[j]==null){h[j]=g[j];}if(d&&d[j]){h[j]=h[j]+d[j];}},this);if(h.x!=g.x||h.y!=g.y){this.start(h.x,h.y);
}return this;}});

rufferLoad = function(){

	// class to hold a cache of data returned
	var Cache = new Class({
	
		initialize: function(){
			this.cache = new Hash({});
		},
	
		get: function(index){
			if (!this.cache.has(index)) return false;
			return this.cache.get(index);
		},
		
		set: function(index,value){
			return this.cache.set(index,value);
		}
	
	});
	
	// startup cache
	cache = new Cache();

	// variable to hold last loaded hashtag
	myhash = '';
	
	// variable to hold last loaded hashtag as array
	myhashparts = [];
	
	// animate - quicklinks don't animate, so they set this to false
	animate = location.hash.replace('#', '') == '' ? true : false;
	
	if (useFlash && location.hash.replace('#', '') == ''){
	
		// animations
		frontanimation = new Swiff(
			'images/front-animation.swf',
			{
				container:$('swf'),
				width:254,
				height:407,
				params:{
					wMode: 'transparent'
				}
			}
		);
	
	} else if (location.hash.replace('#', '') == ''){
		$('swf').set('html', '<img src="images/welcome.png" alt="bowing man" />');
	}
	
	// in animation
	window.inanimation = false;
	
	// function to call on sequence finish
	sequenceFinish = function(){ 
		animate = true; 
		(function(){ window.inanimation = false; }.delay(2000));
	}
	    		    		
	// get array of hash tags from welcome bar
	welcomeArray = ['contact','disclaimer','sitemap'];
	$$('#welcome a').each(function(a){
		if (a.getProperty('href').indexOf('#') == 0){
			welcomeArray.push(a.getProperty('href').replace('#',''));
		}
	});
	
	// handle hashtag changing
	(function(){
		if(myhash != location.hash){
			if (!window.inanimation){
				new Fx.Scroll($(document.body)).toTop();
				try { if (setIframe) setIframe(location.hash); } catch (e) { }
				hashChange(location.hash.replace('#',''));
			}
		}
	}.periodical(200,this));
	
	$('swf').addEvent('click', function(ev){
	
		if(ev) ev.stop();
		
		var t = $(ev.target);
		
		if (t.getProperty('href')){
			var href = t.getProperty('href').split('/');
			href = href[href.length - 1];
			var a = $$('a[name="' + href + '"]');
			if (a.length > 0) new Fx.Scroll($(document.body)).toElement(a[0]);
		}
		
	});
		
	// hash change
	hashChange = function(h){
		
		// change hash variable	
		myhash = location.hash;
		
		// split out h
		var parts = h.split('/');
		
		// old hash parts
		oldhashparts = myhashparts;
		
		// set myhash parts
		myhashparts = parts;
		
		// handle main links and native anchors
		if (parts.length == 1 && parts.join('/') != oldhashparts.join('/')){
			    		    			
			// main strapline links
			if (welcomeArray.contains(h)){
				showSection(h);
			} else if(h == ''){
				// return to homepage
			
	    		// do we need to animate it?
				if (parseInt($('welcome').getStyle('font-size')) != '24'){
				
					new Fx.Morph($('welcome'), { duration:800 })
					.addEvent('start',function(){
						$('rest')
						.setStyles({
							'display':'none',
							'opacity':0
						})
					})
					.start({
						'font-size': '24px',
						'top': 170,
						'width':588
					});
										
					if (useFlash){
						frontanimation = new Swiff(
							'images/front-animation.swf',
							{
								container:$('swf'),
								width:254,
								height:407,
								params:{
									wMode: 'transparent'
								}
							}
						);
					} else {
						$('swf').empty();
					}
					
					resetStage();
				
				}
			
			} else {
			
				// if we get here its a native anchor, so should we do a FX.Scroll?
			
			}
			
			// always animate by default
			sequenceFinish = function(){ animate = true; window.inanimation = false; }
		
		} else if(parts.length != 1) {
		
			// if we get here we have a link with / in it - so its a cms driven link
			
			// if we're moving to a new section...
			if (oldhashparts.length < 1 || oldhashparts[0] != parts[0]){

				// put the rest of the logic in here, so it runs once the flash is done
				sequenceFinish = function(){
																
					// click sublink
					$$('#paper .text ul.sub li > a').each(function(el){
						if (el.getProperty('href') == myhash){	
							el.getParent('li').fireEvent('click');
						}
					});
					
					// click sub-sublink
					$$('#paper .text ul.subsub a').each(function(el){
						if (el.getProperty('href') == myhash){	
							el.getParent('li').getParent('li').fireEvent('click');
							el.getParent('li').fireEvent('click');
						}
					});
									
					// get the page
					getPage(myhash,function(content){
						$('rest2').set('html',content);
						$('rest').set('html',content).morph({
							'opacity':1,
							'height':[$('rest').getSize().y,$('rest2').getSize().y]
						});
					});
				 
					animate = true; 
					window.inanimation = false;
				}
				showSection(parts[0]);
			} else {
						
				// get the page
				getPage(myhash,function(content){
					$('rest2').set('html',content);
					$('rest').set('html',content).morph({
						'opacity':1,
						'height':[$('rest').getSize().y,$('rest2').getSize().y]
					});				
				});
				
				// click sublink
				$$('#paper .text ul.sub li > a').each(function(el){
					if (el.getProperty('href') == myhash){	
						el.getParent('li').fireEvent('click');
					}
				});
				
				// click sub-sublink
				$$('#paper .text ul.subsub a').each(function(el){
					if (el.getProperty('href') == myhash){	
						el.getParent('li').getParent('li').fireEvent('click');
						el.getParent('li').fireEvent('click');
					}
				});
			
			}
		
		}
				
	};
	
	// get page (either from cache or server)
	getPage = function(index,fn){
	
		if (!index) return;
	
		// select link
		$$('a').each(function(el){
			if (el.getParent('li'))	el.getParent('li').removeClass('selected');
		});
		
		$$('a').each(function(el){
			if (el.getProperty('href') == index){
				if (el.getParent('li'))	el = el.getParent('li');
				el.addClass('selected');
			}
		});
		
		// remove animation
		$('swf').empty().setStyle('opacity', 0);
		
		// is it in the cache?
		var c = cache.get(index);
		if (c){
			// set page title
			document.title = c.t;
			fn.run(c.c);
			new ExitPoll({ parent: $('rest') });
			$('swf').empty().setStyle('padding-top', parseInt($('padding').getStyle('height')) + 25).set('html',c.i + '<p class="caption">'+c.cap+'</p>').tween('opacity', 1);
			return;	
		} else {
		
			// nope, so lets get it from the server
			new Request.JSON({ url: 'json.php', method: 'post', data: {index:index} })
			.addEvent('success',function(j){
					
				// if we get json
				if (j){
				
					// format content
					content = textFormat(j.content);
				
					// add it to the cache
					cache.set(j.index,{ c: content, i: j.animation, cap: j.caption, t: j.title });
					
					// set page title
					document.title = j.title;
					
					// if we have an animation, then change it
					//if (j.animation){
					if (j.animation){
						$('swf').empty().set('html',j.animation + '<p class="caption">'+j.caption+'</p>').setStyle('opacity', 0);
					}
					
					//run the function
					fn.run(content);
					new ExitPoll({ parent: $('rest') });
					(function(){ 
						$('swf').setStyle('padding-top', parseInt($('padding').getStyle('height')) + 25).tween('opacity', 1); 
					}.delay(1000));
				}
			
			})
			.send();
		
		}
	}
	
	// text format
	textFormat = function(c){
	
	  var div = new Element('div', { html: c });
	
	  // replace images with captions
	  div.getElements('img').each(function(el) {
	    var captionText = ( el.getProperty('title')!=null ) ? el.getProperty('title') : el.getProperty('alt');
	    if (captionText) {
	      var figure = new Element('div', {
	        'class' : 'figure',
	        'styles' : {
	          'width' : el.get('width').toInt() + 10,
	          'float' : el.get('align') ? el.get('align') : 'none'
	        }
	      });
	      var caption = new Element('p', {
	        'class' : 'caption',
	        'html' : captionText
	      });
	      figure.wraps(el);
	      caption.inject(el,'after');
	    }
	  });
	
	  return div.get('html');
	  
	};
		
	// show a section
	showSection = function(section){
			
		// which main link?
		switch (section){
	
			// about ruffer link
			case 'ruffer':
			
				// call this on complete
				var complete = function(){
				
					if (useFlash) window.inanimation = true;
												
					$('padding').tween('height',152);
					$('rest').setStyles({
						'display':'block',
						opacity:0
					});

					// load in page content 
					if (myhashparts.length == 1){
					
						var l = $('sub-ruffer').getElement('li>a').get('href');
						getPage(l, function(content){
							$('rest2').set('html',content);
							$('rest').set('html',content).morph({
								'opacity':1,
								'height':[$('rest').getSize().y,$('rest2').getSize().y]
							});
						});
					
					}
					
					if (useFlash){
						$('swoop1').setStyle('margin-top','62px');
						//$('swoop2').setStyle('margin-top','138px');
						if (animate){
							$('rest').setStyle('opacity',0);
							if ($(swoop1s).restore) $(swoop1s).restore();
							(function(){ if ($(swoop1s).playMe) $(swoop1s).playMe(); }.delay(100));
							(function(){
								if ($('sub-ruffer')) {
									$$('#padding ul.sub').setStyle('display', 'none');
									$('sub-ruffer').setStyle('display','block'); 	
									if (myhashparts.length == 1) $('sub-ruffer').getElement('li').fireEvent('click');
								}
								//if ($(swoop2s).playMe) $(swoop2s).playMe()
								sequenceFinish.delay(1500);
							}.delay(1600));						
						} else {
							$(swoop1s).finish();
							if ($('sub-ruffer')) {
								$$('#padding ul.sub').setStyle('display', 'none');
								$('sub-ruffer').setStyle('display','block');
								if (myhashparts.length == 1) $('sub-ruffer').getElement('li').fireEvent('click');
								//else $(swoop2s).finish();

							}
							sequenceFinish.attempt();
						}
					} else {
						$('swoop1').setStyle('margin-top','68px');
						//$('swoop2').setStyle('margin-top','142px');
						//$('swoop2').setStyle('margin-left','232px');
						if ($('sub-ruffer')) {
							$('sub-ruffer').setStyle('display','block'); 	
							if (myhashparts.length == 1) $('sub-ruffer').getElement('li').fireEvent('click');
						}	
					}
				}
				
				// animate or not?
				if (animate && parseInt($('welcome').getStyle('font-size')) == '24'){
							
					new Fx.Morph($('welcome'), { duration:1200 })
					.addEvent('complete',complete)
					.start({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
				
				} else {
				
					resetStage();
				
					$('welcome')
					.setStyles({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
					
					complete.attempt();
					
				}
				
			break;
			
			case 'funds':
			
				// call this on complete
				var complete = function(){
				
					if (useFlash) window.inanimation = true;
								
					$('padding').tween('height',172);
					$('rest').setStyles({
						'display':'block',
						'opacity':1
					});
					
					// load in page content 
					if (myhashparts.length == 1){

						// load in page content 
						var l = $('sub-funds').getElement('li>a').get('href');
						getPage(l, function(content){
							$('rest2').set('html',content);
							$('rest').set('html',content).morph({
								'opacity':1,
								'height':[$('rest').getSize().y,$('rest2').getSize().y]
							});
						});
					
					}
					
					if (useFlash){
						$('swoop3').setStyle('margin-top','65px');
						//$('swoop4').setStyle('margin-top','168px');
						if (animate){
						
							$('rest').setStyle('opacity',0);
							(function(){ if ($(swoop3s).playMe) $(swoop3s).playMe(); }.delay(100));
							
							(function(){
								if ($('sub-funds')){
									$$('#padding ul.sub').setStyle('display', 'none');
									$('sub-funds').setStyle('display','block');
									if (myhashparts.length == 1) $('sub-funds').getElement('li').fireEvent('click');
								} 							
		    					if ($(swoop4s).playMe) $(swoop4s).playMe();
								//$('rest').tween('opacity',1);
								sequenceFinish.delay(1500);
							}.delay(1200));
							
						} else {
							$(swoop3s).finish();
							$(swoop4s).finish();
							if ($('sub-funds')){
								$$('#padding ul.sub').setStyle('display', 'none');
								$('sub-funds').setStyle('display','block');
								if (myhashparts.length == 1) $('sub-funds').getElement('li').fireEvent('click');
							}
							sequenceFinish.attempt(); 
						}
					} else {
						$('swoop3').setStyle('margin-top','68px');
						//$('swoop4').setStyle('margin-top','142px');
						if ($('sub-funds')) $('sub-funds').setStyle('display','block'); 
						if ($('sub-funds')){
							$('sub-funds').setStyle('display','block');
							if (myhashparts.length == 1) $('sub-funds').getElement('li').fireEvent('click');
						}
						sequenceFinish.attempt(); 
					}
					
				}
				
				// animate or not?
				if (animate && parseInt($('welcome').getStyle('font-size')) == '24'){
			
					new Fx.Morph($('welcome'), { duration:1200 })
					.addEvent('complete',complete)
					.start({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
				
				} else {
				
					resetStage();
				
					$('welcome')
					.setStyles({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
					
					complete.attempt();
					
				}
			
			break;
			
			case 'institutions':

				// call this on complete
				var complete = function(){
				
					if (useFlash) window.inanimation = true;
				
					$('padding').tween('height',172);
					$('rest').setStyles({
						'display':'block',
						'opacity': 1
					});
					
					// load in page content 
					if (myhashparts.length == 1){
						
						// load in page content 
						var l = $('sub-institutions').getElement('li>a').get('href');
						getPage(l, function(content){
							$('rest2').set('html',content);
							$('rest').set('html',content).morph({
								'opacity':1,
								'height':[$('rest').getSize().y,$('rest2').getSize().y]
							});
						});
					
					}
					
					if (useFlash){
						$('swoop5').setStyle('margin-top','82px');
						//$('swoop6').setStyle('margin-top','164px');
						if (animate){ 
							$('rest').setStyle('opacity',0);
							(function(){ if ($(swoop5s).playMe) $(swoop5s).playMe(); }.delay(100));
							//Swiff.remote(swoop5,'playMe');
							(function(){ 
								if ($('sub-institutions')){
									$$('#padding ul.sub').setStyle('display', 'none');
									$('sub-institutions').setStyle('display','block'); 	
									if (myhashparts.length == 1) $('sub-institutions').getElement('li').fireEvent('click');
								}						
								//$(swoop6).playMe(); 
								//$('rest').tween('opacity',1);
								sequenceFinish.delay(1500);
							}.delay(1950));
						} else {
							$(swoop5s).finish();
							$(swoop6s).finish();
							if ($('sub-institutions')) {
								$$('#padding ul.sub').setStyle('display', 'none');
								$('sub-institutions').setStyle('display','block'); 
								if (myhashparts.length == 1) $('sub-institutions').getElement('li').fireEvent('click');
							}
							sequenceFinish.attempt();	
						}
					} else {
						$('swoop5').setStyle('margin-top','68px');
						//$('swoop6').setStyle('margin-top','164px');
						//$('swoop7').setStyle('margin-top','164px');
						if ($('sub-institutions')) $('sub-institutions').setStyle('display','block'); 	
						if ($('sub-institutions')) {
							$('sub-institutions').setStyle('display','block'); 
							if (myhashparts.length == 1) $('sub-institutions').getElement('li').fireEvent('click');
						}
						sequenceFinish.attempt();						
					}
					
				}
				
				// animate or not?
				if (animate && parseInt($('welcome').getStyle('font-size')) == '24'){
			
					new Fx.Morph($('welcome'), { duration:1200 })
					.addEvent('complete',complete)
					.start({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
				
				} else {
				
					resetStage();
				
					$('welcome')
					.setStyles({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
					
					complete.attempt();
					
				}
				
			break;
			
			case 'privateclients':
			
				// call this on complete
				var complete = function(){
				
					if (useFlash) window.inanimation = true;
				
					$('padding').tween('height',172);
					$('rest').setStyles({
						'display':'block',
						opacity:0
					});
					
					// load in page content 
					if (myhashparts.length == 1){
											
						// load in page content 
						var l = $('sub-privateclients').getElement('li>a').get('href');
						getPage(l, function(content){
							$('rest2').set('html',content);
							$('rest').set('html',content).morph({
								'opacity':1,
								'height':[$('rest').getSize().y,$('rest2').getSize().y]
							});
						});
					
					}
					
					if (useFlash){
						$('swoop8').setStyle('margin-top','75px');
						//$('swoop9').setStyle('margin-top','188px');
						if (animate){
							$('rest').setStyle('opacity',0);
							(function(){ if ($(swoop8s).playMe) $(swoop8s).playMe(); }.delay(100));
							(function(){ 
								if ($('sub-privateclients')) {
									$$('#padding ul.sub').setStyle('display', 'none');
									$('sub-privateclients').setStyle('display','block'); 	
									if (myhashparts.length == 1) $('sub-privateclients').getElement('li').fireEvent('click');
								}
								//$(swoop9).playMe();	
								//$('rest').tween('opacity',1);
								sequenceFinish.delay(1500);
							}.delay(1200));
						} else {
							$(swoop8s).finish();
							//$(swoop9).finish();
							if ($('sub-privateclients')) {
								$$('#padding ul.sub').setStyle('display', 'none');
								$('sub-privateclients').setStyle('display','block'); 	
								if (myhashparts.length == 1) $('sub-privateclients').getElement('li').fireEvent('click');
							}
							sequenceFinish.attempt();
						}
					} else {
						$('swoop8').setStyle('margin-top','68px');
						//$('swoop9').setStyle('margin-top','188px');
						if ($('sub-privateclients')) $('sub-privateclients').setStyle('display','block'); 
						if ($('sub-privateclients')) {
							$('sub-privateclients').setStyle('display','block'); 	
							if (myhashparts.length == 1) $('sub-privateclients').getElement('li').fireEvent('click');
						}
						sequenceFinish.attempt();
					}
				
				}
				
				// animate or not?
				if (animate && parseInt($('welcome').getStyle('font-size')) == '24'){
			
					new Fx.Morph($('welcome'), { duration:1200 })
					.addEvent('complete',complete)
					.start({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
				
				} else {
				
					resetStage();
				
					$('welcome')
					.setStyles({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
					
					complete.attempt();
					
				}
				
			break;
			
			default:
			
				height = 0;
									
				// call this on complete
				var complete = function(){
				
					$('rest').setStyles({
						'display':'block',
						'opacity':0
					});
					
					// contact section
					if (section == 'contact'){
						if ($('sub-contact')){
							//if (oldhashparts[0] != 'contact'){
								//(function(){
									$('sub-contact').setStyles({
										'display':'block',
										'opacity':0
									})
									.tween('opacity',1); 
								//}.delay(400));
							/*} else {
								$('sub-contact').setStyles({
									'display':'block',
									'opacity':1
								});
							}*/
						}
						height = 70;
					}
					
					$('padding').tween('height',height);
					
					getPage(location.hash, function(content){
						$('rest2').set('html',content);
						$('rest').set('html',content);
						if (animate){
							$('rest').morph({
								'opacity':1,
								'height':[$('rest').getSize().y,$('rest2').getSize().y + 70]
							});
						} else {
							$('rest').setStyles({
								'opacity':1,
								'height':$('rest2').getSize().y	+ 70
							});
						}
						sequenceFinish.attempt();
					});
					
				}
			
				// animate or not?
				if (animate && parseInt($('welcome').getStyle('font-size')) == '24'){
			
					new Fx.Morph($('welcome'), { duration:1200 })
					.addEvent('complete',complete)
					.start({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
				
				} else {
				
					resetStage();
				
					$('welcome')
					.setStyles({
						'font-size': '12px',
						'top': 50,
						'width':375
					});
					
					complete.attempt();
					
				}
			
			break;
		
		}

	};
	
	// sub-sub menus
	$('paper').getElements('ul.sub li')
	.addEvent('click',function(ev){
			
		// if its a quick link, do nothing
		if (this.getParent('li.quicklinks')) return;
		
		// get ul
		var ul = this.getParent('ul');
		
		// if its a natural click event, we don't do anything
		if (ev) return;
						
		// hide show sublinks
		$$('#paper ul.sub li ul').setStyle('display','none');
		if (this.getElement('ul')){
			this.getElement('ul').setStyle('display','block');
		}
						
		// is it a submenu?
		if(ul.getProperty('data-sub')){
			if (ev) ev.stopPropagation();
			ul.setStyle('display','block');
			
			lnk = ul.getProperty('data-sub');
			$$('#paper ul.sub li a').each(function(el){
				if (el.getProperty('href') == lnk){
					window.finishmovies = true;
					el.getParent('li').fireEvent('click');
				}
			});
			
			// load in page content 
			getPage(this.getProperty('href'), function(content){
				$('rest2').set('html',content);
				$('rest').set('html',content).morph({
					'opacity':1,
					'height':[$('rest').getSize().y,$('rest2').getSize().y]
				});
			});
			return;
		}
		
		// work out position, and use it to show correct swoop
		var me = this.getAllPrevious('li').length;
						
		switch (myhashparts[0]){
		
			// ruffer sublinks
			case 'ruffer':
												
				// subs in this section - need to be in order of sublinks
				var subs = ['swoop2','swoop2s2','swoop2s3','swoop2s4'];
				var subso = useFlash ? [swoop2s,swoop2s2s,swoop2s3s,swoop2s4s] : [];
				var mt = [138,148,168,128];
				subs.each(function(el){ $(el).setStyle('margin-top',-300); });
				if (useFlash){
					subso.each(function(el){ if($(el).restore) $(el).restore(); });
				}
				
				// depending on the subsection, show the appropriate link
				$(subs[me]).setStyle('margin-top', mt[me] + 'px');
				if (useFlash){
					if (!window.finishmovies){
						(function(){ if($(subso[me]).playMe) $(subso[me]).playMe(); }.delay(100));
					} else {
						(function(){ if($(subso[me]).finish) $(subso[me]).finish(); }.delay(10));
					}
				}
				
			break;
			
			// funds sublinks
			case 'funds':
			
				// subs in this section - need to be in order of sublinks
				var subs = ['swoop4','swoop4s2','swoop4s3','swoop4s4'];
				var subso = useFlash ? [swoop4s,swoop4s2s,swoop4s3s,swoop4s4s] : [];
				var mt = [118,165,74,190];
				subs.each(function(el){ $(el).setStyle('margin-top',-300); });
				if (useFlash){
					subso.each(function(el){ if($(el).restore) $(el).restore(); });
				}
				
				// depending on the subsection, show the appropriate link
				$(subs[me]).setStyle('margin-top', mt[me] + 'px');
				if (useFlash){
					if (!window.finishmovies){
						(function(){ if ($(subso[me]).playMe) $(subso[me]).playMe(); }.delay(100));
					} else {
						(function(){ if ($(subso[me]).finish) $(subso[me]).finish(); }.delay(10));
					}
				}
			
			break;
			
			// institutions sublinks
			case 'institutions':
			
				// subs in this section - need to be in order of sublinks
				var subs = ['swoop6','swoop6s2','swoop6s3','swoop6s4','swoop6s5'];
				var subso = useFlash ? [swoop6s,swoop6s2s,swoop6s3s,swoop6s4s,swoop6s5s] : [];
				var mt = [108,115,134,158,180];
				subs.each(function(el){ $(el).setStyle('margin-top',-300); });
				if (useFlash){
					subso.each(function(el){ if($(el).restore) $(el).restore(); });
				}
				
				// depending on the subsection, show the appropriate link
				$(subs[me]).setStyle('margin-top', mt[me] + 'px');
				if (useFlash){
					if (!window.finishmovies){
						(function(){ if ($(subso[me]).playMe) $(subso[me]).playMe(); }.delay(100));
					} else {
						(function(){ if ($(subso[me]).finish) $(subso[me]).finish(); }.delay(10));
					}
				}
			
			break;
			
			// private clients sublinks
			case 'privateclients':
			
				// subs in this section - need to be in order of sublinks
				var subs = ['swoop9','swoop9s2','swoop9s3','swoop9s4','swoop9s5','swoop9s6','swoop9s7'];
				var subso = useFlash ? [swoop9s,swoop9s2s,swoop9s3s,swoop9s4s,swoop9s5s,swoop9s6s,swoop9s7s] : [];
				var mt = [138,110,144,168,154,80,128];
				subs.each(function(el){ $(el).setStyle('margin-top',-300); });
				if (useFlash){
					subso.each(function(el){ if($(el).restore) $(el).restore(); });
				}
				
				// depending on the subsection, show the appropriate link
				$(subs[me]).setStyle('margin-top', mt[me] + 'px');
				if (useFlash){
					if (!window.finishmovies){
						(function(){ if ($(subso[me]).playMe) $(subso[me]).playMe(); }.delay(100));
					} else {
						(function(){ if ($(subso[me]).finish) $(subso[me]).finish(); }.delay(10));
					}
				}
			
			break;
		
		}
		
		window.finishmovies = false;
		
		// allow something else to animate		
		(function(){
			window.inanimation = false;
		}.delay(1000));
		
	});
	
	// quicklinks
	$('paper').getElements('li.quicklinks li a')
	.addEvent('click',function(ev){
	
		if (this.getProperty('href').indexOf('pdf') !== -1){
			window.open(this.getProperty('href'));
			if (ev) ev.stop();
			return;
		}
		
		animate = false;
		$('paper').getElements('ul.sub li ul').setStyle('display', 'none');
		$('paper').getElements('ul.sub li ul a').each(function(el){
			if (el.getProperty('href') == this.getProperty('href')){
				el.getParent('li').fireEvent('click');
			}
		}, this);
	});
	
};

window.addEvent('domready', function(){

	if (!window.SEENMSG) window.SEENMSG = false;

	if ((Browser.Engine.trident4 || Browser.Engine.presto) && !Cookie.read('seenmsg') && !window.SEENMSG){
		location.href = Browser.Engine.presto ? 'opera.php' : 'ieupdate.php';
	} else {
	
		if (window.ActiveXObject) {
            if (!document.documentMode || document.documentMode < 8) {
            	iframe = new IFrame({ id: 'ieframe' }).setStyle('display', 'none');
            	
            	$(document.body).adopt(iframe);
            	
			    // Don't run until access to the iframe is allowed.
			    try {
			        iframe.contentWindow.document;
			    } catch (e) {
			        setTimeout(setUpIframe, 10);
			        return;
			    }			    
			    
				setIframe = function (newHash) {
				    try {
				        var doc = iframe.contentWindow.document;
				        doc.open();
				        doc.write('<html><body>' + newHash + '</body></html>');
				        doc.close();
				        hash = newHash;
				    } catch (e) {
				        setTimeout(function () { setIframe(newHash); }, 10);
				    }
				}			
			    // Create a history entry for the initial state.
			    setIframe(location.hash);
			    var data = location.hash;
			
			    setInterval(function () {
			        var curData, curHash;
			
			        try {
			            curData = iframe.contentWindow.document.body.innerText;
			            if (curData != data) {
			                data = curData;
			                location.hash = curData;
			            }
			        } catch (e) {
			        }
			    }, 50);
            	
            }
        }

		// should we use flash?
		useFlash = Browser.Plugins.Flash.version ? true : false;
		
		// swoops array
		swoops = [];
		
		// how many flash have loaded
		flashLoads = 0;
		
		flashLoaded = function(){
		
			flashLoads++;
			if (flashLoads == 24){
				window.fireEvent('rufferload');
			}
		
		};
			
		// only if we have flash!
		if (useFlash){
			
			$$('.swoop').setStyles({'margin-top': 200});
			
			// swoop 1 animation
			swoop1s = new Swiff(
				'images/swoop1.swf',
				{
					container:$('swoop1'),
					id: 'Swiff_swoop1s',
					width:778,
					height:132,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
					
			swoops.push(swoop1s);
			
	  		// swoop 2 animation
	  		// ruffer - sub1
			swoop2s = new Swiff(
				'images/swoop2.swf',
				{
					container:$('swoop2'),
					id: 'Swiff_swoop2s',
					width:805,
					height:151,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop2s);
			
			// swoop 2s2 animation
	  		// ruffer - sub2
			swoop2s2s = new Swiff(
				'images/swoop2.1.swf',
				{
					container:$('swoop2s2'),
					id: 'Swiff_swoop2s2s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop2s2s);
			
			// swoop 2s3 animation
	  		// ruffer - sub3
			swoop2s3s = new Swiff(
				'images/swoop2.2.swf',
				{
					container:$('swoop2s3'),
					id: 'Swiff_swoop2s3s',
					width:490,
					height:156,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop2s3s);
			
			// swoop 2s4 animation
	  		// ruffer - sub4
			swoop2s4s = new Swiff(
				'images/swoop2.3.swf',
				{
					container:$('swoop2s4'),
					id: 'Swiff_swoop2s4s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop2s4s);
			
	  		// swoop 3 animation
			swoop3s = new Swiff(
				'images/swoop3.swf',
				{
					container:$('swoop3'),
					id: 'Swiff_swoop3s',
					width:490,
					height:156,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop3s);
			
	  		// swoop 4 animation
			swoop4s = new Swiff(
				'images/swoop4.swf',
				{
					container:$('swoop4'),
					id: 'Swiff_swoop4s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop4s);
			
			// swoop 4s2 animation
			swoop4s2s = new Swiff(
				'images/swoop4.1.swf',
				{
					container:$('swoop4s2'),
					id: 'Swiff_swoop4s2s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop4s2s);
			
			// swoop 4s3 animation
			swoop4s4s = new Swiff(
				'images/swoop4.2.swf',
				{
					container:$('swoop4s4'),
					id: 'Swiff_swoop4s4s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop4s4s);
			
			// swoop 4s4 animation
			swoop4s3s = new Swiff(
				'images/swoop4.3.swf',
				{
					container:$('swoop4s3'),
					id: 'Swiff_swoop4s3s',
					width:508,
					height:250,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop4s3s);
			
	  		// swoop 5 animation
			swoop5s = new Swiff(
				'images/swoop5.swf',
				{
					container:$('swoop5'),
					id: 'Swiff_swoop5s',
					width:680,
					height:220,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop5s);
			
	  		// swoop 6 animation
			swoop6s = new Swiff(
				'images/swoop6.swf',
				{
					container:$('swoop6'),
					id: 'Swiff_swoop6s',
					width:508,
					height:200,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop6s);
			
			// swoop 6s2 animation
			swoop6s2s = new Swiff(
				'images/swoop6.1.swf',
				{
					container:$('swoop6s2'),
					id: 'Swiff_swoop6s2s',
					width:508,
					height:250,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop6s2s);
			
			// swoop 4s3 animation
			swoop6s3s = new Swiff(
				'images/swoop6.2.swf',
				{
					container:$('swoop6s3'),
					id: 'Swiff_swoop6s3s',
					width:508,
					height:200,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop6s3s);
			
			// swoop 6s4 animation
			swoop6s4s = new Swiff(
				'images/swoop6.3.swf',
				{
					container:$('swoop6s4'),
					id: 'Swiff_swoop6s4s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop6s4s);
			
			// swoop 6s5 animation
			swoop6s5s = new Swiff(
				'images/swoop6.4.swf',
				{
					container:$('swoop6s5'),
					id: 'Swiff_swoop6s5s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop6s5s);
			
	  		// swoop 7 animation
			swoop7s = new Swiff(
				'images/swoop7.swf',
				{
					container:$('swoop7'),
					id: 'Swiff_swoop7s',
					width:508,
					height:160,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop7s);
			
	  		// swoop 8 animation
			swoop8s = new Swiff(
				'images/swoop8.swf',
				{
					container:$('swoop8'),
					id: 'Swiff_swoop8s',
					width:700,
					height:140,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop8s);
			
	  		// swoop 9 animation
			swoop9s = new Swiff(
				'images/swoop9.swf',
				{
					container:$('swoop9'),
					id: 'Swiff_swoop9s',
					width:500,
					height:200,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop9s);
			
			// swoop 9s2 animation
			swoop9s2s = new Swiff(
				'images/swoop9.1.swf',
				{
					container:$('swoop9s2'),
					id: 'Swiff_swoop9s2s',
					width:508,
					height:200,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop9s2s);
			
			// swoop 9s3 animation
			swoop9s3s = new Swiff(
				'images/swoop9.2.swf',
				{
					container:$('swoop9s3'),
					id: 'Swiff_swoop9s3s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop9s3s);
			
			// swoop 9s4 animation
			swoop9s4s = new Swiff(
				'images/swoop9.3.swf',
				{
					container:$('swoop9s4'),
					id: 'Swiff_swoop9s4s',
					width:600,
					height:200,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop9s4s);
			
			// swoop 9s5 animation
			swoop9s5s = new Swiff(
				'images/swoop9.4.swf',
				{
					container:$('swoop9s5'),
					id: 'Swiff_swoop9s5s',
					width:600,
					height:200,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop9s5s);
			
			// swoop 9s6 animation
			swoop9s6s = new Swiff(
				'images/swoop9.5.swf',
				{
					container:$('swoop9s6'),
					id: 'Swiff_swoop9s6s',
					width:600,
					height:250,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop9s6s);
			
			// swoop 9s7 animation
			swoop9s7s = new Swiff(
				'images/swoop9.6.swf',
				{
					container:$('swoop9s7'),
					id: 'Swiff_swoop9s7s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop9s7s);
			
			/* swoop 9s8 animation
			swoop9s8s = new Swiff(
				'images/swoop9.7.swf',
				{
					container:$('swoop9s8'),
					id: 'Swiff_swoop9s8s',
					width:508,
					height:172,
					params:{
						wMode: 'transparent'
					},
					callBacks:{
						onLoad: flashLoaded
					}
				}
			);
			
			swoops.push(swoop9s8s);*/
						
		} else {
		
			// image fallbacks
			$$('.swoop img').setStyle('display', 'inline');
		
		}
		
		// if something in hash, we don't need homepage
		if (location.hash.replace('#', '') != ''){
			$('swf').empty();
			
			$('welcome')
			.setStyles({
				'font-size': '12px',
				'top': 50,
				'width':375
			});
			
		}
		
		$('welcome').setStyle('display', 'block');
		
		$$('#paper ul.quicklinks li.login').addEvent('mouseenter', function(){ this.setStyle('background-color','#004A25').getElement('ul.sub').setStyle('display', 'block'); }).addEvent('mouseleave', function(){ this.setStyle('background-color','').getElement('ul.sub').setStyle('display', 'none'); });
		$$('#paper ul.quicklinks li.quicklinks').addEvent('mouseenter', function(){ this.setStyle('background-color','#004A25').getElement('ul.sub').setStyle('display', 'block'); }).addEvent('mouseleave', function(){ this.setStyle('background-color','').getElement('ul.sub').setStyle('display', 'none'); });
		$('login-frame').addEvent('mouseenter', function(){ $$('#paper ul.quicklinks li.login').fireEvent('mouseenter') }).addEvent('mouseleave', function(){ $$('#paper ul.quicklinks li.login').fireEvent('mouseenter') });

		// place back-to-top link
		window.addEvent('resize', function(){
			$('back-to-top').setStyle(
				'top', window.getSize().y - 100
			);
		});
		window.fireEvent('resize');
		
		// add scroll event on click
		$('back-to-top').getElement('a').addEvent('click', function(ev){
			if (ev) ev.stop();
			new Fx.Scroll($(document.body)).toTop();
		});
		
		// add show/hide
		window.addEvent('scroll', function(ev){
			if ($('swf').getElement('p') && !$('swf').getElement('p').hasClass('caption')){
			
				var el = $('swf').getElement('p');
				var showFrom = parseInt(el.getStyle('top')) + parseInt(el.getSize().y);
				
				if (window.getScroll().y > showFrom){
					$('back-to-top').setStyle('display', 'block');	
				} else {
					$('back-to-top').setStyle('display', 'none');	
				}
				
			}
		});

		if (!useFlash) window.addEvent('load', function(){ window.fireEvent('rufferload'); });
	
	}

});

window.addEvent('rufferload', function(){

	// reset the stage
	resetStage = function(){
		swoops.each(function(e){ if ($(e).restore) $(e).restore(); });
		$$('.swoop').setStyle('margin-top',-300);
		$$('#padding ul.sub').setStyle('display','none');
		$('swf').setStyle('padding-top', 0);
	};
	
	$$('.swoop').setStyle('margin-top',-300);
	
	rufferLoad();
					
});