function selectAll() {
	//Checks all checkboxes on page regardless of the amount of forms
	//Requires a checkbox with the name/id "select_all" to initiate this function on click
	var x = document.getElementsByTagName("input");
	for(i=0; i<x.length; i++) {
		if((x[i].type == "checkbox") && (x[i].name != "select_all")) {
			x[i].checked = (document.getElementById("select_all").checked == false) ? false : true;
		}
	}
}

function copyChecked() {
	//Grabs the value of all checked checkboxes, builds a comma seperated string and dumps the string into a hidden field
	var c = new Array();
	var z = 0; //A counter for assembling the array nicely
	var x = document.getElementsByTagName("input");
	for(i=0; i<x.length; i++) {
		if((x[i].type == "checkbox") && (x[i].name != "select_all")) {
			if(x[i].checked == true) {
				c[z] = x[i].value;
				z++;
			}
		}
	}
	document.getElementById("selected").value = c.join(",");
}

function displayClock() {
	var now 	= new Date();
	var hours   = now.getHours();
	var minutes = now.getMinutes();
	var days 	= new Array('Sun','Mon','Tues','Wed','Thurs','Fri','Sat');
	var months 	= new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

	var date = now.getDate();
	if(hours < 10) hours = "0"+hours;
	if(minutes < 10) minutes = "0"+minutes;

	var div = document.getElementById('clock');
	var year = now.getYear();
	year = (year < 1000) ? year+1900 : year;
	div.innerHTML = days[now.getDay()]+" "+date+" "+months[now.getMonth()]+", "+year+" "+hours+":"+minutes;
	setTimeout("displayClock()",1000);
}

function clearField(n) {
	if(n.value == n.defaultValue) {
		n.value = "";
	}
}

function openWindow(url) {
	window.open(url,"FilmExtras","width=300,height=500,resizable=yes,scrollbars=yes,toolbar=no,location=n,directories=no,status=yes,menubar=no")
}

function selectGroup(parent) {
	var x = document.getElementsByTagName("input");
	var bits = parent.id.split("_");
	var prefix = bits[0];
	for(i=0; i<x.length; i++) {
		re = new RegExp("^"+prefix+"_");
		if((x[i].type == "checkbox") && (x[i].id != prefix+"_group") && (x[i].id.match(re))) {
			x[i].checked = (document.getElementById(prefix+"_group").checked == false) ? false : true;
		}
	}
}

function showHelp(content) {
	show = "<p>Click / Hover over an element on the page to get more help.</p>";
	if(content != "") show = content;
	document.getElementById("help_box").innerHTML = show;
}

function showLoading(prefix) {
	document.getElementById(prefix+"_loading").style.visibility = "visible";
	document.getElementById(prefix+"_loading").innerHTML = "Uploading...<br /><img src='/images/site/loading.gif' alt='Uploading' title='Uploading' />";
}