Shenoa.RevealProduct = function(){
	var showproductel, logproductel, gridcontainerel, gridel;
	
	return {
		init : function() {
			showproductel = Ext.get('show-product');
			logproductel = Ext.get('log-product');
			gridcontainerel = Ext.get('grid-container');
			gridel = Ext.get('grid');
		},
		showProduct : function(productid) {
			// hide grid
			setTimeout("hideAllTooltips()",1000);
			gridel.dom.style.height = '0px';
			gridel.dom.style.visibility = 'hidden';
			gridcontainerel.fadeOut();

			// get update manager to refresh element using post
			var mgr = logproductel.getUpdateManager();
			var basepath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/')) ;
			mgr.update(basepath+"/tab2.php", "diamondproductid="+productid);
			// show product details
			showproductel.fadeIn();

			// update tab panel title when page loads
			mgr.on("update", this.updateSelectTabListener);
			
		},
		updateSelectTabListener: function(el, response) {
			// Shenoa.Tabs.updateSelectTab();	
		},
		
		hideProduct : function() {
			//hide all tooltips
			setTimeout("hideAllTooltips()",1000);
			showproductel.dom.style.display = 'none';
			gridel.dom.style.height = '250px';
			gridel.dom.style.visibility = 'visible';
			gridcontainerel.fadeIn();
   		//Shenoa.DiamondGrid.allowRefresh(); // allow datasource to be refreshed
   		//Shenoa.DiamondGrid.refreshDataSource(); // and then refresh it
			// reset tab panel title
			Shenoa.Tabs.resetSelectTab();
		},
		
		addProduct : function() {
			Shenoa.Tabs.activateChooseTab(Shenoa.SelectedProductId); // set in grid.js
		}		
	};
}();
Ext.onReady(Shenoa.RevealProduct.init, Shenoa.RevealProduct, true);
