////
// common.js
// 
// Common Javascript source for Nite Owl Design (niteowldesign.net)

////
// array of images and the order in which they should show up
var ar_images = [
  //"const-purple.jpg",
  "const-blue.jpg",
  //"const-red.jpg",
  //"const-blue-2.jpg",
  //"const-purple.jpg",
  "const-red.jpg"
];

var sz_imageId = "const";
var n_index = 0;
var n_delay = 100; // in milliseconds

function startBlink() {
  
  //window.setTimeout('runBlink()',1000);
  runBlink();
}

/**
 * Function to increment the image index
 * @return
 */
function incrementIndex() {
  n_index += 1;
  if(n_index >= ar_images.length) {
    n_index = 0;
  }
  
  return 0;
}

function runBlink() {
  
  $(sz_imageId).src = "images/" + ar_images[n_index];
  incrementIndex();
  window.setTimeout('runBlink()',n_delay);
}


function openViewer(sz_url,cat,album) {

  var szBrowser = navigator.appName;
  
  /*if(szBrowser.indexOf("Microsoft") != -1) {
    nTop = window.screenTop;
    nLeft = window.screenLeft;
  }
  else {
    nTop = window.screenY;
    nLeft = window.screenX;
  }*/


  /*wHeight = document.body.clientHeight - 20;
  wWidth = document.body.clientWidth - 20;*/

  browserSoft = navigator.appName;
  
  sz_userAgent = navigator.userAgent;
  
  ar_browsers = [];

  ar_browsers['firefox'] = {x:1132, y:667};
  ar_browsers['ie'] = {x:1132, y:668};
  ar_browsers['safari'] = {x:1137, y:675};

  // determine browser
  
  //alert(navigator.userAgent);
  
  if(/firefox/i.test(sz_userAgent)) {
    wHeight = ar_browsers['firefox'].y;
    wWidth = ar_browsers['firefox'].x;
  }
  else if(/safari/i.test(sz_userAgent)) {
    wHeight = ar_browsers['safari'].y;
    wWidth = ar_browsers['safari'].x;    
  }
  else if(/msie/i.test(sz_userAgent)) {
    wHeight = ar_browsers['ie'].y;
    wWidth = ar_browsers['ie'].x;    
  }
  

  /*wWidth = 1132;
  if(browserSoft.indexOf("Microsoft") > -1) {
    wHeight = 667;
  }
  else {
    wHeight = 665;
  }*/
  

  nLeft = (screen.availWidth / 2) - (wWidth / 2);
  nTop = (screen.availHeight / 2) - (wHeight / 2);
  
  if(nTop < 0) {
    nTop = 0;
  }
  
  if(nLeft < 0) {
    nLeft = 0;
  }

  /*wWidth = 900;
  if(screen.availWidth < wWidth) 
    wWidth = screen.availWidth-10;
  
  wHeight = 700;
  if(screen.availHeight < wHeight) 
    wHeight = screen.availHeight-10;*/

  sWindowOptions = "left=" + nLeft + ",top=" + nTop + ",location=no,height=" 
    + wHeight + ",width=" + wWidth;

  viewerWindow = window.open(sz_url + "viewer.php?section=" + cat + "&album_id=" + album,"viewer",sWindowOptions);
}



