
var photosTopPromoHTML = "";
var noPhotosSidebar;
var photosTreatment = "instory";
var photosInterval = "6000";
var photosDrawn = 0;

function fixPubDate () {
	if ( (typeof storyPubDate != 'undefined') && ( /^\d{6}$/.test(storyPubDate) ) ) {
		var pubParts = storyPubDate.match(/(\d{2})(\d{2})(\d{2})/);
		pubParts[3] = ( pubParts[3] < 95 ? '20'+pubParts[3] : '19'+pubParts[3] );
		storyPubDate = pubParts[3] + '/' + pubParts[1] + '/' + pubParts[2];
	}
}

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>');
}

var shareShow = false;
function shareIn() {
	document.getElementById( 'sharing' ).style.display = '';
	shareShow = true;
}

function shareOut() {
	shareShow = false;
	setTimeout(hideSharing,1000);
}

function hideSharing() {
	if ( !shareShow ) {
		document.getElementById( 'sharing' ).style.display = 'none';
	}
}

function storyTools () {
	if ( document.all ) {
		document.write('<a href="#comments" id="story-comments-count">COMMENT</a>');
		document.write('<a href="http://chronicle.augusta.com/cgi-bin/print_story.pl" id="story-print-icon">PRINT</a>');
		document.write('<a href="#" style="font-size:11px;background: transparent url(http://chronicle.augusta.com/images/v4.5/icons/share.png) no-repeat;padding-left:15px;" onmouseover="shareIn();" onmouseout="shareOut();">Share</a><ul id="sharing" style="list-style-type:none;z-index:500;position:absolute;display:none;background:white;border:1px solid #666666;padding: 7px 7px 7px -7px;margin-left:-113px;margin-top:15px;" onmouseover="shareIn();" onmouseout="shareOut();">');
	} else {
		document.write('<div style="float: right"><a href="#" style="font-size:11px;background: transparent url(http://chronicle.augusta.com/images/v4.5/icons/share.png) no-repeat;padding-left:15px;" onmouseover="shareIn();" onmouseout="shareOut();">Share</a><ul id="sharing" style="list-style-type:none;z-index:500;position:absolute;display:none;background:white;border:1px solid #666666;padding: 7px 7px 7px 7px;margin-left:-54px;" onmouseover="shareIn();" onmouseout="shareOut();">');
	}
	writeEmail();
	writeAim();
	writeDelicious();
	writeDiggit();
	writeFacebook();
	writeFark();
	writeNewsvine();
	writeReddit();
	writeStumbleUpon();
	writeYBuzz();
	document.write('</ul>');
	if ( ! document.all ) {
		document.write('</div>');
		document.write('<a href="#comments" id="story-comments-count">COMMENT</a>');
		document.write('<a href="http://chronicle.augusta.com/cgi-bin/print_story.pl" id="story-print-icon">PRINT</a>');
	}
}

function writeAim() {
	document.write( "<li style=\"padding-bottom: 6px; font-size: 14px;background: transparent url(/images/v4.5/icons/aim.png) no-repeat;\"><a href=\"aim:goim?message="+location.href+"\" style=\"font-size:11px;padding-left:20px;\">AOL IM</a></li>" );
}

function writeDelicious() {
	document.write( "<li style=\"padding-bottom: 6px; font-size: 14px;background: transparent url(/images/v4.5/icons/delicious.ico) no-repeat;\"><a href=\"http://del.icio.us/post\" onclick=\"window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=700,height=400'); return false;\" style=\"font-size:11px;padding-left:20px;\">Del.icio.us</a></li>" );
}

function writeDiggit() {
	document.write( "<li style=\"padding-bottom:6px;font-size:14px;background: transparent url(/images/v4.5/icons/digg.ico) no-repeat;\"><a href=\"http://digg.com/submit?url="+encodeURIComponent(location.href)+"\" target=\"blank\" style=\"font-size:11px;padding-left:20px;\">Digg It</a></li>" );
}

function writeEmail() {
	document.write( '<li style=\"padding-bottom:6px;font-size:14px;background: transparent url(/images/v4.5/icons/email.gif) no-repeat;\"><a href="http://apps.augusta.com/email-stories/email-story.html" target="new" onclick="popupEmail();" style=\"font-size:11px;padding-left:20px;\">Email</a></li>');

}

function writeFacebook() {
	document.write( '<li style=\"padding-bottom:6px;font-size:14px;background: transparent url(/images/v4.5/icons/facebook.ico) no-repeat;\"><a href="http://www.facebook.com/share.php?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title)+'" target="blank" style=\"font-size:11px;padding-left:20px;\">Facebook</a></li>' );
}

function writeFark() {
	document.write( '<li style=\"padding-bottom:6px;font-size:14px;background: transparent url(/images/v4.5/icons/fark.ico) no-repeat;\"><a href="http://cgi.fark.com/cgi/fark/farkit.pl?h='+encodeURIComponent(document.title)+'&u='+encodeURIComponent(location.href)+'" target="_blank" style="font-size:11px;padding-left:20px;\">Fark It</a></li>' );
}

function writeNewsvine() {
	document.write( "<li style=\"padding-bottom:6px;font-size:14px;background: transparent url(/images/v4.5/icons/newsvine.ico) no-repeat;\"><a href=\"javascript:void(0)\" onclick=\"window.open('http://www.newsvine.com/_wine/save?popoff=1&u=INSERT-YOUR-URL-HERE','newsvine','toolbar=no,width=590,height=600,resizable=yes,scrollbars=yes')\" style=\"font-size:11px;padding-left:20px;\">Newsvine</a></li>" );
}

function writeReddit() {
	document.write( "<li style=\"padding-bottom:6px;font-size:14px;background: transparent url(/images/v4.5/icons/reddit.ico) no-repeat;\"><a href=\"http://reddit.com/submit?url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title)+"\" target=\"blank\" style=\"font-size:11px;padding-left:20px;\">Reddit</a></li>" );
}

function writeStumbleUpon() {
	document.write( "<li style=\"padding-bottom:6px;font-size:14px;background: transparent url(/images/v4.5/icons/stumbleupon.ico) no-repeat;\"><a href=\"http://www.stumbleupon.com/submit?url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title)+"\" target=\"blank\" style=\"font-size:11px;padding-left:20px;\">StumbleUpon</a></li>" );
}

function writeYBuzz() {
	document.write( '<li style=\"padding-bottom:6px;font-size:14px;background: transparent url(/images/v4.5/icons/yahoobuzz.png) no-repeat;\"><a href="http://buzz.yahoo.com/article/augusta_chron779/'+encodeURIComponent(location.href)+'" target="blank" style="font-size:11px;padding-left:20px;">Yahoo! Buzz</a></li>' );
}

function nextStoryImage () {
	var photoSize;
	if (photosTreatment=="standalone" || photosTreatment=="standalone_auto") {
		photoSize = 256;
	} else if (photosTreatment=="instory"){
		photoSize = 170;
	}
	if (storyImageIndex == (storyImages.length - 1)) {
		storyImageIndex = 0;
	}
	else {
		storyImageIndex++;
	}
	document.getElementById('storyImage').src = 'http://chronicle.augusta.com/images/headlines/'+storyPubDate+'/'+storyImages[storyImageIndex][0]+'_'+photoSize+'.jpg';
	document.getElementById('storyImageLink').href = 'http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[storyImageIndex][0]+'&title='+((window.storySection) ? storySection : 'All+Photos');
	if ( /\/lat_/.test(window.location) == false ) {
		document.getElementById('storyImagePurchase').innerHTML = '<a href="http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[storyImageIndex][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')+'" id="storyImageLink">Click photo for options</a>';
	}
	document.getElementById('storyImageCredit').innerHTML = storyImages[storyImageIndex][1];
	document.getElementById('storyImageCaption').innerHTML = storyImages[storyImageIndex][2];
	document.getElementById('storyImageStatus').innerHTML = (storyImageIndex + 1)+' / '+(storyImages.length);
	document.getElementById('storyImageLink').href = 'http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[storyImageIndex][0]+'&title='+((window.storySection) ? storySection : 'All+Photos');
}

function previousStoryImage () {
	var photoSize;
	if (photosTreatment=="standalone" || photosTreatment=="standalone_auto") {
		photoSize = 256;
	} else if (photosTreatment=="instory"){
		photoSize = 170;
	}
	if (storyImageIndex == 0) {
		storyImageIndex = (storyImages.length - 1);
	}
	else {
		storyImageIndex--;
	}
	document.getElementById('storyImage').src = 'http://chronicle.augusta.com/images/headlines/'+storyPubDate+'/'+storyImages[storyImageIndex][0]+'_'+photoSize+'.jpg';
	document.getElementById('storyImageLink').href = 'http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[storyImageIndex][0]+'&title='+((window.storySection) ? storySection : 'All+Photos');
	if ( /\/lat_/.test(window.location) == false ) {
		document.getElementById('storyImagePurchase').innerHTML = '<a href="http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[storyImageIndex][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')+'" id="storyImageLink">Click photo for options</a>';
	}
	document.getElementById('storyImageCredit').innerHTML = storyImages[storyImageIndex][1];
	document.getElementById('storyImageCaption').innerHTML = storyImages[storyImageIndex][2];
	document.getElementById('storyImageStatus').innerHTML = (storyImageIndex + 1)+' / '+(storyImages.length);
	document.getElementById('storyImageLink').href = 'http://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[storyImageIndex][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')
}


function drawInstoryPhotos () {
	fixPubDate();
	var drawSidebar = true;
	if (noPhotosSidebar) {
		drawSidebar = false;
	} else if ( ((t_Section == 'Football') || (t_Section == 'HighSchool' )) && storyImages.length == 0 ) {
		drawSidebar = false;
	}

	if ( drawSidebar ) {
		document.write ('<div id="photos-sidebar">');
		if (photosTopPromoHTML != ""){
			document.write ('<div id="photos-top-promo">'+photosTopPromoHTML+'</div>');
		}
		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://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[0][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')+'" id="storyImageLink"><img src="http://chronicle.augusta.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>');
			if ( /\/lat_/.test(window.location) == false ) {
				document.write('<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>');
			}
			document.write('</div>');
			storyImageIndex = 0;
		} else {
			var r = rand(2)-1;
			if (r==0){
				document.write('<a href="http://chronicle.augusta.com/rd/email/sidebar.html"><img src="http://chronicle.augusta.com/images/v4.5/story/promo/promo-breakingnews.gif" width="180" alt="Sign up for breaking news alerts from The Chronicle" style="border:none" /></a>');
			} else if (r==1){
				document.write('<a href="http://chronicle.augusta.com/rd/email/sidebar.html"><img src="http://chronicle.augusta.com/images/v4.5/story/promo/promo-headlines.gif" width="180" alt="Sign up to get local news by e-mail" style="border:none" /></a>');
			}
		}
		document.write('</div>');
	}
}

function drawApPhotos () {
	document.write ('<div id="photos-sidebar">');
	if (photosTopPromoHTML != ""){
		document.write ('<div id="photos-top-promo">'+photosTopPromoHTML+'</div>');
	}
	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="'+storyImages[0][0]+'" id="storyImageLink"><img src="'+storyImages[0][0]+'" width=170  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 () {
	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://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[0][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')+'" id="storyImageLink"><img src="http://chronicle.augusta.com/images/headlines/'+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 drawStandalonePhotos_Auto (photosInterval) {
	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 id="slide_control" style="width:50;margin:auto;text-align:center;font-weight:bold" onclick="control_slide();" onmouseover="this.style.cursor=\'pointer\'">STOP</div>');
			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://spotted.augusta.com/chronicle/lookup.html?date='+storyPubDate+'&photo='+storyImages[0][0]+'&title='+((window.storySection) ? storySection : 'All+Photos')+'" id="storyImageLink"><img src="http://chronicle.augusta.com/images/headlines/'+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>');

	timer=setTimeout("slideshow()", "2000");
}

var counter = 1;
function slideshow() {

      counter++;

      if (counter > storyImages.length){
    clearTimeout(timer);
    timer = 0;
    counter = 1;
    document.getElementById('slide_control').innerHTML = 'PLAY';
   } else {
       timer=setTimeout("slideshow()", photosInterval);
   }
   nextStoryImage();

}

function control_slide() {
	  if (timer > 0)
	  {
		  clearTimeout(timer);
		  timer = 0;
		  counter = 1;
		  document.getElementById('slide_control').innerHTML = 'PLAY';
	  } else {
		  timer=setTimeout("slideshow()", photosInterval);
		  document.getElementById('slide_control').innerHTML = 'STOP';
	  }
}

function storyPhotos (photosInterval) {
	if (photosTreatment=="instory")	{
		drawInstoryPhotos();
	} else if (photosTreatment=="standalone"){
		drawStandalonePhotos();
	} else if (photosTreatment=="AP"){
		drawApPhotos();
	} else if (photosTreatment=="standalone_auto"){
		drawStandalonePhotos_Auto(photosInterval);
	}
}

// highlighting for corrections

var storyHighlightColor = "#fafada";
var storyHighlightOffColor = "#ffffff";
function toggleStoryHighlight (id,link,onText,offText) {
	if (id){
		var elem = document.getElementById(id);
		if (elem.highlighted == true)	{			
			elem.style.backgroundColor=storyHighlightOffColor;
			elem.highlighted = false;
			link.innerHTML = onText;
		} else {
			elem.style.backgroundColor=storyHighlightColor;
			elem.highlighted = true;
			link.innerHTML = offText;
		}
	} else {
		toggleStoryHighlightAll (link,onText,offText);
	}
}

function toggleStoryHighlightAll (link,onText,offText) {
	var spans = document.getElementsByTagName('span');
	for (var i =0;i < spans.length ;i++ ){
		var elem = spans[i];
		if (elem.id.match(/^correction/i) != null  ){			
			if (elem.highlighted == true)	{			
				elem.style.backgroundColor=storyHighlightOffColor;
				elem.highlighted = false;
				link.innerHTML = onText;
			} else {
				elem.style.backgroundColor=storyHighlightColor;
				elem.highlighted = true;
				link.innerHTML = offText;
			}
		}
	}
}

// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See:  http://www.msc.cornell.edu/~houle/javascript/randomizer.html
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
	rnd.seed = (rnd.seed*9301+49297) % 233280;
	return rnd.seed/(233280.0);
};
function rand(number) {
	return Math.ceil(rnd()*number);
};
// end central randomizer. -->


function drawRelatedTopics () {
//	var output = '';
//	var linkBase = 'http://chronicle.augusta.com/';
//	for ( var i=0; i < relatedTopics.length; i++ ) {
//		var link = '';
//		var topic = '';
//		if (relatedTopics[i].topicType == 'sports:prep') {
//			var urlName = relatedTopics[i].schoolName.replace(' ', '_').toLowerCase();
//			link = linkBase + 'sports/highschool/teams/' + urlName + '/';
//			topic = relatedTopics[i].schoolName + ' sports';
//		}
//		if ( (link) && (topic)) {
//			if (output) { output += ' | '; }
//			output += '<a class="story-tag" href="'+link+'">' + topic + '</a>';
//		}
//	}
//	output = '<span class="story-tags-label">More:</span> ' + output;
//	var tagsDiv = document.getElementById('story-tags');
//	tagsDiv.innerHTML = output;
//	tagsDiv.style.display = 'block';
}


function parseQueryString() {
	var queryHash = new Array();
	var query = window.location.search.substring(1);
	var params = query.split('&');
	for (var i=0; i<params.length; i++) {
		var pos = params[i].indexOf('=');
		if (pos > 0) {
			var key = params[i].substring(0,pos);
			var val = params[i].substring(pos+1);
			queryHash[key] = val;
		}
	}
	return queryHash;
}

var queryParam = parseQueryString();




