$(document).ready(function() {

	var cnt = 0;

	 /* flick image src */
	$('div.scrollable img').each(function(index){
		if ( $(this).hasClass('active-menu') )
		{
			$(this).attr("src", $(this).attr("src").split(".gif").join("-on.gif"));
			cnt = ( index - 1 );
		}
	});

	$.preloadImages(
		"images/header/menu/3c-business-enterprise-hover.gif",
		"images/header/menu/business-planning-hover.gif",
		"images/header/menu/carbon-zero-hover.gif",
		"images/header/menu/connected-hover.gif",
		"images/header/menu/recruitment-hover.gif",
		"images/header/menu/story-time-dads-hover.gif",
		"images/header/menu/zero-tolerance-hover.gif"
	);

	$("div.scrollable").scrollable({
		size: 6,
		next: '.menu-next',
		prev: '.menu-prev',
		clickable: false,
		speed: 300
	});

	$("div.scrollable img").hover(
      function () {

		/* flick image src */
		$('div.scrollable img').each(function(index){
			$(this).attr("src", $(this).attr("src").split("-hover.").join("."));
		});

		//if -on dont replace img
		if( !$(this).attr("src").match('-on') )
		{
      		$(this).attr("src", $(this).attr("src").split(".gif").join("-hover.gif"));
      	}

      },
      function () {
        $('div.scrollable img').each(function(index){
			$(this).attr("src", $(this).attr("src").split("-hover.").join("."));
		});
      }
    );

	//scroll to relevant menu item
	$("div.scrollable").scrollable().click(cnt);

	var options = {
  		newsList: "#news-ticker",
 		startDelay: 10,
 		placeHolder1: " ",
 		placeHolder2: " _",
 		tickerRate: 40
	}
	$().newsTicker(options);

});