/* Begin popUpWindow  - used to size a popup window to the contained image */
/* Requires the specification of width and height */
function PopUpWindow(URL,features) {
alert("features = "+features); 
alert("URL = "+URL); 
window.open(URL,"popup","'"+features+"'"); 
}
/* End PopUpWIndow */
/* ---------------------------------------------------------------------------------------------------------- */
/* SizeWindow - Adapted from Caricafoto from http://javascript.internet.com */
/* Used to size a popup window to the contained image */
/* Usage:
<a href="image.jpg" 
onClick="SizeWindow('image.jpg','Title'); return false">
Link text</a>
*/

function SizeWindow(img,title){
  var newtitle = title;
/* alert("newtitle@viewphoto function = "+newtitle);  */
  photo1= new Image();
  photo1.src=(img);
  Control(img,newtitle);
}
function Control(img,title){
  var newtitle = title;
/* alert("newtitle@Control function = "+newtitle); */
  if((photo1.width!=0)&&(photo1.height!=0)){
	viewphoto(img,newtitle);
  }
  else{
    funct1="Control('"+img+"')";
    interval=setTimeout(funct1,20);
  }
}
function viewphoto(img,title){
  var newtitle = title;
  horiz=photo1.width;
  vert=photo1.height;
  winhoriz=photo1.width+30;
  winvert=photo1.height+80;
/* alert("newtitle@viewphoto function = "+newtitle); */
  windowsize="width="+winhoriz+",height="+winvert+",left=10,top=10,scrollbars=yes";
  imagestring="<img src=\""+img+"\" width=\""+horiz+"\" height=\""+vert+"\" alt=\"Large image\" border=\"1\">";
  var newwindow=window.open('',"popup",windowsize);
  var tmp = newwindow.document;
  tmp.write('<html lang="en">');
  tmp.write('<head><link href="http://whrc.org/assets/Popup.css" rel="stylesheet" type="text/css">');
  tmp.write('<link href="http://whrc.org/assets/WHRCprint.css" rel="stylesheet" type="text/css"  media="print">');
  tmp.write('<title>WHRC image window</title>');
  tmp.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
  tmp.write('<meta name="description" content="WHRC large image window"></head>');
  tmp.write('<body><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="mainTable">');
  tmp.write('<tr><td valign="middle">');
  tmp.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" id="head"><tr>');
/*
  tmp.write('<td align="center" valign="top">');
  tmp.write('<h3>'+newtitle+'</h3></td>');

*/  tmp.write('<td align="right" valign="middle"><div id="buttons">');
  tmp.write('<FORM><INPUT TYPE="button" VALUE="Print" onClick="window.print()">&nbsp;');
  tmp.write('<INPUT TYPE="button" VALUE="Close" onClick="window.self.close()"></FORM></div></td></tr></table>');
  tmp.write('</td></tr><tr><td align="center" id="maincontent">');
  tmp.write(''+imagestring+''); 
  tmp.write('</td></tr></table></body></html>');
  tmp.close();
  if (window.focus) {newwindow.focus()}
  return false;  
}
/* End of SizeWindow */
/* ---------------------------------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------------------------------------- */
/* Timer for Building System Detail and Energy Flow pages */
/* Adapted from a script made by: Nicolas - http://www.javascript-page.com/timer.html */

var timerID = 0;
var tStart  = null;

function UpdateTimer() {
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }

   if(!tStart)
      tStart   = new Date();

   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();

   tDate.setTime(tDiff);

   document.theTimer.theTime.value = "" 
                                   + tDate.getMinutes() + ":" 
                                   + tDate.getSeconds();
   
   timerID = setTimeout("UpdateTimer()", 1000);
}

function StartTimer () {
   tStart   = new Date();

   document.theTimer.theTime.value = "00:00";

   timerID  = setTimeout("UpdateTimer()", 1000);
}

function StopTimer() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }

   tStart = null;
}

function Reset() {
   tStart = null;

   document.theTimer.theTime.value = "00:00";
}

/* End of Current Time */
/* ---------------------------------------------------------------------------------------------------------- */
/*
Dreamweaver image preload  & swap routines
*/
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
/* End of Dreamweaver Routines */
/* ---------------------------------------------------------------------------------------------------------- */
/*
DateString formats the local users date for display within a page.
Adapted from Chris Maunder's script at http://www.codeproject.com/jscript/datestring.asp
Usage:
<script language="JavaScript">
<!--
document.write("<p>Today is " + DateString() + "</p>\n");
//-->
      </script>
*/

function GetDay(nDay)
{
	var Days = new Array("Sunday","Monday","Tuesday","Wednesday",
	                     "Thursday","Friday","Saturday");
	return Days[nDay]
}

function GetMonth(nMonth)
{
	var Months = new Array("January","February","March","April","May","June",
	                       "July","August","September","October","November","December");
	return Months[nMonth] 	  	 
}

function DateString()
{
	var Today = new Date();
	var suffix = "th";
	switch (Today.getDate())
	{
		case 1:
		case 21:
		case 31: 
			suffix = "st"; break;
		case 2:
		case 22:
			suffix = "nd"; break;
		case 3:
		case 23:
			suffix = "rd"; break;
	};

	var strDate = GetDay(Today.getDay()) + ", " + GetMonth(Today.getMonth()) + " " + Today.getDate();
	strDate += suffix + ", " + Today.getFullYear();
	return strDate
}

/* End of DateString */
/* ---------------------------------------------------------------------------------------------------------- */
/* webcam_refresh */

      function Start() { 
      tmp = new Date(); 
      tmp = "?"+tmp.getTime(); 
      document.images["refresh"].src = image+tmp;
      setTimeout("Start()", t*1000);
      } 
	  
	  function Start1() { 
      tmp = new Date(); 
      tmp = "?"+tmp.getTime(); 
      document.images["refresh1"].src = image1+tmp;
      setTimeout("Start1()", t*1000);
      } 
	  
	  function Start2() { 
      tmp = new Date(); 
      tmp = "?"+tmp.getTime(); 
      document.images["refresh2"].src = image2+tmp;
      setTimeout("Start2()", t*1000);
      } 

	  function Start3() { 
      tmp = new Date(); 
      tmp = "?"+tmp.getTime(); 
      document.images["refresh3"].src = image3+tmp;
      setTimeout("Start3()", t*1000);
      } 
	  
	  function Start4() { 
      tmp = new Date(); 
      tmp = "?"+tmp.getTime(); 
      document.images["refresh4"].src = image4+tmp;
      setTimeout("Start4()", t*1000);
      } 

	


