
var slider;
function initFeature() {
	if (!$('sectionB')) {
		return;
	}
	slider = new Control.Slider('handle', 'scroller', {
		axis: 'vertical',
		onSlide: function(v) { scrollVertical(v, $('sectionB'), slider);  },
		onChange: function(v) { scrollVertical(v, $('sectionB'), slider); }
	});	
	//alert($('sectionA').scrollHeight);
	//alert($('scroller').offsetHeight);			
	if (document.all) {
		var movie_height = 465;
		if ($('feature-main-content').hasClassName('widescreen')) {
			movie_height = 370;
		}
		if ($('sectionB').scrollHeight <= movie_height) { disableScrolling(); }
		$('scroller').height = $('promo').height;			
	} else {
		if ($('sectionB').scrollHeight <= $('scroller').offsetHeight) { disableScrolling(); }
	}
	/*@cc_on @if(@_jscript_version <= 5.7) @*/
		var topStory = document.getElementById("sectionB").getElementsByTagName("H3")[0];
		topStory.style.fontSize = "24px";
	/*@end @*/
	if ($('newsTicker')) {	
		writeTicker(WEBSITE_IMAGES+"/generated/rss/BN/FB-latest.xml","newsTicker","#FFFFFF","#656565","#FFFFFF"); 
	}
	if (window.location.href.indexOf('survivingkatrina') != -1) {
		// this is a hack for thr top headline if the feature is surviving katrina
		ankor = $(topStory).firstDescendant()
		ankor.href = '#';
		ankor.title = '';
		addEvent(ankor, 'mouseover', function() {
			$(ankor).setStyle({
				cursor: 'default',
				textDecoration: 'none'
			});
		}); 
	}
}
	
function scrollVertical(value, element, slider) {
	element.scrollTop = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight));
}

function disableScrolling() {
	slider.setDisabled();
	$('handle').hide();
	$('sectionB').style.width = "332px";
	$('sectionB').style.marginRight = "0";
	$('scroller').style.display = "none";
}

var katrina = {
	swapper : function(v) {
		var vp;
		if (v=="gertrude") {
			vp = new SWFObject("http://www.theglobeandmail.com/v5/content/video/specialhub/survivingkatrina/swf/video_player.swf", "video", "544", "353", "8");
			vp.addVariable("highBandwidthSource", "http://www.theglobeandmail.com/v5/content/video/specialhub/survivingkatrina/flv/gertrude.flv");
			vp.addVariable("prePlaySource", "http://www.theglobeandmail.com/v5/content/video/specialhub/survivingkatrina/gertrude.jpg");
			vp.addVariable("preRollSource", "http://www.theglobeandmail.com/v5/content/video/specialhub/survivingkatrina/swf/gam_preroll.swf");
			vp.write("video-player");	
		} else {
			vp = new SWFObject("http://www.theglobeandmail.com/v5/content/video/specialhub/survivingkatrina/swf/video_player.swf", "video", "544", "353", "8");
			vp.addVariable("highBandwidthSource", "http://www.theglobeandmail.com/v5/content/video/specialhub/survivingkatrina/flv/shrimper.flv");
			vp.addVariable("prePlaySource", "http://www.theglobeandmail.com/v5/content/video/specialhub/survivingkatrina/shrimper.jpg");
			vp.addVariable("preRollSource", "http://www.theglobeandmail.com/v5/content/video/specialhub/survivingkatrina/swf/gam_preroll.swf");
			vp.write("video-player");
		}
	}
}
	
addEvent(window, "load",  initFeature);