$(document).ready(function() { 
	//initialize shadowbox without running setup... 
	Shadowbox.init(); 

	var countries = new Object();

	//intercept the form's submission event... 
	var fm = $('#whereform').bind('submit',function(e){ //on submit... 
		//open shadowbox... 
		var url = "/map.html?country=" + $('#map-country-select').val() + "&zip=" + $('#map-zip-code').val();
		Shadowbox.open({player:'iframe',content:url,width:920,height:639,handleOversize:"none"}); 
		//reset form (if desired)... 
		fm[0].reset(); 
		$('#zipcodecontainer').hide();
		//prevent form submission... 
		return false; 
	});

  $("#liberty-map").click(function() {
    var url = "/map.html?country=US";
    Shadowbox.open({player:'iframe',content:url,width:920,height:639,handleOversize:"none"});
  });

	$('#map-country-select').bind('change', function(e) {
		if($(this).val() == "US") {
			$('#zipcodecontainer').show();
		} else {
			$('#zipcodecontainer').hide();
		}
	});
	
	$('#map-zip-code').bind('focus', function(e) {
		if($(this).val() == "ZIP CODE") {
			$(this).attr("value","");
		}
	});
	$('#map-zip-code').bind('blur', function(e) {
		if($(this).val() == "") {
			$(this).attr("value","ZIP CODE");
		}
	});


	$.ajax({
		type: "GET",
		url: "/countries.xml",
		success: function(xml) {
			$(xml).find('country').each(function(){
				var name_text = $(this).text();
				$('<option></option>')
					 .html(name_text)
					 .appendTo('#map-country-select');
			});
		}
	});
	
}); 

