var port =[], dur = 3, blend_speed = 2, crossFadeDuration =2, photos=[], ct=0, imgct=1, timer, running=false;
var splash = [], splashes = [], sct=0, simgct=1;
function pagePreload()
{
 if (document.images && document.portimg && port.length>0)
  {
   timer = setTimeout('showPort()',dur*1000);
  }
 if (document.images && document.splashimg && splash.length>0)
  {
   timer = setTimeout('showSplash()',dur*1000);
  }
}


function loadport(src, url)
{
 this.src = src;
 this.url = url;
}

function loadsplash(src)
{
 this.src = src;
}

function loadpid(pid)
{
 if (pid)
   {
   var src='/scripts/npv.dll?photo?s='+siz+'&c='+bgc+'&i=', zoom='javascript:ZoomPhoto("/scripts/nsm.dll?storefront?p=3&c='+phtg+'&i='; 
   port[port.length] = new loadport(src+pid, zoom+pid+'")');
   }
}

function loadsrc(src)
{
 if (src)
   {
   splash[splash.length] = new loadsplash(src);
   }
}

function ZoomPhoto(url)
{
if(port.length>0)
   {
   NewWindow = window.open(url,'NikonPortfolio','resizable=yes,width=600,height=600');
   NewWindow.top.focus();
   }
}

function switchPort(step)
{

 if(document.portimg && port.length>0)
  {
  timer=clearTimeout(timer);
  if (running)
   {
   if (ct+step<0)ct=port.length;
   ct=(ct+step);
   running=false;
   }
  if (ct==1 && photos.lenght==2 && step==1)ct++;
  if (ct+step<0)ct=port.length;
  ct=(ct+step);
  if (ct>port.length-1) ct=0;
  if (! photos[ct])
   {
    photos[ct] = new Image;
    photos[ct].src = port[ct].src;
   }
   document.portimg.src = port[ct].src;
   if(document.anchors[0])
   {
   document.anchors[0].href = port[ct].url;
   }
  if (document.images && ! running)
   {
   timer = setTimeout('showPort()',dur*1000);
   }
 }
}

function showSplash()
 {
 if(document.splashimg && splash.length>0)
 {
  if (sct<0)sct=splash.length;
  if (sct>splash.length-1) sct=0;
  if (document.all)
    {
    document.splashimg.style.filter="blendTrans(duration=blend_speed)";
    document.splashimg.style.filter="blendTrans(duration=crossFadeDuration)";
    document.splashimg.filters.blendTrans.Apply() ;  
    }
  if (splashes[sct] && (splashes[sct].complete || splashes[sct].complete==null))
    {
    document.splashimg.src = splashes[sct].src;
    if (document.all)
      {
      document.splashimg.filters.blendTrans.Play();
      }
    }
    if(sct==0) sct=splash.length;
    if(sct==splash.length) sct=0;
    if (++sct>splash.length-1) sct=0;
    splashes[sct] = new Image;
    splashes[sct].src = splash[sct].src;
    timer = setTimeout('showSplash()',dur*1000);
 }
}

function setPort(pno)
{
 if(document.portimg && port.length>0)
 {
  timer=clearTimeout(timer);
  running=false;
  ct = pno-1;
  if (! photos[ct])
   {
    photos[ct] = new Image;
    photos[ct].src = port[ct].src;
   }
   document.portimg.src = port[ct].src;
   if(document.anchors[0])
   {
   document.anchors[0].href = port[ct].url;
   }
  if (document.images && ! running)
   {
   timer = setTimeout('showPort()',dur*1000);
   }
  }
}


function showPort()
 {
 if(document.portimg && port.length>0)
 {
  if (ct<0)ct=port.length;
  if (ct>port.length-1) ct=0;
  if (document.all)
    {
    document.portimg.style.filter="blendTrans(duration=blend_speed)";
    document.portimg.style.filter="blendTrans(duration=crossFadeDuration)";
    document.portimg.filters.blendTrans.Apply() ;  
    }
  if (photos[ct] && (photos[ct].complete || photos[ct].complete==null))
    {
    document.portimg.src = photos[ct].src;
    if (document.all)
      {
      document.portimg.filters.blendTrans.Play();
      }
    if(document.anchors[0])
     {
     document.anchors[0].href = port[ct].url;
 	}
    running=true;
    }
    if(ct==0) ct=port.length;
    if(ct==port.length) ct=0;
    if (++ct>port.length-1) ct=0;
    photos[ct] = new Image;
    photos[ct].src = port[ct].src;
    timer = setTimeout('showPort()',dur*1000);
 }
}

function checkMMDDYYYY()
{
 if(document.dateform.s.value=="mm/dd/yyyy" || document.dateform.s.value == "")
  {
  alert('Please enter a valid date before pressing find.');
  document.dateform.s.value="mm/dd/yyyy";
  return false; 
  }
  else
  {
  return true;
  }
}

function ClearThis(vDateName)
{
var enteredstring = new String(vDateName.value);
if(!(enteredstring.indexOf('mm')!=-1&&enteredstring.indexOf('all events')!=-1))
 {
 vDateName.value = "";
 }
}