$ (function () {

	$ ("div#content form div.field").each (function () {
		if (! $ (this).find (":button, :image, :password, :reset, :submit, :text, select, textarea").size ()) {
			$ (this).addClass ("compact-field");
		}
	});

	$ ("div#content span.marker").parent ().parent ().each (function () {
		var marker = $ (this).children ().children ("span.marker");
		var width = 0;
		marker.each (function () {
			width = Math.max (width, $ (this).css ("display", "inline").width ("auto").width () - parseInt ($ (this).css ("text-indent")));
		});
		var margin = (parseInt ($ (marker [0]).css ("margin-right")) + width) + "px";
		$ (this).css ("margin-left", margin);
		marker.width (width).css ("margin-left", "-" + margin);
	});

	$ (".external").attr ("target", "_blank");

	if ($.browser.msie) {
		if ($.browser.version < 7) {
			$ (":first-child").addClass ("first-child");
			$ ("input").each (function () {
				$ (this).addClass ($ (this).attr ("type"));
			});

			$ ("div#content img.icon").each (function () {
				var margin = Math.max (0, (parseInt ($ (this).css ("line-height")) - $ (this).height ()) / 2);
				$ (this).css ({ marginBottom : Math.ceil (margin) + "px", marginTop : Math.floor (margin) + "px" });
			});

		}
		if ($.browser.version < 8) {
			$ (":last-child").addClass ("last-child");
		}
	}

	$ ("img.hover").each (function () {
		(new Image).src = this.src.replace (/\.(gif|jpg)$/, "_hover." + "$1");
	});
	$ ("img.hover").parents ("a").hover (function () {
		$ ("img.hover", this).each (function () {
			this.src = this.src.replace (/\.(gif|jpg)$/, "_hover." + "$1");
		});
	}, function () {
		$ ("img.hover", this).each (function () {
			this.src = this.src.replace (/_hover\.(gif|jpg)$/, "." + "$1");
		});
	});

	$ ("img.btn").filter (function () { return !/_o\.(gif|jpg)$/.test (this.src); }).each (function () {
		(new Image).src = this.src.replace (/\.(gif|jpg)$/, "_o." + "$1");
	});
	$ ("img.btn").filter (function () { return !/_o\.(gif|jpg)$/.test (this.src); }).parents ("a").hover (function () {
		$ ("img.btn", this).each (function () {
			this.src = this.src.replace (/\.(gif|jpg)$/, "_o." + "$1");
		});
	}, function () {
		$ ("img.btn", this).each (function () {
			this.src = this.src.replace (/_o\.(gif|jpg)$/, "." + "$1");
		});
	});

	if (/_window$/.test (window.name)) {
		window.self.focus ();
	}
});

function openImageWindow (url) {
	window.open (url, "image_window", "width=600,height=600").focus ();
}
function openFeatureWindow (url) {
	window.open (url, "feature_window", "width=620,height=700,scrollbars=1").focus ();
}
function openMapWindow (url) {
	window.open (url, "map_window", "width=600,height=600").focus ();
}