// Hidden from DW's XHTML converter extension

// replaces litBox
glowHover = function() {
	var sfEls = document.getElementsByTagName("DIV");
	for (var i=0; i<sfEls.length; i++) {
       if (sfEls[i].className == "glowcontainernormal") {
	      sfEls[i].onmouseover=function() {
		     this.className = "glowcontainerhover";
		  }
		  sfEls[i].onmouseout=function() {
		     this.className = "glowcontainernormal";
		  }
	   }
	}
}


if (window.addEventListener) //DOM method for binding an event
window.addEventListener("load", glowHover, false)
else if (window.attachEvent) //IE exclusive method for binding an event
window.attachEvent("onload", glowHover)
else if (document.getElementById) //support older modern browsers
window.onload=glowHover



// Wizard of Oz validator - Just click on the heading 3 times...
var val_chk = 0;
function w3c_val() {
  val_chk++;
  if (val_chk >= 3) {
    val_chk = 0;
    window.open ('http://validator.w3.org/check?uri=' + document.URL);
    for(var i=0;i<parent.frames.length;i++) { // send off frames if exist
      window.open ('http://validator.w3.org/check?uri=' + parent.frames[i].document.URL);
    }
  }	
}


// TYPE IN INDEX.HTML (THEN CALL fadeIt)
function typeIt() {
  if (!typeIt.currentchar) { //runs once
    typeIt.currentchar = 1;
    typeIt.flip = true;
    typeIt.typedtext = "YOUR WHEEL CONNECTS YOU TO YOUR YACHT...";
    typeIt.tL1 = getLyr('typeLyr1');
    typeIt.tL2 = getLyr('typeLyr2');
  }
  // alternating layers stops flicker in firefox
  typeIt.flip = !typeIt.flip;
  if (typeIt.flip) {
    typeIt.tL1.write(typeIt.typedtext.substr(0, typeIt.currentchar));
  } else {
    typeIt.tL2.write(typeIt.typedtext.substr(0, typeIt.currentchar));
  }
  typeIt.currentchar++;
  if (typeIt.currentchar<=typeIt.typedtext.length) {
  // delay was 40
    setTimeout('typeIt()', 70);
  } else {
    setTimeout('fadeIt(0)',500);
  }
}

// FADE IN INDEX.HTML (THEN CALL tickIt)
function fadeIt(num) {
  var incr, fL = getLyr('fadeLyr');
  // incr was 5
  incr = 2;
  fL.vis('visible');
  num += incr;
  fL.alpha(num);
  // delay was 50
  if (num < 100 - incr) {
    setTimeout('fadeIt(' + num + ')', 50);
  // Run once since it may be already running!
  } else if (!tickIt.runOnce) {  
    setTimeout('tickIt()', 1000);  
  }
}


// TICKER IN INDEX.HTML (THEN LOOP FOREVER)
// imports tickerLength from html page
function tickIt(){
  if (!tickIt.runOnce) {
    tickIt.runOnce = 'once';
    // allow graceful shutdown by removal of layer
    if (document.getElementById('tickLyr') == null) return;
    tickIt.L = getLyr('tickLyr');
    tickIt.count = tickIt.L.w();
    tickIt.L.sty.visibility = 'visible';
  }
  tickIt.count -= 3;
  if (tickIt.count < -tickerLength) { tickIt.count = tickIt.L.w() };
  tickIt.L.sty.textIndent = tickIt.count + 'px';
  setTimeout('tickIt()', 40);
}	


// POPUP WINDOWS IN CUSTOMER GALLERY
function marvPop(url, pic_width, pic_height) {
  var text, preview, windowprops, scrn_w, scrn_h, calc_left;
  scrn_w = screen.width;
  scrn_h = screen.height;
  if (navigator.appVersion.indexOf('Mac') != -1) {
    pic_width = pic_width + 5;
    pic_height = pic_height + 5;
  }
  calc_left = scrn_w-pic_width-50; // used to place window on right side...
  if (scrn_w < pic_width + 50 && scrn_h < pic_height + 50) {
    windowprops = "scrollbars=yes,resizable=yes,left="+ calc_left +",top=50,width=" + (scrn_w-100) + ",height=" + (scrn_h-150);
  } else if (scrn_w < pic_width + 50) {
    windowprops = "scrollbars=yes,resizable=yes,left=" + calc_left + ",top=50,width=" + (scrn_w-100) + ",height=" + (pic_height);
  } else if (scrn_h < pic_height + 50) {
    windowprops = "scrollbars=yes,resizable=yes,left=" + calc_left + ",top=50,width=" + (pic_width) + ",height=" + (scrn_h-150);	
  } else { // is small enough
    windowprops = "resizable=yes,left=" + calc_left + ",top=50,width=" + (pic_width) + ",height=" + (pic_height);
  } 
  text = "<html><head><title>" + url + "</title></head><body style='margin: 0; padding: 0; background-color: #000;'";
  text += "><center><img src='" + url + "'>";
  text += "</center></body></html>";
  preview = window.open("", "p" + (Math.round(Math.random()*1000000)), windowprops); // different window id each time...
  preview.document.open();
  preview.document.write(text);
  preview.document.close();
}