//
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
	return request_type;
}

var http = createObject();


/* -------------------------- */
/* Edit Image */
/* -------------------------- */
var nocache = 0;
function email_post() {
	// Optional: Show a waiting message in the layer with ID ajax_response
	document.getElementById("ajax_response").innerHTML = "Sending..."
	// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
	name=document.getElementById("name").value 
	email=document.getElementById("email").value
     // Set te random number to add to URL request
	nocache = Math.random();
	params='name='+name+'&email='+email+'&nocache = '+nocache;
	// Pass the login variables like URL variable
	http.open('post', 'newsletter_e.php');
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = email_editReply;
	http.send(params);
}
function email_editReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		if (response=="0"){
			document.getElementById("return").innerHTML ='<table width="100%" border="0" cellspacing="0" cellpadding="40"><tr><td align="center">Newsletter Subscription submitted successfully.<br /><br />Thanking You!</td></tr></table>';
		}else{
			document.getElementById("ajax_response").innerHTML = response;
		}
	}
}

/* -------------------------- */
/* Edit Image */
/* -------------------------- */
var nocache = 0;
function snailmail_post() {
	// Optional: Show a waiting message in the layer with ID ajax_response
	document.getElementById("ajax_response").innerHTML = "Sending..."
	// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
	name=document.getElementById("name").value 
	address=document.getElementById("address").value
     // Set te random number to add to URL request
	nocache = Math.random();
	params='name='+name+'&address='+address+'&nocache = '+nocache;
	// Pass the login variables like URL variable
	http.open('post', 'newsletter_p.php');
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = snailmail_reply;
	http.send(params);
}
function snailmail_reply() {
	if(http.readyState == 4){
		var response = http.responseText;
		if (response=="0"){
			document.getElementById("return").innerHTML ='<table width="100%" border="0" cellspacing="0" cellpadding="40"><tr><td align="center">Newsletter Subscription submitted successfully. <br /><br />Thanking You!</td></tr></table>';
		}else{
			document.getElementById("ajax_response").innerHTML = response;
		}
	}
}

/* -------------------------- */
/* Edit Image */
/* -------------------------- */
var nocache = 0;
function contact_post() {
	// Optional: Show a waiting message in the layer with ID ajax_response
	document.getElementById("ajax_response").innerHTML = "Sending..."
	// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
	name=document.getElementById("name").value 
	email=document.getElementById("email").value
	organisation=document.getElementById("organisation").value 
	phone=document.getElementById("phone").value
	comments=document.getElementById("comments").value
     // Set te random number to add to URL request
	nocache = Math.random();
	params='name='+name+'&email='+email+'&organisation='+organisation+'&phone='+phone+'&comments='+comments+'&nocache = '+nocache;
	// Pass the login variables like URL variable
	http.open('post', 'contact.php');
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = contact_reply;
	http.send(params);
}
function contact_reply() {
	if(http.readyState == 4){
		var response = http.responseText;
		if (response=="0"){
			document.getElementById("return").innerHTML ='<table width="100%" border="0" cellspacing="0" cellpadding="40"><tr><td align="center">Your contact request has been submitted successfully.<br /> Thanking You! <br/><br />We will get back to you at the earliest possible time.</td></tr></table>';
		}else{
			document.getElementById("ajax_response").innerHTML = response;
		}
	}
}

/* -------------------------- */
/* Edit Image */
/* -------------------------- */
var nocache = 0;
function volunteer_post() {
	// Optional: Show a waiting message in the layer with ID ajax_response
	document.getElementById("ajax_response").innerHTML = "Sending..."
	// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
	Name=document.getElementById("Name").value 
	Email=document.getElementById("Email").value
	phone=document.getElementById("phone").value 
	mobile=document.getElementById("mobile").value
	Address=document.getElementById("Address").value
	Suburb=document.getElementById("Suburb").value
	var selIndex = document.getElementById("State").selectedIndex;
	State = document.getElementById("State").options[selIndex].value;
	//State=document.getElementById("State").value
	Postcode=document.getElementById("Postcode").value 
	age=document.getElementById("age").value
	Birth=document.getElementById("Birth").value
	children=document.getElementById("children").checked 
	families=document.getElementById("families").checked
	women=document.getElementById("women").checked 
	men=document.getElementById("men").checked
	fundraising=document.getElementById("fundraising").checked
	management=document.getElementById("management").checked 
	admin=document.getElementById("admin").checked
	volunteermanagement=document.getElementById("volunteermanagement").checked 
	programmanagement=document.getElementById("programmanagement").checked
	recruitment=document.getElementById("recruitment").checked
	trainingvolunteers=document.getElementById("trainingvolunteers").checked 
	languages=document.getElementById("languages").value
	why=document.getElementById("why").value 
	skills=document.getElementById("skills").value
	involvement=document.getElementById("involvement").value
	police=document.getElementById("police").value 
	volunteer=getCheckedValue(document.forms['volunteerApp'].elements['volunteer'])
	confidentiality=getCheckedValue(document.forms['volunteerApp'].elements['confidentiality'])
	conflicts=document.getElementById("conflicts").value
	firstaid=getCheckedValue(document.forms['volunteerApp'].elements['firstaid'])
	qualifications=document.getElementById("qualifications").value 
	findus=document.getElementById("findus").value
	currently=document.getElementById("currently").value 
	more=document.getElementById("more").value
	     // Set te random number to add to URL request
	nocache = Math.random();
	params='Name='+Name+'&Email='+Email+'&phone='+phone+'&mobile='+mobile+'&Address='+Address+'&Suburb='+Suburb+'&State='+State+'&Postcode='+Postcode+'&age='+age+'&Birth='+Birth+'&children='+children+'&families='+families+'&women='+women+'&men='+men+'&fundraising='+fundraising+'&management='+management+'&admin='+admin+'&volunteermanagement='+volunteermanagement+'&programmanagement='+programmanagement+'&recruitment='+recruitment+'&trainingvolunteers='+trainingvolunteers+'&languages='+languages+'&why='+why+'&skills='+skills+'&involvement='+involvement+'&police='+police+'&volunteer='+volunteer+'&confidentiality='+confidentiality+'&conflicts='+conflicts+'&firstaid='+firstaid+'&qualifications='+qualifications+'&findus='+findus+'&currently='+currently+'&more='+more+'&nocache = '+nocache;
	// Pass the login variables like URL variable
	http.open('post', 'volunteer.php');
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = volunteer_reply;
	http.send(params);
}
function volunteer_reply() {
	if(http.readyState == 4){
		var response = http.responseText;
		if (response=="0"){
			document.getElementById("return").innerHTML ='<table width="100%" border="0" cellspacing="0" cellpadding="40"><tr><td align="center">Your Volunteer Application has been submitted successfully.<br /> Thanking You!<br /><br/> We will get back to you at the earliest possible time.</td></tr></table>';
		}else{
			document.getElementById("ajax_response").innerHTML = response;
		}
	}
}



