var wgStrophe = new StropheWrapper();

//utility functions such as reading cookie or parsing the query string
var wgBrowser = new BrowserUtilities();

//Attributes that will get passed into the swf when it is embedded
//in the page.
//Add key value pairs specific to your app into this
//object and they will get passed into the swf.
var swfConfig = {};
swfConfig.locale = jsp_locale;
swfConfig.serviceapi = jsp_serviceApi;
swfConfig.secureauth = (jsp_secureAuth == "true");
swfConfig.secureport = jsp_securePort;
swfConfig.bookmark = jsp_bookmark;
swfConfig.buildid = "15585";

swfConfig.canvasXOffset = jsp_leftWidth;
swfConfig.canvasYOffset = jsp_headerHeight;

var wgWebtop = new Webtop();
wgWebtop.minWidth = jsp_minWidth;
wgWebtop.minHeight = jsp_minHeight;
wgWebtop.preferredLocale = jsp_preferredLocale; //what's this for???

//remove this javascript if you don't use the mail app
var wgMail = new Mail();

wgMail.downloadMessage = jsp_downMessage;
wgMail.popDownloadText = jsp_downloadLabel;
wgMail.popCancelText = jsp_cancelLabel;

var appDebug = ((wgBrowser.getQueryVariable("debug") == "true") ? "true" : "false");
var backtrace = ((wgBrowser.getQueryVariable("backtrace") == "true") ? "true" : "false");
var lzr = wgBrowser.getQueryVariable("lzr");
var defaultRuntime = "swf8";
lzr = (lzr ? lzr : defaultRuntime);
var isDHTML = (lzr == 'dhtml');
if (isDHTML) {
    var imageroot = "/trunk/"; //Set by the build-dev target
    // We must load the LFC in the head element for DHTML.
    var append = '';
    if (backtrace == 'true') {
        append = '-backtrace';
    } else if (appDebug == 'true') {
        append = '-debug';
    }
    lz.embed.lfc('15585/lps/includes/lfc/LFCdhtml' + append + '.js', imageroot);
}

function init() {
    wgWebtop.init(isDHTML);
    if(wgMail) wgMail.init();
    
    //this ensures that when you click on the swf the iframe doesn't hide
    if (wgBrowser.isie && !isDHTML) {
        var theSwf = document.getElementById('lzapp');
        if (theSwf) theSwf.onfocus = wgWebtop.forceIframesVisible;
    }
    if (!isDHTML) wgWebtop.returnFocus();
}
Lz.attachEventHandler(window, 'load', this, 'init');

//This is used to call methods on index.jsp from inside the swf, because you 
//can't call methods outside your own frame in Firefox2 using lz.Browser.callJS.
//Only use this method if your context object lives in index.jsp.
function callMethodOnIndexJSP(context, method, args) {
    return this[context][method].apply(this[context], args);
}

