﻿/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

function do_signup() {
	if( document.getElementById( "FirstName" ).value == "" || document.getElementById( "Email" ).value == "" ||
	    document.getElementById( "FirstName" ).value == "Your Name" || document.getElementById( "Email" ).value == "Email Address" ) {
		alert( "Please supply a name and email." );
	} else {
		data = "name=" + escape( document.getElementById( "FirstName" ).value ) + "&email=" + escape( document.getElementById( "Email" ).value );
		url = "signup.php";
		xmlHttp.open( "POST", url, true );
		xmlHttp.onreadystatechange = updatePage;
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send( data );
	}
}

function updatePage() {
	if( xmlHttp.readyState == 4 ) {
		if( xmlHttp.responseText == "OK" ) { 
			display_thanks_page(); 
		} else { 
			alert( xmlHttp.responseText ); 
		}
	}
}

function display_thanks_page() {
 var mypage = "http://fengshui5.com/thanks.html";
 var w = 750;
 var h = 750;
 var features = 'resizable,scrollbars,status,toolbar';
 var myname = "";

 var winl = (screen.width-w)/2;
 var wint = 0;
 if (winl < 0) winl = 0;
 if (wint < 0) wint = 0;
 var settings = 'height=' + h + ',';
 settings += 'width=' + w + ',';
 settings += 'top=' + wint + ',';
 settings += 'left=' + winl + ',';
 settings += features;
 win = window.open(mypage,myname,settings);
}
