

function rand(l,u) // lower bound and upper bound
{     return Math.floor((Math.random() * (u-l+1))+l);
}  
//alert(rand(3,6));

/******************** cODING TO CHECK USERNAME AVAILABLITY GIVEN BELOW ***********/

function updateValid() { 
var url2 = '/ajaxphp/valid.php?id='; 
  	var name = document.getElementById('candidate_login_name').value; 
	if(name==''|| name.length < 6)
		{ 
		alert("Please fill a valid loginId");
		document.getElementById('candidate_login_name').value='';
		return false
		
		}
	document.getElementById('unc').innerHTML = '...Please wait...'; 	
	url2=url2+escape(name)+'&code=';
	var cc=rand(10000,99999);
		
  	http2.open('GET', url2 + cc, true); 
	http2.onreadystatechange = handleHttpResponse2; 
  	http2.send(null); 
} 

	


function handleHttpResponse2() { 
  if (http2.readyState == 4) { 
    results = http2.responseText; 
	
	document.getElementById('unc').innerHTML=results;
	document.getElementById('pass_tr').style.display='';
	//document.getElementById('course_tr').style.display='';
	document.getElementById('submit2').style.display='';
	document.getElementById('get_pass').style.display='none';
	document.getElementById('m').innerHTML='<font color="#33CC66">Enter password and  click <b>LogIn</b></font>';

	
	
  } 
} 

function getHTTPObject2() { 
  // will store the reference to the XMLHttpRequest object
					var xmlHttp;
					// if running Internet Explorer
					if(window.ActiveXObject)
					{		try
							{	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");		}
							catch (e)
							{			xmlHttp = false;				}
					}
							// if running Mozilla or other browsers
					else
					{		try
							{	xmlHttp = new XMLHttpRequest();			}
							catch (e)
							{	xmlHttp = false;					}
					}
					// return the created object or display an error message
					if (!xmlHttp)
						alert("Error creating the XMLHttpRequest object.");
					else
						return xmlHttp;

} 
var http2 = getHTTPObject2(); // We create the HTTP Object 



/********* cODING TO CHECK USERNAME aVAILABLITY ABOVE **********/
/**************************/



