<!--

//for all forms
var emailRE = /^\w+([-|\.]\w+)*@\w+([-|\.]\w+)*\.\w+(-*\w+)*$/;
var phoneRE = /^(((\+| \+ )?[0-9]{1,3}(-| )?\(?[0-9]{1,3}\)?(-| )?[0-9]{1,5})|(\(?[0-9]{2,6}\)?))(-| )?([0-9]{2,4})(-| )?([0-9]{4,5})(( \w{1,3}| \w{1,3} )[0-9]{1,5}){0,1}$/;
var passRE = /^\w+$/;

//sniffer
function Is() {
  var agent = navigator.userAgent.toLowerCase();
  var is_major = parseInt(navigator.appVersion);
  var is_minor = parseFloat(navigator.appVersion);
  this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)) && (is_major < 5));
  this.ie = (agent.indexOf("msie") != -1);
  this.dom = ((agent.indexOf('mozilla')!=-1) && (agent.indexOf('gecko') != -1) && (is_major >= 5));
}

var is = new Is();

function RemoveHTML( strText ) {
	var regEx = /<[^>]*>/g;
	return strText.replace(regEx, "");
}


var doesSupport = 0;
function sendAjax(whichFunction,whichForm) {
	var ajaxObj;
	try {
		ajaxObj = new XMLHttpRequest();
		doesSupport = 1;
	} catch (e) {
		var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp","MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.5.0"];
		for (var i = avers.length -1; i >= 0; i--) {
			try {
				if(doesSupport == 0) {
					ajaxObj = new ActiveXObject(avers[i]);
					doesSupport = 1;
				}
			} catch(e) {
				//nothing supported, do something else
			}
		}
	}
	if(doesSupport == 1) {
		ajaxObj.open("POST", "functions/"+whichFunction, true);
		ajaxObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		// Create a function that will receive data sent from the server
		ajaxObj.onreadystatechange = function(){
			//alert(this.readyState + ' / ' + this.status + ' / ' + this.responseText);
			if(this.readyState == 0){
			}
			if(this.readyState == 4){
				if (this.status != 200) {
					//error!
					document.getElementById("doError").innerHTML = 'Error : Status '+this.status+' returned.';
					document.getElementById("doError").style.color = "#CC0000";
					document.getElementById("doError").style.display = "block";
				} else {
					//return message
					var findString = this.responseText;
					var errorLoc = findString.search("error");
					if(errorLoc < 0) {
						document.getElementById("doError").style.display = "none";
						document.getElementById("replaceHTML").innerHTML = this.responseText;
						document.getElementById("replaceHTML").style.fontSize = "16px";
						document.getElementById("replaceHTML").style.fontWeight = "bold";
						if(whichFunction == "account.asp") {
							document.location.href = '/member-account.asp?error=1';
						}
						if(whichFunction == "login.asp") {
							document.location.href = '/member-account.asp';
						}
					} else {
						document.getElementById("doError").innerHTML = this.responseText;
						document.getElementById("doError").style.color = "#CC0000";
						document.getElementById("doError").style.display = "block";
					}
					//var cType = this.getResponseHeader("Content-Type");
					//if (cType == 'text/xml') {
						//// XML response
						//alert(this.responseXML);
					//} else if (cType == 'text/plain') {
						// plain text response
						//alert(this.responseText);
					//} else {
						//alert('unknown content type');
					//}
				}
			}
		}
		var myform = document.forms[0];
		var reqBody = getRequestBody(whichForm);
		//alert(reqBody);
		ajaxObj.send(reqBody);
	} else {
		//old fashioned post
	}
}

function checkAjax(whichFunction,whichValue,whichDiv) {
	var ajaxObj;
	try {
		ajaxObj = new XMLHttpRequest();
		doesSupport = 1;
	} catch (e) {
		var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp","MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.5.0"];
		for (var i = avers.length -1; i >= 0; i--) {
			try {
				if(doesSupport == 0) {
					ajaxObj = new ActiveXObject(avers[i]);
					doesSupport = 1;
				}
			} catch(e) {
				//nothing supported, do something else
			}
		}
	}
	if(doesSupport == 1) {
		ajaxObj.open("POST", "functions/"+whichFunction, true);
		ajaxObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		// Create a function that will receive data sent from the server
		ajaxObj.onreadystatechange = function(){
			//alert(this.readyState + ' / ' + this.status + ' / ' + this.responseText);
			if(this.readyState == 4){
				if (this.status != 200) {
					//error!
					document.getElementById(whichDiv).innerHTML = 'Error : Status '+this.status+' returned.';
					document.getElementById(whichDiv).style.display = "inline";
				} else {
					//return message
					document.getElementById(whichDiv).innerHTML = this.responseText;
					document.getElementById(whichDiv).style.display = "inline";
				}
			}
		}
		var myform = document.forms[0];
		var reqBody = ncode("incfield",whichValue);
		//alert(reqBody);
		ajaxObj.send(reqBody);
	} else {
		//old fashioned post
	}
}


 
function ncode(n,v) {
	return encodeURIComponent(n) + '=' + encodeURIComponent(RemoveHTML(v));
}
function getRequestBody(theForm) {
	var p = [];
	p.push(ncode("ajax","true"));
	for (var i = theForm.elements.length-1; i >= 0; i--) {
		var fld = theForm.elements[i];
		switch (fld.type) {
			case "button": case "submit": case "reset": break;
			case "checkbox": case "radio": if (!fld.checked) break;
			default:
				if ("select" == fld.tagName.toLowerCase()) {
					p.push(ncode(fld.name,fld.options[fld.selectedIndex].value));
				} else {
					p.push(ncode(fld.name,fld.value));
				}
		}
	}
	return p.join('&');
}

// -->
