var ButtonId = "zoominbutton";
var ButtonWidth = 21;           // if you change this, change the button anchors too
var ButtonHeight = 21;          // if you change this, change the button anchors too
var ButtonLocation = "left";
var SpaceBetweenButtonAndEdge = 40;
var SpaceBetweenButtonAndTop = 200;

   // global vars - the web page parameters
   var strOurLocation = GetOurLocation();
   var strGenMapURL = strOurLocation + "staticmapS.htm";
   var strXRegID;		    // encrypted seq reg ID
   var strRegToken;		    // reg token
   var strSrcToken;		    // src token
   var strMapID;                // map ID. to keep map requests synch'd with map parameter set data
   var strSessionID;            // session ID.  // current not set and "used" but not needed
   var strThumb;		    // non-blank param indicates this map is a thumb nail for its own larger version
   var strParamSetMapID;	    // map ID from the parameter set. this should match the request map ID
   var strCenter;		    // google static map param
   var strViewpoint;            // google static map param
   var viewpointX, viewpointY;  // floating x,y pixel values for viewpoint
   var mapX, mapY;              // pixel pos upper left corner of map jpg
   var strZoom;                 // google static map param
   var strSize;                 // google static map param
   var strPath;                 // google static map param
   var strTitle;
   var strPersist;		    // "Saved map" or "Temporary map"
   var strFilters;
   var strSelfRef;
   var fMultiplier;
   var VisiblePoints = [];      // master target list (sorted alphabetically) name, heading, loc.lat, loc.long for each visible point
   var fStdScrollVal = 0.020    // standard lat/long scroll value
   var iStdCropVal = 40;        // standard expand/contract pixel value
   // NOTE NOTE the max and min sizes should be evenly divisible by iStdCropVal !!
   var iMaxSize = 640;          // max pixel size allowed
   var iMinSize = 200;          // min pixel size allowed (arbitrary)
   var fDegreeWidthAt640 = 0.110;  // width of map in degrees at 640 pixels
   var fDegreeHeightAt640 = 0.074205;  // height of map in degrees at 640 pixels (an estimate!)
   var strLatitudeExtent;       // same as fDegreeHeightAt640 except corrected for mercator north-south distortion
   var fLatitudeExtent;         // ditto
   //var bInitFavoriteSaved = false;  // already ran the browser create-favorite dialog

TotalWidth = parseInt(ButtonWidth) + parseInt(SpaceBetweenButtonAndEdge);
ButtonLocation = ButtonLocation.toLowerCase();
ButtonLocation = ButtonLocation.substr(0,1);
var ButtonOnLeftEdge = (ButtonLocation=='l') ? true : false;

// get full path to this HTML file
// NOTE - this is the current window - usually www.RoseLineMaps.com/roseline/staticmapS.htm
function GetOurLocation()
{
    var myloc = window.location.href;
    var locarray = myloc.split("/");
    delete locarray[(locarray.length-1)];
    var arraytext = locarray.join("/");
    return arraytext;
}

// get address of this HTML file
// NOTE - this is the current browser page - usually www.RoseLineMaps.com/roseline/roselinemapS.htm
// if we're running on a local machine (not on the web) we return empty string
function GetTopLocation()
{
    // NOTE NOTE that top.location.href throws an error if we call it locally - like while testing
    // our web pages in frontpage !

    var myloc = "xyz";
    try {
        myloc = top.location.href;
    }
    catch (err) {
        return "";
    }
    var locarray = myloc.split("?");
    return locarray[0];
}

function AddButtonPlacementEvents(f1,f2)
{
   var cache = window.onload;
   if(typeof window.onload != 'function') { window.onload = f1; }
   else { window.onload = function() { if(cache) { cache(); } f1(); }; }
   cache = window.onresize;
   if(typeof window.onresize != 'function') { window.onresize = f2; }
   else { window.onresize = function() { if(cache) { cache(); } f2(); }; }
}

function WindowHasScrollbar() {
    var ht = 0;
    if(document.all) {
        if(document.documentElement) { ht = document.documentElement.clientHeight; }
        else { ht = document.body.clientHeight; }
    } 
    else { ht = window.innerHeight; }
    if (document.body.offsetHeight > ht) { return true; }
    else { return false; }
}

// DESCRIPTION:
//  place all the floating navigation buttons
function GlueButtons(ledge) {
    // arrange our buttons in a nice pattern
    GlueButton(ledge,"zoominbutton",50,0);
    GlueButton(ledge,"upbutton",50,25);
    GlueButton(ledge,"leftbutton",25,50);
    GlueButton(ledge,"rightbutton",75,50);
    GlueButton(ledge,"downbutton",50,75);
    GlueButton(ledge,"zoomoutbutton",50,100);

    GlueButton(ledge,"expandvertbutton",25,150);
    GlueButton(ledge,"expandallbutton",50,150);
    GlueButton(ledge,"expandhorizbutton",75,150);
    GlueButton(ledge,"contractvertbutton",25,175);
    GlueButton(ledge,"contractallbutton",50,175);
    GlueButton(ledge,"contracthorizbutton",75,175);
}

// DESCRIPTION:
//  place one floating navaigation button
function GlueButton(ledge,buttonid,x,y) {
    var did = document.getElementById(buttonid);
    did.style.top = (SpaceBetweenButtonAndTop + y) + "px";
    did.style.width = ButtonWidth + "px";
    did.style.height = ButtonHeight + "px";
    did.style.left = (ledge + x) + "px";
    did.style.display = "block";
    did.style.zIndex = "9999";
    // check for IE6
    if ( navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf( "MSIE 6" ) != -1 ) {
        // position:fixed isn't support by IE6 so we create regular buttons
        did.style.position = "absolute";
    }
    else {
        // this causes the "buttons" to float
        did.style.position = "fixed";
    }
}

function handleMDown() {
 // document.images["jsbutton"].src = "buyit15d.jpg";
 return true;
}

var queryString = new Array();

function InitPage() {
    // if we're not running from the web we aren't supported. Possibly an attempt to run from MHT file
    if ( location.href.indexOf( "http://" ) != 0 ) {
        // redirect to a page that explains...
        window.location.href = "http://www.roselinemaps.com/roseline/errorloc.htm";
        return false;
    }

    // decode page parameters 

    var parameters = window.location.search.substring(1).split('&');
    process_params(parameters);

    var temp;
    temp = queryString['mapid'];
    strMapID = unescape(temp);

    temp = queryString['sessionid'];
    strSessionID = unescape(temp);

    temp = queryString['token'];
    strRegToken = unescape(temp);

    temp = queryString['src'];
    strSrcToken = unescape(temp);

    temp = queryString['xregid'];
    strXRegID = unescape(temp);

    temp = queryString['thumb'];
    strThumb = unescape(temp);

    // ***********

    // get stuff from the <div params> section
    if ( !HandleDivParams( strMapID ) ) {
        // false return means the map has expired.  if we do nothing but return at
        // at this point the user will see a white screen with our buttons and the
        // red text that says "press F5 if your map doesn't appear". if you press F5
        // you'll again see the js alert that says your map has expired.
        // ??? this code should redirect to a page with some explanation and links
        // ??? to documentation

	 window.location.href = "http://www.roselinemaps.com/roseline/mapexpired.htm";  // redirect to explanation page

        return;
    }
    // ***********

    // make "save this map" button invisible if this map isn't permanent
    var savebutton = document.getElementById("savemap")
    if ( strPersist == "Saved map" ) { savebutton.style.visibility="visible"; }
    else { savebutton.style.visibility="hidden"; }

    // make "save this map" button invisible if we're running inside any frame
    // other than roselinemapS.htm.    

    // this makes it so that once a map is published it can't be edited

    // NOTE that when running/testing the google map locally the top.location.href throws
    // an error.  this happens when previewing the RoseLineMaps home page in frontpage...

    var toploc = GetTopLocation();
    // if ( top.location.href != window.location.href )   // <- simple test for running in a frame
    if ( toploc != "http://www.metatropo.com/roseline/roselinemapS.htm" 
         && 
         toploc != "http://www.roselinemaps.com/roseline/roselinemapS.htm" ) { 
        savebutton.style.visibility="hidden";
    }

    // create a request for a google static map. we have one marker (which is the viewpoint) and a 'path' parameter which 
    // defines a star shaped pattern connecting all the targets with the viewpoint

    var strMapImg = "default";
    strMapImg = "<img border=\"0\"   onMouseover=\"ddrivetip(strToolTipPeakInfo,'cyan', 300)\"; onMouseout=\"hideddrivetip()\"   name=\"gmap\" src=\"http://maps.google.com/maps/api/staticmap?center=" + strCenter + "&zoom=" + strZoom + "&size=" + strSize + "&maptype=terrain&markers=" + strViewpoint + "&sensor=false&path=" + strPath + "\" />";

    var mapNode = document.getElementById("map");
    mapNode.innerHTML = strMapImg;

    mapX = mapNode.offsetLeft;
    mapY = mapNode.offsetTop;

    UpdateLocSize();  // update the line that shows the map img stats: center, size, zoom
    
    CalcNewMultiplier();
    if (ButtonOnLeftEdge) {
       GlueButtons(SpaceBetweenButtonAndEdge);
    }

    // things to do if this map is a thumbnail (thumb param = non-blank)
    if ( strThumb == "1" ) {

        // hide the print button
        var printbutton = document.getElementById("printmap")
        printbutton.style.visibility="hidden";

        // hide the "save this map" button
    	 var savebutton = document.getElementById("savemap")
	 savebutton.style.visibility="hidden";

        // hide all the nav buttons

    	 var button = document.getElementById("zoominbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("zoomoutbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("upbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("downbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("leftbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("rightbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("contractvertbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("contracthorizbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("expandvertbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("expandhorizbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("expandallbutton")
	 button.style.visibility="hidden";
	 button = document.getElementById("contractallbutton")
	 button.style.visibility="hidden";

        // remove all the usual header text area

    	 var div = document.getElementById("Sfiltersettings")
	 div.parentNode.removeChild(div);
    	 div = document.getElementById("locplus")
	 div.parentNode.removeChild(div);
    	 div = document.getElementById("Slabel")
	 div.parentNode.removeChild(div);
    	 div = document.getElementById("Svisit")
	 div.parentNode.removeChild(div);
    	 div = document.getElementById("Sheader")
	 div.parentNode.removeChild(div);
    	 div = document.getElementById("Sbuttons")
	 div.parentNode.removeChild(div);

	 // set the thumb header
    	 document.getElementById("thumbheader").innerHTML = document.getElementById("viewpointname").innerHTML;

        // create a "click here for large map" link.  This is the same as the link that created this
	 // thumb except  staticS -> roselinemapS  and   thumb=1&   is removed

	 var orglink = window.location.href;
        var orglink2 = orglink.replace( "staticmapS", "roselinemapS" );
        var link = orglink2.replace( "thumb=1&", "" );
        var newlink = "Click <a target=\"_blank\" href=\"" + link + "\">here</a> for a larger map";
        //document.getElementById("thumbclick").innerHTML = newlink;


    } else {

	 // we are not being displayed as a thumbnail so get rid of the thumb related elements

    	 div = document.getElementById("thumbvisit")
	 div.parentNode.removeChild(div);
    	 div = document.getElementById("thumbheader")
	 div.parentNode.removeChild(div);
        //div = document.getElementById("thumbclick");
        //div.parentNode.removeChild(div);        
    }

    // trying to only show the bookmark dialog the first time we display the
    // the page and not during an F5 refresh.  but apparently all the variables
    // get reset on a refresh so this test doesn't work for me.
    //if ( strPersist == "Saved map" && bInitFavoriteSaved == false ) {
      //  CreateBookmarkLink(location.href, document.title); 
        //bInitFavoriteSaved = true; 
    //}
}

function getelementPosition(el) { 
    var l = 0, t = 0; 
    while (el.offsetParent) { 
        l += el.offsetLeft; 
        t += el.offsettop; 
        el = el.offsetParent; 
    } 
    return {left:l, top:t}; 
} 


// DESCRIPTION:
//   update the line that displays some img specs: center, size, zoom
function UpdateLocSize()
{
    strLocSize = "Center: " + strCenter + " Size: " + strSize + " Zoom: " + strZoom;
    document.getElementById("locsize").innerHTML = strLocSize;
}

// DESCRIPTION:
//  get stuff from the <div params> parameter set and place them with the map display
// RETURNS:
//  true if ok, else false if the map has expired

function HandleDivParams() {
    // get the map ID from the param set. this must match the page mapid parameter
    // else the user is requesting a map that has expired.

    strParamSetMapID = document.getElementById("mapid").innerHTML;
    if ( strMapID != strParamSetMapID ) {
        alert( 'This map has expired' );
        return false;
    }

    strLatitudeExtent = document.getElementById("latitudeextent").innerHTML;
    fLatitudeExtent = parseFloat( strLatitudeExtent );

    // this sets the title of the map frame and the parent page ( which contains our
    // two frames : the map and the peak list )
    document.title = document.getElementById("title").innerHTML;
    try {
      parent.document.title = document.getElementById("title").innerHTML;
    } 
    catch (err) {
        // do nothing
    }

    document.getElementById("Sviewpointname").innerHTML = document.getElementById("viewpointname").innerHTML;
    strPersist = document.getElementById("persist").innerHTML;
    document.getElementById("Spersist").innerHTML = strPersist;

    document.getElementById("Slabel").innerHTML = document.getElementById("label").innerHTML;
    document.getElementById("Svisit").innerHTML = document.getElementById("visit").innerHTML;
    document.getElementById("Sfiltersettings").innerHTML = document.getElementById("filtersettings").innerHTML;
	
    // decode the google static map params

    strCenter = document.getElementById("center").innerHTML;
    strViewpoint = document.getElementById("vp").innerHTML;
    strZoom = document.getElementById("zoom").innerHTML;
    strSize = document.getElementById("size").innerHTML;
    // note - path comes in two parts. the first part is params related to color and weight
    // the second part is the list of points that comprise the path
    strPath = document.getElementById("pathparams").innerHTML;
    strPath += document.getElementById("path0").innerHTML;

    // some derived values

    // the pixel position of the viewpoint is the center of the map when we start out
    var size = GetSize( strSize );
    viewpointX = size.x / 2;
    viewpointY = size.y / 2;

    var stryyy = document.getElementById("targetlist").innerHTML;
    var targets = stryyy.split( '$' );

    VisiblePoints = [];  // emtpy the array
    var i;

    // decode each target + data from <div id=targetlist>.  the data contained is comma delimited with
    // each record ending with a $ char.  the data is formatted thusly:
    // heading (2 dec), name, strName, latitude (4 dec), longitude (4 dec), elevation (in feet), distance (in miles, 2 dec), vertical angle (2 dec)
    // the data is sorted alphabetically by name.  The name is the unique name.

    for ( i = 0; i < targets.length; i++ ) {
        var VisiblePoint = new Object;
        var t = targets[i].split(',');
        if ( t[1] == undefined ) continue;

        VisiblePoint.name = t[1];
        VisiblePoint.heading = parseFloat(t[0]);
        VisiblePoint.loc = new Object;
        VisiblePoint.loc.lat = parseFloat(t[2]);
        VisiblePoint.loc.long = parseFloat(t[3]);
        VisiblePoint.elevation = parseInt(t[4]);
        VisiblePoint.distance = parseFloat(t[5]);
        VisiblePoint.verticalangle = parseFloat(t[6]);

        VisiblePoints[i] = VisiblePoint;
        //alert( 'target: ' + VisiblePoint.name + ',' + VisiblePoint.heading + ',' + VisiblePoint.loc.lat + ',' + VisiblePoint.loc.long + ',' + VisiblePoint.elevation + ',' + VisiblePoint.distance + ',' + VisiblePoint.verticalangle );
    }
    //var i;
    //for ( i = 0; i < VisiblePoints.length; i++ ) {
    //    alert( 'target: ' + VisiblePoints[i].name + ',' + VisiblePoints[i].heading + ',' + VisiblePoints[i].loc.lat + ',' + VisiblePoints[i].loc.long );
    //}

    return true;
}

function UpdatePage() {

    var mapNode = document.getElementById("map");

    CalcNewMultiplier();

    if (ButtonOnLeftEdge) {
       GlueButtons(SpaceBetweenButtonAndEdge);
       return;
    }
    if (document.documentElement && document.documentElement.clientWidth) { GlueButtons(document.documentElement.clientWidth-TotalWidth); }
    else {
        if (navigator.userAgent.indexOf('MSIE') > 0) { GlueButtons(document.body.clientWidth-TotalWidth+19); }
        else {
            var scroll = WindowHasScrollbar() ? 0 : 15;
            if (typeof window.innerWidth == 'number') { GlueButtons(window.innerWidth-TotalWidth-15+scroll); }
            else { GlueButtons(document.body.clientWidth-TotalWidth+15); }
        }
    }
}

function GenerateMap() {
    strURL = strGenMapURL + "?sessionid=" + strSessionID + "&mapid=" + strMapID;
    // window.location.href = strURL;  // <- this refreshes the whole page
    document.images["gmap"].src="http://maps.google.com/maps/api/staticmap?center=" + strCenter + "&zoom=" + strZoom + "&size=" + strSize + "&maptype=terrain&markers=" + strViewpoint + "&sensor=false&path=" + strPath;
    // update the line with the map img specs: center, size, zoom
    UpdateLocSize();
}

function ZoomInButton() {
    var iZoom = parseInt( strZoom ) + 1 ;
    if ( iZoom > 17 ) {
        iZoom = 17; strZoom = "17";
    } else {
        strZoom = iZoom + "";
        GenerateMap();
        CalcNewMultiplier();
    } 
}

function ZoomOutButton() {
    var iZoom = parseInt( strZoom ) -1 ;
    if ( iZoom < 1 ) {
        iZoom = 1; strZoom = "1";
    } else {
        strZoom = iZoom + "";
        GenerateMap();
        CalcNewMultiplier();
    } 
}

function GetLatLong(strLoc) {
    var loc = strLoc.split(",");
    lat = parseFloat(loc[0]);
    long = parseFloat(loc[1]);
    return { lat : lat, long : long };
}

function GetSize(str) {
    var size = strSize.split("x");
    x = parseInt(size[0]);
    y = parseInt(size[1]);
    return { x : x, y : y };
}

function UpButton() {
    var lat,longx;
    loc = GetLatLong( strCenter );
    loc.lat += (fStdScrollVal * fMultiplier);
    loc.lat = loc.lat.toFixed(4);
    strCenter = loc.lat + "," + loc.long;
    GenerateMap();
    CalcNewMultiplier();
}

function DownButton() {
    var lat,longx;
    loc = GetLatLong( strCenter );
    loc.lat -= (fStdScrollVal * fMultiplier);
    loc.lat = loc.lat.toFixed(4);
    strCenter = loc.lat + "," + loc.long;
    GenerateMap();
    CalcNewMultiplier();
}

function LeftButton() {
    var lat,longx;
    loc = GetLatLong( strCenter );
    loc.long -= (fStdScrollVal * fMultiplier);
    loc.long = loc.long.toFixed(4);
    strCenter = loc.lat + "," + loc.long;
    GenerateMap();
    CalcNewMultiplier();
}

function RightButton() {
    var lat,longx;
    loc = GetLatLong( strCenter );
    loc.long += (fStdScrollVal * fMultiplier);
    loc.long = loc.long.toFixed(4);
    strCenter = loc.lat + "," + loc.long;
    GenerateMap();
    CalcNewMultiplier();
}

function ExpandVertButton() {
    var size = GetSize( strSize );
    if ( size.y < iMaxSize ) {
        size.y += iStdCropVal;
        strSize = size.x + "x" + size.y;
        viewpointY += ( iStdCropVal / 2 );
        GenerateMap();
        CalcNewMultiplier();
    }
}

function ContractVertButton() {
    var size = GetSize( strSize );
    if ( size.y > iMinSize ) {
        size.y -= iStdCropVal;
        strSize = size.x + "x" + size.y;
        viewpointY -= ( iStdCropVal / 2 );
        GenerateMap();
        CalcNewMultiplier();
    }
}

function ExpandHorizButton() {
    var size = GetSize( strSize );
    if ( size.x < iMaxSize )
    {
        size.x += iStdCropVal;
        strSize = size.x + "x" + size.y;
        viewpointX += ( iStdCropVal / 2 );
        GenerateMap();
        CalcNewMultiplier();
    }
}

function ContractHorizButton() {
    var size = GetSize( strSize );
    if ( size.x > iMinSize ) {
        size.x -= iStdCropVal;
        strSize = size.x + "x" + size.y;
        viewpointX -= ( iStdCropVal / 2 );
        GenerateMap();
        CalcNewMultiplier();
    }
}

function ContractAllButton() {
    var size = GetSize( strSize );
    if ( size.x > iMinSize && size.y > iMinSize ) {
        size.x -= iStdCropVal;
        size.y -= iStdCropVal;
        strSize = size.x + "x" + size.y;
        viewpointX -= ( iStdCropVal / 2 );
        viewpointY -= ( iStdCropVal / 2 );
        GenerateMap();
        CalcNewMultiplier();
    }
}

function ExpandAllButton() {
    var size = GetSize( strSize );
    if ( size.x < iMaxSize && size.y < iMaxSize ) {
        size.x += iStdCropVal;
        size.y += iStdCropVal;
        strSize = size.x + "x" + size.y;
        viewpointX += ( iStdCropVal / 2 );
        viewpointY += ( iStdCropVal / 2 );
        GenerateMap();
        CalcNewMultiplier();
    }
}

function CalcNewMultiplier() {
    fMultiplier = Math.pow(2, 12 - parseInt(strZoom) );
}

/* querystring.js - Contains functions to extract querystring parameters from URL
The parameters are loaded into the associative array queryString[]. */

// For each element in the array, find the equal sign that separates the parameter
// name from the parameter value.  If there is one, divide the expression into
// the parameter name and save them in the associative array querystring
function process_params( parameters ) {
    for (var i=0; i<parameters.length; i++) {
        var pos = parameters[i].indexOf('=');
        // If there is an equal sign, separate the parameter into the name and value,
        // and store it into the queryString array.
        if (pos > 0) {
            var paramname = parameters[i].substring(0,pos);
            var paramval = parameters[i].substring(pos+1);
            queryString[paramname] = unescape(paramval.replace(/\+/g,' '));
        } else {
            //special value when there is a querystring parameter with no value
            queryString[parameters[i]]="" 
        }
    }
}

function SaveMap() {
    // call  persistmap.cgi with all our current nav params so that the map can later
    // be restored exactly as it is right now.
    
    var strURL = 'http://www.roselinemaps.com/roseline/cgi-bin/persistmap.cgi';
    //var p = {center:strCenter,zoom:strZoom,size:strSize,mapid:strMapID,sessionid:strSessionID,xregid:strXRegID,regtoken:strRegToken,srctoken:strSrcToken};
    //postwith( strURL, p );
    strURL += "?center=" + strCenter + "&zoom=" + strZoom + "&size=" + strSize + "&mapid=" + strMapID + "&sessionid=" + strSessionID + "&xregid=" + strXRegID + "&regtoken=" + strRegToken + "&srctoken=" + strSrcToken;
    //alert( strURL );
    window.location.href = strURL;  // <- this refreshes the whole page

    // ??? the post leaves the window blank - not sure how to avoid this ? so
    // ??? for now we force a refresh.  BUT BUT BUT it turns out that the refresh
    // ??? apparently happens before the call to persistmap.cgi is complete so the
    // ??? refresh changes the map back to whatever was saved before !!! SO SO SO
    // ??? we do the CreateBookmarkLink() call before the refresh request to give
    // ??? persistmap.cgi time to run...  this is a hack.

    //CreateBookmarkLink(location.href, document.title);
    // not top.location.href throws when this script is run on a local computer
    var favloc;
    try { favloc = top.location.href; }
    catch (err) { favloc = location.href; }
    CreateBookmarkLink( favloc, document.title )
}

// DESCRIPTION:
//  create a bookmark in several kinds of browsers. code taken from
//    http://labnol.blogspot.com/2006/01/add-to-favorites-ie-bookmark-firefox.html

function CreateBookmarkLink( url, title ) {
    if (window.sidebar) { 
        // Mozilla Firefox Bookmark
	window.sidebar.addPanel(title, url,"");	
    } else if ( window.external ) { 
        // IE Favorite
	window.external.AddFavorite( url, title); 
    } else if (window.opera && window.print) { 
        // Opera Hotlist
	return true; 
    }
}

// NOTE - nothing calls this function right now
// DESCRIPTION:
//   do a post operation from JS. this generates a form on the fly and 
//   posts from it
// this code from this page on the web:
//    http://mentaljetsam.wordpress.com/2008/06/02/using-javascript-to-post-data-between-pages/
// NOTE:
//  ??? this process leaves the window blank after this function is called which is annoying.
//  ??? I would prefer that the window was left unchanged. not sure how to do that. for now,
//  ??? I'm forcing a refresh after this call to get my org window back !

function postwith (to,p) {
  var myForm = document.createElement("form");
  myForm.method="post" ;
  myForm.action = to ;
  for (var k in p) {
    var myInput = document.createElement("input") ;
    myInput.setAttribute("name", k) ;
    myInput.setAttribute("value", p[k]);
    myForm.appendChild(myInput) ;
  }
  document.body.appendChild(myForm) ;
  myForm.submit() ;
  document.body.removeChild(myForm) ;
}

AddButtonPlacementEvents(InitPage,UpdatePage);

