
var oPeak, oMarquee, oMarquee2, oSignature, oPhoto;
var isIE, s, d, w, h, w1, w2, w3, h2, h3;
var wLinks = 180; // width of links section of menu
var imgPeak;
var numflash = 6, iflash = 0;

function startup()
{
  isIE = document.all ? 1 : 0;
  d = isIE ? document.all : document;
  oPeak = dom('layerPeak');
  oMarquee = dom('layerMarquee');
  oSignature = dom('layerSignature');
  oPhoto = dom('layerPhoto');
  imgPeak = new Image(); imgPeak.src = "images/peakPhoto.jpg";
  resizeIt();
  flashLink();
}

function dom(s)
{
  return document.getElementById(s);
}

function flashLink()
{
  var i, o;
  if(++iflash > numflash) iflash=1;
  for(i=1; i<= numflash; i++)
  {
    o = dom('flashIt' + i);
    o.className = (i == iflash) ? 'myLinksFlashOn' : 'myLinksFlashOff';
  }
  setTimeout("flashLink()",500);
}

function resizeIt()
{
  if(isIE)
  {
    h = document.body.clientHeight;
    w = document.body.clientWidth;
  }
  else
  {
    h = window.innerHeight;
    w = window.innerWidth;
  }
  w1 = 20 + wLinks + 5; // width of menu
  w2 = w - w1; // width of Peak, etc.
  w3 = w2 - 20; // width of Peak minus right margin
  h3 = 178; //95; // height of signature
  h2 = h - (h3 + 10); // height of peak photo (above signature)
  s =
    "<IMG SRC='images/dot.gif'" +
    " WIDTH='" + w2 + "' HEIGHT='" + h2 + "'" +
    " ONLOAD='JAVASCRIPT: loadImage(this, imgPeak);'>";
  writeIt(oPeak, s);
  writeMarquee(w3);
  var wSignature = w3; //528;
  if(wSignature > w3) wSignature = w3;
  //if(wSignature > 684) wSignature = 684;
  s =
    "<TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0' RULES='NONE'" +
    "HEIGHT='" + h2 + "' WIDTH='" + w3 + "'>" +
    "<TR>" +
    "<TD>&nbsp;</TD>" +
    "<TD ALIGN='RIGHT' VALIGN='TOP' NOWRAP CLASS='callUs'>" +
    "&nbsp;" +
    //"<B>Call Us Today!<BR>Phone: 719-536-4440<BR>" +
    //"Toll Free: 877-536-4362</B>" +
    "</TD>" +
    "</TR>" +
    "</TABLE>" +
    "<TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0' RULES='NONE'" +
    "HEIGHT='" + h3 + "' WIDTH='" + w3 + "' BGCOLOR='#FFFFFF'>" +
    "<TD ALIGN='LEFT' VALIGN='BOTTOM'>" +
    "<IMG SRC='images/signature.gif' ALT='Frank & Melissa Fanelli'" +
    " WIDTH='" + wSignature + "' HEIGHT='" + h3 + "'" +
    "></TD>" +
    "<TD>&nbsp;</TD>" +
    "</TR>" +
    "</TABLE>";
  writeIt(oSignature, s);
  s =
    "<TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0' RULES='NONE'" +
    "HEIGHT='" + h + "' WIDTH='" + w3 + "'>" +
    "<TR>" +
    "<TD ALIGN='RIGHT' VALIGN='BOTTOM'>" +
    "<IMG SRC='images/photoStanding_v3.gif' ALT='Frank & Melissa Fanelli'" +
    " HSPACE='20' VSPACE='90'" +
    "></TD>" +
    "</TR>" +
    "</TABLE>";
  writeIt(oPhoto, s);
}

function loadImage(o1, o2)
{
  if(instr(o1.src, 'dot.gif')) o1.src = o2.src;
}

function writeIt(o, s)
{
  //if(isIE)
  //{
    o.innerHTML = s;
  //}
  //else
  //{
  //  var d = o.document;
  //  d.write(s);
  //  d.close();
  //}
}

function instr(s1, s2)
{
  s1 = s1.toString();
  s2 = s2.toString();
  var n = s1.indexOf(s2) + 1;
  return n;
}

function mid(sOrig, mStart, nBytes)
{// m is 1-based - we will convert to zero-based
//alert('mid: ' + s + '/' + mStart + '/' + nBytes);
  var x, n;
  var s = sOrig.toString();
  if(nBytes) n = nBytes; else n = s.length + 1 - mStart;
  x = s.substr(mStart - 1, n);
  return(x);
}

//--------------------------------------
// Scrolling marquee

function writeMarquee(wMarquee)
{
  var w = wMarquee;
  var s = 4; // speed
  var msg1 =
    '<DIV CLASS=\'marquee1\' style=\'text-align:center; width:6in;\'>' +
    'Welcome to FanelliTeam.com!' +
    '<br>Serving Colorado Springs<br>and the Pikes Peak Region since 1983!<br>';
  var msg2 =
    '<p CLASS=\'marquee2\'>' +
    'Contact us toll-free 877-536-4362<br>' +
    ' or email us at <A HREF=\'Frank@FanelliTeam.com\'>' +
    'Frank@FanelliTeam.com</A>!' +
    //'<br><img src=images/e25.jpg vspace=10' +
    '</p></div>';
  if(isIE)
  {
    var sMsg = //'<marquee scrollamount=4>Howdy!</marquee>';
      '<marquee scrollAmount=\''+s+'\' style=\'width:'+w+'px;\'>' +
      msg1 + msg2 +
//      '</marquee>'
//      +
//      '<marquee scrollAmount=\''+s+'\' style=\'width:'+w+'px;\'>' +
//      msg2 +
      '</marquee>';
    writeIt(oMarquee, sMsg);
  }
  else
  {
    writeIt(oMarquee,
      '<p style="width:'+w+';text-align:center;">' +
      msg1 + '<BR>' + msg2 +
      '</p>'
      );
  }
}

function launchPlayer5(streamingID)
{
  window.open
  (
    'http://www.i2on.com/homesandland/play.php?id=' + streamingID,
    'newwindow', 'height=240,width=320',
    'toolbar=no,menubar=no,resizable=yes,scrollbars=no,status=no,location=no'
  );
}

function showTeam()
{
  window.open
  (
    //'images/fanelliTeam.jpg',
    'MeetTheFanelliTeam.pdf',
    'newwindow', 'width=900,height=601',
    'toolbar=no,menubar=no,resizable=yes,scrollbars=no,status=no,location=no'
  );
}
