// JavaScript Document
var preloadFlag = false;
var playStatus = 1;
var noteStatus = 0;

function newImage(arg) {
    if (document.images) {
       rslt = new Image();
       rslt.src = arg;
       return rslt;
    }
}

function preloadImages() {
    if (document.images) {
    	bg_image_ = newImage("images/bg.jpg");
        btn_help_ = newImage("images/btn-help-.gif");
        btn_help_over = newImage("images/btn-help-over.gif");
        btn_help_down = newImage("images/btn-help-down.gif");
        btn_quit_ = newImage("images/btn-quit-.gif");
        btn_quit_over = newImage("images/btn-quit-over.gif");
        btn_quit_down = newImage("images/btn-quit-down.gif");
        btn_ctrl_pause_ = newImage("images/btn-ctrl-pause-.gif");
        btn_ctrl_pause_over = newImage("images/btn-ctrl-pause-over.gif");
        btn_ctrl_pause_down = newImage("images/btn-ctrl-pause-down.gif");
        btn_ctrl_play_ = newImage("images/btn-ctrl-play-.gif");
        btn_ctrl_play_over = newImage("images/btn-ctrl-play-over.gif");
        btn_ctrl_play_down = newImage("images/btn-ctrl-play-down.gif");
        btn_prev_ = newImage("images/btn-prev-.gif");
        btn_prev_over = newImage("images/btn-prev-over.gif");
        btn_prev_down = newImage("images/btn-prev-down.gif");
        btn_next_ = newImage("images/btn-next-.gif");
        btn_next_over = newImage("images/btn-next-over.gif");
        btn_next_down = newImage("images/btn-next-down.gif");
        btn_hide_ = newImage("images/btn-hide-.gif");
        btn_hide_over = newImage("images/btn-hide-over.gif");
        btn_hide_down = newImage("images/btn-hide-down.gif");
        btn_save_ = newImage("images/btn-save-.gif");
        btn_save_over = newImage("images/btn-save-over.gif");
        btn_save_down = newImage("images/btn-save-down.gif");
        preloadFlag = true;
    }
}

function btnClick(entity,state){
    if (state == "over"){
        imageUrl = "url(images/" + event.srcElement.id + "over" + ".gif" + ")";
        MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        //playSound(0);
        if ((playStatus == 1)&&(event.srcElement.id == "btn-ctrl-pause-")){
	        imageUrl = "url(images/" + "btn-ctrl-pause-" + "over" + ".gif" + ")";
        	MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        }
        else if ((playStatus == 0)&&(event.srcElement.id == "btn-ctrl-pause-")){
	        imageUrl = "url(images/" + "btn-ctrl-play-" + "over" + ".gif" + ")";
        	MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        }
    }
    if (state == "down"){
        imageUrl = "url(images/" + event.srcElement.id + "down" + ".gif" + ")";
        MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        if ((playStatus == 1)&&(event.srcElement.id == "btn-ctrl-pause-")){
	        imageUrl = "url(images/" + "btn-ctrl-pause-" + "down" + ".gif" + ")";
        	MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        }
        else if ((playStatus == 0)&&(event.srcElement.id == "btn-ctrl-pause-")){
	        imageUrl = "url(images/" + "btn-ctrl-play-" + "down" + ".gif" + ")";
        	MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        }
    }
    if (state == "up"){
        imageUrl = "url(images/" + event.srcElement.id + "over" + ".gif" + ")";
        MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        if ((playStatus == 1)&&(event.srcElement.id == "btn-ctrl-pause-")){
	        imageUrl = "url(images/" + "btn-ctrl-play-" + "over" + ".gif" + ")";
        	MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        	playStatus = 0;
        }
        else if ((playStatus == 0)&&(event.srcElement.id == "btn-ctrl-pause-")){
	        imageUrl = "url(images/" + "btn-ctrl-pause-" + "over" + ".gif" + ")";
        	MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        	playStatus = 1;
        }
    }
    if (state == "out"){
       	imageUrl = "url(images/" + event.srcElement.id + ".gif" + ")";
       	MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        if ((playStatus == 1)&&(event.srcElement.id == "btn-ctrl-pause-")){
	        imageUrl = "url(images/" + "btn-ctrl-pause-" + ".gif" + ")";
        	MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        }
        else if ((playStatus == 0)&&(event.srcElement.id == "btn-ctrl-pause-")){
	        imageUrl = "url(images/" + "btn-ctrl-play-" + ".gif" + ")";
        	MM_changeProp(event.srcElement.id,'','style.backgroundImage',imageUrl);
        }
    }
}

function btnChange(entity){
  if (playStatus == 1){
    imageUrl = "url(images/" + "btn-ctrl-play-" + "over" + ".gif" + ")";
    MM_changeProp(entity,'','style.backgroundImage',imageUrl);
    playStatus = 0;
  }
  else if (playStatus == 0){
    imageUrl = "url(images/" + "btn-ctrl-pause-" + "over" + ".gif" + ")";
    MM_changeProp(entity,'','style.backgroundImage',imageUrl);
    playStatus = 1;
  }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function hideNote(){
  if (noteStatus == 1){
    document.all.commentBgArea.style.pixelLeft = 268;
	move(commentBgArea,674,10);
    noteStatus = 0;
  }
  else {
    document.all.commentBgArea.style.pixelLeft = 674;
	move(commentBgArea,268,10);
    noteStatus = 1;
  }
}

function move(i, y, a){
	yNow = i.style.pixelLeft;
	var b = a - 1;
	if (yNow > (y + b)){
		yNow = yNow - a;
        i.style.pixelLeft = yNow;
	}
	else if (yNow < (y - b)){
		yNow = yNow + a;
		i.style.pixelLeft = yNow;
	}
	else{
		yNow = y;
		i.style.pixelLeft = yNow;
	}
	if (yNow == y){
		return;
	}
	ab1 = window.setTimeout("move("+i.id+","+y+","+a+");", 1);
}

function btn_change(idx,path){
	eval(idx).src=path;	
}

function openwindow(fn,w,h)
{
var nw;
nw = window.open(fn,'','resizable=no,scrollbars=yes,status=no,menubar=no,location=no,toolbar=no,width='+w+',height='+h);
nw.moveTo((screen.width-w)/2,(screen.height-h)/2);
}

function startStudy(fileName){
    var nbw = window.open(fileName,'',''); 
}