function menuOpen() {
    if ( document.getElementById('tblMenu').style.display != 'block' )
        Slide('tblMenu').open();
}

function menuClose() {
    Slide('tblMenu').close();
}

window.onscroll = function() { 
    if ( getScrollY() > 60 )
        document.getElementById('imgMenu').style.top = getScrollY() + "px";
}

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY ;
}


var slideInUse = new Array();

function Slide(objId, options) {
	this.obj = document.getElementById(objId);
	this.duration = 1;
	this.width = parseInt(this.obj.style.width);

	if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
	if(this.options.duration) { this.duration = this.options.duration; }
		
	this.close = function() {
		this.curWidth = this.width;
		this.newWidth = '1';
		if(slideInUse[objId] != true) {
			var finishTime = this.slide();
			window.setTimeout("Slide('"+objId+"').complete("+this.width+");",finishTime);
		}
	}
	
	this.open = function() {
		this.newWidth = this.width;
		this.curWidth = '1';
		if(slideInUse[objId] != true) {
			this.obj.style.width = '1px';
			this.obj.style.display = 'block';
			this.slide();
		}
	}
	
	this.slide = function() {
		slideInUse[objId] = true;
		var frames = 30 * duration; // Running at 30 fps

		var tIncrement = (duration*1000) / frames;
		tIncrement = Math.round(tIncrement);
		var sIncrement = (this.curWidth-this.newWidth) / frames;

		var frameSizes = new Array();
		for(var i=0; i < frames; i++) {
			if(i < frames/2) {
				frameSizes[i] = (sIncrement * (i/frames))*4;
			} else {
				frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
			}
		}
		
		for(var i=0; i < frames; i++) {
			this.curWidth = this.curWidth - frameSizes[i];
			window.setTimeout("document.getElementById('"+objId+"').style.width='"+Math.round(this.curWidth)+"px';document.getElementById('"+objId+"').scrollLeft=document.getElementById('"+objId+"').scrollWidth",tIncrement * i);
		}
		
		window.setTimeout("delete(slideInUse['"+objId+"']);",tIncrement * i);
		
		if(this.options.onComplete) {
			window.setTimeout(this.options.onComplete, tIncrement * (i-2));
		}
	    
		return tIncrement * i;
	}
	
	this.complete = function(width) {
		this.obj.style.display = 'none';
		this.obj.style.width = width + 'px';
	}
	
	return this;
}


if (document.images)
{
  preload_image_object = new Image();
  image_url = new Array();
  image_url[0] = "images/lessons/bg.jpg";
  image_url[1] = "images/lessons/GameOff.jpg";
  image_url[2] = "images/lessons/GameOn.jpg";
  image_url[3] = "images/lessons/GameOver.jpg";
  image_url[4] = "images/lessons/Mark8Off.jpg";
  image_url[5] = "images/lessons/Mark8On.jpg";
  image_url[6] = "images/lessons/Mark8Over.jpg";
  image_url[7] = "images/lessons/TheoryOff.jpg";
  image_url[8] = "images/lessons/TheoryOn.jpg";
  image_url[9] = "images/lessons/TheoryOver.jpg";

   var i = 0;
   for(i=0; i<=9; i++) 
     preload_image_object.src = image_url[i];
}
  