YAHOO.namespace("sun.site");
YAHOO.sun.site.active_tip = 'none';
YAHOO.sun.site.active_div = 'none'

function doPop(e) {

	var x_adjust = -60;
	var y_adjust = -1;
	var split_class_array = this.id.split("__");
	var prod_id_raw = split_class_array[0];
	var ptype_id = split_class_array[1];
	prod_id = 'panel_' + prod_id_raw;
	var x = YAHOO.util.Event.getPageX(e);
	var y = YAHOO.util.Event.getPageY(e);	
	x = x + x_adjust;
	// this sets y based on the row position, 
	// so the panel will always appear at the same height relative to the row 
	var y = YAHOO.util.Dom.getY(this) + 20;
	
	//this sets y based on the click position	
	//var y = YAHOO.util.Event.getPageY(e);
	//y = y + y_adjust;
	//alert("y = " + YAHOO.util.Dom.getY(this) + " height= " + YAHOO.util.Dom.getHeight(this));

	// if active tip is none, then there is no active tip
	if (YAHOO.sun.site.active_tip == 'none') {
		YAHOO.sun.site.active_tip = prod_id;
		YAHOO.sun.site.active_div = this;
		
		// activate the clicked item
		YAHOO.util.Dom.addClass(this, 'program_row_active' );
		
		YAHOO.sun.site[prod_id].cfg.setProperty("xy", [x, y ]);

		YAHOO.sun.site[prod_id].show();
	} else {
		// if they are reactivating the currently active tip, skip the hide processing
		if (YAHOO.sun.site.active_div != this)
		{
			// this hides the active panel
			YAHOO.sun.site[YAHOO.sun.site.active_tip].hide();			
			
			// this DE-activates the currently active row
			YAHOO.util.Dom.removeClass(YAHOO.sun.site.active_div, 'program_row_active' );
		}
		// store the newly activated tip in YAHOO.sun.site.active_div
		YAHOO.sun.site.active_div = this;	
		YAHOO.sun.site.active_tip = prod_id;
		
		// make the clicked item active state
		YAHOO.util.Dom.addClass(this, 'program_row_active' );
		
		// locate the new popup
		YAHOO.sun.site[prod_id].cfg.setProperty("xy", [x, y]);
		// show it
		YAHOO.sun.site[prod_id].show();
	}
	 
}



function closeActive(e)
{
	// if there is an active tip, hide it
	if (YAHOO.sun.site.active_tip != 'none' && YAHOO.sun.site.active_div != null ) 
	{
		YAHOO.util.Dom.removeClass(YAHOO.sun.site.active_div, 'program_row_active' );	
		YAHOO.sun.site.active_tip = 'none';
	}
}

function rollActive(e)
{
	YAHOO.util.Dom.replaceClass(this, 'program_row', 'program_row_over' );
	//alert("roll");
}

function rollInactive(e)
{
	YAHOO.util.Dom.replaceClass(this, 'program_row_over', 'program_row' );
	//alert("roll off");
}


function setupPanel(productId) {
	// this sets up the panel
	YAHOO.sun.site['panel_' + productId] = new YAHOO.widget.Panel("puwin_"+productId,  {
		width:"289px", 
		fixedcenter: false, 
		constraintoviewport: false, 
		underlay: "none", 
		close: true, 
		visible: false, 
		draggable: false,
		effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.15}
	}
	);

	// this renders the panel
	YAHOO.sun.site['panel_' + productId].render();
}


