/**
 * Do the page init
 */
function init() {
    // Run once only
    if (arguments.callee.done) return;
    arguments.callee.done = true;
    
    // Replace flash
    if ( document.getElementById('flash') ) {
        var filename = '/resources/ui/flash/mitre10_dreamhome_2009.swf';
        swfobject.embedSWF(
            filename + '?' + getLastModifiedDate(filename).valueOf(), 
            'flash', 
            990, 
            852, 
            '10.0.0',
            '/resources/ui/flash/expressInstall.swf',
            { 'session_name':session_name, 'session_id':session_id }
        );
    }
}

/**
 * A simple document.write for old browsers.
 */
function flash_oldBrowserWarning(container, el) {
	if (container == 'summary')
	{
		document.write('<' + el + ' class="upgrade"><span class="summary-text">Please wait, Flash Player is loading...<\/span><\/' + el + '>');
	}
	else if (container == 'detail')
	{			
		document.write('<' + el + '><span class="detail-text">If the Flash player does not appear after 10 seconds (depending on your connection speed), then it is likely that your browser is not supported. Please upgrade to a standards compliant browser such as <a href="http://www.firefox.com/">Firefox<\/a> and then refresh this page. <\/span><\/' + el + '>');
	}			
}

/**
 * Cross browser AJAX call
 */
function createXMLHttpRequest() {
    if (typeof XMLHttpRequest != 'undefined') {
        return new XMLHttpRequest();
    } else if (typeof ActiveXObject != 'undefined') {
        return new ActiveXObject('Microsoft.XMLHTTP');
    } else {
        // XMLHttpRequest not supported
    }
}

/**
 * Get last modified date of a file on the server
 * getLastModifiedDate(filename).valueOf() - use in query string
 * getLastModifiedDate(filename).toLocaleString() - human readable
 */
function getLastModifiedDate(filename) {
    var request = createXMLHttpRequest();
    request.open('HEAD', filename, false);
    request.send(null);
    return new Date(request.getResponseHeader('Last-Modified'));
}


