/**
 * Shared JS.
 */

function $( id )
{
  return document.getElementById( id );
}
function createPermalink( title )
{
    var chart = $('applet');
    var t = chart.getTime();
    var ot = chart.getOuterTime();
    var p = chart.getPlaceInfo();
    var z = chart.getZoneInfo();
    var d = chart.getDisplayInfo();
    var args = "t=" + escape( t ) + "&p=" + escape( p ) + "&z=" + escape( z )
      + "&d=" + escape( d );
    if (title)
      args += "&title=" + escape(title);
    if (ot != "")
      args += "&ot=" + escape( ot );
    if (title)
      document.location = "chart.php?" + args;
    else
    {
      document.location.hash = null;
      document.location.search = args;
    }
}
function createChartPermalink()
{
  var title = prompt("Title for chart:","");
  if (title) 
    createPermalink( title );
}
function save()
{
  var file = $('applet').save('save.php');
  if (file.substring( 0, 5 ) == "ERROR")
    alert( file );
  else
	window.open( file );
}
