function debug(str) {
	if (window.console)
		window.console.log(str);
}

/* addthis */

var addthis_config = { ui_language : 'fi' }
var addthis_share = { title : 'lastenseurassa.fi' }

var initialvid = Math.ceil(Math.random()*2);
var currentvid = -1;

/* ext if */

var questionID = -1;

function linkFB() {
	addthis_sendto('facebook');
}

function linkMail() {
	addthis_sendto('email');
}

function navigate(id) {
	switch (id) {
		case 1:
			window.location.href = 'v2_osallistu_keskusteluun.php';
			break;
		case 2:
			window.location.href = 'v2_nakokulmia.php';
			break;
		case 3:
			window.location.href = 'v2_testaa.php';
			break;
		case 4:
			window.location.href = 'v2_puhu.php';
			break;
		case 5:
			window.location.href = 'v2_tietoa.php';
			break;
		default:
	}
}

function addComment() {
	window.location.href = 'v2_vastaa.php?q=' + questionID;
}

function showComments() {
	window.location.href = 'v2_keskustelu.php?q=' + questionID;
}

function voteYes() {
	window.location.href = 'v2_vote.php?y=' + questionID;
}

function voteNo() {
	window.location.href = 'v2_vote.php?n=' + questionID;
}

/* / ext if */

function revealVideo() {
        $('videolink').blur();
	showVideo(initialvid);
}

function showVideo(n) {
	if ($('videoswf'))
		swfobject.removeSWF('videoswf');
	var div = new Element('div', { 'id': 'videoswf' });
	$('vw').appendChild(div);
	currentvid = n;
	swfobject.embedSWF('v2assets/swf/video2.swf', 'videoswf', '622', '391', '9.0.0', 'v2assets/swf/expressInstall.swf', { videourl:'../video/1105_video' + n + '.f4v' });
	$('video').show();
	$('video').clonePosition($('main-right'), { offsetLeft: -627, offsetTop: -29, setWidth:false, setHeight:false });
}

function swapVideo() {
	if (currentvid == 1)
		showVideo(2);
	else
		showVideo(1);
}

function hideVideo() {
        $('video').hide();
	if ($('videoswf'))
		swfobject.removeSWF('videoswf');
}

Event.observe(window, 'resize', function() {
	if ($('video')) {
		hideVideo();
	}
});

