// JavaScript Document

<!--

function clear_text(){
	var args = clear_text.arguments;
	var obj = args[0];
	var this_content = obj.value;
	var display_value = args[1];
	if (this_content == display_value){
		obj.value = '';
	}
}

function populate_text(){
	var args = populate_text.arguments;
	var obj = args[0];
	var this_content = obj.value;
	var display_value = args[1];
	if (this_content == ''){
		obj.value = display_value;
	}
}


function validation(){
	return true;
}

function set_focus(){
	var args = set_focus.arguments;
	var obj = document.getElementById (args[0]);
	obj.select();
	return false;
}

function getElementByClass(classname){
	var inc=0;
	var customcollection = new Array();
	var alltags=document.all? document.all : document.getElementsByTagName("*");
	for (i=0; i<alltags.length; i++){
		if (alltags[i].className==classname){
			customcollection[inc++]=alltags[i];
		}
	}
	return customcollection;
}

function change(){
	var args = change.arguments;
	var select_email = args[0];
	var _thelist = getElementByClass('email_checkbox');
	for (i=0; i<_thelist.length; i++){
		_thelist[i].checked = select_email;
	}
	return false;
}

function copy_email_addresses(){
	var email_list = "";
	var _thelist = getElementByClass('email_checkbox');
	for (i=0; i<_thelist.length; i++){
		if (_thelist[i].checked){
			email_list += _thelist[i].value + "; ";
		}
	}
	pasteboard = document.getElementById('pasteboard');
	var close_link = "<h2>Selected E-mail addresses</h2><p><a href=\"#\" onclick=\"return paste_board();\">X close</a>";
	pasteboard.innerHTML = close_link + "<textarea id=\"pasteboard_content\">" + email_list + "</textarea>";
	paste_board(true);
	document.getElementById('pasteboard_content').select();
	return false;
}

function paste_board(){
	var args = paste_board.arguments;
	if (args[0]){
		_style = "block";
	} else {
		_style = "none";
	}
	pasteboard = document.getElementById('pasteboard');
	pasteboard.style.display = _style;
	return false;
}

function confirm_reg_form(){
	var reg_form = document.getElementById('registration_form');
	var error = "";
	// Validate Email
	var p = reg_form['email'].value.indexOf('@');
	if (p < 1 || p == (reg_form['email'].value.length - 1)){
		error += "Please include an email address\r\n";
	}
	// Validate Password/s
	if ((reg_form['password'].value == '') || (reg_form['password'].value.length < 6) && (reg_form['password'].value != reg_form['confirm_password'].value)){
		error += "Please verify your password. Your password MUST be 6 characters or more\r\n";
	}
	// Firstname
	if (!reg_form['firstname'].value){
		error += "Please include your Firstname.\r\n";
	}
	if (!reg_form['surname'].value){
		error += "Please include your Surname.\r\n";
	}
	if (!reg_form['daytime_telephone'].value){
		error += "Please include your Daytime Contact Telephone number.\r\n";
	}
	if (!reg_form['authorise_contact'].checked){
		error += "Please confirm that you authorise the National Fishing Week to contact you.\r\n";
	}
	if (error){
		alert (error);
		return false;
	} else {
		return true;
	}
}

function _remove(){
	if (_remove.arguments){
		var _highlight = document.getElementById(_remove.arguments[0]);
		_highlight.className = 'to_remove';
	}
	var conf = confirm ("This action will permanently remove this record.\r\nAre you sure you wish to proceed?\r\nClick 'OK' to remove the item");
	if (conf){
		return true;
	} else {
		_highlight.className = '';
	}
	return false;
}

function hide_block(){
	if (args = hide_block.arguments){
		if (block = document.getElementById(args[0])){
			block.style.display = 'none';
			return false;
		}
	}
	return false;
}

function amend_image(){
	if (args = amend_image.arguments){
		obj = args[0];
		new_image = '/_lib/_images/_structure/' + args[1] + '.gif';
		obj.src = new_image;
		return false;
	}
}

-->
