
$(document).ready(function() {
	
	$(".communityLink").click(function() {
		var urlName = $(this).attr("href");

		if(! /^http:.*$/.test(urlName)) {
			var url = "/ajax/community/communitylocationinfo/name/" + urlName + "/";
			var city = $(this).text(), state = "";
			
			$.ajax({
				async: false,
				dataType: "json",
				url: url,
				success: function(data) {
					var envelope = new Envelope(data);
					if(envelope.payload) {
						var addresses = envelope.payload;
						if(addresses.length > 0) {
							city = addresses[0].city;
							state = addresses[0].state;
						}
					}
				}
			});
			
			urlName ="http://en.wikipedia.org/wiki/" + city + (state != "" ? ("%2C_" + state) : "");
		}

		openWin(urlName,800,600,"yes");
	});
	
	$(".schoolmattersLink").click(function() {
		var zipcode = $(this).attr("zipcode");
		var url ="http://www.schoolmatters.com/schools.aspx/q/page=sr/mr=5/zc="+zipcode+"/p=1/fp=1";
		openWin(url,800,600,"yes");
	});

});

