$.noConflict();
var count = 1;   
var playSlideshow;
function slideSwitch( slideTo ) {
	if (count >= linkArray.length) count = 0; 
	var $active = jQuery('#slideshow IMG.active');
	if ( $active.length == 0 ) $active = jQuery('#slideshow IMG:last');
	var $next = $active.next().length ? $active.next() : jQuery('#slideshow IMG:first');
	$active.addClass('last-active');
	// added ariable to allow transition to a selected slide
	// defaults to null, but if  >= 0, it will use this index for "$next"
	var slideTo = ( slideTo+1 )? slideTo : null;
 
	if ( slideTo != null ) $next = jQuery('#slideshow IMG').eq(slideTo);
	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});

	var anchor = document.getElementById('linkTitle');
	var link = document.createElement('a');
	link.setAttribute('href', linkArray[count]);	
	link.className = 'linkeTitle';
	link.id =  'linkTitle';
	link.innerHTML = linkTileArray[count];
	jQuery('#linkText>a').replaceWith( link );
//	anchor.parentNode.replaceChild(link, anchor);

	document.getElementById("copyrightText").firstChild.nodeValue = copyrightArray[count];
	//document.getElementById("linkTitle").firstChild.nodeValue = link;
	count++;
	return false;
}

jQuery(document).ready(function(){   
	// hide all images except first to avoid initial flicker
	jQuery("#slideshow IMG").css({opacity: 0.0});
	jQuery("#slideshow IMG:first").css({opacity: 1.0});
	// use setInterval to traverse list
	playSlideshow = setInterval( "slideSwitch()", 5000 );
	// create buttons to move to specific slide
	var $slideButtons = jQuery("#slide-buttons a");

	var anchor = document.getElementById('linkTitle');
	var link = document.createElement('a');
	link.setAttribute('href', linkArray[0]);
	link.className = 'linkeTitle';
	link.id =  'linkTitle';
	link.innerHTML = linkTileArray[0];
	jQuery('#linkText>a').replaceWith( link );
	//anchor.parentNode.replaceChild(link, anchor);
	document.getElementById("copyrightText").firstChild.nodeValue = copyrightArray[count];
 
jQuery("#slide-buttons a").click(function(){
	var index = jQuery("#slide-buttons a").index(this);
	count = index;
	// stop the slideshow, to keep it from trying to overlap our transition
	clearInterval(playSlideshow);
	// call the function using the index of the clicked button
	slideSwitch( $slideButtons.index(this) );
	return false;
});
});

