window.onload = function(){
	Event.observe('user','change',react);
}
function react(event)
{
		var uname = $F('user');
		if(uname == "")
		{
			$('user_avl').innerHTML = "";
		}
		else
		{
			$('user_avl').innerHTML = "Checking Availibility";
			new Ajax.Request(
							 'check_user.php?uname='+uname,
							 {
								 method: 'get',
								 onSuccess:function(xhr){
									$('user_avl').innerHTML = xhr.responseText;
								 },
								 onFailure:function(xhr){
									$('user_avl').innerHTML = "Data could not be retrieved. Please continue...";
								 }
							 }
							 );
		}
}							
function update_institutes()
{
	var type = $F('ins_type')
	
	if (type == '') 
	{
		document.getElementById('institute').innerHTML = '<center>Select Institute type first</canter>';
		return;
	}
	document.getElementById('institute').innerHTML = '<center>Loading&hellip;</canter>';
	new Ajax.Request('get_ins.php?type='+type,
					 {
						 method:'get',
						 onSuccess: populate,
						 onFailure: function(r)	{
							 alert('Institute List Fetch failed. Contact the WebMaster for notification.');
							 document.getElementById('institute').innerHTML = '<center>Error in fetching institute list</canter>';
						 }
					 }
					 );
}
function add_institute()
{
	var type = $F('institution')
	
	if (type == 'Others') 
	{
		document.getElementById('other').innerHTML = '<br/>Enter your institute name*:<br/> <input name="new" type="text"/>';
		return;
	}
	else
	{
		document.getElementById('other').innerHTML = ' ';
		return;
	}
	
}
function populate(xhr)
{
	document.getElementById('institute').innerHTML = xhr.responseText;
}

