var defaultComments = "Enter your comments here (optional)";



function getRadioValue(radioObj) { 



   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;

		}

	}



}



function submitInquiryForm() {

   var params;



   myHttpRequest = new AW.HTTP.Request();



   myHttpRequest.setURL("AJAXServer.php");

//   myHttpRequest.setURL("index.html");

   myHttpRequest.setRequestMethod("GET");

   

   myHttpRequest.setAsync(true);

   myHttpRequest.setParameter("screen", 'general');

   myHttpRequest.setParameter("inquiryFormWhichForm", document.getElementById('inquiryFormWhichForm').value);

   myHttpRequest.setParameter("inquiryFormEmail", document.getElementById('inquiryFormEmail').value);

   myHttpRequest.setParameter("inquiryFormName", document.getElementById('inquiryFormName').value);

   myHttpRequest.setParameter("inquiryFormPhone", document.getElementById('inquiryFormPhone').value);

    

   if (document.getElementById('inquiryFormWhyInterested').value !== defaultComments) {

      myHttpRequest.setParameter("inquiryFormWhyInterested", document.getElementById('inquiryFormWhyInterested').value);

   }

         

   if (document.getElementById('inquiryFormAppointment').checked) {

      myHttpRequest.setParameter("inquiryFormAppointment", 'Y');

   }

   else {

      myHttpRequest.setParameter("inquiryFormAppointment", 'N');      

   }



   if (document.getElementById('inquiryFormSpeak').checked) {

      myHttpRequest.setParameter("inquiryFormSpeak", 'Y');

   }

   else {

      myHttpRequest.setParameter("inquiryFormSpeak", 'N');      

   }



   myHttpRequest.setParameter("request", 'submitInquiry');



   myHttpRequest.response = function(xml){



      if (typeof(xml) != 'object') { 

         alert('Error:' + this.getResponseText());

         return;

      }

      

      var messageNode = xml.selectNodes('//response/message'); 

      if (messageNode && messageNode[0].text) { 

         alert(messageNode[0].text);

      }



      var rcNode = xml.selectNodes('//response/rc'); 

      if (rcNode && rcNode[0].text=='1') { 

         document.getElementById('inquiryFormEmail').value = '';

         document.getElementById('inquiryFormName').value = '';

         document.getElementById('inquiryFormPhone').value = '';

         document.getElementById('inquiryFormSpeak').checked=false;

         document.getElementById('inquiryFormAppointment').checked=false;

         document.getElementById('inquiryFormWhyInterested').value = defaultComments;

         document.getElementById('inquiryFormWhyInterested').className = 'commentsInstructions';

      }

      

   }

   



   myHttpRequest.request();



   return;

     

}



function commentsFocus() {

   var whyInterested = document.getElementById('inquiryFormWhyInterested');

   if (whyInterested.value==defaultComments) {

      whyInterested.value='';

   }

   whyInterested.className = '';

}



function commentsBlur() {

    var whyInterested = document.getElementById('inquiryFormWhyInterested');

   if (whyInterested.value=='') {

      whyInterested.value=defaultComments;

      whyInterested.className = 'commentsInstructions';

   }

}
