	// Modified from Captain's AJAX HTML Form POST/Submit with AJAX Tutorial Example
	// http://www.captain.at/howto-ajax-form-post-request.php
   var http_request = false;
   function makePOSTRequest(url, parameters,debug) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...even IE7 now!
 		 http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
	  if (debug == 'debug') {
		http_request.onreadystatechange = alertContents;
	  }
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            alert (result);
			return true;
         } else {
            alert('There was a problem with the request.');
			return false;
         }
      }
   }
   
	function makePost(beautybulletin,specialsbulletin,beautypedia,email,firstName,lastName,zipCode,country,destinationURL,debug) {
		// Array to hold bulletin array
		var allBulletins = new Array();
		var billing_country = "";
		var birthdate = "";
		
		
		if(beautybulletin == 'yes') {
			allBulletins.push('Beauty Bulletin - Tips and Reviews - Twice a month');
		}

		if(specialsbulletin == 'yes') {
			allBulletins.push('Special Bulletin - Paula\'s Choice Product Specials');
		}
		if(beautypedia == 'yes') {
			allBulletins.push('Beautypedia Bulletin - New Reviews - Twice a month');
		}

				
		/* Set up the input string per EmailLabs' specifications.
			Demographic info:
			1 = First Name
			2 = Last Name
			7 = Zip/Postal Code
			8 = Country
			33690 = Birthday
			33692 = Bulletins
		*/
		var input =	'<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>' +
					'<DATASET>' +
					'<SITE_ID>666758</SITE_ID>' +
					'<MLID>5426</MLID>' +
					// Testing		'<MLID>5805</MLID>' +
					'<DATA type="email">' + encodeURI(email) + '</DATA>' +
					'<DATA type="demographic" id="1">' + encodeURI(firstName) + '</DATA>' +
					'<DATA type="demographic" id="2">' + encodeURI(lastName) + '</DATA>' +
				 	'<DATA type="demographic" id="7">' + encodeURI(zipCode) + '</DATA>' +
					'<DATA type="demographic" id="8">' + encodeURI(country) +'</DATA>' +
					'<DATA type="demographic" id="33690"></DATA>' +
					'<DATA type="demographic" id="33692">' + encodeURI(allBulletins.join("||")) + '</DATA>' +					
'<DATA type="extra" id="ms_option">add</DATA><DATA type="extra" id="trigger">yes</DATA><DATA type="extra" id="state">active</DATA></DATASET>';
					var poststr = "type=record" +
					"&activity=add" +
					"&input=" + input +
					"&submit=yes";
      makePOSTRequest(destinationURL, poststr,debug);
   }

