(function() {
	var glow,
		simages;
	
	gloader.load(
	["glow", "1", "glow.dom", "glow.events"],
	{
		async: false,
		onLoad: function(fetchedGlow) {
			glow = fetchedGlow;
			glow.ready(init);
		}
	});
	
function init() {
	simages = glow.dom.get("div#gas_pipeline img");
	simages.css("display", "none");
	glow.dom.get("div#gas_pipeline_controls").css("display", "block");
	// def affected
	simages[0].style.display = "block";
	glow.dom.get("div#gas_pipeline_controls").children().filter(
	function(i) { return glow.dom.get(this).is("input"); }).each(
	function(i) {
		if (glow.dom.get(this).attr("type") == "radio") {
			glow.events.addListener(
			this,
			"click",
			trigger,
			this);
		} else if (glow.dom.get(this).attr("type") == "checkbox") {
			glow.events.addListener(
			this,
			"click",
			labels,
			this);
		}
	});
}

function trigger() {
	var elm = glow.dom.get(this);
	var rg = new RegExp(this.id);
	simages.each(function(i) {
		if (this.src.match(rg)) {
			this.style.display = "block";
		} else {
			if (!this.id.match(/overlayimg/)){
				this.style.display = "none";
			}
		}
	});
}

function labels() {
	var label = glow.dom.get("#gas_overlayimg");
	if (label.css("display") == "block"){
		label.css("display","none");
	} else {
		label.css("display","block");
	}
}

})();