//
// openGISWindow
//
// Last Revision: 2008/11/07
//
// Defines the function to be used for opening the GIS window in BISON-M.
//

function openGISWindow(sSpeciesID) {
	var sLocation;

	// if the window is already open, give it focus
	
	if (wGIS && !wGIS.closed) {
		UpdateGIS(sSpeciesID);
	} else {
		// open the GIS window
		//alert('about to open the GIS window');
		wGIS = window.open('bisongis.aspx?SpeciesID=' + sSpeciesID,'GISwin','width=1015,height=690,resizable=yes,scrollbars=yes,location=yes');
	}
	
	// give the window focus
	wGIS.focus();
	
	return false;
}

function UpdateGIS(sSpeciesID) {
	//alert('booklet is already open');
	// is the proper species loaded, or is it a different species?
	sLocation = wGIS.location.href;
	var sKey = "SpeciesID=";
	var iStart = sLocation.indexOf(sKey) + sKey.length;
	var sGISSpeciesID = sLocation.substr(iStart, 6);
	if (sGISSpeciesID != sSpeciesID) {
		// species is different, reload the booklet
		sLocation = 'bisongis.aspx?SpeciesID=' + sSpeciesID;
		wGIS.location.assign(sLocation);
	}
}

function syncGISWindowHandles() {
	wGIS.wBooklet = wBooklet;
}

