
// 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();
	}

	//self.location.href = '/OS4/index.php/Shell/Desktop';
	// OS_URI is a hidden var that must exist in the ddml page that includes this script.
	//alert(document.getElementById('OS_URI').value + '/Shell/Desktop');
	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 path = window.location.pathname;
	var prefix = path.substring(0,path.indexOf("/index.php"));
		
	var feedbackurl = prefix + "/Classic/apps/feedback/index.phtml?AppID=feedback&helpname="+app;
	
	window.open(feedbackurl,"feedback","height=500,width=450,resizeable=1,titlebar=1,dependant=1,scrollbars=1");
}

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

