/*
 * gsd.js     ($Id: gsd.js 69 2008-05-17 21:42:55Z rhaft $)
 *
 * This file contains the common Javascript library for the
 * Metro Ethernet Forum Global Services Directory.
 *
 * $Rev: 69 $
 * $Date: 2008-05-17 14:42:55 -0700 (Sat, 17 May 2008) $
 * $HeadURL: http://dexter/svn/mefgsd/trunk/gsd/templates/gsd.js $
 * $Author: rhaft $
 *
 */

// base dir
var gsd_baseDir = "gsd/";
// global window
var provListWind = null;
// define the offsets from the current window for newly created sub-windows
var winXOffset = 10;
var winYOffset = 10;

function citySelected(event_str, id_str) {
	GSD_closeWin(provListWind);
	url = gsd_baseDir + "provlist.php?" + "i=" + id_str;
	var woptions = newWinLocation() + ",height=500,width=630,resizable,toolbar,scrollbars";
	provListWind = window.open(url, "subWindow", woptions);
}

function getSelectedButton(buttonGroup) {
	for (var i = 0; i < buttonGroup.length; i++) {
		if (buttonGroup[i].checked)
			return i;
	}
	return 0;
}

function showProvInfo(form) {
	var i = getSelectedButton(form.rad_showall);
	var selectedSvc = form.rad_showall[i].value;
	var provSelector = document.getElementById("selProv");
	var provID = provSelector.options[provSelector.selectedIndex].value;
	if (selectedSvc == "locs")
		url = gsd_baseDir + "svclocsvc.php?" + "p=" + provID;
	else
		url = gsd_baseDir + "provinfo.php?" + "p=" + provID;
	GSD_closeWin(provListWind);
	var woptions = newWinLocation() + ",height=500,width=750,resizable,toolbar,scrollbars";
	provListWind = window.open(url, "subWindow", woptions);
}

function newWinLocation() {
	var newWinX = EE_Lib.winX() + winXOffset;
	var newWinY = EE_Lib.winY() + winYOffset
	return "left=" +  newWinX + ",top=" + newWinY;
}

function GSD_closeWin(win) {
	if (win && !win.closed)
		win.close();
}

function GSD_setBaseDir(dir) {
	gsd_baseDir = dir;
}
/* -------- end of gsd.js ---------- */
