var photosTopPromoHTML = "";
var photosTreatment = "instory";
var noPhotosSidebar;

function breadcrumbTrail () {

	for (i=0;i < breadCrumbs.length; i++ ) {
		var crumbclass = "crumb";
		var items = breadCrumbs[i].split('|');
		if (i > 0){
			document.write (" &raquo; ");
		}
		if (i == breadCrumbs.length - 1) {
			crumbclass = "last_crumb";
		}
		document.write ('<a class="' + crumbclass + '" href="' + items[1] + '">' + items[0] + "</a>");
	}

}

function popupEmail () {
	window.open('','new','width=590,height=350, resize=yes,scrollbars=yes');
}

function siteTools () {
	document.write (memberServicesStory());
	document.write ('<span class="sep">|</span><a href="/faq/">Help</a>');
}


function storyTools () {
	document.write ('<a href="/cgi-bin/print_story.pl"><img src="/images/v4.5/story/print3.gif" width=45 height=14 border=0 /></a><a href="http://apps.augusta.com/email-stories/email-story.html" target=new onclick="popupEmail();"><img src="/images/v4.5/story/email3.gif" width=47 height=14 border=0 style="margin-left:8px" /></a>');
}


// ---------------------------------------------------------------------------------------------------------
// In-Story images
// ---------------------------------------------------------------------------------------------------------

function nextStoryImage () {
	var photoSize;
	if (photosTreatment=="standalone") {
		photoSize = 256;
	} else if (photosTreatment=="instory"){
		photoSize = 170;
	}
	var storyImageFolder = "";
	if (storySection == "latestnews") { storyImageFolder = "latest/";  } else { storyImageFolder = ""; }
	if (storyImageIndex == (storyImages.length - 1)) {
		storyImageIndex = 0;
	}
	else {
		storyImageIndex++;
	}
	document.getElementById('storyImage').src = 'http://augustachronicle.com/images/headlines/'+storyImageFolder+storyPubDate+'/'+storyImages[storyImageIndex][0]+'_'+photoSize+'.jpg';
//	document.getElementById('storyImageLink').href = 'http://augustachronicle.com/images/headlines/'+storyPubDate+'/'+storyImages[storyImageIndex][0]+'_512.jpg';
	document.getElementById('storyImageLink').href = 'http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[storyImageIndex][0]+'&title='+((window.storySection) ? storySection : 'All+Photos');
	document.getElementById('storyImageCredit').innerHTML = storyImages[storyImageIndex][1];
	document.getElementById('storyImageCaption').innerHTML = storyImages[storyImageIndex][2];
	document.getElementById('storyImageStatus').innerHTML = (storyImageIndex + 1)+' / '+(storyImages.length);
}

function previousStoryImage () {
	var photoSize;
	if (photosTreatment=="standalone") {
		photoSize = 256;
	} else if (photosTreatment=="instory"){
		photoSize = 170;
	}
	var storyImageFolder = "";
	if (storySection == "latestnews") { storyImageFolder = "latest/";  } else { storyImageFolder = ""; }
	if (storyImageIndex == 0) {
		storyImageIndex = (storyImages.length - 1);
	}
	else {
		storyImageIndex--;
	}
	document.getElementById('storyImage').src = 'http://augustachronicle.com/images/headlines/'+storyImageFolder+storyPubDate+'/'+storyImages[storyImageIndex][0]+'_'+photoSize+'.jpg';
//	document.getElementById('storyImageLink').href = 'http://augustachronicle.com/images/headlines/'+storyPubDate+'/'+storyImages[storyImageIndex][0]+'_512.jpg';
	document.getElementById('storyImageLink').href = 'http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[storyImageIndex][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')
	document.getElementById('storyImageCredit').innerHTML = storyImages[storyImageIndex][1];
	document.getElementById('storyImageCaption').innerHTML = storyImages[storyImageIndex][2];
	document.getElementById('storyImageStatus').innerHTML = (storyImageIndex + 1)+' / '+(storyImages.length);
}


function drawInstoryPhotos () {
	if (! noPhotosSidebar) {
		var storyImageFolder = "";
		if (storySection == "latestnews") { storyImageFolder = "latest/";  } else { storyImageFolder = ""; }
		document.write ('<div id="photos-sidebar">');
		if (storyImages.length > 0) {
			document.write('<div id="photos"><img src="/images/v4.5/story/photos_top.gif" width=180 height=4 border=0 /><br>');
			if (storyImages.length > 1){
				document.write('<div style="text-align:center;padding:1px 0 4px 0"><a href="javascript:previousStoryImage()"><img src="/images/v4.5/story/photo_prev.gif" width=6 height=11 border=0 align=middle /></a><span id="storyImageStatus"></span><a href="javascript:nextStoryImage()"><img src="/images/v4.5/story/photo_next.gif" width=6 height=11 border=0 align=middle /></a></div>');
				document.getElementById('storyImageStatus').innerHTML = '1 / '+(storyImages.length);
			} else {
				document.write('<div style="height:6px;overflow:hidden;"></div>');
			}
	//		document.write('<div style="text-align:center;"><a href="http://augustachronicle.com/images/headlines/'+storyPubDate+'/'+storyImages[0][0]+'_512.jpg" target="NEW" id="storyImageLink"><img src="http://augustachronicle.com/images/headlines/'+storyPubDate+'/'+storyImages[0][0]+'_170.jpg"  border=0 class="gallery_photo" id="storyImage"></a></div><div class="credit" id="storyImageCredit">'+storyImages[0][1]+'</div><div class="caption" id="storyImageCaption">'+storyImages[0][2]+'</div></div>');
			document.write('<div style="text-align:center;"><a href="http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[0][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')+'" id="storyImageLink"><img src="http://augustachronicle.com/images/headlines/'+storyImageFolder+storyPubDate+'/'+storyImages[0][0]+'_170.jpg"  border=0 class="gallery_photo" id="storyImage"></a></div><div class="credit" id="storyImageCredit">'+storyImages[0][1]+'</div><div class="caption" id="storyImageCaption">'+storyImages[0][2]+'</div></div>');
			storyImageIndex = 0;
		}
		document.write('<a href="http://chronicle.augusta.com/rd/email/sidebar.html"><img src="http://chronicle.augusta.com/images/promos/breaking-promo.gif" width="180" height="121" alt="Get local breaking news alerts from The Chronicle" style="border:none" /></a>');
		document.write('</div>');
	}
}

function drawStandalonePhotos () {
	var storyImageFolder = "";
	if (storySection == "latestnews") { storyImageFolder = "latest/";  } else { storyImageFolder = ""; }
	document.write('<div style="text-align:center">');
	document.write ('<div id="photos-standalone">');
	if (storyImages.length > 0) {
		document.write('<div id="standalone"><img src="/images/v4.5/story/standalone_top.gif" width=266 height=9 border=0 /><br>');
		if (storyImages.length > 1){
			document.write('<div style="text-align:center;padding:1px 0 4px 0"><a href="javascript:previousStoryImage()"><img src="/images/v4.5/story/photo_prev.gif" width=6 height=11 border=0 align=middle /></a><span id="storyImageStatus"></span><a href="javascript:nextStoryImage()"><img src="/images/v4.5/story/photo_next.gif" width=6 height=11 border=0 align=middle /></a></div>');
			document.getElementById('storyImageStatus').innerHTML = '1 / '+(storyImages.length);
		} else {
			document.write('<div style="height:6px;overflow:hidden;"></div>');
		}
//		document.write('<div style="text-align:center;"><a href="http://augustachronicle.com/images/headlines/'+storyPubDate+'/'+storyImages[0][0]+'_512.jpg" target="NEW" id="storyImageLink"><img src="http://augustachronicle.com/images/headlines/'+storyPubDate+'/'+storyImages[0][0]+'_170.jpg"  border=0 class="gallery_photo" id="storyImage"></a></div><div class="credit" id="storyImageCredit">'+storyImages[0][1]+'</div><div class="caption" id="storyImageCaption">'+storyImages[0][2]+'</div></div>');
		document.write('<div style="text-align:center;"><a href="http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[0][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')+'" id="storyImageLink"><img src="http://augustachronicle.com/images/headlines/'+storyImageFolder+storyPubDate+'/'+storyImages[0][0]+'_256.jpg" border=0 class="gallery_photo" id="storyImage"></a></div><div class="credit" id="storyImageCredit">'+storyImages[0][1]+'</div><div class="caption" id="storyImageCaption">'+storyImages[0][2]+'</div><div class="purchase" id="storyImagePurchase"><a href="http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[0][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')+'" id="storyImageLink">Click photo for options</a></div></div>');
		storyImageIndex = 0;
	}
	document.write('</div>');
	document.write('</div>');
}



function storyPhotos () {
	if (photosTreatment=="instory")	{
		drawInstoryPhotos();
	} else if (photosTreatment=="standalone"){
		drawStandalonePhotos();
	}
}
