#!/usr/bin/perl

use URI::Escape;

print <<EOT;
<html>
 <head>
  <title>Graph</title>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--

if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

//-->
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
<!--

HM_PG_MenuWidth = 300;
HM_PG_FontFamily = "Arial,sans-serif";
HM_PG_FontSize = 10;
HM_PG_FontBold = 0;
HM_PG_FontItalic = 0;
HM_PG_FontColor = "blue";
HM_PG_FontColorOver = "green";
HM_PG_BGColor = "#DDDDDD";
HM_PG_BGColorOver = "#FFCCCC";
HM_PG_ItemPadding = 3;

HM_PG_BorderWidth = 2;
HM_PG_BorderColor = "black";
HM_PG_BorderStyle = "solid";
HM_PG_SeparatorSize = 2;
HM_PG_SeparatorColor = "#d0ff00";

HM_PG_ImageSrc = "HM_More_black_right.gif";
HM_PG_ImageSrcLeft = "HM_More_black_left.gif";
HM_PG_ImageSrcOver = "HM_More_white_right.gif";
HM_PG_ImageSrcLeftOver = "HM_More_white_left.gif";

HM_PG_ImageSize = 5;
HM_PG_ImageHorizSpace = 0;
HM_PG_ImageVertSpace = 2;

HM_PG_KeepHilite = true; 
HM_PG_ClickStart = 0;
HM_PG_ClickKill = false;
HM_PG_ChildOverlap = 20;
HM_PG_ChildOffset = 10;
HM_PG_ChildPerCentOver = null;
HM_PG_TopSecondsVisible = .5;
HM_PG_StatusDisplayBuild =0;
HM_PG_StatusDisplayLink = 0;
HM_PG_UponDisplay = null;
HM_PG_UponHide = null;
HM_PG_RightToLeft = 0;

HM_PG_CreateTopOnly = 0;
HM_PG_ShowLinkCursor = 1;
HM_PG_NSFontOver = true;

//HM_a_TreesToBuild = [2];


//-->
</SCRIPT>

<script>
function setParam(url,name,value)
{
  var urla = url.split("?");
  var search = urla[1];
  var args = search.split("&");

  for (var i = 0 ; i < args.length ; i++) {
     var couple = args[i].split("=");
     if (couple[0] == name) args[i] = name + "=" + value;
  }


  return (urla[0] + "?" + args.join("&"));
}

function getParam0(search,name)
{
  var args = search.split("&");
  var value = "???";

  for (var i = 0 ; i < args.length ; i++) {
     var couple = args[i].split("=");
     if (couple[0] == name) value = couple[1];
  }

  if (value == "???") value = getDefaultParam(name);

  return value;
}

function getParam(name)
{
  return getParam0(location.search.slice(1),name);
}

function getParam3(from,name)
{
  //var url = unescape(getParam('xmluri'));
  //var tmp = url.split("?");
  var tmp = from.split("?");

  if (tmp.length > 1)
     return getParam0(tmp[1],name);
  else
     return getDefaultParam(name);
}
</script>

<script>
function mkDepURL(uri)
{
   var iurl = unescape(getParam("url"));
   var getterURL = getParam3(iurl,"param.getterURL");
   var interfaceURL = unescape(getParam3(iurl,"param.interfaceURL"));
   var url = setParam(iurl,"keys","MDG");
   url = setParam(url,"xmluri", getterURL + "getxml%3Furi%3D" + uri);
   url = setParam(url,"param.CICURI",uri);
   url = setParam(url,"param.RDFURI","helm:rdf:www.cs.unibo.it/helm/rdf/rdfprova//" + uri);
   var draw_graph_url =
    location.protocol + '//' + location.host + location.pathname;
   url = draw_graph_url + "?url=" + escape(url);
   return url;
}

function mkCICURL(uri)
{
   var iurl = unescape(getParam("url"));
   var getterURL = getParam3(iurl,"param.getterURL");
   var interfaceURL = unescape(getParam3(iurl,"param.interfaceURL"));
   var url = setParam(iurl,"keys",getParam3(iurl,"param.keys"));
   url = setParam(url,"xmluri", getterURL + "getxml%3Furi%3D" + uri);
   url = setParam(url,"param.CICURI",uri);
   url = setParam(url,"param.RDFURI","helm:rdf:www.cs.unibo.it/helm/rdf/rdfprova//" + uri);
   url = interfaceURL + "?url=" + escape(url);
   return url;
}

function mkMetaURL(uri)
{
   var iurl = unescape(getParam("url"));
   var getterURL = getParam3(iurl,"param.getterURL");
   var interfaceURL = unescape(getParam3(iurl,"param.interfaceURL"));
   var url = setParam(iurl,"keys","MMG");
   url = setParam(url,"xmluri", getterURL + "getxml%3Furi%3Dhelm:rdf:www.cs.unibo.it/helm/rdf/rdfprova//" + uri);
   url = setParam(url,"param.CICURI",uri);
   url = setParam(url,"param.RDFURI","helm:rdf:www.cs.unibo.it/helm/rdf/rdfprova//" + uri);
   var draw_graph_url =
    location.protocol + '//' + location.host + location.pathname;
   url = draw_graph_url + "?url=" + escape(url);
   return url;
}
</script>


 </head>
 <body bgcolor="white" onLoad="window.focus()">
  <script>
   var draw_graph_url =
    location.protocol + '//' + location.host;
   document.write('<img border="false" src="' + draw_graph_url + '/get_gif?pid=$ARGV[0]" usemap="#graphe">');
  </script>
  <map name="graphe">
EOT

my $count = 0;

while (<STDIN>) {
 $count++;
 my (undef,$point1,$point2,$uri) = split;
 my ($point1x,$point1y) = split /,/,$point1;
 my ($point2x,$point2y) = split /,/,$point2;
 $point1y = substr($point1y,0,-1);
 $point2y = substr($point2y,0,-1);
 $point1x = substr($point1x,1);
 $point2x = substr($point2x,1);

 print <<EOT;
   <area shape="rect" href="$url" coords="$point1x,$point2y,$point2x,$point1y"
   onMouseOver="HM_f_PopUp('elMenu$count',event)"
   onMouseOut="HM_f_PopDown('elMenu$count')">
EOT

 print <<EOT;
  <script>
HM_Array$count = [
[,,,
,,,,,,,,,,,,,,,,
1,true],
["Objects this one depends on.",mkDepURL('$uri'),1,0,1],
["Render this object.","javascript:window.open('" + mkCICURL('$uri') + "','cic')",1,0,0],
["Objects depending on this one.",mkMetaURL('$uri'),1,0,1],
];
  </script>
EOT
}

print <<EOT;
   </map>
  </img>
  <SCRIPT LANGUAGE="JavaScript1.2"
          SRC="http://www.cs.unibo.it/~sacerdot/jsmenu/HM_Loader_prova.js"
          TYPE='text/javascript'></SCRIPT>
 </body>
</html>
EOT
