//var pagePath = 'http://192.168.1.15/good-vibrations/';
//var pagePath = 'http://www.deviatebeta.co.uk/good-vibrations/';
var pagePath = 'http://www.good-vibrations.org.uk/';

function showForm(){
	
	if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete"){   
		
		document.getElementById("selected_form").innerHTML = xmlhttp.responseText;
	}
	
}


function changeForm(id,opt,cid){
		var timestamp = new Date();
		var now = timestamp.getTime();

		if(cid != id){

			var url = pagePath + "ajax/change_form.php?id=" + id + "&opt=" + opt + "&ts=" + now;
			
			run_ajax(showForm,url);
		}
}

//
// Main Ajax Function
//
function run_ajax(state_changed_function,url)
{
	xmlhttp = null
	// code for Mozilla, opera, netscape etc.
	if (window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest()
	 }
	// code for IE
	else if (window.ActiveXObject){
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
	 }
	if (xmlhttp != null){
		xmlhttp.onreadystatechange=state_changed_function
		xmlhttp.open("GET",url,true)
		xmlhttp.send(null)
	 }
	else{
		alert("Your browser does not support Ajax.")
	 }
}

