Y = YUI().use('anim','event','node', function(Y) {
	Y.namespace('X');

	Y.X.rightPin = function(id) {
		openPin = function(id) {
			var n;
			if(id) {
				n = Y.one('#'+id+'t');	
			}
			if(n == undefined) {
				n = Y.one('#rightcol a.pin')
			}
			if(n) {
				n.addClass('active');
				id = n.get('id').replace('t','d');
				n = Y.one('#'+id);
				n.setStyles({opacity:0,display:'block',overflow:'visible'});
				h = n.getStyle('height');
				n.setStyles({overflow:'hidden',height:0,opacity:1});
				a = new Y.Anim({node:n,from:{height:0,paddingTop:0,paddingBottom:0},to:{height:h,paddingTop:10,paddingBottom:10},duration:.6,easing:Y.Easing.easeOutStrong});
				a.on('end',function(){
					n.setStyle('filter','');
				});				
				a.run();
			}
		}
		if(n = Y.one('#rightcol a.active')) {
			if(n.get('id').replace('t','') == id)return;
			n.removeClass('active');
			n = Y.one('#'+n.get('id').replace('t','d'));
			h = n.getStyle('height');
			n.setStyles({overflow:'hidden'});
			a = new Y.Anim({node:n,from:{height:h,paddingTop:10,paddingBottom:10},to:{height:0,paddingTop:0,paddingBottom:0},duration:.3,easing:Y.Easing.easeOutStrong});
			a.on('end',function(){
				n.setStyles({opacity:0,height:h,display:'none'});
				openPin(id);
			});
			a.run();
		} else {
			openPin(id);
		}
	}

	Y.on("domready", function(){
		Y.X.rightPin();
	});
});

