var xmlHttp;
function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest;
	} 
} 
function GetRefData(id) {
	createXMLHttpRequest();
	var url="index.php?a=refback_history&t=ajax&lid="+id;
        xmlHttp.onreadystatechange=CallBack;      
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
} 
function CallBack() {
	if (xmlHttp.readyState==1) {
	   document.getElementById("RefData").innerHTML="<center>Processing... <img src=\"/images/loading.gif\" align=\"absmiddle\"></center>";
	} 
	if (xmlHttp.readyState==4 && xmlHttp.status==200) {
	   document.getElementById("RefData").innerHTML=xmlHttp.responseText;
	} 
  } 

function HideDate() {
	   document.getElementById("RefData").innerHTML="";
	} 
 
function CalRefback(a)
{
 var b = document.getElementById('r').value;
 document.getElementById('rcb').innerHTML='$'+(a*b/100).toFixed(2);
}

		function checkform() {
				
			if (document.mainform.refname.value == '') {
				alert("Please type Your program ID or username!");
				document.mainform.refname.focus();
				return false;
			}
			if (document.mainform.email.value == '') {
				alert("Please enter your e-mail address!");
				document.mainform.email.focus();
				return false;
			}
			if (document.mainform.ecnum.value == '') {
				alert("Please enter your account number!");
				document.mainform.ecnum.focus();
				return false;
			}
			if (document.mainform.amount.value == '') {
			 alert("Please enter amount of your spend!");
			 document.mainform.amount.focus();
			 return false;
			}
			if (parseFloat(document.mainform.amount.value) != document.mainform.amount.value) {
			 alert("Invalid amount of the spend!");
			 document.mainform.amount.focus();
			 return false;
			}
			if (document.mainform.validation_number.value == '') {
			 alert("Please enter the turing number!");
			 document.mainform.validation_number.focus();
			 return false;
			}
			return true;
		}

function textCounter(field, countfield, maxlimit) {
 if (field.value.length > maxlimit){
    field.value = field.value.substring(0, maxlimit);
 }
 else {
       countfield.value = maxlimit - field.value.length;
     }
 }
