//photo captions
var caption = new Array();
caption[1] = "Brad Lashua";
caption[2] = caption[3] = caption[4] = caption[5] = "Bart Rulon";
caption[6] = caption[7] = "Jami Nagel";
caption[8] = caption[9] = caption[10] = "Kate Janes";
caption[11] = caption[12] = caption[13] = "Terry Bare";

function initBannerFade(){
    var banner = document.getElementById("banner");
    var photocredit = document.getElementById("photocredit");
    var n = caption.length-1;
    var ph = genRand(n);
    photocredit.innerHTML += "Photo Credit: " + caption[ph];
    banner.innerHTML = "<img src=\""+path+"img/photo"+ph+".jpg\" width=\"960\" height=\"217\" alt=\"\" id=\"bannerphoto\" />" + banner.innerHTML;
    var image = document.getElementById("bannerphoto");
    setOpacity(image, 0)
    image.style.visibility = 'visible';
    fadeIn("bannerphoto",0);
    
    var wrap = document.getElementById("wrap");
    var phs=genRand(10);    
    if ((browser.isIE55 || browser.isIE6x) && browser.isWin32) {
        wrap.innerHTML += "<div id=\"photostrip\" style=\"filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path+"img/photostrip"+phs+".png', sizingMethod='scale')\"></div>";
    } else {
        wrap.innerHTML += "<div id=\"photostrip\"><img src=\""+path+"img/photostrip"+phs+".png\" width=\"960\" height=\"169\" alt=\"\" /></div>";
    }
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  obj = document.getElementById(objId);
  if (opacity <= 100) { 
    setOpacity(obj, opacity);
    opacity += 5;
    window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 40);
  }
}

function genRand(x) {
    var range = x;
    return Math.floor(Math.random() * range) + 1;
}

//tesimonials
var testimonials = [
    ['This cruise was the most spectacular day of our vacation. The crew was very helpful, knowledgeable, and kind. And all the scenery was beautiful&mdash;the eagles, the harbor seals, and all the whales. Pat and I highly recommend this cruise!!','Steve and Pat from Chiefland, FL'],
    ['I was on your whale watching tour on September 26, 2007. It was the most incredible day and I would like to extend a big thank you to all your employees. They were fantastic and the day couldn&rsquo;t have been more successful. I have told many people about our experience. They plan on booking with your company in the future.','Sylvia O.'],
    ['I want to thank you for the wonderful tour my daughter and I took with Island Adventures.  Your staff were outstanding and made our tour the highlight of my vacation. We saw J, K and some of L pods. The Orcas gave us a show to remember!  We will be back next year. We&rsquo;ve already marked our calendars!','Alice V. from St. Louis, MO'],
    ['We wanted to share photos from our trip 9/14.  We had an AWESOME time.  The new Island Explorer III is a beautiful boat! Keep up the terrific work&hellip; we will be back again!','Ron &amp; Cheri T. and Bob &amp; Pam J.'],
    ['Thank you for another wonderful day on the water. What a knockout line up: orcas, a minke, stellar sea lions, harbor seals, eagles, harbor porpoise, turkey vulture. Pretty darn cool. And Captain Shane the naturalist! That was a first for me. What fun.','Annette C.'],
    ['This was my husbands&rsquo; and my 15th anniversary celebration trip and it couldn&rsquo;t have gone better.  We were so impressed with your staff, that we will be back every year at least 1 time.  Unfortunately, we live in Portland, Oregon, so it takes us time to get up here, but it will be worth the while.&hellip;  Again, thank you for such a great time and a memory that will last a lifetime.','Wayne J. from Portland, OR'],
    ['Today I went on your 9 am tour and want to tell you a wonderful trip it was. I have lived in the Pacific NW for 18 years and have always wanted to go whale watching, but was &ldquo;waiting&rdquo; to go with someone. I decided to give myself a birthday present and went by myself. I went out with a heavy heart. But as I stood at the bow of the boat, almost the entire trip, my soul was soothed to be out in the open water with the wind, fresh air, beautiful scenery, and of course the wildlife, particularly the whales. They made me squeal like a little girl. Thank you to the crew for an awesome day!!!','Christine R. from Kent, WA'],
    ['One of the reasons we always chose Island Adventures is we know they are respected for their adherence to whale watching regulations and have a sound &ldquo;green&rdquo; policy.  We were first introduced to you by People For Puget Sound, and have been out, always with you, several times since.','Barbara L. from Camano Island, WA'],
    ['Thanks for running a terrific operation.  Thanks for knowing that being generous with time, when one of nature&rsquo;s great dramas is being played out, is more important than watching the clock.  We&rsquo;ll go whale watching again.  Will it be with Island Adventures?  Emphatically, yes!','Barbara L. from Camano Island, WA'],
    ['This is our second cruise this summer.  Didn&rsquo;t think the second could be as good as the first.  WRONG.  It was so different.  Different boat, different crew, different whales, different weather&hellip;different WONDERFUL caring crew that made each one feel like they were special from the front desk when we checked in (bought jackets for all and Christmas tree ornaments) to the hand shake at the end&hellip;again, we WILL be back with more people&hellip; Thanks again for the great day.','Jan &amp; Norman P.'],
    ['I just wanted to thank you again for the wonderful whale watching adventure we (myself and two grandsons) had on Friday, June  29th.   We went out at Noon and had the opportunity to see many of the J Pod Orcas&mdash;they  were so  beautiful and the crew made the experience overwhelming with  their knowledge  and abilities&hellip;from the information about some of the wildlife we saw on the way to the Pod and then the  able way that the Captain moved the boat to get the best views of the Orcas&hellip;it was just something spectacular.   I have been wanting to go whale watching for so many years and now my dream has come true!   I will gladly refer folks to you so that they can have a great experience too.  &ldquo;Thank you&rdquo; seems inadequate but it is from the heart!','Sue Z. and grandsons'],
    ['We just wanted to say thank you for the great trip.  We got to see the orca&rsquo;s the way nature intended them to be&mdash;free&mdash;and it was amazing.  The crew was wonderful and went out of there way to make sure we saw all wild life.&hellip;  Thank you once again for a life time memory.','Tammy &amp; Dennis from Everett, WA'],
    ['Hello. I would just like to send a little note to let you know how much we LOVED our trips with your company. We first would like to say your crew is spectacular. Captain Carl worked so hard especially on the second day to get us out to the whales!!!! Your staff was polite, very knowledgeable and the tours were AWESOME!!! We would recommend your company to anyone and will definitely tell everyone we know about your company!!!!! We couldn&rsquo;t have asked for a better time aboard your ship!! The whales were awesome and we have great memories to last us a lifetime!!!!! I can&rsquo;t really put into words what a wonderful time we had&hellip;it just doesn&rsquo;t say enough. Thanks again for such a great experience!!!!!   Hope to see you all again!!!=)','Scott, Amy, Shilo and Aeryn W. from Billings, MT'],
    ['We want to again express our gratitude for a most wonderful day.  The trip was way more than we expected.  You went overboard (pun intended) to give everyone the best possible experience.  Your staff are great.  They made everyone feel that they were the only people on board.  You took little side stops so we could all see everything possible. We have spent many summers in the waters from Anacortes to Desolation Sound and have seen many of the animals we saw Monday.  You made it all new again.  I could go on and on, but by now you get the drift of our feelings.  Our family is coming from California this July so we WILL be back in force with you.  We want to be on your boat with the same crew as you have totally spoiled us.   Thanks so much again for a wonderful day.','Norman and Jan P. from Redmond, WA'],
    ['I have now returned to Wisconsin and want to thank you for the wonderful time we had whale-watching.  Your crew was exceptionally friendly, interesting and helpful.  They played a large part in making the trip such a success. I&rsquo;ve been on many trips but never felt so comfortable with the providers.  Thanks again.','Barbara I. from Wisconsin'],
    ['I would like to thank you for the awesome trip!  Before we set out on our trip from Wisconsin to Washington we had called to book our whale watching trip.  Sam had answered the phone, and had informed us not only of Island Adventures but also information of the area, with lodging and restaurant information.  He went out of his way to help us. Once we arrived we had a fantastic trip! The captain and other staff on the Island Explorer were accommodating and entertaining. We saw more than promised by your staff, and have wonderful memories.','Mike &amp; Linda Lee W. from Wisconsin'],
    ['THANK YOU for a wonderful cruise on our whale watching tour. The crew was great&mdash;they were fun, helpful, knowledgeable, attentive, and just&hellip;great! We will most definitely consider you when whale watching comes up again for our July Meeting. It was a terrific experience and folks are raving about it.','Bonnie B. from WA &amp; Northern ID District Council of Laborers'],
    ['We wanted to express our thanks to you and your crew for a very successful cruise. We really appreciated everyone&rsquo;s efforts and wanted to especially say thanks to Drew and Brooke; they both did an exceptional job making our guests feel special. Thanks for everything, and we look forward to next year.','Viviano G. and Mary K. from Ferndale, WA'],
    ['I would like to thank you for a truly amazing tour on August 19, 2007 aboard the Island Explorer 3. This was the most beautiful boat I have ever been on! I thought the captain was hilarious and the crew was terrific! I really enjoyed meeting your naturalist Bart Rulon, and was very excited to purchase some of his photography in your shop! This tour was definitely the biggest highlight of my vacation. I will be sure to come back to tour with you next summer!','Barbara B. from Lady Lake, FL'],
    ['Wow! What a show! The captain and crew were great and so knowledgeable about the local wildlife and orca whales. This was my third time out and on the afternoon trip we seemed to stop in the middle of 3 pods. They were all around the boat. About the Explorer 3&mdash;what a great boat. The set up is just perfect. Extra seating all around. Nice snack bar area for the crew and all. At the end of our tour, the captain himself took our picture at the bow of the boat from the dock. I thought I would see one&mdash;instead we saw so many more. Amazing! Thanks so much. Orca whales do exist!!','Gloria from Mt. Vernon, WA'],
    ['Just wanted to thank you for the wonderful sunset cruise last Saturday (4/26/08). My children and I loved every second of it! Shane, Kate and Brooke were fantastic&mdash;so knowledgable about the wildlife, especially the whales. But more importantly, they were so enthusiastic about what we were seeing. It&rsquo;s hard to believe that they experience these things every day and yet are still so in awe. They gasped and cheered with the rest of us every time those whales surfaced or made a move. We have not stopped talking about it &mdash;even my teenagers! We can&rsquo;t wait to come back. Thanks for everything&mdash;it was perfect in every way!!!','Judy M. from Frankfort, IL'],
    ['We had a wonderful time. I wanted to personally thank Kate, our naturalist, though. She was so wonderful. She truly made the trip stand out in my mind from the many I&rsquo;ve taken. I&rsquo;ve traveled the country (and parts of the world) whale watching, but I&rsquo;d never experienced a crew as lovely as yours! If it were possible, would you pass this message along to our naturalist in particular? I also plan on joining you in early May to see Pacific Coast resident Orcas for the first time in my life! Thank you all once again!', 'Tori H.'],
    ['I went on a cruise today, Saturday (4/5), and just wanted to thank you for such a great trip.  I grew up in the Puget Sound area and had never seen a gray whale until today.  I got to see at least 4!!!!It was a great trip and I was impressed with the knowledge and friendliness of the crew.  I also chose your company because I heard from my friends that you comply with the rules and don&rsquo;t get too close to the whales.  You ran a tight ship.','Samantha E. from Seattle, WA']
]

var path = "../";

function initTestimonial(){
    var n=genRand(testimonials.length);
    var testimonial = document.getElementById("testimonial");
    var content = "<p class=\"quote\">"+testimonials[n-1][0]+"</p>\n";
    content += "<p class=\"attr\">"+testimonials[n-1][1]+"</p>\n";
    content += "<p class=\"more\"><a href=\""+path+"about/testimonials.htm\">Read more testimonials&hellip;</a></p>\n";
    testimonial.innerHTML = content;
}

function initSubnav(){
    var subnav = document.getElementById('sectionnav');
    var subnavas = subnav.getElementsByTagName('a');
    for (var a=0; a<subnavas.length; a++){
        var currenthref=String(subnavas[a].href);
        var currentloc=String(document.location);
        if (unescape(currenthref)==unescape(currentloc)){
            subnavas[a].className="current"
        }
    }
}

function initDatePop(){
    var dp = document.getElementById('datepop');
    addAnEvent(dp,'click',getdate);
}

function initWebcamPop(){
    var w = document.getElementById('webcam');
    var was = w.getElementsByTagName('a');
    for (var a=0; a<was.length; a++){
        addAnEvent(was.item(a),'click',WebcamPop);
    }
    
}

function WebcamPop(){
        appWindow = window.open (this.href,"appWindow","width=660,height=500,toolbar=0,resizable=1");
        appWindow.focus ();
        return false;        
}

function initLinks(){
    var content = document.getElementById('wrap');
    var links = content.getElementsByTagName('a');
    
    for(var i=0;i<links.length;i++){
        var linky = links[i];
        if (linky.className == "video1") {
            addAnEvent(links.item(i),'click',VidWindow1);
        } else if (linky.className == "video2") {
            addAnEvent(links.item(i),'click',VidWindow2);
        } else if (linky.className == "recording") {
            addAnEvent(links.item(i),'click',RecWindow);
        } else if (linky.className == "dotmap") {
            addAnEvent(links.item(i),'click',MapWindow);
        }
    }
}


function VidWindow1(){
        appWindow = window.open (this.href,"appWindow","width=200,height=170,toolbar=0,resizable=1");
        appWindow.focus ();
        return false;        
}

function VidWindow2(){
        appWindow = window.open (this.href,"appWindow","width=660,height=520,toolbar=0,resizable=1");
        appWindow.focus ();
        return false;        
}

function RecWindow(){
        appWindow = window.open (this.href,"appWindow","width=200,height=200,toolbar=0,resizable=1");
        appWindow.focus ();
        return false;        
}

function MapWindow(){
        appWindow = window.open (this.href,"appWindow","width=570,height=660,toolbar=0,resizable=1");
        appWindow.focus ();
        return false;        
}

function initialize(){
    if ( document.getElementById ){  
        if (document.getElementById("home") || document.getElementById("e404")) path = "";
        if (document.getElementById("banner") && !document.getElementById("gallery") && !document.getElementById("visitor_map")) initBannerFade();
        if (document.getElementById("sectionnav")) initSubnav();
        if (document.getElementById("datepop")) initDatePop();
        if (document.getElementById("webcam")) initWebcamPop();
        initLinks();
        if (document.getElementById("testimonial")) initTestimonial();  
        if (document.getElementById("reserve") || document.getElementById("visitor_map")) initPageAux();
    }
}

function addAnEvent( target, eventName, functionName){
   eval('target.on'+eventName+'=functionName');
}

function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser name
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   
   // specific browser shortcuts
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
}
var browser = new BrowserDetect();

function getdate(){
    window.open('../mini_calendar_book.cfm?FormName=bookonline&FieldName=idate','cal','width=400,height=400');
}

window.onload=initialize;