dojo.require("dojo.fx");
dojo.addOnLoad(function() {
	var inter = setInterval(function() {
		var tabs = dojo.query("#prodTable");
		if(tabs.length !== 0) {
			dojo.query("td", tabs[0]).forEach(function(o) {
				new ContentExpansionController({
					"trigger" : dojo.query(".viewMoreLink", o)[0],
					"content" : dojo.query(".viewMoreContent", o)[0],
					"animate" : false
				});
			});
			clearInterval(inter);
		}
	}, 500);
});
function ContentExpansionController(cfg) {
	this.trigger = dojo.byId(cfg.trigger);
	this.content = dojo.byId(cfg.content);
	this.animate = cfg.animate;
	this.expanded = false;
	this.allow = true;
	if(typeof this.trigger != "undefined" && typeof this.content != "undefined") {
		dojo.connect(this.trigger, "onclick", this, this.toggle);
	}
}
ContentExpansionController.prototype.toggle = function(e) {
	if(this.allow) {
		this.allow = false;
		if(this.expanded) {
			if(this.animate) {
				dojo.fx.wipeOut({
					"node" : this.content,
					"duration" : 1000,
					"onEnd" : dojo.hitch(this, function() {
						this.allow = true;
						this.expanded = false;
					})
				}).play();
			} else {
				dojo.style(this.content, { "display" : "none" });
				this.allow = true;
				this.expanded = false;
			}
			this.trigger.innerHTML = "View More";
		} else {
			if(this.animate) {
				dojo.fx.wipeIn({
					"node" : this.content,
					"duration" : 1000,
					"onEnd" : dojo.hitch(this, function() {
						this.allow = true;
						this.expanded = true;
					})
				}).play();
			} else {
				this.allow = true;
				this.expanded = true;
				dojo.style(this.content, { "display" : "block" });
			}
			this.trigger.innerHTML = "View Less";
		}
	}
	dojo.stopEvent(e);
};