$(document).ready(function(){
		$('#location_search').hide();
		
		$('#country_id').change(
			country_trigger = function(){
				switch($('#country_id').val()){
					case "1":
					case "2":
					case "3":
						show = true;
					break;
					default:
						show = false;
					break;
				}	
				if(show==true){
					$('#location_search').show();
					$.ajax({
						url: '/config/xml.php?method=get_states'+"&"+'is_front=1'+"&"+'param='+$('#country_id').val(),
						processData: false,
						dataType: "html",
						success: function(html){
							$("#state_id").html(html);
						}
					});
					setTimeout('state_change()',300);
				}
				else{
					$('#location_search').hide();
				}
			}
		);
		
		country_trigger();
		
		$('#state_id').change(
			state_change = function(){
				$.ajax({
					url: '/config/xml.php?method=get_regions'+"&"+'param='+$('#state_id').val()+"&"+'is_front=1',
					processData: false,
					dataType: "html",
					success: function(html){
						$("#region_id").html(html);
					}					
				});
				$('#post_code').val('');
				$.ajax({
					url: '/config/xml.php?method=get_front_locations'+"&"+'country_id='+$('#country_id').val()+"&"+'param='+$('#post_code').val(),
					processData: false,
					dataType: "html",
					success: function(html){
						$("#location_id").html(html);
					}
				});
			}
		);
		
		$('#post_code').blur(
			post_code_change = function(){
				$.ajax({
					url: '/config/xml.php?method=get_front_locations'+"&"+'country_id='+$('#country_id').val()+"&"+'param='+$('#post_code').val(),
					processData: false,
					dataType: "html",
					success: function(html){
						$("#location_id").html(html);
					}
				});
				$('#state_id').val(0);
				$.ajax({
					url: '/config/xml.php?method=get_regions'+"&"+'param='+$('#state_id').val()+"&"+'is_front=1',
					processData: false,
					dataType: "html",
					success: function(html){
						$("#region_id").html(html);
					}					
				});
			}
		);
		
		$("#marital_2").click(
			function(){
				$("#marital_dont_mind").attr('checked',"");
			}
		);
		
		$("#marital_3").click(
			function(){
				$("#marital_dont_mind").attr('checked',"");
			}
		);
		
		$("#marital_dont_mind").click(
			function(){
				$("#marital_2").attr('checked',"");
				$("#marital_3").attr('checked',"");
			}
		);
	});