				/*******************************************************
				 * 
				 * Miscellaneous Functions/Prototypes
				 * 
				 ******************************************************/
				
				String.prototype.trim = function() {
					return this.replace(/^\s+|\s+$/g,"");
				}
				
				String.prototype.ltrim = function() {
					return this.replace(/^\s+/,"");
				}
				
				String.prototype.rtrim = function() {
					return this.replace(/\s+$/,"");
				}
				
				function nl2br(input) {
					var regX = new RegExp("\\n", "g");
					var replaceString = "<br />\n";
					return input.replace(regX, replaceString);
				}
				
				function stripCarriageReturns(input) {
					var regX = new RegExp("\\r", "g");
					var replaceString = "";
					return input.replace(regX, replaceString);
				}
				
				function strReplaceAll(input, findWhat, replaceWith) {
					output = input;
					intIndexOfMatch = output.indexOf(findWhat);
					while (intIndexOfMatch != -1){
						output = output.replace(findWhat, replaceWith);
						intIndexOfMatch = output.indexOf(findWhat);
					}
					return output;
				}
				
				function checkEnter(event) {
					var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
					if ((keyCode == 13)) {
						return true;
					}
					else {
						return false;
					}
				}

				
				/*******************************************************
				 * 
				 * AJAX Basic Functions
				 * 
				 ******************************************************/
				
				var ajaxIsBusy = false;
				
				function getAjax() {
					var xmlHttp = false;
					try {
						//Firefox, Opera 8.0+, Safari
						xmlHttp = new XMLHttpRequest();
					}
					catch (e) {
						//Internet Explorer
						try {
							xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
						}
						catch (e) {
							try {
								xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
							}
							catch (e) {
								
							}
						}
					}
					return xmlHttp;
				}
				
				function ajaxObject(url, callback) {
					var that = this;
						//workaround for some javascript idiosyncrocies
					var updating = false;
						//set to true if this object is already working on a request
					
					this.update = function(params) {
						//calling object.update(params) initiates the server call
						if (updating == true) { return false; }
							//abort if we're already processing a call
						updating = true;
							//set the updating flag
						var AJAX = getAjax();
							//get an xmlHttpRequest object
						if (!AJAX) {
							alert("Your browser does not support AJAX. Please upgrade your browser");
							return false;
						}
						else {
							AJAX.onreadystatechange = function() {
								//when the browser has the request info..
								if (AJAX.readyState == 4 || AJAX.readyState == "complete") {
									//if the complete flag is set...
									/*
									if (typeof LayerID != 'undefined') {
										//if a layer/div/span/object was passed when this 
										//object was created, set the response as its innerHTML
										LayerID.innerHTML = AJAX.responseText;
									}
									*/
									updating = false;
										//set the updating flag to false so we can do a new request
									that.callback(AJAX.responseText,AJAX.status,AJAX.responseXML);
										//that.callback();
										//call the post-processing function
									delete AJAX;
										//delete the AJAX object since it's done
								}
								//end Ajax readystate check
							}                                                           	
							//end create post-process fucntion block
							var timestamp = new Date();
								//get a new date (this will make the url unique)
							var uri = encodeURI(urlCall + '?nocache=' + (timestamp * 1));
								//append date to url (so the browser doesn't cache the call)
							AJAX.open("POST", uri, true);
								//open the url this object was set-up with
							AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					      	AJAX.setRequestHeader("Content-length", uri.length);
					      	AJAX.setRequestHeader("Connection", "close");
				      			//set some headers
							AJAX.send(params);
								//send the request
							return true;
								//everything went well
						}
					}
					//do something with constructor parameters
					/*
					var LayerID;
					if (typeof layer != 'undefined') {
						LayerID = document.getElementById(layer);
					}
					*/
					var urlCall = url;
					this.callback = callback || function() {}
						//post-processing call
				}
				
				function evalJavascript(scanThis) {
					var jsSpans = new Array();
					for (var i = 0; i < scanThis.length; i++) {
						if ((scanThis.substr(i, 7) == '<script') && (scanThis.indexOf('<' + '/script>', i) > -1)) {
							jsSpans[jsSpans.length] = scanThis.substring((scanThis.indexOf(">", i) + 1), (scanThis.indexOf("<" + "/script>", i)));
							i = scanThis.indexOf("<" + "/script>", i) + 8;
						}
					}
					if (jsSpans.length > 0) {
						for (var i = 0; i < jsSpans.length; i++) {
							//alert("evaluating: \n\n" + jsSpans[i]);
							eval(jsSpans[i]);
						}
					}
				}
				
				function isAjaxBusy() {
					if (ajaxIsBusy == false) {
						return false;
					}
					else {
						return true;
					}
				}				
/*******************************************************
 * 
 * AJAX "Worker" Functions
 * 
 ******************************************************/

var idEmailSignupAjaxResponse = 'joinEmailLightbox';

//Variables for Both Signups
var idOfListTypeInput = 'ajaxListType';
var tempStoreListType;

//Variables for Individual Signup
var idOfIndividualEmailInput = 'ajaxIndividualEmail';
var idOfIndividualFirstNameInput = 'ajaxIndividualFirstName';
var idOfIndividualGenderInput = 'ajaxIndividualGender';
var idOfIndividualBDMonthInput = 'ajaxIndividualBDMonth';
var idOfIndividualBDDayInput = 'ajaxIndividualBDDay';
var idOfIndividualBDYearInput = 'ajaxIndividualBDYear';
var tempStoreIndividualEmail;
var tempStoreIndividualFirstName;
var tempStoreIndividualGender;
var tempStoreIndividualBDMonth;
var tempStoreIndividualBDDay;
var tempStoreIndividualBDYear;

//Variables for Business Signup
var idOfBusinessCompanyInput = 'ajaxBusinessCompany';
var idOfBusinessEmailInput = 'ajaxBusinessEmail';
var idOfBusinessFirstNameInput = 'ajaxBusinessFirstName';
var idOfBusinessLastNameInput = 'ajaxBusinessLastName';
var idOfBusinessCityInput = 'ajaxBusinessCity';
var idOfBusinessStateInput = 'ajaxBusinessState';
var idOfBusinessPhoneInput = 'ajaxBusinessPhone';
var idOfBusinessLeadSourceInput = 'ajaxBusinessLeadSource';
var tempStoreBusinessEmail;
var tempStoreBusinessFirstName;
var tempStoreBusinessCompany;
var tempStoreBusinessLastName;
var tempStoreBusinessCity;
var tempStoreBusinessState;
var tempStoreBusinessPhone;
var tempStoreBusinessLeadSource;

var loadingAjaxTopLevel = '<div class="message">Loading, please wait...</div>';

				
function getAjaxEmail() {
		
	
	if (isAjaxBusy()) {
		alert ('Please wait until your most recent request finishes processing before making another request');
	} 
	else if(idOfListTypeInput == 'Individual') {
		
		var v_individualfirstname = document.getElementById(idOfIndividualFirstNameInput).value.trim();
		var v_individualemail = document.getElementById(idOfIndividualEmailInput).value.trim();
		var v_individuallistType = document.getElementById(idOfIndividualListTypeInput).options[document.getElementById(idOfListTypeInput).selectedIndex].value;
		var v_individualgender = document.getElementById(idOfIndividualGenderInput).options[document.getElementById(idOfGenderInput).selectedIndex].value;
		var handle_individualbirthdayMonth = document.getElementById(idOfIndividualBDMonthInput);
		var handle_individualbirthdayDay = document.getElementById(idOfIndividualBDDayInput);
		var handle_individualbirthdayYear = document.getElementById(idOfIndividualBDYearInput);		
						
		tempStoreFirstName = v_individualfirstname;
		tempStoreEmail = v_individualemail;
		tempStoreBDMonth = handle_individualbirthdayMonth.options[handle_individualbirthdayMonth.selectedIndex].value;
		tempStoreBDDay = handle_individualbirthdayDay.options[handle_individualbirthdayDay.selectedIndex].value;
		tempStoreBDYear = handle_individualbirthdayYear.options[handle_individualbirthdayYear.selectedIndex].value;
		tempStoreGender = v_individualgender;
		tempStoreListType = v_listType;
		
		document.getElementById(idOfEmailInput).value = v_individualemail;
		document.getElementById(idOfFirstNameInput).value = v_individualfirstname;
		
		var individualbirthday = handle_individualbirthdayMonth.options[handle_individualbirthdayMonth.selectedIndex].value + "/" + handle_individualbirthdayDay.options[handle_individualbirthdayDay.selectedIndex].value + "/" + handle_individualbirthdayYear.options[handle_individualbirthdayYear.selectedIndex].value;
		div = document.getElementById(idEmailSignupAjaxResponse);
		div.innerHTML = loadingAjaxTopLevel;
		var params = "";
		params += "email=" + encodeURIComponent(v_individualemail) + "&firstname=" + encodeURIComponent(v_individualfirstname) + "&gender=" + encodeURIComponent(v_individualgender) + "&birthday=" + encodeURIComponent(individualbirthday) + "&listType=" + encodeURIComponent(v_listType);
		var ajaxObject1 = new ajaxObject('/scripts/ajax_email_signup.php', ajaxResponseEmail);
		ajaxIsBusy = true;
		ajaxObject1.update(params);
		
	}
	else if(idOfListTypeInput == 'Business') {
		alert('Business');	
	}
}



function ajaxResponseEmail(response, status, responseXML) {
	div = document.getElementById(idEmailSignupAjaxResponse);
	div.innerHTML = response;
	evalJavascript(response);
	ajaxIsBusy = false;
}
