// JavaScript Document

$(document).ready(function(){
	//เปลี่ยนหมายเลขบัตรประชาชน
   $("#IDCard").change(function(){
   		$("#IDCard_remark").html('please wait...');
		$.ajax({
  		url: "idcard_check.php",
		data: ({IDCard : $("#IDCard").val()}),
  		success: function(html){
		$("#IDCard_remark").html(html);
		}
		});
   });

   $("#Institute_type").ready(function(){
		LoadInstitute();
	});

   $("#Institute_type").change(function(){
		LoadInstitute();
   });



});//document ready

function LoadInstitute()
{
		$.ajax({
			url: "institute_dropdown.php",
			data: ({Type : $("#Institute_type").val()}),
			success: function(html){
			$("#Institute_span").html(html);
			$("#Institute").ready(function(){
				CheckInstitute($("#Institute").val())
			});
			$("#Institute").change(function(){
				CheckInstitute($("#Institute").val())
			});	
			}
		});	
}

function CheckInstitute(data)
{
	if (data=='other')
	{
		$("#OtherInstitute").css('display','block');
		$("#OtherInstitute").removeAttr("disabled");
	}else{
		$("#OtherInstitute").css('display','none');
		$("#OtherInstitute").attr("disabled","disabled");			
	}
}

function OpenCountry(openup)
{
	if (openup==6)
	{
		for(var i=1;i<=6;i++)
		{
			$("#Country"+i).removeAttr("disabled");
		}
	}else{
		for(var i=1;i<=6;i++)
		{
			$("#Country"+i).attr("disabled","disabled");
		}		
	}
}


