function Homepage_Details() {
  this.loaded = 0;
  
  this.root = "";
  this.photos = new Array(1,0,0);
  
  this.message = [];
  /*
  this.message['text'] = "Dear Friends^"
                       + "Central Nova is my home. This is where I went to school,|played sports, and met life-long friends.^"
                       + "You elected me to office over 13 years ago and I have always|valued your opinions. Whether we chat in the coffee shop,|stop in the grocery store, or meet in my office, it is your|comments that I take to Ottawa.^"
                       + "We’ve made a real difference working together. But there|is more to accomplish. The world economy is changing|and that affects things at home. We need a steady|hand and real leadership to move forward.^"
                       + "This election, I am asking for your support so we can ensure|that our families continue to prosper right here in Central Nova.";
  */
  
  this.message['text'] = "Dear Friends^"
                       + "Thank you for re-electing me as your Member of Parliament here|in Central Nova. For almost 14 years you have given me the honour of|representing you. I am incredibly grateful and humbled to have earned|your trust once again.^"
                       + "Much respect is due to my fellow candidates who ran high road campaigns.^"
                       + "Thanks to all who participated by voting, working, and contributing to our|democratic process. Your greetings, interest and lively discussions as you welcomed me at your door, your street, your place of business or social gatherings were appreciated.^"
                       + "I will continue to work with all of you to enhance our communities|and deliver results for Central Nova.^"
                       + "Peter MacKay";
  
  this.message['written'] = "";
  this.message['display'] = "";
  this.message['place'] = 0;
}

function homepage_details_initialize() {
  with (this) {
    if (Site.loaded == 2) {
      loaded = 1;
      root = Site.root;
      Homepage.Welcome();
      Homepage.Photos();
    } else {
      window.setTimeout('Homepage.Initialize()',10);
    }
  }
}

function homepage_details_welcome() {
  var msg = $('homepage_details_welcome_message');
  var signature = $('homepage_details_signature');
  
  with (this) {
    if (loaded == 1) {
      if (msg) {
        message['written'] += message['text'].charAt(message['place']);
        
        if (message['text'].charAt(message['place']) == "|") {
          message['display'] += "<br>";
        } else if (message['text'].charAt(message['place']) == "^") {
          if (Site.safari == "1") {
            message['display'] += "<br>";
          } else {
            message['display'] += "<br><br style = \"font-size:4px; line-height:4px;\">";
          }
        } else {
          message['display'] += message['text'].charAt(message['place']);
        }
        
        message['place']++;
        
        msg.innerHTML = message['display'];
      }
      
      if (message['written'].length < message['text'].length) {
        window.setTimeout('Homepage.Welcome()',25);
      } else {
        if (signature) {
          signature.style.display = "inline";
          signature.style.visibility = "visible";
        }
        
        message['written'] = "";
        message['display'] = "";
        message['place'] = 0;
        //window.setTimeout('Homepage.Welcome()',5000);
      }
    }
  }
}

function homepage_details_photos(opt) {
  var p = $('homepage_details_splash_photo');
  
  /* var list = new Array();
      list[0] = "kids.jpg";
      list[1] = "veterans.jpg";
      list[2] = "uey.jpg";
      list[3] = "computer.jpg";
      list[4] = "acoa.jpg"; */
  
  //var base = root+"x/img/layout/s/";
  
  var base = "/x/img/front/slides/";
  var list = "annoucement-in-antigonish.jpg,dancing-with-the-stars-2010.jpg,dr-j-h.jpg,dsme-tour-jan2011.jpg,glen-haven-manor-garden-party-2010.jpg,haiti-canadian-produced-water.jpg,i-matheson-annc-january2011.jpg,peter-and-veteran.jpg,peter-in-afghaniastan.jpg,port-bickerton-fire-and-community-hall.jpg,sheet-harbour-sidewalk-celebration.jpg,sherbrooke-village.jpg,thorburn-fire-department.jpg".split(",");
  
  with (this) {
    if (loaded == 1) {
      if (p) {
        switch (opt) {
        case "pause":
          photos[2] = 1;
          break;
        case "start":
          if (photos[2] == 1) {
            photos[2] = 0;
            
            window.setTimeout('Homepage.Photos()',10);
          }
          break;
        case "next":
          if (photos[0] != 1) {
            photos[1] = (photos[1]+1 > (list.length-1) ? 0 : photos[1]+1);
            p.src = base+list[photos[1]];
          }
          break;
        case "previous":
          if (photos[0] != 1) {
            photos[1] = (photos[1]-1 < 0 ? (list.length-1) : photos[1]-1);
            p.src = base+list[photos[1]];
          }
          break;
        default:
          if (photos[2] != 1) {
            if (photos[0] != 1) {
              photos[1] = (photos[1]+1 > (list.length-1) ? 0 : photos[1]+1);
              p.src = base+list[photos[1]];
            }
            
            photos[0] = 0;
            
            window.setTimeout('Homepage.Photos()',6000);
          }
          break;
        }
      } else {
        window.setTimeout('Homepage.Photos()',20);
      }
    }
  }
}

Homepage_Details.prototype.Initialize = homepage_details_initialize;
Homepage_Details.prototype.Welcome = homepage_details_welcome;
Homepage_Details.prototype.Photos = homepage_details_photos;

var Homepage = new Homepage_Details();
    Homepage.Initialize();

