var nextimage = 0;

var c=0;
var t;
var timer_is_on=0;
var timer_has_stopped=0;

function timedCount(){
	t = setTimeout("doSlideshow()",5000);
}

function doTimer(){
	if(!timer_is_on){
		timer_is_on = 1;
		timedCount();
	}
}

function stopCount(){
	clearTimeout(t);
	timer_is_on = 0;
}

function doSlideshow(){
	//alert('hi mom');
	//$('.centerpiece').prepend(
	//	$('<img class="centerpieceimage" src="' + images[nextimage][0] + '" style="display:none">').fadeIn(500,0,function(){
			//alert(nextimage);
			
			$('.centerpieceFrame').css('background-image', 'url(' + images[nextimage][0] + ')');
			$('#bookmarkTitle').html(images[nextimage][1]);
			$('#bookmarkSummary').html(images[nextimage][2]);
			$('#bookmarkUrl').attr('href',images[nextimage][3] + '.html');
			if(images[nextimage][4] == '1'){
				$('#bookmarkMacOSX').attr('src', rootPath + 'images/MacOSX.png');
			} else {
				$('#bookmarkMacOSX').attr('src', rootPath + 'images/spacer.gif');
			}
			
			if(images[nextimage][5] == '1'){
				$('#bookmarkWindows').attr('src', rootPath + 'images/Windows.png');
			} else {
				$('#bookmarkWindows').attr('src', rootPath + 'images/spacer.gif');
			}
			
			showSelectedBullet(nextimage);
			
			nextimage += 1;
			if(nextimage >= images.length){
				nextimage = 0;
			}
			//$(this).remove();
	//	}));
	
	if(!timer_has_stopped){
		timedCount();
	}
	
	//*/
}

function showSelectedBullet(sel){
	for(i=0; i<images.length; i++){
		$('#centerpiece_' + i).attr('src', rootPath + 'images/hero_navigation_ini.png');
	}
	$('#centerpiece_' + sel).attr('src', rootPath + 'images/hero_navigation_sel.png');
}

function specificSlideshowImage(num){
	clearTimeout(t);
	timer_has_stopped=1;
	nextimage = num;
	doSlideshow();
}
