﻿    // Constants
var DROP_ITEM_OFF_CLASS = "item-off";
var DROP_ITEM_ON_CLASS = "item-on";
var DROP_DISAPPEAR_MS = 5000

var initDone = false;

// A Stack to keep track of window timeouts
var timeoutIDs = [];

function Point(x, y) {
	this.x = x;
	this.y = y;
}

function getObj(id) {
	if(document.layers) {
		return document.layers[id];
	} else if(document.all) {
		return document.all[id];
	} else if(document.getElementById) {
		return document.getElementById(id);
	}
}

function getPosition(el) {
	if(document.all) {
		return getPositionIE(el);
	} else if(document.getElementById) {
		return getPositionNS(el);
	}
}

function getPositionNS(el) {
	return new Point(el.x, el.y);
}

function getPositionIE(el) {
	var r = new Point(el.offsetLeft, el.offsetTop);
	
	if(el.offsetParent) {
		var tmp = getPositionIE(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}

	return r;
}

function toggleQuickStart(){
    var menu = getObj('TakeMeToDrop');
    if(menu.style.display != 'block'){
        menu.style.display = 'block';
    }else{
        menu.style.display = 'none';
    }   
   
}

function initTakeMeTo(){
   var el = getObj('TakeMeToDrop');
   var target =  getObj('TakeMeToImage');
   var pt;
   pt = getPosition(el);
   var prevState = target.style.display;
   target.style.display = 'block';
   target.style.left = new String(85) + 'px';
   target.style.top = new String(pt.y + el.offsetHeight + 1) + 'px';
   target.style.display = prevState;
}

function dropItemOver(obj) {
	obj.className = DROP_ITEM_ON_CLASS;
}

function dropItemOut(obj) { 
	obj.className = DROP_ITEM_OFF_CLASS;
}

function dropItemClick(obj) {
	document.location.href = obj.href;
}

function navOver(obj, index) {
	if(!initDone){
	    initStudentDrops();
	}
	actualObj = getObj(obj);
	dropHideAll();
	var target = getObj(drop[index][0]);
	target.style.display = 'block';
	timeoutIDs.push([ window.setTimeout('dropHideAll();', DROP_DISAPPEAR_MS), obj, index ]);
	obj.src = drop[index][3].src;
}

function navOverStudent(obj, index) {
	if(!initDone){
	    initStudentDrops();
	}
	actualObj = getObj(obj);
	dropHideAllStudent();
	var target = getObj(dropStudent[index][0]);
	target.style.display = 'block';
	timeoutIDs.push([ window.setTimeout('dropHideAllStudent();', DROP_DISAPPEAR_MS), obj, index ]);
	obj.src = dropStudent[index][3].src;
}


