				/*******************************************************
				 * 
				 * 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 idOfTargetDivForAjaxResponse = 'ajaxEmailForm';
				var idOfEmailInput = 'ajaxEmail';
				var idOfNameInput = 'ajaxName';
				var idOfBDMonthInput = 'ajaxBDMonth';
				var idOfBDDayInput = 'ajaxBDDay';
				var idOfBDYearInput = 'ajaxBDYear';
				var idOfGenderInput = 'ajaxGender';
				var loadingAjaxTopLevel = '<div class="message">Loading, please wait...<br /><img src="/images/utility/loadingBarGrey.gif" border="0"></div>';
								
				function getAjaxEmail() {
					if (isAjaxBusy()) {
						alert ('Please wait until your most recent request finishes processing before making another request');
					}
					else {
						var v_email = document.getElementById(idOfEmailInput).value.trim();
						var v_name = document.getElementById(idOfNameInput).value.trim();
						var handle_birthdateMonth = document.getElementById(idOfBDMonthInput);
						var handle_birthdateDay = document.getElementById(idOfBDDayInput);
						var handle_birthdateYear = document.getElementById(idOfBDYearInput);
						var v_gender = document.getElementById(idOfGenderInput).value.trim();
						
						document.getElementById(idOfEmailInput).value = v_email;
						document.getElementById(idOfNameInput).value = v_name;
						document.getElementById(idOfGenderInput).value = v_gender;
						if (v_email.length == 0) {
							alert('Please supply an email address');
							document.getElementById(idOfEmailInput).focus();
						}
						else if (v_name.length == 0) {
							alert('Please supply your name');
							document.getElementById(idOfNameInput).focus();
						}
						else {
							var birthdate = handle_birthdateMonth.options[handle_birthdateMonth.selectedIndex].value + "/" + handle_birthdateDay.options[handle_birthdateDay.selectedIndex].value + "/" + handle_birthdateYear.options[handle_birthdateYear.selectedIndex].value;
							div = document.getElementById(idOfTargetDivForAjaxResponse);
							div.innerHTML = loadingAjaxTopLevel;
							var params = "langId=-1&storeId=10052&catalogId=10051&";
							params += "email=" + encodeURIComponent(v_email) + "&name=" + encodeURIComponent(v_name) + "&birthdate=" + encodeURIComponent(birthdate) + "&gender=" + encodeURIComponent(v_gender);
							var ajaxObject1 = new ajaxObject('/webapp/wcs/stores/servlet/AJAXEmailSignup', ajaxResponseEmail);
							ajaxIsBusy = true;
							ajaxObject1.update(params);
						}
					}
				}
				
				function ajaxResponseEmail(response, status, responseXML) {
					div = document.getElementById(idOfTargetDivForAjaxResponse);
					div.innerHTML = response;
					evalJavascript(response);
					ajaxIsBusy = false;
				}
