// 
// topbar.js 
//
browser = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 3 )))

if (browser) {
	var images_dir = '/images/';
	var button_dir = (images_dir + "button/");
	var bar_dir = (images_dir + "bar/");

}
	
function makeWin(url) {
	makeWin(url, 400, 600);	  
}

function makeWin(url, width, height ) {
	openWin(url, "Sitelet", width, height, 0);
}

function makeWin(url, width, height, menubarEnable ) {
	openWin(url, "Sitelet", width, height, menubarEnable);
}

function openWin( url, name, width, height ) {
	openWin( url, name, width, height, 0);
}

function openWin( url, name, width, height, menubarEnable ) {

	var agent = navigator.userAgent;
	var params = "";
	var windowName = name; 

	params += "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=0,";
	params += "menubar=" + menubarEnable + ",";
	params += "scrollbars=1,";
	params += "resizable=1,";
	params += "width=" + width + ",";
	params += "height=" + height;
	   
	win = window.open(url, windowName, params);
	
	if ( agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) {
		win = window.open(url, windowName, params);
	}
     	if (!win.opener) {
	          win.opener = window;
	}			

}

  
function showLocalDoc(url, width, height) {
	targetUrl = "http://" + window.location.host + url;
	makeWin(targetUrl, width, height);   
}
  
function showGlossary(anchor) {
	baseUrl = "http://" + window.location.host;
	if (anchor == null) 
		glossaryUrl = baseUrl + "/education/glossary.html";
	else
		glossaryUrl = baseUrl + "/education/glossary.html#" + anchor;
	makeWin(glossaryUrl, 500, 350);
}  
	
function showDemo(url) {
	showLocalDoc(url, 640, 475);
}

// open a secure/unsecure link
function openSecureLink(url, security) {
	if (security == "secured") {
		protocol = "https";
	}
	else {
		protocol = "http";
	}
	targetUrl = protocol + "://" + document.location.host + url + "?security=" + security;
	document.location = targetUrl;
}

// for login/register
function compItem (name, width, height) {
  this.on = new Image();
  this.on.src = button_dir + name + 'on.gif'
  this.off = new Image();
  this.off.src = button_dir + name + 'off.gif'
}

function comp_new (name) {
  compItem[name] = new compItem(name);
}

function img_act (imgName) {
  if (document.images) document[imgName].src = compItem[imgName].on.src;
}

function img_inact (imgName) {
  if (document.images) document [imgName].src = compItem[imgName].off.src;
}

function load_comp (name, num) {
  for (i = 1; i <= num; i++) comp_new(name + i);
}

if (document.images) {
	comp_new('login1');
	comp_new('signup2');
	comp_new('logoff3');
}
