// JavaScript Document
//Sends an email address to the database
function sendEmail(){	
	
	var email = document.getElementById("emailAddress").value;
	//alert(email);
	xajax_subscribe(email);
	document.getElementById("newsletter").innerHTML = "<p><img src='../assets/images/busy.gif' align='top' /> Submitting your email address, please wait...</p>";
}

//Shows the "subscribe" form
function showForm(){

	document.getElementById("newsletter").innerHTML = '<p>Your Email Address <br /><input name="emailAddress" type="text" id="emailAddress" size="26" /><input type="submit" name="Submit" value="Submit" onclick="sendEmail(); return false;" /></p>';
}

//Submits the "registration" form 
function submitForm(){

	
	//Disable form fields
	disableFields(true);
	
	//Set a "please wait" message
	document.getElementById("status").innerHTML = "Submitting form, please wait...";
	
	//Get Form details
	var title = document.registerForm.title.value;
	var name = document.registerForm.name.value;
	var company = document.registerForm.company.value;
	var email = document.registerForm.emailAddress2.value;
	var phone = document.registerForm.phone.value;
	var occupation = document.registerForm.occupation.value;
	var fax = document.registerForm.fax.value;
	
	//Call the "xajax function to send details"
	xajax_register(title,name,company,email,phone,fax,occupation);
}

//Submits the "subscription" form
function submitSubForm(){


	//Disable form fields
	disableSubFields(true);
	
	//Set a "please wait" message
	document.getElementById("status").innerHTML = "Submitting form, please wait...";
	
	//Get Form details
	var title = document.subForm.title.value;
	var name = document.subForm.name.value;
	var address1 = document.subForm.address1.value;
	var address2 = document.subForm.address2.value;
	var phone = document.subForm.phone.value;
	var email = document.subForm.email.value;
	var payment = document.subForm.payment.value;
	
	//Call the "xajax function to send details"
	xajax_sendSubscription(title,name,address1,address2,email,phone,payment);
}

//Submits the "question" form
function submitQForm(){
	
	disableQFields(true);
	
	var name = document.qForm.name.value;
	var email = document.qForm.email.value;
	var question = document.qForm.question.value;
	
	//Call the "xajax function to send the question
	xajax_sendQuestion(name,email,question);
}

//Submits the "letter" form
function submitLetterForm(){
	
	disableQFields(true);
	
	var name = document.qForm.name.value;
	var email = document.qForm.email.value;
	var question = document.qForm.question.value;
	var phone = document.qForm.phone.value;
	
	//Call the "xajax function to send the question
	xajax_sendLetter(name,email,phone,question);
}

//Function "disableFields". Disables fields on the register form
function disableFields(state){
	document.registerForm.Send.disabled = document.registerForm.name.disabled = document.registerForm.company.disabled = document.registerForm.emailAddress2.disabled = document.registerForm.phone.disabled = document.registerForm.fax.disabled = document.registerForm.occupation.disabled = state;

}

//Function "disableSubFields". Disables fields on the subscription form
function disableSubFields(state){
	document.subForm.Send.disabled = document.subForm.name.disabled = document.subForm.address1.disabled = document.subForm.address2.disabled = document.subForm.phone.disabled = document.subForm.email.disabled = document.subForm.title.disabled = document.subForm.payment.disabled = state;

}

//Function "disableQFields". Disables fields on the question form
function disableQFields(state){
	document.qForm.Send.disabled = document.qForm.name.disabled = document.qForm.email.disabled = document.qForm.question.disabled = state;

}
//Function "sendMessage". Submits the "contact" form
function sendMessage(){
	
	//Call the "xajax" function to send the message
	xajax_sendMessage(xajax.getFormValues('contactForm'));
	
	document.getElementById("formHolder").innerHTML = '<p><img src="../assets/images/busy.gif" class="icon" />  Submitting form, please wait...</p><br/><br/><br/><br/><br/>';	
}

//Function "emailResults". Handles results return from server after sending "contact" form
function emailResults(){
	
	alert('Thanks for taking time to write to us');
	document.getElementById("formHolder").innerHTML = '<p>Thank you for taking time to fill and submit the form. Based on your request, question or comment, you should receive a response from us in the next 2 to 3 business days.</p><p>Thank you for visiting <a href="http://www.takaii.com">www.takaii.com</a>.</p> <p><span class="title"><b>CONTACT INFORMATION</b></span><br> <br> <strong>dtalkshop</strong><br /> 26 Commercial Avenue<br />Sabo, Yaba<br />Lagos, Nigeria</p>  <p>P. O. Box 3183, Sabo, Yaba<br /> Lagos, Nigeria<br />  <strong>Phone : </strong>+234 -01 342 5603, 01 470 6307 <br />  <strong>Fax : </strong>+234 -01 342 5403</p>';
	document.getElementById("other").innerHTML = '';

}
