/* Shared.js */
var RTI;
if(!RTI) RTI = {};

window.addEvent('domready', function() {
	//var myMenu = new MenuMatic({duration: '400', opacity: '100'});
	//RTI.socialLinks = new SocialLinks({});
	//RTI.mottoFader = new MottoFader({});
	//console.log('hi');
	//RTI.videoOverlays = new VideoOverlays({});
	new FloatingTips('#artist-sidebar a', {position: 'bottom'}); // Top position is default
	new FloatingTips('div.video-description a', {position: 'top'}); // Top position is default
	new FloatingTips('div.thumb a', {position: 'bottom'}); // Top position is default
	new FloatingTips('div#stories-menu a', {position: 'bottom'}); // Top position is default
	
		
	if($('main-search')) {
		$('main-search').setStyle('color', '#aaa');
		$('main-search').addEvent('focus', function(e) {
			this.setStyle('color', '#000');
			this.value = '';
		});
	}
	
	//RTI.lazyLoad = new LazyLoad();
	

});

SocialLinks = new Class({
	initialize: function() {
		this.links = $$('.social-button');
		//console.log(this.links);
		
		this.pullouts = $$('.footer-pullout');
		this.container = $('social-pullout');
		
		//console.log(this.pullouts);
		
		this.links.addEvents({
			'click':function(e) {
					new Event(e).stop();
					
					var targetType = e.target.id.substring(7);
					
					var targetDiv = $('pullout-' + targetType);
					this.container.empty();
					var copy = targetDiv.clone().inject(this.container);
					copy.setStyle('display','block').set('opacity', 0).fade('in');
					
				}.bindWithEvent(this)
		});
			
	}
	
});

MottoFader = new Class({
	initialize: function() {
		this.container = $('motto');
		
		this.img = new Element('img', {
			'id':'fader',
			'src':'/images_ui2/motto-2.png',
			styles: {
				'display':'block',
				'width':'960px',
				'height':'16px'
			}
		});
		
		this.img.set('opacity', 0).set('tween', {duration: 2000});
		this.img.inject(this.container, 'top');

		var fnToRepeat = function() {
			if(this.img.get('opacity') < .01) {
				this.img.tween('opacity', [0,1]);
			} else {
				this.img.tween('opacity', [1,0]);
			}
		}.bind(this);
		
		var periodicalID = fnToRepeat.periodical(10000);
	}
});
/**/

