//javascript to show/hide international/domestic form fields

jQuery(document).ready(function(){
	jQuery("*.javascriptEnabled").show();
    jQuery("*.javascriptDisabled").hide();

    jQuery("#Domestic").click(function(){
        jQuery(".international").hide();
        jQuery(".domestic").show(); 
    });

    jQuery("#International").click(function(){
        jQuery(".domestic").hide();
        jQuery("#location").css("display","block"); 
        jQuery(".international").show();    
    });

    if(jQuery("input[name=location]:checked").val()=="domestic"){
        jQuery(".international").hide();
        jQuery(".domestic").show();
    } else if (jQuery("input[name=location]:checked").val()=="international"){
        jQuery(".domestic").hide();
        jQuery(".international").show();
    }
   
    //avoid submitting formfields with the same name
    jQuery("form").submit(function() {
        if(jQuery("input[name=location]:checked").val()=="domestic"){               
            jQuery("#countryInternational").attr("name", "discard-country");
            jQuery("#province").attr("name", "discard-state");
        } else if (jQuery("input[name=location]:checked").val()=="international"){
            jQuery("#countryDomestic").attr("name","discard-country");
            jQuery("#state").attr("name","discard-state");
        }
    });
	
	
});

