//document.observe('dom:loaded', ajaxIt);
YAHOO.util.Event.addListener(window, "load", ajaxIt);

function ajaxIt() {
    if (document.getElementById("submit")){
	YAHOO.util.Event.addListener("submit", "click", checkForm);
	//$("submit").observe("click", checkForm);
    }
}

function getItUp(){
    var fullName, email, phone, type, topic, size, className, question, timeFrame, reqtype;


    if (document.getElementById("fullname")){
	fullName=document.getElementById("fullname").value;
    } else fullName=null;
    if (document.getElementById("email")){
	email=document.getElementById("email").value;
    } else email=null;
    if (document.getElementById("phone")){
	phone=document.getElementById("phone").value;
    } else phone=null;
    if(document.getElementById("type")){
	type=document.getElementById("type").value;
    } else type=null;
    if (document.getElementById("topic")){
	topic=document.getElementById("topic").value;
    } else topic=null;
    if (document.getElementById("size")){
	size=document.getElementById("size").value;
    } else size=null;
    if (document.getElementById("classname")){
	className=document.getElementById("classname").value;
    } else classname=null;
    if (document.getElementById("question")){
	question=document.getElementById("question").value;
    } else question=null;
    if (document.getElementById("timeframe")){
	timeFrame=document.getElementById("timeframe").value;
    } else timeframe=null;
    if (document.getElementById("reqtype")){
	reqtype=document.getElementById("reqtype").value;
    } else reqtype="general";

	var postData = "fullname=" + fullName + "&phone=" + phone + "&email=" + email + "&type=" + type +
					"&topic=" + topic + "&size=" + size + "&classname=" + className + "&question=" + question
					+ "&timeframe=" + timeFrame + "&reqtype=" + reqtype;
					
	var formURL = "form.php";
	
	var responseSuccess = function(o){ 
		//document.getElementById("formbox").innerHTML=o.responseText;
		//alert(o.responseText);
                window.location="/thank-you.php"
	}; 
	 
	var responseFailure = function(o){ 
		document.getElementById("formbox").innerHTML="<div id='comeBack'><p>Your request was not processed please try again</p></div>";
	}; 

	var callBack = 
	{ 
	  success:responseSuccess, 
	  failure:responseFailure 
	  //argument:args 
	}; 

	var connectionObject = YAHOO.util.Connect.asyncRequest("POST", formURL, callBack, postData);


	 

	
}

function updateIt(response){
	alert("response");
	document.getElementById("contact-form").innerHTML="<h3 class='post'>Get your questions answered</h3>";
	//document.getElementById("errorreport").innerHTML="<h3 class='post'>Get your questions answered</h3>";
	/*	$("getMe").innerHTML=response.responseText;
	$("submitP").innerHTML="";
	new Effect.Opacity("classRequest", {from: 0, to: 1, duration:.5});
	*/
}


