﻿//create namespace

var npg = {};

function openphotos(file,input,width,height) {
  attr = "top=5,left=75,width=" + width + ",height=" + height + ",resizable=1,scrollbars=yes";
  window.open(file, input, attr);
}
function tedTurner(pid){
  var cPic = document.getElementById(pid  + 'i');
  //alert(cPic.getAttribute("src"));
  var cPSrc = cPic.getAttribute("src");
  var re = /http:\/\/www.baltimore-maryland.org/gi;
  cPSrc = cPSrc.replace(re, "");
  var pat = cPSrc.indexOf(".");
  var nCS = cPSrc.substr(0, pat - 3);
  //alert(cPSrc);
  cPic.setAttribute('src', nCS + '.jpg');
}
function restoration(pid){
  var cPic = document.getElementById(pid  + 'i');
  var cPSrc = cPic.getAttribute('src');
  var re = /http:\/\/www.baltimore-maryland.org/gi;
  cPSrc = cPSrc.replace(re, "");
  var pat = cPSrc.indexOf(".");
  var nCS = cPSrc.substr(0, pat);
  cPic.setAttribute('src', nCS+ '-bw.jpg');
}
function initNPG(neName){
  npg.docID = document.getElementById('nePiGa');
  npg.ppImg = document.getElementById('nePP');
  npg.name = neName;
  npg.current = 50;
  npg.tI = 6500;
  nPGStart();
  //npg.intID = setInterval("nPGShow();", npg.tI);
 
}

function nPGShow(){
  npg.current++;
  npg.docID.setAttribute('src', '/images/gallery/' + npg.name + (npg.current % npg.max) + '.jpg');
}

function nPGPP(){
  if(npg.ppImg.getAttribute('src') == 'images/pause.png'){
    nPGStop();
  }
  else {
    nPGStart();
  }
}

function nPGStop(){
  window.clearInterval(npg.intID);
  npg.ppImg.setAttribute('src', 'images/play.png');
}

function nPGStart(){
  npg.intID = setInterval("nPGShow();", npg.tI);
  npg.ppImg.setAttribute('src', 'images/pause.png');
}

function nPGNext(){
  nPGStop();
  npg.current++;
  npg.docID.setAttribute('src', '/images/gallery/' + npg.name + (npg.current % npg.max) + '.jpg');
}
function nPGPrev(){
  nPGStop();
  npg.current--; 
  npg.docID.setAttribute('src', '/images/gallery/' + npg.name + (npg.current % npg.max) + '.jpg');
 
}