services = new Object();

$(document).ready(function(){
	services.initScroller();
});

services.initScroller = function(){
	//Init hover and click functions for scroller
	$('.check_mark').click(function(){
		services.clearAllDivBGs();
		if ($(this).find('img.check_img').attr('src')=='' + global.baseUrl + 'images/check_click-trans.png'){
			$(this).removeClass('active').find('img.check_img').attr('src', '' + global.baseUrl + 'images/check-trans.png');
			services.scroll('home');
		} else {
			$('div#servicesSelector a.active').removeClass('active').find('img.check_img').attr('src', '' + global.baseUrl + 'images/check-trans.png');
			$(this).addClass('active').find('img.check_img').attr('src', '' + global.baseUrl + 'images/check_click-trans.png');
			services.scroll($(this).attr('href'));
		}
		return false;
	});
	
	//Find all links with anchor #top and activate scroller
	$("a.scrollToTop").click(function(){
		var activeDivs = $.makeArray($('div#servicesScroller div.active'));
		if (activeDivs.length==0){
			$(document).scrollTo($('div#top'), global.animSpeed, {axis:'y'});
		} else {
			//Fade in color
			$('div#servicesScroller div.active').animate({ backgroundColor: '#ffffff' }, 'slow', 'linear', function(){
				$('.check_mark').removeClass('active');
				$(document).scrollTo($('div#top'), global.animSpeed, {axis:'y'});
			}).removeClass('active');
			return false;
		}
	});
}

services.scroll = function(id){
	id = id.replace('#', '');
	$(document).scrollTo($('div#servicesScroller_' + id), global.animSpeed, {axis:'y', onAfter: function(){
		$('div#servicesScroller_' + id).animate({ backgroundColor: '##FFF7E9' }).addClass('active'); //Changed color from #FFEDD1
	}});
}

services.clearAllDivBGs = function(){
	$('div#servicesScroller div.active').each(function(){
		$(this).css({ backgroundColor: '#ffffff' });
	});
}
