function TPErrorMessage(overrideId) {
	              var _errorMessageBG = null;
                var _messages = null;
                var _xhtml = null;
 
                return {
 
                    _setErrorMessageBG: function() {
 
                        for (var x=0; x<document.getElementsByTagName('table').length; x++) {
                            if (document.getElementsByTagName('table')[x].className.indexOf('errorMessageBG')>-1) {
                                this._errorMessageBG = document.getElementsByTagName('table')[x];
                                break;
                            }
                        }
                        
                    },
 
                    getErrorMessageBG: function() {
 
                        if (!this._errorMessageBG) {
                            this._setErrorMessageBG();
                        }
 
                        return this._errorMessageBG;
 
                    },
 
                    _setMessages: function() {
 
                        var message;
 
                        if (!this._errorMessageBG) this._setErrorMessageBG();
 
                        this._messages = this._errorMessageBG.getElementsByTagName('td')[1].childNodes[0].innerHTML.split(/<BR>/i);
 
                        if (this._messages[this._messages.length-1] == '') {
                            this._messages.splice(this._messages.length-1, 1);
                        }
 
                    },
 
                    getMessages: function() {
 
                        if (!this._messages) {
                            this._setMessages();
                        }
 
                        return this._messages;
 
                    },
 
                    _setXhtml: function(strIntro) {
 
                        var div, intro, ol, li;
 
                        if (!this._messages) this._setMessages();
 
                        div = document.createElement('DIV');
                        if (overrideId) {
                            div.className = overrideId;
                        } else {
                            div.className = "errorMessageBG";
                        }
 
                        if (strIntro) {
 
                            intro = document.createElement('p');
                            intro.appendChild(document.createTextNode(strIntro));
                            div.appendChild(intro);
 
                        }
 
                        ol = document.createElement('div');
											
												
                        for (var x=0; x<this._messages.length; x++) {
												
												
												
												//array of default error message output	
												var str = new Array();
												str[0] = "EmailFormat";
												str[1] = "FirstName";
												str[2] = "LastName";
												str[3] = "Store";
												str[4] = "Sorry, the";
												str[5] = "Comments";
												str[6] = "Name cannot";
												//array of new error messages
												var new_str = new Array();
												new_str[0] = "Email Format cannot be blank";
												new_str[1] = "First Name cannot be blank";
												new_str[2] = "Last Name cannot be blank";
												new_str[3] = "Store of Interest cannot be blank";
												new_str[4] = "The email address you gave us is either incorrect or does not exist";
												new_str[5] = "Comment is longer than allowed maximum length (1500 characters).";
												new_str[6] = "Nick name cannot be blank";
												
												//loop through each instance of message - loop prior to this one
												//and check for matches - loop through message array. Replace with new
												//message when a match occurs
												for (i=0; i<str.length; i++){
													if (this._messages[x].match(str[i])){
														this._messages[x] = new_str[i];
														}
													}
													
											
                            li = document.createElement('p');
                            li.innerHTML = this._messages[x];
                            //li.appendChild(document.createTextNode(this._messages[x]));
                            ol.appendChild(li);
                        }
 
                        div.appendChild(ol);
 
                        this._xhtml = div;
 
                    },
 
                    getXhtml: function(strIntro) {
 
                        if (!this._xhtml) {
                            this._setXhtml(strIntro);
                        }
 
                        return this._xhtml;
 
                    },
 
                    convertToXhtml: function(strIntro) {
 
                        if (!this._xhtml) this._setXhtml(strIntro);
                        this._errorMessageBG.parentNode.replaceChild(this._xhtml, this._errorMessageBG);
 
                    }
 
                }
 
            }


function validate(){
	var el = document.getElementsByName("terms-and-conditions");
	if (el[0].checked == false){
	alert("Please read and accept the terms and conditions");
		return false;
		}	
	return true;
	}
	
function checkAll(){
var box_01 = document.getElementsByName("running");
var box_02 = document.getElementsByName("rugby");
var box_03 = document.getElementsByName("original");
var box_04 = document.getElementsByName("gym");
var box_05 = document.getElementsByName("women");
var box_06 = document.getElementsByName("other");
var el = document.getElementById("all");

	if (el.checked == true){
		box_01[0].checked = true;
		box_02[0].checked = true;
		box_03[0].checked = true;
		box_04[0].checked = true;
		box_05[0].checked = true;
		box_06[0].checked = true;
		}	
		
	if (el.checked == false){
		box_01[0].checked = false;
		box_02[0].checked = false;
		box_03[0].checked = false;
		box_04[0].checked = false;
		box_05[0].checked = false;
		box_06[0].checked = false;
		}	
	}