//Browser Support Code
function ajaxFunction(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	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 does not support AJAX!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
		 	document.getElementById('status').innerHTML = ':: Refreshing ::';
			var ajaxStr = ajaxRequest.responseText
			var myArray = ajaxStr.split('~');
			recordSet(myArray);
			//addBlock.js
		 	document.getElementById('status').innerHTML = ':: Status :: Looping';

		}
	}
	ajaxRequest.open("GET", "ajax-getRecords.php", true);
	ajaxRequest.send(null); 
}

function ajaxFunctionGetURL(URL){
	var ajaxRequestURL;  // The variable that makes Ajax possible!
	URL = URL.replace("http://","");
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequestURL = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequestURL = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequestURL = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequestURL.onreadystatechange = function(){
		if(ajaxRequestURL.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
			var ajaxStr = ajaxRequestURL.responseText;
			//alert(ajaxStr);
			showImage(ajaxStr);
		}
	}
	var ajaxURL = "functions/ajax-getURL.php?URL="+URL;
	ajaxRequestURL.open("GET", ajaxURL, true);
	ajaxRequestURL.send(null); 	
}

function ajaxCaptchaCheck(captcha){
	var ajaxRequestURL;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequestURL = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequestURL = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequestURL = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}	 

	// Create a function that will receive data sent from the server
	ajaxRequestURL.onreadystatechange = function(){
		//alert(ajaxRequestURL.readyState);
		if(ajaxRequestURL.readyState == 4){
			var captchaOK = 2; // 2 - not yet checked, 1 - correct, 0 - failed
			captchaOK = ajaxRequestURL.responseText;
			cPF(captchaOK);
		}
	}	
	
	
	
	var ajaxURL = "http://www.godsurfer.com/captcheck.php?code="+captcha;
	//alert(ajaxURL);
	ajaxRequestURL.open("GET", ajaxURL, true);
	ajaxRequestURL.send(null); 	
	
}

function ajaxUpdateProfile(profileName, profileURL, email, voteEmail, commentEmail, siteNav, userId){
	var ajaxRequestURL;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequestURL = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequestURL = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequestURL = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequestURL.onreadystatechange = function(){
		if(ajaxRequestURL.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
			var ajaxStr = ajaxRequestURL.responseText;
			//profileEdit();
		}
	}

	var ajaxURL = "functionUpdateProfile.php?profileName=" + profileName + "&profileURL="+ profileURL + "&email=" + email+ "&voteEmail=" + voteEmail + "&commentEmail=" + commentEmail + "&siteNav=" + siteNav + "&userId=" + userId;
	//prompt(' ',ajaxURL);
	ajaxRequestURL.open("GET", ajaxURL, true);
	ajaxRequestURL.send(null); 	
}

function ajaxFunctionAddPrayers(){

	var ajaxRequest;  // The variable that makes Ajax possible!
	prayerText = document.getElementById("prayerText").value;
	if (prayerText.length == 0)
		{
			//alert('nope');
		}else{
			
			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 does not support AJAX!");
						return false;
					}
				}
			}
		
			// Create a function that will receive data sent from the server
			ajaxRequest.onreadystatechange = function(){
				if(ajaxRequest.readyState == 4){
					//var ajaxDisplay = document.getElementById('ajaxDiv');
					var ajaxStr = ajaxRequest.responseText
					window.location = 'http://www.godsurfer.com/';
				}
			}
	
			var passURLString = "./functions/functionPrayer.php?prayerText="+prayerText;
			ajaxRequest.open("GET", passURLString , true);
			//alert(passURLString);
			ajaxRequest.send(null); 
		}
}
