// JavaScript Document

function LoadPage(x){

if(x==0){
window.open("index.html", "_parent");
}

if(x==1){
window.open("1a.htm","_parent");
}
if(x==2){
window.open("2.htm", "_parent");
}
if(x==3){
window.open("3.htm", "_parent");
}
if(x==4){
window.open("4.htm", "_parent");
}
if(x=="taktil"){
window.open("1b.htm", "_parent");
}
if(x=="reiki"){
window.open("1c.htm", "_parent");
}
if(x=="svensk"){
window.open("1a.htm", "_parent");
}
}
var msgWidth = 500, 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 = 'hidden';
}

/* 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(250, 10, 200);
   } 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 actually 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);
  else{
	scrollIt(250, 10, 200);
}
}
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)
}
window.onload = startBlink;