var popupWindowsByFamily = [];

function closeWin(popupFamily){	
	if (popupWindowsByFamily[popupFamily] != null){
		if(!popupWindowsByFamily[popupFamily].closed)
			popupWindowsByFamily[popupFamily].close();
	}
}

function popUpCWin(url, type, pxWidth, pxHeight, popupFamily) {
	var pxLeft = (screen.availWidth - pxWidth)/2;
	var pxTop = (screen.availHeight - pxHeight)/2;
	return popUpWin(url, type, pxTop, pxLeft, pxWidth, pxHeight, popupFamily);	
}
function popUpWin(url, type, pxTop, pxLeft, pxWidth, pxHeight, popupFamily){
	if( popupFamily!=null && popupFamily != "" ) {
		closeWin(popupFamily);
	}
	
	if (type == "fullScreen"){
		pxWidth = screen.availWidth - 10;
		pxHeight = screen.availHeight - 160;
		pxTop=0;
		pxLeft=0;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+pxWidth+",height="+pxHeight+",top="+pxTop+",left="+pxLeft;
	if (type == "scroll-console") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+pxWidth+",height="+pxHeight+",top="+pxTop+",left="+pxLeft;
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+pxWidth+",height="+pxHeight+",top="+pxTop+",left="+pxLeft;
	var newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
	
	if( popupFamily!=null && popupFamily != "" ) {
		popupWindowsByFamily[popupFamily] = newWindow;
	}
	return false; // used so that onclick can return this value and suppress the link
}


/**
 * cross browser function to ADD an event callback to an element
 * very useful for adding stuff to window.onload without harming existing callbacks
 **/
function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    //alert("Handler could not be attached");
  }
} 

/**
 * cross browser function to REMOVE an event callback from an element
 * reverses the effect of addEvent
 **/
function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    //alert("Handler could not be removed");
  }
} 

// JavaScript Document