function checkShowOther(selectEl, otherId, match) {
	var otherEl = document.getElementById(otherId);
	if(selectEl.value.indexOf(match) > -1) {
		otherEl.style.visibility = "visible";
	} else {
		otherEl.style.visibility = "hidden";
	}
}

function clearText(el, text) {
	if(el.value == text) {
		el.value = "";
	}
}


function notEnabled() {
	alert("This feature is not currently enabled");
}

function checkConfirm() {
	if(document.forms[0].confirm.checked) {
		return true;
	} else {
		alert("You must tick the 'Confirm Changes' checkbox before submitting your details.");
		return false;
	}
}


/*
 * This function turns an editable form into a view
 * by making the inputs read-only, changing their styles
 * and also hiding any elements with the name "hideable"
 * note that these elements also have to have the style
 * class "hideable" set - also see elareg.css for the
 * definition of this class
 *
 * Note: with IE we cannot use this with <tr>, <td> and
 * <div> tags, as I had hoped to do. <a> tags work, but
 * we can't use this generally as the CSS definitions
 * will make these tags' bodies styles wrong if they're
 * not actual links. So instead a delightful hack has
 * been implaced to get also an array of <span> elements, and
 * concanact it with the existing element array. We should
 * be able to use these spans with sufficient generality.

 *
 */
function makeReadOnly() {
	var elArray = document.forms[0].elements;
	for(var i=0; i<elArray.length; i++) {
		var el = elArray[i];
		el.disabled = "true";
		el.style.borderColor = "white";
		el.style.borders = "1px";
		el.style.borderStyle = "solid";
		el.style.backgroundColor = "white";
		el.style.color = "black";   			
	}
	var hiddenEls = new Array();
	var hiddenElsIE = new Array();
	hiddenEls = document.getElementsByName("hideable");
	hiddenElsIE = getElementsByNameIE("span", "hideable");
	hiddenEls = concacate(hiddenEls, hiddenElsIE);
	for(var i=0; i<hiddenEls.length; i++) {
		hiddenEls[i].style.visibility = "hidden";
		hiddenEls[i].style.display = "none";
	}
}

/*
 * Oh Jesus..
 *
 */
function getElementsByNameIE(tag, name) {
     
     var els = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i=0, iarr = 0; i<els.length; i++) {
          att = els[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = els[i];
               iarr++;
          }
     }
     return arr;
}

/*
 * contacactate the elements of two containers
 *
 */
function concacate(obj1, obj2) {
    var i;
    var arr  = new Array();
    for (i=0; i<obj1.length; i++) {
        arr.push(obj1[i]);
    }
    for (i=0; i<obj2.length; i++) {
        arr.push(obj2[i]);
    }
    return arr;
}

/*
 * show only the options with a specified class name, 
 * given by filter.value in a select widget, identified
 * by id selectid
 * Assumes you have the styles clubTypeHide and clubTypeShow defined
 *
 */
function filterClubType(selectId, filter) {
    var select = document.getElementById(selectId);
    if (select && select.options) {
        for (var i=0; i<select.options.length; i++) {
            if (select.options[i].className.indexOf(filter.value) < 0 && filter.value != "any") {
                select.options[i].className = select.options[i].className.replace('clubTypeShow', 'clubTypeHide');
            } else {
                select.options[i].className = select.options[i].className.replace('clubTypeHide', 'clubTypeShow');
            }
            select.selectedIndex = 0;
        }
    }
}
