if (typeof(FERRING) == 'undefined') {
	FERRING	= {};
	FERRING.UI	= {};
}

FERRING.UI.Global	= function()
{
	var init	= function() {
		$('body').addClass('js');
		clientHover();
		initSlides();
		fixFooter();
	};
	
	/* for the listing of client logos on the client page*/
	var clientHover	= function() {
		$('#clientlist li img').hover(function() {
					
			img = this.src;
			
			if(img.indexOf('_grey') > -1) {
				newimg = img.replace('_grey','');	
				this.src = newimg;
			};

		},function(){
		     	this.src = img;
		   	});
	};
	
	
	var slideshow = function() {
		
		var active = $('#homefeature #homebanner img.active');
	    if ( active.length == 0 ) active = $('#homefeature #homebanner img:last');
	
	    var next =  active.next().length ? active.next()
	        : $('#homefeature #homebanner img:first');
	
	    active.addClass('last-active');
	
	    next.css({opacity: 0.0})
	        .addClass('active')
	        .animate({opacity: 1.0}, 1000, function() {
	            active.removeClass('active last-active');
	        });
	};
	
	var initSlides = function() {
		$('#homefeature #homebanner img:first-child').addClass('active');
		setInterval( "FERRING.UI.Global.slideshow()", 5000 );
	};
	
	var fixFooter = function() {
		var viewport_h = $(window).height();
		
		var footer = $('#footer');
		var footer_btm = parseInt(footer.position().top + footer.outerHeight(), 10);
				
		if (footer_btm < viewport_h) {
			if ($.browser.msie && parseInt($.browser.version, 10)<7) {
				$('#wrapper').css('height', parseInt(viewport_h - footer.outerHeight(), 10));
			}else{
				$('#wrapper').css('min-height', parseInt(viewport_h - footer.outerHeight(), 10));
			}
			
		}
	};
	
	
	return {
		init: init, 
		slideshow: slideshow
	};
	
}();

jQuery(function($) { FERRING.UI.Global.init(); });