function randomNum(){
	var length = $('#mainImage img').length;
	var ran=Math.floor(Math.random()*length)+1;
	$('#mainImage img:nth-child('+ran+')').addClass('active');
}

function slideSwitch(){
	var $active=$('#mainImage img.active');
	if($active.length==0){
		$active = $('#mainImage img:last');
	}
	var $next = $active.next().length ? $active.next() : $('#mainImage img:first');
	$active.addClass('last-active');
	$next.css({opacity:0.0})
						.addClass('active')
						.animate({opacity:1.0},1000,function(){
								$active.removeClass('active last-active')
							})
		}
		
		
$(function(){
		randomNum();
		setInterval("slideSwitch()",6500);
});
