//
// UniSoft Corporation, 2007-2009.
//
// Simple javascript functions used currently only by
// the home page.
//

var	global_id;
var	ids = new Array("dropmenu", "dropmenu1", "dropmenu2",
		"dropmenu3");
var	colours = new Array("#003300", "#9900CC", "#660033",
			"#FF6633", "#6666CC", "#FF0000",
			"#FF00FF", "#990000", "#CC66FF",
			"#666633", "#666600", "#FF6666",
			"#660066", "#6600FF", "#FF0033",
			"#330033", "#000066", "#333366",
			"#999966", "#006699", "#330066",
			"#990066", "#993300", "#000099",
			"#996633", "#CC00CC", "#FFCC33",
			"#00CCFF", "#FF6600", "#009900",
			"#330099", "#000000");

var	months = new Array("January", "February", "March", "April",
			"May", "June", "July", "August", "September",
			"October", "November", "December");

function get_index(id) {
	var	n = ids.length;
	var	i;

	for(i = 0; i < n; i++)
		if(ids[i] == id)
			return(i);
	document.write("get_index: HTML error\n");
	return(-1);
}


// dropall() - before we make one of the drop down menus visible,
//             we hide all menus so that we are not left with more
//             than one menu dropped down at any one time.

function dropall() {
	var	n = ids.length;
	var	i;

	for(i = 0; i < n; i++)
		hidemenu(ids[i]);
}


// showmenu() - simple function which turns on the CSS
//		"visibility" to make a particular dropdown
//		menu visiable. We set a timeout of 10 seconds
//		to hide the menu. Before we set visibility
//		we called dropall() to ensure none of the
//		other drop downs are active.
//
//		hidemenu() does the reverse and makes the
//		menu item invisible.

function showmenu(id) {
	var	elem = document.getElementById(id);
	global_id = id;
	var t = setTimeout("hidemenu(global_id)", 10000);

	dropall();
	
	if(elem == "")
		elem = document.all.getElementById(id);

	elem.style.visibility = "visible";
}


// Hide the element

function hidemenu(id) {
	var	elem = document.getElementById(id);

	if(elem == "")
		elem = document.all.getElementById(id);

	elem.style.visibility = "hidden";
}


//  set_background -	sets the background colour referenced by id
//			to a certain colour according to the day of
//			the week.

function set_background(id) {
	var	elem = document.getElementById(id);
	var	d = new Date();
	var	index = d.getDate();

	if(elem == "")
		elem = document.all.getElementById(id);

	elem.style.background = colours[index];
}


// print_date -	fill-in the date into the table within the home
//		page header

function print_date(id1) {
	var	d = new Date();
	var	m = d.getMonth();
	var	day = d.getDate();
	var	year = d.getFullYear();
        var     year = d.getFullYear();
        var     x = document.getElementById(id1);

        var     new_row = document.createElement("tr");
        var     newtd = document.createElement("td");
        var     new_tx = document.createTextNode(months[m] + " " + day + ", " + year);
        newtd.appendChild(new_tx);
        new_row.appendChild(newtd);
        new_row.setAttribute("class",  "maintext");
	x.appendChild(new_row);
}

function new_para(id2) {
	var	curp = document.getElementById(id2);
	var	textstuff = document.createTextNode("UniSoft loves you.");
	var	para = document.createElement("p");

	para.appendChild(textstuff);
	para.setAttribute("class", "maintext");
	curp.appendChild(para);
}



// get_index() - gets the index of the id which should be present
//               in the ids[] array. Currently not used.
