$(function(){


	$('input[@type=radio]').focus(function(){
		
		$(this).blur();
		
	});
	

	$('#countySelect').change(function()
	{
		$('#townPicker').html('loading...');
		$('#townPicker').load('../get_town.php?county=' + $(this).val());		
	});


	$('#areaSelect').change(function()
	{
		$('#countyPicker').html('loading...');
		$('#countyPicker').load('../get_county.php?area=' + $(this).val());		
	});

	$('#countrySelect').change(function()
	{
		$('#areaPicker').html('loading...');
		$('#areaPicker').load('../get_area.php?country=' + $(this).val());		
	});




	$('#lnkFp').click(function(){
		$('#frmFp').css({display:'block'});
	});
	/*
	alert($('#form_bg').css('height'));
	alert($('#login_top').css('height'));
	
	$('#form_bg').css({
		'height' : $('#login_top').css('height')
	});
	
	if($.browser.msie && $.browser.version=='6.0' ){
		$('form#login_top input').css({
			'margin-left':'0px'
		});
	}
	
	alert($('#form_bg').css('height'));
	*/
	
	
	
	$('select#country_select').change(function(){
		var id = $(this).val();
		pop_area(id);
	});
	
	$('select#area_select').change(function(){
		var id = $(this).val();
		pop_county(id);
	});
	
	$('select#county_select').change(function(){
		var id = $(this).val();
		pop_town(id);
	});
	
	
	
});

function pop_country(selected){
	
	$('select#country_select option').each(function(){
		if($(this).attr('value') == selected || ($(this).attr('value')==undefined && selected=='')){
			$(this).attr('selected','selected');
		}
	});
}

function pop_area(id, selected){
	$('select#area_select').load('select_pop.php?type=area&id='+id,function(){
		$('select#area_select option').each(function(){
			if($(this).attr('value') == selected || ($(this).attr('value')==undefined && selected=='')){
				$(this).attr('selected','selected');
			}
		});
	}).attr('disabled','');
}
function pop_county(id, selected){
	$('select#county_select').load('select_pop.php?type=county&id='+id,function(){
		$('select#county_select option').each(function(){
			if($(this).attr('value') == selected || ($(this).attr('value')==undefined && selected=='')){
				$(this).attr('selected','selected');
			}
		});
	}).attr('disabled','');
}
function pop_town(id, selected){
	var txt = '';
	
	$('select#town_select').load('select_pop.php?type=town&id='+id,function(){
		$('select#town_select option').each(function(){
			
			if($(this).attr('value') == selected || ($(this).attr('value')==undefined && selected=='')){
				$(this).attr('selected','selected');
			}
		});
		
	}).attr('disabled','');
}
