var myOnload = new Array;
myOnload[0] = "fnWriteHomeFlash";
myOnload[1] = "fnWriteQuotesFlash";

function changeMenu (ele) {
	if (d = document.getElementById(ele)) {
		if (d.style.display != "block") {
			d.style.display = "block";
		} else{
			d.style.display = "none";
		}
	}
	return false;
}

function changeClass (x) {
	x.classname=(x.className == 'parentSelected') ? '' : 'parentSelected';
}

function closeMenu (total, str) {
	var exceptions = createArray(str);
	for (i = 0; i < total; i++) {
		if (m = document.getElementById("m"+exceptions[i])) {
			m.style.display = "block";
		}
	}
}

/**
* create an javascript array from a comma seperate string
* @return array
*/
function createArray (str) {
	var arr = str.split(",");
	var arrValues = new Array(arr.length);
	for (i = 0; i < arr.length; i++) {
		arrValues[i] = arr[i];
	}
	return arrValues;
}

/**
* check if a value is in an array
* @return boolean
*/
function inArray (value, arr) {
	for (x = 0; x < arr.length; x++) {
		if (arr[x] == value) {
			return true;
		}
	}
	return false;
}

/**
* stop spammers getting email address
*/
var emailDomain = "upd8.org.uk";
function doEmail (user) {
	document.write('<a href="mailto:' + user + '@' + emailDomain + '" title="Email ' + user + '@' + emailDomain + '!">');
	document.write(user + '@' + emailDomain);
	document.write('</a>');
}

window.onload = function () {
	for (i = 0; i < myOnload.length; i++) {
		eval(myOnload[i]+"()");
	}
}

function validate (x, type) {
	switch (type) {
		case "contact" : fields = ['name', 'email', 'subject', 'comments']; break;
		case "register" : fields = ['firstname', 'surname', 'school', 'town', 'county', 'email', 'password', 'confirm', 'find', 'interest', 'schooltype']; break;
		default :
			return false;
			break;
	}
	
	for (var i = 0; i < fields.length; i++) {
		if (x.elements[fields[i]].value == "" || x.elements[fields[i]].value.length == 0) {
			alert("Please fill in all required fields");
			return false;
		}
	}
	return true;
}

/**
* @param x is the object
* @param s is the string
* @param d is the default value
*/
function changeValue (x, s, d) {
	if (x.value == d) {
		x.value = s;
	}
}

//
/* Filters for transparencies */
//
var pageFilters = '<style type="text/css" media="screen">'
// the alpha hovers for images
//+	'a:hover {filter:alpha(opacity=70);-moz-opacity:0.7;opacity:0.7;}'
+	'a:hover img {filter:alpha(opacity=70);-moz-opacity:0.7;opacity:0.7;}'
+	'</style>';
document.write(pageFilters);