// slide down contact form
function openContact() 
{
	$("#contact").slideDown(500);
	$("#contact-open").hide();
	$("#contact-close").show();
}

// slide up contact form
function closeContact() 
{
	$("#contact").slideUp(500);
	$("#contact-close").hide();
	$("#contact-open").show();
}

function getXMLHttp()
{
	var xmlHttp
	
	try
	{
		//Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		//Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your browser does not support AJAX!")
				return false;
			}
		}
	}
	return xmlHttp;
}

// make feedback request call
function sendFeedback(idl_name, idl_comments)
{
	var xmlHttp = getXMLHttp();
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{
			handleResponse(xmlHttp.responseText);
		}
	}
	
	var ajax_send = "/_inc/feedback.php?action=send&idl_name=" + idl_name + "&idl_comments=" + idl_comments;
	
	xmlHttp.open("GET", ajax_send, true); 
	xmlHttp.send(null);
}

// accept response from feedback script
function handleResponse(response)
{
	
	if(response == "success") {
		$("#step1").slideUp(500);
		$("#step2").slideDown(500);
	} else {
		alert("Whoops! There was an error, please try again!");
	}
}

// submit feedback function
function submitFeedback() 
{
	
	var idl_name = ($("#idl_name").val());
	var idl_comments = ($("#idl_comments").val());	
	
	if(idl_name != "Your Name" && idl_name != "" && idl_comments != "Your Comments" && idl_comments != "") {
		sendFeedback(idl_name, idl_comments);
	} else {
		alert("Whoops! Please fill out your name and your comments");
	}
	
}
