var i = 0;
var speed = 1;

function sidebar_scroll() {
	i = i + speed;
	var scroll = $('scroll_content');
	var iscroll = $('iscroll_content');
	if (scroll) {
		scroll.scrollTop = i;
		//if (i > scroll.scrollHeight - 160) { i = 0 }; //trying a different formula
		if (i > (scroll.scrollHeight/2)+50) { i = 0 };
		t1 = setTimeout("sidebar_scroll();", 100);
	}

	if (iscroll) {
		iscroll.scrollTop = i;
		if (i > (iscroll.scrollHeight/2)+50) { i = 0 };
		t1 = setTimeout("sidebar_scroll();", 100);
	}
}

window.addEvent('domready', function() {
	sidebar_scroll();

	$('compassClick').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/contact-us/#directions';
	});

	$('home').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/';
	});

	$('golfcourse').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/golf-course/';
	});

	$('golfrates').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/golf-rates/';
	});

	$('golfoutings').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/golf-outings/';
	});

	$('specialevents').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/special-events/';
	});

	$('leagues').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/leagues/';
	});

	$('contactus').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/contact-us/';
	});

	$('blog').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/blog/';
	});

	$('lessons').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/lessons/';
	});

	$('blog').addEvent('click', function(event) {
		window.location = 'http://www.centennialacres.com/blog/';
	});

	//resize the scrolling div on interior pages depending on the size of the icontent div
	var ic = $('icontent');
	if (ic) {
		var icHeight = ic.getHeight();
		if (icHeight > 90) {
			$('iscroll_content').setStyle('max-height', icHeight-90);
		}
	}

	//resize the scrolling div on interior pages depending on the size of the icontent div
	var hc = $('home_content');
	if (hc) {
		var hcHeight = hc.getHeight();
		if (hcHeight > 90) {
			$('scroll_content').setStyle('max-height', hcHeight+52);
		}
	}



});


