$(document).ready(init);

function drawFlash()
{
	var vars = {videoURL:"wizardVideo_lowQuality.f4v"};
	var params = {menu:"false", wmode:"opaque", allowScriptAccess:"always"};
	var attributes = { id:"appSWF", name:"appSWF" }; // give an id to the flash object
	swfobject.embedSWF("../../flash/RatioVideoPlayer.swf", "wizard_videoSWF", "285", "160", "9.0.115", "", vars, params, attributes);
}
drawFlash(); //we need to call this ASAP, not only after the page is ready

var _rootImagePath = "../../images/skins/skinA/"
var _imagesToPreload =
[
	"youLikedThisIcon.png",
	"thanksForVoting.gif",
	"clickHereForTheResultsButton.gif",
	"bg-smartbar_share.gif",
	"bg-smartbar_body.png",
	"wizard/wizard/hint1_off.png",
	"wizard/hint1_off.png",
	"wizard/hint1_on.png",
	"wizard/hint2_on.png",
	"wizard/hint3_on.png",
	"wizard/hintButton-green.gif",
	"wizard/number1_off.png",
	"wizard/number1_on.png",
	"wizard/number2_on.png",
	"wizard/number3_on.png",
	"wizard/tooltip-poll1.png",
	"wizard/tooltip-opinion2.png",
	"wizard/tooltip-rate3.png"
]
var _wizard;
var _sharing;

function init()
{
	jQuery.each(jQuery.browser, function(i) {
		if($.browser.safari)$("body").addClass("safari");
	});
	preloadImages();
	_wizard = new Wizard();
	_sharing = new Sharing();
	window.onresize = handleResize;
	handleResize();
	if($.browser.msie){
		//$("heroImage").css("margin-left", "");
		$(".pollImagery").css("margin-top", "-30px");
		$(".pollImagery").css("margin-left", "50px");
		$(".pollOption_results").css("margin-left", "0");
		$(".pollOption_barChart").css("margin-left", "0");
		$(".comment-link").css("height", "32px");
		$(".captchaInputContainer").css("margin-left", "0");
	}
	//$(".pollImagery").css("display", "block");
}

function preloadImages()
{
	var m = _imagesToPreload.length;
	for(var i=0; i<m; i++){
		var image = new Image(10, 10);
		image.src= _rootImagePath + _imagesToPreload[i];
	}
}

function trackClick(label)
{
	countClick(globalSparkwordId, label);
}

function handleResize()
{
	var w = window.innerWidth;
	var h = window.innerHeight;
	_wizard.onResize();
	_sharing.onResize();
}

