/** Home JS
	Vertically centers the testimonial in the left hand side.
	
	**/
	
var verticalCenterTestimonial = function(){

	var featured = $('featured_content');

	if(featured){
	
		featured.setStyle('top',(featured.getParent().getSize().y - (featured.getSize().y + featured.getNext().getSize().y))/2 +'px');
	
	}

};

var portfolioTicker = new Class({
	
	requester: $empty,
	periodical_timer: $empty,
	container: $empty,
	swap: $empty,
	Implements: [Options,Events],
	options: {
		base_url: 'http://www.insightpartners.com/',
		function_path: 'home/get_next_ticker_ajax',
		swap: 'home_logos_swap',
		data: 'offset=0',
		refresh_delay: 3000,
		recoup_delay: 2500,
		transition_time: 500
	},
	initialize: function(container, options){
	
		this.container = $(container);
		this.swap = $(this.options.swap);
		this.shown =  this.container;
		
		this.container.set('tween',{duration:'long'});
		this.swap.set('tween',{duration:'long'}).setStyle('opacity',0);
		this.setOptions(options);
		this.requester = new Request({
			url: this.options.base_url + this.options.function_path,
			data: this.options.data,
			evalScripts: false,
			onComplete: this.inject_response.bind(this)
		});
		
		this.next_refresh = this.get_response.delay(this.options.refresh_delay,this);
	},
	inject_response: function(response,xml){
		
		this.swap_holder = this.swap.set('html',response);
		this.show_response.delay(this.options.recoup_delay,this);
		
	},
	show_response: function(){
		this.swap = this.container.fade("out");
		this.container = this.swap_holder.fade("in");
		this.next_refresh = this.get_response.delay(this.options.refresh_delay,this);
	},
	get_response: function(){
		
		this.requester.send();
	
	}
})
