/*
 General site functions for Northcote High School
 Including menu setup
 
 Author: Rod Pettit, Webtrix.com.au
 Modified: 25/04/2005
*/

// ********************* CMS login window***********************************
var loginWin;
function login ( ) {
	loginWin = window.open('system/cms/login.php','login', "height=500,width=400,dependent");
	loginWin.focus(); 
}

// ********************* Preload menu images *******************************
var menuImage0 = new Image();
var menuImage1 = new Image();
var menuImage2 = new Image();
var menuImage3 = new Image();
var menuImage4 = new Image();

function preloadMenuImages(){
	if (document.images) {
			menuImage0.src = "system/images/AboutUs2.gif";
			menuImage1.src = "system/images/TeachLearning2.gif";
			menuImage2.src = "system/images/Enrolment2.gif";
			menuImage3.src = "system/images/Community2.gif";
			menuImage4.src = "system/images/Students2.gif";
			}
}

// ********************* General DHTML utility functions *******************************
var NS4DOM = (document.layers) ? true:false;
var IEDOM = (document.all) ? true:false;
var W3CDOM = (document.getElementById) ? true:false;

function getObject(id) {
   if (NS4DOM) ref="document."+id;
   else if (IEDOM) ref=id;
   else if (W3CDOM) ref="document.getElementById('"+id+"')";
   var object=eval(ref);
   return object;
}

function placeIt(id, x, y) {
   var object=getObject(id);
   if (NS4DOM) object.moveTo(x, y)
   else if (IEDOM || W3CDOM) {
      object.style.left=x+"px";
      object.style.top=y+"px";
   } 
}

function moveIt(id, dx, dy) {
   var object=getObject(id);
   if (NS4DOM) object.moveBy(dx, dy);
   else if (IEDOM) {
      object.style.pixelLeft=object.style.pixelLeft+dx;
      object.style.pixelTop=object.style.pixelTop+dy;
   } 
   else if (W3CDOM) {
      newleft=parseInt(object.style.left)+dx;
      newtop=parseInt(object.style.top)+dy;
      object.style.left=newleft+"px";
      object.style.top=newtop+"px";
   }
}

function getYCoord(id) {
   object=getObject(id);
   if (NS4DOM) return object.top;
   else if (IEDOM || W3CDOM) return parseInt(object.style.top);
}

function getXCoord(id ) {
   object=getObject(id);
   if (NS4DOM) return object.left;
   else if (IEDOM || W3CDOM) return parseInt(object.style.left);
}

// ********************* Quicklinks movement  *******************************
var ql_enabled = false;
var ql_startDelay = 3000; 	// 5s
var ql_updatePeriod = 100; 	// Once every 100mS
var ql_stop = true;
var timer1 = null;
var timer2 = null;

// Move Quicklinks div out of the way of the About menu	
function QuicklinksDown() {
	if (ql_enabled) {
		QuicklinksHover();
		placeIt('quicklinksdiv', 0, 200); 
//		placeIt('quicklinksdiv', 150, 0); 
	}
}

// Scroll the Quicklinks div back near the About menu	
function QuicklinksUp() {
	if (ql_enabled) {
		if (getYCoord('quicklinksdiv') > 0) { // Move up if needed
			moveIt('quicklinksdiv', 0, -5); 
			timer1 = setTimeout( "QuicklinksUp();", ql_updatePeriod );
			}
		else if (getXCoord('quicklinksdiv') > 0) { // Move left if needed
			moveIt('quicklinksdiv', -2, 0); 
			timer1 = setTimeout( "QuicklinksUp();", ql_updatePeriod );
			}
	}
}

function QuicklinksHover() {
	if (ql_enabled) {
		clearTimeout(timer1);	// Stop timers
		clearTimeout(timer2);
	}
}

function QuicklinksOut() {
	if (ql_enabled)
		timer2 = setTimeout( "QuicklinksUp();", ql_startDelay );
}

// Used to disguise email addresses. Adds the full address to the passed unique part, then calls the email program
function email(id) {
	window.location.href="mailto:"+id+"@nhs.vic.edu.au?subject=NHS%20website";
}

function emailName(name,id) {
	window.location.href="mailto:"+name+" <"+id+"@nhs.vic.edu.au>?subject=NHS%20website";
}
