function validateme(pageToGoTo) {
	try{
		
		if (((document.getElementById('child_id'))!=null)&&
		(document.getElementById('child_id').value=="other")&&
		(document.getElementById('otherpleasespecify').value=="")){
		
		} else if (
				(document.getElementById('parent_id').value != "0")	&& 
					((
						((document.getElementById('child_id'))!=null)&&
						(document.getElementById('child_id').value != "0")))||
					(document.getElementById('child_id')==null)){
			thirdAjaxFunction();
			window.location.href = pageToGoTo;
			return false;
	}
	} catch (e) {
		alert (e);
	}
	alert("please complete the form to tell us how you found this site");

}

function createHttpRequest() {
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	return ajaxRequest;
}
//Browser Support Code
function ajaxFunction(){
	
	if (document.getElementById('parent_id').value != 0) {
		
		var ajaxRequest = createHttpRequest();  // The variable that makes Ajax possible!
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				
				var ajaxDisplay = document.getElementById('ajaxDiv');
				ajaxDisplay.innerHTML = ajaxRequest.responseText;
			}
		}
		var parent_id = document.getElementById('parent_id').value;
	
		var queryString = "?step=1&parent_id=" + parent_id;
		
		//alert(queryString);
		
		ajaxRequest.open("GET", "/holding/ajaxresponsescript.php" + queryString, true);
		ajaxRequest.send(null);
		
		var ajaxDisplay = document.getElementById('ajax2Div');
		ajaxDisplay.innerHTML = "";
					document.getElementById('submitbutton3').style.visibility = 'visible';
		document.getElementById('submitbutton2').style.visibility = 'visible';
		document.getElementById('submitbutton').style.visibility = 'visible';

	}
	
	
}

function secondAjaxFunction(){
	var ajaxRequest = createHttpRequest();
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			
			var ajaxDisplay = document.getElementById('ajax2Div');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var child_id = document.getElementById('child_id').value;

	var queryString = "?step=2&child_id=" + child_id;
	ajaxRequest.open("GET", "/holding/ajaxresponsescript.php" + queryString, true);
	ajaxRequest.send(null);

}

function thirdAjaxFunction(){
	var ajaxRequest = createHttpRequest();
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			
		//	var ajaxDisplay = document.getElementById('ajax3Div');
		//	ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	try {
		var otherpleasespecify = document.getElementById('otherpleasespecify').value;
		var parent_id = document.getElementById('parent_id').value;
		var child_id = document.getElementById('child_id').value;
		var queryString = "?step=3&child_id=" + child_id + "&parent_id=" + parent_id+ "&otherpleasespecify=" + otherpleasespecify;

	} catch(e) {
		try {
		var parent_id = document.getElementById('parent_id').value;
		var child_id = document.getElementById('child_id').value;
		var queryString = "?step=3&child_id=" + child_id + "&parent_id=" + parent_id;

		} catch (e) {
			var parent_id = document.getElementById('parent_id').value;
			var queryString = "?step=3&parent_id=" + parent_id;
		}
	}

	ajaxRequest.open("GET", "/holding/ajaxresponsescript.php" + queryString, true);
	ajaxRequest.send(null); 
}
//-->

