Array.prototype.inArray = function (value)
// Returns true if the passed value is found in the
// array. Returns false if it is not.
{
var i;
for (i=0; i < this.length; i++) {
// Matches identical (===), not just similar (==).
if (this[i] === value) {
return true;
}
}
return false;
};

function same_as_above() {

	$( "#s_name_first" ).val( $( "#b_name_first" ).val());
	$( "#s_name_last" ).val( $( "#b_name_last" ).val());
	$( "#s_addr1" ).val( $( "#b_addr1" ).val());
	$( "#s_addr2" ).val( $( "#b_addr2" ).val());
	$( "#s_city" ).val( $( "#b_city" ).val());
	$( "#s_name_state" ).val( $( "#b_name_state" ).val());
	$( "#s_id_state" ).val( $( "#b_id_state" ).val());
	$( "#s_zip" ).val( $( "#b_zip" ).val());
	
}

function choose_b_id_field() {
  $("#b_id_country").each(
    function() {
	    if($(this).val() == 141) {
	      show_b_states();
	    } else {
	      hide_b_states();
	    }
    }
  );
}

function choose_b_field() {
  $("#b_country").each(
    function() {
	    if($(this).val() == "United States") {
	      show_b_states();
	    } else {
	      hide_b_states();
	    }
    }
  );
}

function change_b_state() {
	$('#b_state').val( $('#b_id_state').val() );
}

function change_s_state() {
	$('#s_state').val( $('#s_id_state').val() );
}

function change_b_id_state() {
	$('#b_id_state').val( $('#b_state').val() );
}

function change_s_id_state() { alert('test');
	$('#s_id_state').val( $('#s_state').val() );
}

function show_b_states() {
	$("#b_id_state").show();
	$("#b_state").hide();
}

function hide_b_states() {
	$("#b_id_state").hide();
	$("#b_state").show();
}

function choose_s_id_field() {
  $("#s_id_country").each(
    function() {
	    if($(this).val() == 141) {
	      show_s_states();
	    } else {
	      hide_s_states();
	    }
    }
  );
}

function choose_s_field() {
  $("#s_country").each(
    function() {
	    if($(this).val() == "United States") {
	      show_s_states();
	    } else {
	      hide_s_states();
	    }
    }
  );
}

function show_s_states() {
	$("#s_id_state").show();
	$("#s_state").hide();
}

function hide_s_states() {
	$("#s_id_state").hide();
	$("#s_state").show();
}