/*
This code gets around an issue with the 4/2006 release of internet explorer
forcing users to click active content once before it becomes active.

$Header: /httpd/htdocs/test/RCS/map.js,v 1.1 2007/05/08 00:07:29 sgray Exp $
$Log $
*/

var saveMapWidth = null;

function writeMap(session, path, type, debug) {
    var initstr = "debugmode=" + debug + "&xmlfilepath=" + path + "/st" + type + ".xml/%2b/" + session + "/init";
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
    document.write('    codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"');
    document.write('    width="520" height="300" id="usamap1101base" align="middle">');
    document.write('    <param name="allowScriptAccess" value="sameDomain" />');
    document.write('    <param name="movie" value="/images/map/usamap1101base.swf?' + initstr + '" />');
    document.write('    <param name="menu" value="true" />');
    document.write('    <param name="quality" value="high" />');
    document.write('    <param name="bgcolor" value="#ffffff" />');
    document.write('    <param name="BASE" value="/images/map/" />');
    document.write('    <param name="wmode" value="transparent" />');
    document.write('    <embed src="/images/map/usamap1101base.swf?' + initstr + '"');
    document.write('        BASE="/images/map/" wmode="transparent"');
    document.write('        menu="true" quality="high" bgcolor="#ffffff" width="520" height="300" name="usamap1101base"');
    document.write('        align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"');
    document.write('        pluginspage="https://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

/* allow changing size */
function writeMap2(session, path, type, width, debug) {
    var pparts = path.split('/texis');
    var host = pparts[0];
    var initstr = "debugmode=" + debug + "&xmlfilepath=" + path + "/st" + type + ".xml/%2b/" + session + "/init";
    var ratio = 0.576923;
    if (typeof width == 'undefined' || width < 100 || width == '') width = 520;
    var height = Math.round(width * ratio);
    saveMapWidth = width;
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
    document.write('    codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"');
    document.write('    width="' + width + '" height="' + height + '" id="usamap1101base" align="middle">');
    document.write('    <param name="allowScriptAccess" value="sameDomain" />');
    document.write('    <param name="movie" value="' + host + '/images/map/usamap1101base.swf?' + initstr + '" />');
    document.write('    <param name="menu" value="true" />');
    document.write('    <param name="quality" value="high" />');
    document.write('    <param name="bgcolor" value="#FFFFFF" />');
    document.write('    <param name="BASE" value="' + host + '/images/map/" />');
    document.write('    <param name="wmode" value="transparent" />');
    document.write('    <embed src="' + host + '/images/map/usamap1101base.swf?' + initstr + '"');
    document.write('        BASE="' + host + '/images/map/" wmode="transparent"');
    document.write('        menu="true" quality="high" bgcolor="#FFFFFF" width="' + width + '" height="' + height + '" name="usamap1101base"');
    document.write('        align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"');
    document.write('        pluginspage="https://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}

function writeMapTo(id, session, path, type, debug) {
    var width = 520;
    if (saveMapWidth != null) width = saveMapWidth;
    writeMapTo2(id, session, path, type, width, debug);
}

function writeMapTo2(id, session, path, type, width, debug) {
    var initstr = "debugmode=" + debug + "&xmlfilepath=" + path + "/st" + type + ".xml/%2b/" + session + "/init";
    var ratio = 0.576923;
    if (typeof width == 'undefined' || width < 100 || width == '') width = 520;
    var height = Math.round(width * ratio);
    var pparts = path.split('/texis');
    var host = pparts[0];
    var text = ""
    text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
    text += '    codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"';
    text += '    width="' + width + '" height="' + height + '" id="usamap1101base" align="middle">';
    text += '    <param name="allowScriptAccess" value="sameDomain" />';
    text += '    <param name="movie" value="' + host + '/images/map/usamap1101base.swf?' + initstr + '" />';
    text += '    <param name="menu" value="true" />';
    text += '    <param name="quality" value="high" />';
    text += '    <param name="bgcolor" value="#ffffff" />';
    text += '    <param name="BASE" value="' + host + '/images/map/" />';
    text += '    <param name="wmode" value="transparent" />';
    text += '    <embed src="' + host + '/images/map/usamap1101base.swf?' + initstr + '"';
    text += '        BASE="' + host + '/images/map/" wmode="transparent"';
    text += '        menu="true" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="usamap1101base"';
    text += '        align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"';
    text += '        pluginspage="https://www.macromedia.com/go/getflashplayer" />';
    text += '</object>';
    document.getElementById(id).innerHTML = text;
}

/**
Write a map to the division identified by id.  Include a menu option to load and 
create regions.
*/
function writeMapTo3(id, session, path, type, width, debug) {
    var text = "";
    text += '<div id="mpRegMapDiv">\n';
    text += '    <div><a class="hmenu" href="#" onclick="psDoCriteriaMenu(\'Region\');return false;">REGION OPTIONS</a></div>\n';
    text += '    <div id="mpRegMap"></div>\n';
    text += '</div>\n';
    document.getElementById(id).innerHTML = text;
    if (!width) width = 520;
    if (!debug) debug = 'off';
    writeMapTo2("mpRegMap", session, path, type, width, debug);
}

function writeStaticMap(fname, debug) {
    var initstr = "debugmode=" + debug + "&xmlfilepath=" + fname;
    var text = ""
    text += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
    text += '    codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"';
    text += '    width="520" height="300" id="usamap1101base" align="middle">';
    text += '    <param name="allowScriptAccess" value="sameDomain" />';
    text += '    <param name="movie" value="/images/map/usamap1101base.swf?' + initstr + '" />';
    text += '    <param name="menu" value="true" />';
    text += '    <param name="quality" value="high" />';
    text += '    <param name="bgcolor" value="#ffffff" />';
    text += '    <param name="BASE" value="/images/map/" />';
    text += '    <param name="wmode" value="transparent" />';
    text += '    <embed src="/images/map/usamap1101base.swf?' + initstr + '"';
    text += '        BASE="/images/map/" wmode="transparent"';
    text += '        menu="true" quality="high" bgcolor="#ffffff" width="520" height="300" name="usamap1101base"';
    text += '        align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"';
    text += '        pluginspage="https://www.macromedia.com/go/getflashplayer" />';
    text += '</object>';
    document.write(text);
}


