
function validateRequestForm() {
			var code=document.frmRequest.txtDescription.value;
			var email=document.frmRequest.txtEmail.value;
			var msg="";
			if(code.length >100) {
				msg+="The length of the description should be less than 100\n";
			} 
			if(code.length ==0) {
				msg+="No description provided\n";	
			}
			if(email.length>50) {
				msg+="Too lengthy email\n";
			}
			if(email.length ==0) {
				msg+="The email field should not be empty\n";
			}
			if(/^\w+([\._]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
				
			} else {
				msg+="The email is invalid";
			}
			if(msg!="") {
				msg="Please check the following errors\n\n"+msg;
				alert(msg);
				return false;
			} else {				
				return true;
			}																			
	}
	
	function getPostElements(frmRequest) {
		var str="";
		for(var i=0;i<frmRequest.elements.length;i++) {
			str+=frmRequest.elements[i].name+"="+frmRequest.elements[i].value+"&";
		}
		return str;
	}
	
	function postRequest(objID,path) {
		var obj=document.getElementById(objID); // get the html object using objID
		var validated=validateRequestForm();
		if(!validated) {
			return false;
		}
		var str= getPostElements(document.frmRequest);	
		xmlHTTP=getXmlHttpObject();		
		xmlHTTP.open("POST",path+"postCodeRequest.php",true);
		xmlHTTP.setRequestHeader("Content-Type",
		"application/x-www-form-urlencoded; charset=UTF-8");	
		xmlHTTP.onreadystatechange=function () {		
			if(xmlHTTP.readyState==4 ) {
				obj.innerHTML=xmlHTTP.responseText;
			} else {
				obj.innerHTML="Processing...";	
			}
		}
		xmlHTTP.send(str);		
		return false;
	}
		
		