var facts = new Array();
facts[0] = "Wines made in 4 weeks offer great value and are generally ready to drink immediately.";
facts[1] = "Premium and ultra-premium wines made in 6-8 weeks are best kept for a few months as they will improve with age.";
facts[2] = "These wine kits may also include oak chips and grape skins to really bring out and develop all the best qualities of a premium wine.";
facts[3] = "The cost to make your own wine is around one-third the cost of buying it in a liquor store.";
facts[4] = "Our craft winemakers offer you a satisfaction guarantee or your money back.";
facts[5] = "Making your own wine is kind to the environment.  You can re-use your bottles time after time, recycle your corks and have fun whilst doing it!";
facts[6] = "Craft winemaking is fun, sociable & produces a great quality wine.";
facts[7] = "It's easy to make your own wine! It takes less time than shopping for your weekly groceries.";
facts[8] = "It takes as little as 4 weeks to make 30 bottles of great tasting wine... you choose how long it takes to drink them.";
facts[9] = "There are over 1,300 craft winemaking outlets across Canada.";
facts[10] = "You can make a wine from almost every country covered by the liquor store.";
facts[11] = "The same materials and care are used for craft winemaking as for commercially bought wine.";
facts[12] = "The grapes that make the juice in our kits come from many of the same vineyards as wine bought from the liquor store.";
facts[13] = "Crafting wine at home takes less time than you think.  It only takes 2-3 hours spread over 4-6 weeks.";

var factnumbers = new Array();
factnumbers[0] = "images/sf_04.gif";
factnumbers[1] = "images/sf_06.gif";
factnumbers[2] = "images/sf_08.gif";
factnumbers[3] = "images/sf_10.gif";
factnumbers[4] = "images/sf_12.gif";
factnumbers[5] = "images/sf_14.gif";
factnumbers[6] = "images/sf_15.gif";
factnumbers[7] = "images/sf_17.gif";
factnumbers[8] = "images/sf_19.gif";
factnumbers[9] = "images/sf_20.gif";
factnumbers[10] = "images/sf_24.gif";
factnumbers[11] = "images/sf_26.gif";
factnumbers[12] = "images/sf_28.gif";
factnumbers[13] = "images/sf_30.gif";


function widgetTick() {
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0) {
		if (window.pageYOffset)
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	
	var height = document.body.clientHeight;
	
	if (height == 0) {
		if (window.innerHeight) {
			height = window.innerHeight;
		}
	}

	if(ScrollTop + height > $('#facts_wrap').position().top + 175) {
		rnd = Math.floor(Math.random() * factnumbers.length);		

		$('#facts').html('<p>' + facts[rnd] + '</p>');
		$('#facts_number').html('<img src="' + factnumbers[rnd] + '" alt="Smart Facts" width="75" height="100">');
		
		$('#facts_wrap').animate({"width":"450px"}, 500, null, function() {
			$('#facts').animate({"top":"-=30px",opacity:"1"}, 500);						
		});
		
		return;
	}
		
	setTimeout('widgetTick()',0);
}

$(document).ready(
	function() {	
		for (var i = 0; i < factnumbers.length; i++) {
			(new Image()).src = factnumbers[i];
		}	
		
		$('#facts').css("position","relative");
		if (navigator.appName == "Microsoft Internet Explorer") {
			$('#facts').css("background-image","url('/images/fact_text_bg.gif')");						
			$('#facts').css("overflow","auto");
			$('#fact').css("margin-right","0px");
			$('#facts_wrap').css("overflow","auto");
		}
		$('#facts').css("padding-top","0px");
		$('#facts').animate({"top":"+=70px",opacity:"0.0"}, 0);		
		$('#facts_wrap').animate({"width":"0px"}, 0);
		
		setTimeout('widgetTick()',500);
	});
	
