/*
  Copyright 2007 Orcas Net, Inc.
  All Rights Reserved.
  webcam.js

  Contains routines used by the webcam
  
  Changes
  03-15-07, P.C.; Initally created
*/

// URLs for webcam change these if the address changes
var dayURL   = "http://smuggler.com/new/smug-cam.html";
var nightURL = "http://photos.orcasisland.com/slideshow.php?set_albumName=smuggler";

/*
  Function:    gotoWebCam
  Parameters:  None.
  Return:      None.
  Description: Opens the slide show window if it's after dark or the webcam if it's
               during the day.
  Calls:       None.
  Notes:       Opens the web page in a new 800x800 window.
  History:     03-15-07, P.C.; Initally written
*/

function gotoWebCam()
{
    var gotoURL  = dayURL;
    var today    = new Date();
    var timeNow  = (today.getHours() * 60) + today.getMinutes();
    var isDST    = true;
    var sun      = SunriseSunset(today.getMonth(),
                                 String(today.getDate()),
                                 String(today.getFullYear()),
                                 "8.0",            // TZ offest from GMT
                                 "122", "32", "0", // Bellingham Longitude
                                 "48", "48", "0"); // Bellingham Latitude
    var sunset;
    var sunrise;
          
    if (isDST)
    {
     sun.riseHours += 1;
     sun.setHours  += 1;
    }
  
    sunrise = (sun.riseHours * 60) + sun.riseMinutes;
    sunset  = (sun.setHours * 60) + sun.setMinutes;
    
    if ((timeNow > sunset) || (timeNow < sunrise))
        gotoURL = nightURL;

    window.open(gotoURL, 'o','width=800,height=800,toolbar=no,menubar=no,status=no,location=no,directories=no,scrollbars=no,resizable');
}

