function init_slider() 
{
	//check the slider exists
	if( $('#slides').length ) 
	{
		$("#slides").slides({
			preload: true,
			preloadImage: 'img/loading.gif',
			play: 5000,
			pause: 2500,
			effect: 'fade',
			fadeSpeed: 600
		});
	}
}

function init_info_panels()
{
	//if info_col class exists, this is homepage
	if( $('.info_col').length ) 
	{
		//hide the text content
		$('.info_col > div').hide();
		//toggle the first info boxes
		slide_animation('.info_col h4:first');
		slide_animation('#faqs > h4:first');
	}
	
	//check if main_col exists
	if( $('.main_col').length )
	{	
		$('.main_col > div').hide();
		slide_animation('.main_col > h4:first');
	}
	//init the click slider
	slide_box('.info_col h4, .main_col h4');
	//init the jquery hover listener
	apply_hover('.info_col h4, .main_col h4');
}	

function apply_hover(el)
{
	$(el).hover(
		function() {
			$(this).addClass('bright');
		},
		function() {
			$(this).removeClass('bright');
		}
	);	
}

function slide_box(el)
{
	$(el).click(function() {
		slide_animation($(this));
	});	
}

function slide_animation(el)
{
	$(el).next().animate(
		{'height':'toggle'}, 'slow', 'swing', function() {
			toggle_arrow($(el));
		}
	);	
}

function toggle_arrow(title)
{
	//url("http://localhost/takepart-training.co.uk/img/arrow-off.png")
	current_bg = title.css('background-image');
	if(current_bg.match(/arrow-off/))
	{
		title.css("background-image", "url('img/arrow-on.png')");
		title.css("background-repeat", "no-repeat");
		title.css("background-position", "center left");
	} else {
		title.css("background-image", "url('img/arrow-off.png')");
		title.css("background-repeat", "no-repeat");
		title.css("background-position", "center left");
	}
}

function scroll_to(id)
{
	
	//open the info col
	$('#' + id).next().animate(
		{'height':'toggle'}, 'slow', 'swing', function(){
			//toggle the H4 arrow
			toggle_arrow($('#' + id));
			//smooth scroll to element
			$.scrollTo('#' + id, 'slow');	
		}
	);
}
