// When called this returns a string based on the exit state of the Flex Application.

window.onbeforeunload = checkUnload;

function checkUnload()
{
	return getExitMessage();
}

function getExitMessage()
{
	var exitString = Photatobug_App.exitMessage();
	
	if(exitString != "")
		return exitString;
	else
		return;
}

function gotoAccount()
{	
	window.location.assign('/account/');
	return true;
}

function gotoUploader()
{
	window.location.assign('/photos/upload');
	return true;
}

function gotoBugBuilder()
{
	window.location.assign('/account/bug_builder');
	return true;
}

function gotoUpgrade()
{
	window.location.assign('/account/upgrade');
	return true;
}

function gotoUrl(url)
{	
	window.location.assign(url);
	return true;
}

function onCreateYourOwn() {
	window.location.assign('/');
	return true;
}

function shareToFacebook(urlKey) {
	var pageURL = '/account/share_to_facebook?url_key='+urlKey;
	var winNew = window.open(pageURL,'sharer','toolbar=0,status=0,width=626,height=436');
	if(!winNew)
	{
		getSwf("Photatobug_App").openWindowFromFlash(pageURL); //Flash('/account/share_to_facebook?url_key='+urlKey,'sharer','toolbar=0,status=0,width=626,height=436');	
	}
	return true
}

function getSwf(id) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[id];	
	}
	else {
		return document[id];	
	}
}