﻿/*-----------------Blink Simulator----------------------------------*/
function doBlink() {
	var blink = document.all.tags("blink")
	for (var i=0; i<blink.length; i++)
		blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
	if (document.all)
		setInterval("doBlink()",1000)
}
/*-----------------Blink Simulator End------------------------------*/

window.onload = startBlink;

if (document.images)
{
    image1 = new Image;
    image2 = new Image;
    image3 = new Image;
    image4 = new Image;
    image5 = new Image;
    image6 = new Image;
    image7 = new Image;
    image8 = new Image;
    image9 = new Image;
    image10 = new Image;
    image1.src = "Images/btn02_home_on.jpg";
    image2.src = "Images/btn02_home_off.jpg";
    image3.src = "Images/btn02_bedunit_on.jpg";
    image4.src = "Images/btn02_bedunit_off.jpg";
    image5.src = "Images/btn02_contactus_on.jpg";
    image6.src = "Images/btn02_contactus_off.jpg";
    image7.src = "Images/btn02_webspecial_on.jpg";
    image8.src = "Images/btn02_webspecial_off.jpg";
    image9.src = "Images/Versa-logo_on.png";
    image10.src = "Images/Versa-logo_off.png";
}

function chgImg(name, image)
{
    if (document.images)
    {
        document[name].src = eval(image+".src");
    }
}

/*-----------------Marquee Simulator----------------------------------*/
var msgWidth = 570, bannerWidth;
var timerID;
/* This function centers the banner window in the main browser window */
function centerBanner() {
  if (bannerWidth == null) setBannerWidth();
  var el = document.getElementById('canvas');
  var scrnWidth = (document.all ? document.body.clientWidth : window.innerWidth);
  el.style.left = parseInt(0.5*(scrnWidth - bannerWidth)) + "px";
  el.style.visibility = 'visible';
}

/* Gets the banner window width from the select box value */
function setBannerWidth() {
  var selEL = document.getElementById('banWidth');
  bannerWidth = parseInt(selEL.options[selEL.selectedIndex].text);
  document.getElementById('canvas').style.width = bannerWidth + "px";
  document.getElementById('canvasText').style.left = bannerWidth + "px";
  centerBanner();
}

/* Function to start and stop scrolling */
function scroll(type) {
   if (type == 'start') {
     scrollIt(bannerWidth, 10, 250);
   } else 
     if (timerID != null) clearTimeout(timerID);
}

/* Function to reset the text layer for next scroll */
function clearText() {
  scroll('stop');
  var el = document.getElementById('canvasText');
/* Reposition the scrolling text */
  el.style.left = bannerWidth + "px";
}

/* Function which toggles the display of the script code.
 * Rather than going through the textNode creation shown here
 * the node value can be directly set to accomplish the
 * same thing */
function showCode() {
  var toggleEL = document.getElementById('toggleCode');
  var scrpEL = document.getElementById('scriptContainer');
  if (toggleEL.childNodes[0].nodeValue.indexOf('Show') != -1) {
     var eTEXT = document.createTextNode("Hide Script Code");
     toggleEL.replaceChild(eTEXT, toggleEL.childNodes[0]);
     scrpEL.className = 'scrShow';
  } else {
     var eTEXT = document.createTextNode("Show Script Code");
     toggleEL.replaceChild(eTEXT, toggleEL.childNodes[0]);
     scrpEL.className = 'scrHidden';
  }
  return false; 
}

/* Function that does the actual scrolling */
function scrollIt(Left, dx, speed) {
  var text = document.getElementById('canvasText');
  Left -= dx;
  text.style.left = Left + "px";
  if (Left > -msgWidth)
    timerID = setTimeout("scrollIt(" + Left + ", " + dx + ", " + speed + ")", speed);
}
/*-----------------Marquee Simulator End------------------------------*/

