//------------------------------------------------------------------------------
//
// PURPOSE:	javascript library
// AUTHOR:	Flavio Fusco
// WEB SITE:	http://ffusco.altervista.org
//
//------------------------------------------------------------------------------



//------------------------------------------------------------------------------
//detect browser MSIE version 5.5 or up
//function Is_MSIE55up() {
//   version=0
//   if (window.navigator.appVersion.indexOf("MSIE")!=-1){
//      temp=window.navigator.appVersion.split("MSIE");
//      version=parseFloat(temp[1]);
//   }
//   if (version>=5.5) return true;
//}

//------------------------------------------------------------------------------
function fullScreen() {
   window.open(window.location.href, '', 'fullscreen=yes, scrollbars=auto');
}

//------------------------------------------------------------------------------
function closeWindow() {
   window.close(window.location.href);
}

//------------------------------------------------------------------------------
function Row_Open() {window.document.write("<tr>");}

//------------------------------------------------------------------------------
function Row_Close() {window.document.write("</tr>");}

//------------------------------------------------------------------------------
function Black_Cell() {
   //adds an empty black cell to a table
   window.document.write("<td bgcolor=#000000><img src=graphics/spacer.gif width=1 height=1 alt=></td>");
}

//------------------------------------------------------------------------------
function Separator() {
   //adds a separator row to a table
   //use only as page content separator (not as page layout element)
   //since it spans the entire table width
   window.document.write("<tr><td colspan=50><br><hr><br></td></tr>");
}

//------------------------------------------------------------------------------
function Skyscraper() {
google_ad_client = "pub-1670552575752772";
google_alternate_color = "000000";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_type = "text_image";
google_ad_channel = "";
google_color_border = "C0C0C0";
google_color_bg = "000000";
google_color_link = "FFFFFF";
google_color_text = "C0C0C0";
google_color_url = "C0C0C0";
google_ui_features = "rc:10";
window.document.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
}


//------------------------------------------------------------------------------
function Leaderboard() {
   google_ad_client = "pub-1670552575752772";
   google_alternate_color = "505050";
   google_ad_width = 728;
   google_ad_height = 90;
   google_ad_format = "728x90_as";
   google_ad_type = "text_image";
   google_ad_channel = "";
   google_color_border = "000000";
   google_color_bg = "000000";
   google_color_link = "FFFFFF";
   google_color_text = "C0C0C0";
   google_color_url = "C0C0C0";
   google_ui_features = "rc:6";
   window.document.write('<tr><td colspan=50 align="center">');
   window.document.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
   window.document.write("</td></tr>");
}

//------------------------------------------------------------------------------
function Menu_Left() {
   window.document.write("<td valign=top rowspan=50>"); 
   window.document.write("<A class=menu1 HREF=photo/index.htm>PHOTOGRAPHY</a><br> \
   <A class=menu2 HREF=photo/newyork/index.htm>NEW YORK</a><br> \
   <A class=menu2 HREF=photo/balticsea/index.htm>BALTIC SEA</a><br> \
   <A class=menu2 HREF=photo/scotland/index.htm>SCOTLAND</a><br> \
   <A class=menu2 HREF=photo/milano/index.htm>MILANO</a><br> \
   <A class=menu2 HREF=photo/napoli/index.htm>NAPOLI</a><br> \
   <A class=menu2 HREF=photo/puglia/index.htm>PUGLIA</a><br>\
   <A class=menu2 HREF=photo/trentino/index.htm>TRENTINO</a><br><br> \
   <A class=menu1 HREF=space/index.htm>SPACE ROBOTICS</a><br> \
   <A class=menu2 HREF=space/era/index.htm>ERA</a><br> \
   <A class=menu2 HREF=space/rosetta/index.htm>ROSETTA</a><br> \
   <A class=menu2 HREF=space/europa/index.htm>EUROPA</a><br> \
   <A class=menu2 HREF=space/hipercar/index.htm>HIPERCAR</a><br><br> \
   <A class=menu1 HREF=software/index.htm>SOFTWARE</a><br> \
   <A class=menu2 HREF=software/genetic/index.htm>GENETIC</a><br> \
   <A class=menu3 HREF=software/genetic/robotrunk/index.htm>ROBOTRUNK</a><br> \
   <A class=menu2 HREF=software/forth/index.htm>FORTH</a><br> \
   <A class=menu2 HREF=software/unix/index.htm>UNIX</a><br><br> \
   <A class=menu1 HREF=awards/index.htm>AWARDS</a><br><br> \
   <A class=menu1 HREF=links/index.htm>LINKS</a><br><br> \
   <A class=menu1 HREF=contact/index.htm>CONTACT</a><br> \
   <A class=menu2 HREF=contact/tesi/index.htm>THESIS</a><br><br> \
   <A class=menu1 HREF=index.htm>HOME</a><br> \
   <img src=graphics/spacer.gif width=140 height=1 alt=> </td>");
}

//------------------------------------------------------------------------------
function Page_Header(title, summary) {

   //write title and big rounded angles in the context of the background table
   window.document.write(" \
      <td colspan=2> \
         <table cellspacing=0 cellpadding=0 border=0 align=left> \
            <tr> \
               <td> \
                  <img src=graphics/angle_nw.gif width=40 height=40 alt=> \
               </td> \
               <td bgcolor=#000000  valign=bottom class=tabtitle>");
   window.document.write(title);
   window.document.write(" \
               </td> \
               <td> \
                  <img src=graphics/angle_ne.gif width=40 height=40 alt=> \
               </td> \
            </tr> \
         </table>");

   // in MSIE55up, display navigation controls
   // Condition commented out because it works also in Firefox, excluding the full screen mode
   //if (Is_MSIE55up()) {
      window.document.write(" \
         <table cellspacing=0 cellpadding=0 border=0 align=right> \
            <tr> \
               <td nowrap> \
                  <a href='javascript:history.back()'><img class=nav src=graphics/nav_backward.gif width=9 height=9 title='Page backward' alt='Page backward'></a> \
                  <a href='javascript:history.forward()'><img class=nav src=graphics/nav_forward.gif width=9 height=9 title='Page forward' alt='Page forward'></a> \
                  <a href='javascript:void(fullScreen())'><img class=nav src=graphics/nav_full.gif width=9 height=9 title='Full screen (Internet Explorer only)' alt='Full screen'></a> \
                  <a href='javascript:void(closeWindow())'><img class=nav src=graphics/nav_close.gif width=9 height=9 title='Close window' alt='Close window'></a> \
               </td> \
            </tr> \
         </table>");
    //  }

   window.document.write(" \
      </td> \
   </tr>");
   //the above /tr is the closure of the first row in the background table,
   //containing left menu and page title tab

   //add to table a black top row with small rounded angles
   window.document.write(" \
   <tr> \
      <td align=left width=10 bgcolor=#000000> \
         <img src=graphics/spacer.gif alt=> \
      </td>");
   Black_Cell();
   window.document.write(" \
      <td align=left width=10> \
         <img src=graphics/angle_s_ne.gif width=10 height=10 alt=> \
      </td> \
   </tr>");

   //write page summary if not blank
   if (summary != "") {
      Row_Open();
      Black_Cell();
      window.document.write("<td bgcolor=#000000><br>");
      window.document.write("<div id=divsummary>" + summary + "</div>");
      window.document.write("</td>");
      Black_Cell();
      Row_Close();
   }

   //write separator line under summary
   Row_Open();
   Black_Cell();
   window.document.write("<td bgcolor=#000000><br><hr><br></td>");
   Black_Cell();
   Row_Close();
}

//------------------------------------------------------------------------------
function Page_Footer() {
   //adds to a table a black bottom row with small rounded angles
   window.document.write(" \
   <tr> \
      <td><img src=graphics/angle_s_sw.gif width=10 height=10 alt=></td>");
   Black_Cell();
   window.document.write(" \
      <td><img src=graphics/angle_s_se.gif width=10 height=10 alt=></td> \
   </tr>");
}

//------------------------------------------------------------------------------
function Page_Layout_Top(title, summary, spacing) {

   window.document.write("<table align=center width=100% cellspacing=0 cellpadding=0><tr>");
   Menu_Left();
   Page_Header(title, summary)
   Row_Open();
   window.document.write("<td bgcolor=#000000><img src=graphics/spacer.gif width=1 height=200 alt=></td>");
   window.document.write("<td bgcolor=#000000 width=100%><div id=innercontent><table cellspacing=");
   window.document.write(spacing);
   window.document.write("cellpadding=0 border=0 width=100% align=left>");
}

//------------------------------------------------------------------------------
function Page_Layout_Bottom() {
   window.document.write("</table></div></td>");
   Black_Cell();
   Row_Close();
   Page_Footer();
   window.document.write("</table>");

   //Ads by Altervista
   //google_color_border = "505050";
   //google_color_bg = "505050";
   //google_color_link = "FFFFFF";
   //google_color_url = "C0C0C0";
   //google_color_text = "C0C0C0";
   //window.document.write("<div align=right><br>");
   //window.document.write('<s'+'cript type="text/javascript" src="http://eu.ad.altervista.org/js.ad/size=468X60/r='+new Date().getTime()+'"><\/s'+'cript>');
   //window.document.write("</div>");


   //Ads by Google AdSense
   google_ad_client = "pub-1670552575752772";
   google_alternate_color = "505050";
   google_ad_width = 728;
   google_ad_height = 90;
   google_ad_format = "728x90_as";
   google_ad_type = "text_image";
   google_ad_channel = "";
   google_color_border = "505050";
   google_color_bg = "505050";
   google_color_link = "FFFFFF";
   google_color_text = "C0C0C0";
   google_color_url = "C0C0C0";
   google_ui_features = "rc:6";
   window.document.write("<div align=right><br>");
   window.document.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
   window.document.write("</div>");


   //Stats by Google Analytics
   //   window.document.write('<script type="text/javascript">');
   //   window.document.write('var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");');
   //   window.document.write('document.write(unescape("%3Cscript src=" + gaJsHost + "google-analytics.com/ga.js type=text/javascript%3E%3C/script%3E"));');
   //   window.document.write('</script>');

   //   window.document.write('<script type="text/javascript">');
   //   window.document.write('var pageTracker = _gat._getTracker("UA-3253722-1");');
   //   window.document.write('pageTracker._initData();');
   //   window.document.write('pageTracker._trackPageview();');
   //   window.document.write('</script>');

}

//------------------------------------------------------------------------------
function Update_Message(value) {
   window.document.getElementById("message").innerHTML=value;
}

//------------------------------------------------------------------------------
function Display_Photo(N) {
   Nm1 = N-1;
   Np1 = N+1;
   thisPhoto = new Image();
   if (Nm1>=0) {Nm1alt='Previous: '+Photo[Nm1][0]} else {Nm1alt='Previous: none'}
   if (Np1<Photo.length) {Np1alt='Next: '+Photo[Np1][0]} else {Np1alt='Next: none'}
   if ((N>=0) && (N<Photo.length)) {
      thisPhoto.src=Page_Dir+Photo[N][1];
      window.document.getElementById("divsummary").innerHTML=Photo[N][0];
      window.document.getElementById("innercontent").innerHTML=" \
      <table cellspacing=0 cellpadding=0 border=0 width=100% height=500 align=left> \
         <tr><td><div align=center> \
            <a href=javascript:void(Display_Photo("+ Nm1 + "))><img class=nav src=graphics/nav_backward.gif width=9 height=9 alt='" + Nm1alt +"' title='" + Nm1alt +"'></a> \
            <a href=" + window.document.location.href + "><img class=nav src=graphics/nav_gall.gif width=9 height=9 alt='Back to gallery' title='Back to gallery'></a> \
            <a href=javascript:void(Display_Photo(" + Np1 + "))><img class=nav src=graphics/nav_forward.gif width=9 height=9 alt='" + Np1alt +"' title='" + Np1alt +"'></a> \
         </div></td></tr> \
         <tr> <td bgcolor=#000000><img src=graphics/spacer.gif width=1 height=10 alt=></td> </tr> \
         <tr> <td><div id=bigphoto align=center><a href=" + window.document.location.href + "><img src="+thisPhoto.src+" alt='Back to gallery' title='Back to gallery'></a></div></td></tr> \
       </table>";
   }
}

//------------------------------------------------------------------------------
function Generate_Photo_Gallery() {
   var Photos_In_Row=0;
   Row_Open();
   for (var N=0; N<Photo.length; N++) {
      window.document.write("<td><a href=javascript:void(Display_Photo(" + N + "))>");
      window.document.write("<img src=" + Page_Dir + "tn_" + Photo[N][1] + " title='" + Photo[N][0] + "' alt='" + Photo[N][0] + "'></a></td>");
      Photos_In_Row+=1;
      if ((Photos_In_Row==3) && (N<Photo.length-1)) {Row_Close(); Row_Open(); Photos_In_Row=0;};
   }
   Row_Close();
}

//------------------------------------------------------------------------------