var $j = jQuery.noConflict();

$j(document).ready(function() {
	$j('#bottom_logos').hide();
	$j('#slide').length ? slideShow() : null;
	$j('.ResultsCustomLink').length ? addLink() : null;
	$j('.buttons').mousedown(function() {
		var thisId = $j(this).attr('id');
		var newSrc = 'images/aboutBtnIn.png';
		switch (thisId) {
			case 'about': newSrc = 'images/aboutBtnIn.png';
			break;
			case 'news': newSrc = 'images/newsBtnIn.png';
			break;
			case 'recruit': newSrc = 'images/recruitBtnIn.png';
			break;
			case 'contact': newSrc = 'images/contactBtnIn.png';
			break;
		}
		$j(this).find('img').attr('src',newSrc);
		$j('span.title_text2').hide();
	})
});

function slideShow() {
	$j('#imgContainer  > img').hide();
	$j('#subSlide div.left  > img').hide();
	$j('#subSlide div.right  > img').hide();//hide all of the images
	$j('#imgContainer  > img').eq(0).show();
	$j('#subSlide div.left  > img').eq(0).show();
	$j('#subSlide div.right  > img').eq(0).show();//show the first one
	var noOfImages = $j('#imgContainer > img').length;
	var count = 0;
	var fadeSpeed = 'slow';
	window.setInterval(function() {
		
		$j('#imgContainer  > img').eq(count).fadeOut(fadeSpeed);
		$j('#subSlide div.left  > img').eq(count).fadeOut(fadeSpeed);
		$j('#subSlide div.right  > img').eq(count).fadeOut(fadeSpeed);
		count<noOfImages-1 ? count++ : count=0;
		$j('#imgContainer  > img').eq(count).fadeIn(fadeSpeed);
		$j('#subSlide div.left  > img').eq(count).fadeIn(fadeSpeed);
		$j('#subSlide div.right  > img').eq(count).fadeIn(fadeSpeed);
		    
		}, 5000);
}

function addLink() {
	$j('td.ResultsDescriptionDataCell').append('<a class="ResultsCustomLink" style="margin-top:10px;" href="mailto:uxbridge@cameron-group.co.uk">Make Appointment</a>');

}
