/**
 * Flash parameters
 */
var params = 
{
	name: "OpenHappiness",
	quality: "high",
	scale: "noscale",
	wmode: "window",
	allowscriptaccess: "always",
	bgcolor: "#DD0000"
};



/**
 * Flash attributes
 */
var attributes = 
{
	id: "OpenHappiness",
	name: "OpenHappiness"
};



/**
 * Embed the swf
 */
swfobject.embedSWF("main.swf", "flashcontent", "100%", "100%", "10.0.0", "expressInstall.swf", flashvars, params, attributes);



/**
 * Set focus on the user input textfield.
 */
function setFocus()
{
	document.getElementById("userInput").focus();
}



/**
 * User typed in input textfield.
 * Send input to flash.
 */
function userInputFieldChanged()
{
	var input = document.getElementById("userInput").value;
	document.getElementById("userInput").value = '';
	getMovie('OpenHappiness').sendInput(input);
}



/**
 * Get the flash movie by name.
 */
function getMovie(movieName) 
{
	return navigator.appName.indexOf("Microsoft") != -1 ? window[movieName] : document[movieName];
}



/**
 * Open facebook sharer
 */
function openFacebook(u, t)
{
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}



/**
 * Open netlog share
 */
function openNetlog(t)
{
	window.open('http://nl.netlog.com/go/logs/shouts/view=friends&origin=external&message='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=800,height=600');
	return false;
}



/**
 * Open skyrock share
 */
function openSkyrock(id, title, text)
{	
	window.open('http://www.skyrock.com/m/blog/share-widget.php?idp=135&idm=' + encodeURIComponent(id) + '&title=' + encodeURIComponent(title) + '&text=' + encodeURIComponent(text),'sharer', 'toolbar=0,scrollbars=1,width=800,height=600');
	return false;
}



/**
 * Gives back focus when flash file reference popped up.
 * Firefox only.
 */
function regainFocus(message)
{
	if(navigator.userAgent.indexOf("Firefox")!=-1)
	{
		window.confirm(message);
	}
}



/**
 * Regain on confirm
 */
function regainFocusOnConfirm()
{
	regainFocus("Lookin' good C-: \nUpload completed");
}



/**
 * Regain on cancel
 */
function regainFocusOnCancel()
{
	regainFocus("Upload cancelled");
}
