jQuery.noConflict();

jQuery(document).ready(function() {
	var maxCount= jQuery('#image-container').children('img').length;
	var count=2;
	var previous=1;
	var timerval;
	var originalTitle;
	var title;
	var currentRel;
	
	/*
	originalTitle = jQuery('#mutli a img.first').attr('title');
	jQuery('#mutli p').html(originalTitle);
	*/
	
	timeron();
	
	function timeron(){
		if(maxCount >1 ){
			clearInterval(timerval);	
			timerval = setInterval(imageRotation,5000);			
		}
	} 
		
	function imageRotation() {
		jQuery('#image-'+previous).fadeOut(500); //fade out speed this is set to 0.5 seconds at the moment
		jQuery('#image-'+count).fadeIn(500); //fade in speed this is set to 0.5 seconds at the moment
		previous = count;
		count ++;
		if(count==maxCount+1) {
			count=1;
		}
	};	
		
	jQuery('#mutli a').click(function () {
		count = jQuery(this).attr('rel').replace('image-','');
		
		title = jQuery(this).children('img').attr('title');
		jQuery('#mutli p').html(title);
		
		imageRotation();
		timeron();
		return false;
    });
	
});

