$(document).ready(function() {


$('#UnivType').change(function(){
		$('#UniversityName').fadeOut();
		$.post("JS/loadUniversity.asp", {
			parent_id: $('#UnivType').val(),
		}, function(response){
			
			setTimeout("finishAjax('UniversityName', '"+escape(response)+"')", 400);
		});
		return false;
	});

$('#FieldType').change(function(){
		$('#FieldName').fadeOut();
		$.post("JS/loadField.asp", {
			parent_id: $('#FieldType').val(),
		}, function(response){
			
			setTimeout("finishAjax('FieldName', '"+escape(response)+"')", 400);
		});
		return false;
	});
	
$('#ProfileState').change(function(){
		$('#ProfileCity').fadeOut();
		$.post("JS/loadCity.asp", {
			parent_id: $('#ProfileState').val(),
		}, function(response){
			
			setTimeout("finishAjax('ProfileCity', '"+escape(response)+"')", 400);
		});
		return false;
	});
	
$(".CancelFollow").click(function(){
	var element = $(this);
	var itemid = element.attr("id");
	var parent = $(this);
	var info = 'id=' + itemid + '&act=cancel';
	$(this).parent().html("<img src='../ask/spinner.gif'/>");
	 $.ajax({
		   type: "GET",
		   url: "data/Update_follow.asp",
		   data: info,
		   success: function(html){$("span#User_"+itemid).html(html);}
			});
return false;
});

$(".FollowReject").click(function(){
	var element = $(this);
	var itemid = element.attr("id");
	var parent = $(this);
	var info = 'id=' + itemid + '&act=reject';
	$(this).parent().html("<img src='../ask/spinner.gif'/>");
	 $.ajax({
		   type: "GET",
		   url: "data/Update_follow.asp",
		   data: info,
		   success: function(html){$("span#User_"+itemid).html(html);}
			});
return false;
});

$(".RejectFollow").click(function(){
	var element = $(this);
	var itemid = element.attr("id");
	var parent = $(this);
	var info = 'id=' + itemid + '&act=reject';
	$(this).parent().html("<img src='../ask/spinner.gif'/>");
	 $.ajax({
		   type: "GET",
		   url: "data/Update_follow.asp",
		   data: info,
		   success: function(html){$("span#User_"+itemid).html(html);}
			});
return false;
});
	
$(".FollowAccept").click(function(){
	var element = $(this);
	var itemid = element.attr("id");
	var parent = $(this);
	var info = 'id=' + itemid + '&act=accept';
	$(this).parent().html("<img src='../ask/spinner.gif'/>");
	 $.ajax({
		   type: "GET",
		   url: "data/Update_follow.asp",
		   data: info,
		   success: function(html){$("span#User_"+itemid).html(html);}
			});
return false;
});
	
});

function finishAjax(id, response){
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
} 

function alert_id()
{
	if($('#sub_category_id').val() == '')
	alert('Please select a sub category.');
	else
	alert($('#sub_category_id').val());
	return false;
}
