function viewChart(type){
	this.DEFAULT_WIDTH = 338;
	this.type = type;
	this.lightboxObj = (type == 'home') ? new lightbox('div#homeFeaturedChart', this, 'home/featuredchart', this.applyHomeHandlers) : 
																				new lightbox('div#chartDetail', this, 'home/featuredchart', this.applyInteriorHandlers);
	this.width = null;
	this.init();
}

viewChart.prototype = {
	init: function(){
		var instance = this;
		$('a.viewChart').click(function(){
			instance.width = $(this).attr('rel');
			instance.showChartDetail(this);
			return false;
		});
	},
	
	showChartDetail: function(el){
		this.lightboxObj.showLightbox();
		
		if (this.type == 'home'){
			if ($('div#homeFeaturedChart').length > 0){
				this.applyHomeHandlers();
			}
		}
		else{
			if ($('div#chartDetail').length > 0){
				this.applyInteriorHandlers();
			}
		}
	},
	
	applyHomeHandlers: function(width){
		var instance = this;
		//INITIALIZE THE MEMBER MEDIA BOX HERE
		
		if (this.width > this.DEFAULT_WIDTH){
			var moduleWidth = parseInt(this.width) + 72; //72 = left padding + right padding of chart image container
			//80 = left padding + right padding of lightbox div
			var moduleMargin = -(Math.floor(parseInt((moduleWidth + 80) / 2)));
			$('div#homeFeaturedChart').css('width', moduleWidth + 'px').css('margin-left', moduleMargin + 'px');
			$('div#homeFeaturedChart div.image').css('width', this.width + 'px');
		}
		
		$('div#homeFeaturedChart div.close a').unbind().click(function(){
			instance.hideChartDetail();
			return false;
		});
	},
	
	applyInteriorHandlers: function(){
		var instance = this;
		//INITIALIZE THE MEMBER MEDIA BOX HERE
		
		$('div#chartDetail div.close a').unbind().click(function(){
			instance.hideChartDetail();
			return false;
		});
	},
	
	hideChartDetail: function(){
		this.lightboxObj.hideLightbox();
	}
}
