function viewImage(image) {
	objImage = new Image();
	objImage.src = image;

	//allow image to load and contain proper width + height
	setTimeout("openImagePop('"+image+"')",750);
}

function openImagePop(image)
{
	var width = objImage.width+25;
	var height = objImage.height+25;
	window.open(image,'img','width='+width+',height='+height+',resizable=1');
}

function printThisPage() 
{ 
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

   var sWinHTML = document.getElementById('content').innerHTML; 
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write('<html><link href="../css/main.css" rel="stylesheet" type="text/css" /><body onload="window.print()">\n');
       winprint.document.write(sWinHTML);  
       winprint.document.write('</body></html>');
       winprint.document.close(); 
       winprint.focus(); 
}

function Clock(strElemId,intOffset)
{
   var objDate = new Date();

   objDate.setHours(objDate.getUTCHours() + intOffset)

   var strHours = objDate.getHours();
   var strMinutes = objDate.getMinutes();

   if (strHours < 10) strHours = '0'+ String(strHours);
   if (strMinutes < 10) strMinutes = '0' + String(strMinutes);

   document.getElementById(strElemId).innerHTML = strHours+':'+strMinutes;
}

//generate three clocks
function clocks()
{
   /*
      DST (means +1):
         Delft: "last sunday march, 02:00 - last sunday october, 03:00h"
                  "UTC: last sunday march 01:00 - last sunday oct 02:00"
         New York: "first sunday march, 02:00 - last sunday october, 02:00h"
                  "UTC: first sunday march 07:00 - last sunday oct 07:00"
         Tokyo: "no DST"
   */
   var objDate = new Date();
   var objSearchDate = objDate;

   var intMonth = objDate.getUTCMonth();
   var intDayOfMonth = objDate.getUTCDate();
   var intDayOfWeek = objDate.getUTCDay();

   var intHours = objDate.getUTCHours();
   var intMinutes = objDate.getUTCMinutes();

   var boolDST;  // DST period, true when DST
   var intFirstSun;
   var intLastSun;
   

   //New York   
   boolDST = false;
   if (intMonth == 3) // april, possible DST
   {
      objSearchDate.setUTCDate(1);  // 1st day of month
      intFirstSun = objSearchDate.getUTCDate() + (7-objDate.getUTCDay());

      if ((intDayOfMonth > intFirstSun) || 
         ((intDayOfMonth == intFirstSun) && (intHours >= 7)) )
      {
         boolDST = true;
      }
   }  else if ((intMonth > 3) && (intMonth < 10)) // may - sept DST
   {
      boolDST = true;
   }  else if (intMonth == 10) // nov, possible DST
   {
      objSearchDate.setUTCDate(1);  // 1st day of month
      intFirstSun = objSearchDate.getUTCDate() + (7-objDate.getUTCDay());

      if ((intDayOfMonth > intFirstSun) || 
         ((intDayOfMonth == intFirstSun) && (intHours >= 6)) )
      {
         boolDST = false;
      }
   }
   if (boolDST)
   {
      Clock('clock_boston',-4);
   } else
   {
      Clock('clock_boston',-5);
   }

   //Amsterdam
   boolDST = false;
   if (intMonth == 2) // march, possible DST
   {
      objSearchDate.setUTCDate(31);  // last day of month
      intLastSun = ( objSearchDate.getUTCDate() - objDate.getUTCDay() );

      if ((intDayOfMonth > intLastSun) || 
         ((intDayOfMonth == intLastSun) && (intHours >= 1)) )
      {
         boolDST = true;
      }
   }  else if ((intMonth > 2) && (intMonth < 9)) // apr - sept DST
   {
      boolDST = true;
   }  else if (intMonth == 9) // oct, possible DST
   {
      objSearchDate.setUTCDate(31);   // last day of october
      intLastSun = ( objSearchDate.getUTCDate() - objDate.getUTCDay() );

      if ((intDayOfMonth < intLastSun) || 
         ((intDayOfMonth == intLastSun) && (intHours < 1)))
      {
         boolDST = true;
      }
   }
   if (boolDST)
   {
      Clock('clock_delft',2);
   } else
   {
      Clock('clock_delft',1);
   }
   
   //Tokyo
   Clock('clock_tokyo',9);
   
}

function setClocks()
{
   clocks();
   setInterval('clocks()', 60000);
}