// MISCALLENOUS FUNCTIONS
// +------------------------------------------------------------------------------------------------------------------------------+
// | 
// +------------------------------------------------------------------------------------------------------------------------------+
// | AUTHORS: 
// | Neil Champion (neil@cambridgenewmedia.co.uk)
// +------------------------------------------------------------------------------------------------------------------------------+
// | INSTRUCTIONS:
// +------------------------------------------------------------------------------------------------------------------------------+
// | COMMENTS:
// +------------------------------------------------------------------------------------------------------------------------------+
// | FILES REQUIRED FOR PROCESSING
// | Please read the instructions and comments for all included files
// | none
// +------------------------------------------------------------------------------------------------------------------------------+
// | VERSION HISTORY:
// | v 1.0     |     03.01.2004     |     Original version
// +------------------------------------------------------------------------------------------------------------------------------+

	//Changes the action attribute of the specified form and submits it
	function SubmitForm(target, form_name) {
		var form = document.forms[form_name];
		if (document.getElementById && target != '') {form.action = target;}
		form.submit();
		return;
	}
	
	//Tick or untick all checkboxes with a specified ID
	function CheckAll(id, form, obj) {
		if (!document.getElementById) return;
		var checkboxes = document.getElementsByName(id);
		if (checkboxes.length > 0) {
			for (var i = 0; i < checkboxes.length; i++) {
				checkboxes[i].checked = document.forms[form][obj].checked;
			}
		}
	}

	//Textarea Counter
	function CharacterCounter(obj1, maxlength) {
		if (!document.getElementById) return;
		if (obj1) {
			if (obj2 = document.getElementById(obj1.name+'_Label')) {
				if (obj1.value.length > maxlength) {
					obj2.className = 'Red';
					//alert('Sorry, you are over the limit of ' + maxlength + characters');
					//obj1.value = obj1.value.substring(0,maxlength);
				}
				else {
					obj2.className = '';
				}
				obj2.innerHTML = obj1.value.length + '/' + maxlength;
			}
		}
	}

	//Requests confirmation before proceeding to specified location
	function ConfirmAction(message, link) {
		if (message != '' && link != '') {
			agree = false;
			agree = confirm(message);
			if (agree) {window.location = link;}
		}
	}
	
	//Return current date and time
	function CurrentDate(flagTime) {
		var now = new Date();
		var year = now.getYear();
		var month = now.getMonth()+1;
		var day = now.getDate();
		var hour = now.getHours();
		var minutes = now.getMinutes();
		var seconds = now.getSeconds();
		if (year < 2000) {year = year + 1900;}
		if (month < 10) {month = '0' + month;}
		if (day < 10) {day = '0' + day;}
		if (minutes < 10) {minutes = '0' + minutes;}
		if (seconds < 10) {seconds = '0' + seconds;}
		if (flagTime == 0) {return day + '/' + month + '/' + year;}
		else {return day + '/' + month + '/' + year + ' ' + hour + ':' + minutes + ':' + seconds;}
	}
