function writeDateModifiedCopyright(time, copyright) {
  var days = new Array;
  var months = new Array;
  days[0] = "Sunday";
  days[1] = "Monday";
  days[2] = "Tuesday";
  days[3] = "Wednesday";
  days[4] = "Thursday";
  days[5] = "Friday";
  days[6] = "Saturday";
  months[0] = "January";
  months[1] = "February";
  months[2] = "March";
  months[3] = "April";
  months[4] = "May";
  months[5] = "June";
  months[6] = "July";
  months[7] = "August";
  months[8] = "September";
  months[9] = "October";
  months[10] = "November";
  months[11] = "December";
  var modDate = new Date(Date.parse(document.lastModified));
  if (modDate != 0) {
    var day = days[modDate.getDay()];
    var ndate = modDate.getDate();
    var month = months[modDate.getMonth()];
    var year = modDate.getYear();
    if (year < 1000) year = year + 1900;
    if (time) {
      var hour = modDate.getHours().toString();
      if (hour.length == 1) hour = "0" + hour;
      var minute = modDate.getMinutes().toString();
      if (minute.length == 1) minute = "0" + minute;
      var second = modDate.getSeconds().toString();
      if (second.length == 1) second = "0" + second;
    }
    document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    document.write("This page was last modified: ");
    document.write(day + " " + ndate + " " + month + " " + year + " ");
    if (time) {
      document.write(hour + ":" + minute + ":" + second + " ");
    }
    if (copyright) {
      modDate = new Date();
      year = modDate.getYear();
      document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
      document.write("Copyright &copy; Bayside Yamaha 2009 - " + year + " ");
      document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    }
  }
}

function hoverPicture(source, caption) {
  var oImage = new Image();
  var oClose = new Image();
  var oDate = new Date();
  var oDiv = document.createElement('div');
  var multiplier = 1;

  oImage.src = source;
  var iWidth = oImage.width;
  var iHeight = oImage.height;
  var sLeft = document.body.scrollLeft;
  var sTop = document.body.scrollTop;
  var cWidth = document.body.clientWidth;
  var cHeight = document.body.clientHeight;
  var iLeft = sLeft + ((cWidth - iWidth) / 2);
  var iTop = sTop + ((cHeight - iHeight) / 2);

  if (iWidth > cWidth) {
    multiplier = cWidth / iWidth;
    iWidth = iWidth * multiplier;
    iHeight = iHeight * multiplier;
  }
  if (iHeight > cHeight) {
    multiplier = cHeight / iHeight;
    iWidth = iWidth * multiplier;
    iHeight = iHeight * multiplier;
  }

  oImage.id = oDate.getYear() + '' + oDate.getMonth() + '' + oDate.getDate() + '' + oDate.getHours() + '' + oDate.getMinutes() + '' + oDate.getSeconds() + '' + oDate.getMilliseconds();
  oImage.style.position = 'absolute';
  oImage.style.left = iLeft + 'px';
  oImage.style.top = iTop + 'px';
  oImage.style.width = iWidth + 'px';
  oImage.style.height = iHeight + 'px';
  oImage.style.cursor = 'pointer';
  oImage.style.border = 'medium outset silver';
  oImage.onclick = function(event) { resetPicture(this.id); };
  oImage.title = 'Click to close';
  oImage.alt = 'Click to close';
  oImage.style.zIndex = 1;

  oDiv.setAttribute('id', 'v' + oImage.id);
  oDiv.style.position = 'absolute';
  oDiv.style.width = (iWidth + 8) + 'px';
  oDiv.style.height = '21px';
  oDiv.style.top = (iTop + iHeight + 4) + 'px';
  //  oDiv.style.top = (iTop - 20) + 'px';
  oDiv.style.left = iLeft + 'px';
  oDiv.style.background = '#111111';
  oDiv.style.color = '#FFFFFF';
  oDiv.style.border = 'medium outset silver';
  oDiv.style.cursor = 'pointer';
  oDiv.style.textAlign = 'left';
  oDiv.innerHTML = '&nbsp;' + caption;
  oDiv.style.fontFamily = 'arial';
  oDiv.style.fontSize = '10pt';
  oDiv.onclick = function(event) { closeCaption(this.id); };
  oDiv.title = 'Click to close';
  oDiv.alt = 'Click to close';
  oDiv.style.zIndex = 1;

  oClose.src = 'images/close.png';
  oClose.id = 'x' + oImage.id;
  oClose.style.position = 'absolute';
  oClose.style.left = (iLeft + iWidth - 37) + 'px';
  oClose.style.top = (iTop + iHeight + 9) + 'px';
  //  oClose.style.top = (iTop - 15) + 'px';
  oClose.onclick = function(event) { closePicture(this.id); };
  oClose.title = 'Close';
  oClose.alt = 'Close';
  oClose.style.zIndex = 1;

  //  document.body.appendChild(oImage);
  document.body.appendChild(oDiv);
  document.body.appendChild(oClose);
  document.body.appendChild(oImage);

}

function resetPicture(id) {
  document.body.removeChild(document.all.item('x' + id));
  document.body.removeChild(document.all.item('v' + id));
  document.body.removeChild(document.all.item(id));
}

function closePicture(id) {
  document.body.removeChild(document.all.item(id));
  document.body.removeChild(document.all.item(id.substring(1)));
  document.body.removeChild(document.all.item('v' + id.substring(1)));
}

function closeCaption(id) {
  document.body.removeChild(document.all.item(id));
  document.body.removeChild(document.all.item(id.substring(1)));
  document.body.removeChild(document.all.item('x' + id.substring(1)));
}


function openURL(sURL, newWindow) {
  if (newWindow) {
    openWindow = window.open(sURL);
  } else {
    location = sURL;
  }
}

function writeSpecials() {
  var months = new Array;
  months[0] = "January";
  months[1] = "February";
  months[2] = "March";
  months[3] = "April";
  months[4] = "May";
  months[5] = "June";
  months[6] = "July";
  months[7] = "August";
  months[8] = "September";
  months[9] = "October";
  months[10] = "November";
  months[11] = "December";
  var oDate = new Date();
  var month = months[oDate.getMonth()];
  document.write(month + " Specials");
}

function toggle(tag) {
  var iPlusMinus = 0;
  var iBrands = 4;
  for (var x = 0; x < tag.childNodes.length; x++) {
    if (tag.childNodes[x].id == 'imgPlusMinus') {
      iPlusMinus = x;
    }
    if (tag.childNodes[x].id == 'divBrands') {
      iBrands = x;
    }
  }
  if (tag.childNodes[iBrands].style.display == "none") {
    tag.childNodes[iPlusMinus].src = '../icons/minusRed.gif';
    tag.childNodes[iBrands].style.display = "block";
  }
  else {
    tag.childNodes[iPlusMinus].src = '../icons/plusRed.gif';
    tag.childNodes[iBrands].style.display = "none";
  }
}

function groupShowHide() {
  var iPlusMinus = 0;
  var iSelected = 0;
  try {
    for (var x = 0; x < divGroup[divBrands.length - 1].children.length; x++) {
      // for (var x = 0; x < divGroup[divBrands.length - 1].childNodes.length; x++) {
      if (divGroup[divBrands.length - 1].children[x].id == 'imgPlusMinus') {
        // if (divGroup[divBrands.length - 1].childNodes[x].id == 'imgPlusMinus') {
        iPlusMinus = x;
      }
    }
    for (var x = 0; x < divSelected[divBrands.length - 1].children.length; x++) {
      // for (var x = 0; x < divSelected[divBrands.length - 1].childNodes.length; x++) {
      if (divSelected[divBrands.length - 1].children[x].id.indexOf('cbxSelected', 0) > -1) {
        // if (divSelected[divBrands.length - 1].childNodes[x].id.indexOf('cbxSelected', 0) > -1) {
        iSelected = x;
      }
    }
    if (divSelected[divBrands.length - 1].children[iSelected].checked == true) {
      // if (divSelected[divBrands.length - 1].childNodes[iSelected].checked == true) {
      divBrands[divBrands.length - 1].style.display = "block";
      divGroup[divBrands.length - 1].children[iPlusMinus].src = '../icons/minusRed.gif';
      // divGroup[divBrands.length - 1].childNodes[iPlusMinus].src = '../icons/minusRed.gif';
    }
  }
  catch (e) {
    for (var x = 0; x < divGroup.children.length; x++) {
      // for (var x = 0; x < divGroup.childNodes.length; x++) {
      if (divGroup.children[x].id == 'imgPlusMinus') {
        // if (divGroup.childNodes[x].id == 'imgPlusMinus') {
        iPlusMinus = x;
      }
    }
    for (var x = 0; x < divSelected.children.length; x++) {
      // for (var x = 0; x < divSelected.childNodes.length; x++) {
      if (divSelected.children[x].id.indexOf('cbxSelected', 0) > -1) {
        // if (divSelected.childNodes[x].id.indexOf('cbxSelected',0) > -1) {
        iSelected = x;
      }
    }
    if (divSelected.children[iSelected].checked == true) {
      // if (divSelected.childNodes[iSelected].checked == true) {
      divBrands.style.display = "block";
      divGroup.children[iPlusMinus].src = '../icons/minusRed.gif';
      // divGroup.childNodes[iPlusMinus].src = '../icons/minusRed.gif';     
    }
  }
}

