/*
=======================================================================================
NOTES
---------
This file used as part of the homepagelist section of site (project/senearthco/homepage/)

=======================================================================================
*/

YAHOO.namespace("sec.homepagelist.associations_list");

var _ns = YAHOO.sec.homepagelist.associations_list;
/*
=======================================================================================
MAIN FUNCTIONS
=======================================================================================
*/

_ns.Pop_Window = function(e) {
	
	// get the selected value from the association select box
	var oForm = YAHOO.util.Event.getTarget(e).form;
	var oSelectBox = document.getElementsByName('associations')[0];
	var selectedAssociationURL = oSelectBox[oSelectBox.selectedIndex].value;
	
	// params
	sUrl = selectedAssociationURL;
	var query_string = selectedAssociationURL;
	var urlKey = query_string.split('&')[2].split('=')[1];
	if(!sConfig) var sConfig;
	if(!sName) var sName = urlKey; //this will mean we popup one for each association
	
	if (sConfig == null) {
		sConfig = 'width=850,height=600,toolbar=no,scrollbars=yes,resizable,menubar=no,status=no,directories=no,location=no';
	}
	
	YAHOO.sec.gui.oWin = window.open(sUrl, sName, sConfig);

	var notice = 'Unable to launch popup window, please allow popups for senearthco.com and try again.';
	if (YAHOO.sec.gui.oWin == null || typeof(YAHOO.sec.gui.oWin) == 'undefined')
	{
		if (ShowAlert)
		{
			if (!YAHOO.sec.gui.noticeBox)
			{
				alert(notice);		
			}
			else
			{
				YAHOO.sec.gui.addNotice(notice);
			}		
		}
	}
	
	return YAHOO.sec.gui.oWin;
}

/*
=======================================================================================
START PAGE LOADING FUNCTIONS
=======================================================================================
*/
_ns.Page_Load = function(e) {
	
	//-----------------------------------------------------------
	// on initial load, do the first page load to make sure the 
	// quick view tab is being displayed by default.
	//-----------------------------------------------------------
	var oSubmitBtn = document.getElementById('submitBtn');
	
	//-----------------------------------------------------------
	// Resize the tabs' div container to be the correct size
	//-----------------------------------------------------------
	YAHOO.util.Event.addListener(oSubmitBtn, 'click', _ns.Pop_Window );
}

/*
=======================================================================================
WIRE UP THE PAGE
=======================================================================================
*/
YAHOO.util.Event.onDOMReady( _ns.Page_Load );