// general purpose javascript routines for use by WebsiteOS apps

function appHelp(lang,resource)
{
	var helpsite = "http://help.websiteos.com/websiteos_" + lang + "/context_help.phtml?helpName=";
	helpsite += resource + ".htm";
	
	if (resource.indexOf("://") > 0) {
		helpsite = resource;			// use custom documentation
	}
	
	window.open(helpsite,"HELP","resizeable=1,titlebar=1,dependant=1,scrollbars=1");
}

function appLoaded(appid)
{
	if (top.location != self.location) {
		if (parent.frames['NAVDETAIL'])
			parent.frames['NAVDETAIL'].refreshTaskbar(appid);
	}
}

function appClose()
{
	if ( parent.frames['NAVDETAIL'] )
	{
		parent.frames['NAVDETAIL'].closer();
	}

	// OS_URI is a hidden var that must exist in the ddml page that includes this script.
	self.location.href = document.getElementById('OS_URI').value + '/Shell/Desktop';
}

function appAddFavorite(appid)
{
	taskloc = parent.frames['TASKBAR'].location.href;
	
	if (taskloc.indexOf('?') > 0) {
		taskloc += "&command=AddFavorite&app="+appid;
	} else {
		taskloc += "?command=AddFavorite&app="+appid;
	}

	parent.frames['TASKBAR'].location = taskloc;	
}

function appFeedback(app)
{
	var appparam = '';
	if (app)
		appparam = '?appid='+app;
	self.location.href = document.getElementById('OS_URI').value + '/Run/feedback'+appparam;
}

// opens the "script page" display in Workspace
function scriptRun(id)
{
	document.forms[0].ActivePage.value = id;
	document.forms[0].submit();      
}

