 //new user name checking
function course_list_loading() {
var courseid = Form.getInputs('courselistpage','radio','course').find(function(radio) { return radio.checked; }).value;
var url = 'ajax_courselist.php';
if(courseid !="") { 
// make all block empty to procced.
$('state_block').innerHTML = "";
$('city_block').innerHTML  = "";
enable_disable_button('disable');

new Ajax.Request(
	   url, { 
		  method: 'get',
		  parameters: {course_id:courseid,onaction:'get_course_detail'}, 
		  onCreate: function(transport) { 
		  		$('course_description').innerHTML = display_loading(150,626);
				$('state_block').innerHTML = display_loading(150,800);
		  	},
		  onSuccess: function(transport) { 
		  	var response_obj =transport.responseText.evalJSON(true);
		 	 	$('course_description').innerHTML = response_obj.course_desc;
				$('state_block').innerHTML = response_obj.course_state;
				$('city_block').innerHTML = "";
				
				var optreghide = response_obj.hide_register;
				if(optreghide == "yes") {
					$('register_image').hide();
				}
			}, 
		  onFailure: function(transport) { 
		 	  	$('course_description').innerHTML = "oops! There is a problem. Try Again";
				$('state_block').innerHTML = "oops! There is a problem. Try Again";
			}
		}
	); 
}
else {
	$('course_description').innerHTML = "Please, Select the course from the list";
}
}

function state_list_loading() {
var stateid = Form.getInputs('courselistpage','radio','state').find(function(radio) { return radio.checked; }).value;
var courseid = Form.getInputs('courselistpage','radio','course').find(function(radio) { return radio.checked; }).value;
var url = 'ajax_courselist.php';
if(stateid !="" && courseid !="") { 
// make all block empty to procced.
$('city_block').innerHTML  = "";
enable_disable_button('disable');
new Ajax.Request(
	   url, { 
		  method: 'get',
		  parameters: {course_id:courseid,state_id:stateid,onaction:'get_state_detail'}, 
		  onCreate: function(transport) { 
		  		$('state_description').innerHTML = display_loading(150,626);
				$('city_block').innerHTML = display_loading(150,800);
		  	},
		  onSuccess: function(transport) { 
		  	var response_obj =transport.responseText.evalJSON(true);
		 	 	$('state_description').innerHTML = response_obj.state_desc;
				$('city_block').innerHTML = response_obj.state_city_area;
			}, 
		  onFailure: function(transport) { 
		 	  	$('state_description').innerHTML = "oops! There is a problem. Try Again";
				$('city_block').innerHTML = "oops! There is a problem. Try Again";
			}
		}
	); 
}
else {
	$('state_description').innerHTML = "Please, Select the course and state from the list";
}
}

function city_list_loading() {
var cityid = Form.getInputs('courselistpage','radio','city').find(function(radio) { return radio.checked; }).value;
var stateid = Form.getInputs('courselistpage','radio','state').find(function(radio) { return radio.checked; }).value;
var courseid = Form.getInputs('courselistpage','radio','course').find(function(radio) { return radio.checked; }).value;
var url = 'ajax_courselist.php';
if(stateid !="" && courseid !="" && cityid !="") { 
new Ajax.Request(
	   url, { 
		  method: 'get',
		  parameters: {course_id:courseid,state_id:stateid,city_id:cityid,onaction:'get_city_detail'}, 
		  onCreate: function(transport) { 
		  		$('city_description').innerHTML = display_loading(150,626);
			//	$('city_block').innerHTML = display_loading(150);
		  	},
		  onSuccess: function(transport) { 
		  	var response_obj =transport.responseText.evalJSON(true);
		 	$('city_description').innerHTML = response_obj.city_desc;
				enable_disable_button('enable');
			}, 
		  onFailure: function(transport) { 
		  alert(transport.responseText);
		 	  	$('city_description').innerHTML = "oops! There is a problem. Try Again";
				//$('city_block').innerHTML = "oops! There is a problem. Try Again";
			}
		}
	); 
}
else {
	$('city_description').innerHTML = "Please, Select the course,state and city from the list";
}
}

function display_loading(height,width){
	var str = '<div style="text-align:center; height:'+height+'px; width:'+width+'px; "><br /><br /><br /><br /><br /><img src="images/new_loading.gif" align="middle" /></div>';
return str;
}

function enable_disable_button(activity) {
	if(activity == 'enable' ){
		$('register_button').show();
		$('register_button').enable();
		$('register_image').hide();
	}else {
		$('register_button').hide();
		$('register_button').disable();
		$('register_image').show();
	}
	
}