function popup(popup_url, name, width, height, el, offX, offY, hasStatus) {
	//var winl = (screen.width - width) / 4; 
	//var wint = 15; 
	var elDims, objEl, top, left;
	
	if (hasStatus != "yes"){hasStatus = "no";}
	if (el!= undefined)
	{
		objEl = document.getElementById(el)
		//alert(objEl);
		elDims = getDim(objEl);
		//window.alert('x:' + elDims.x + ', y:' + elDims.y + ', sx:' + document.body.scrollLeft + ', wx:' + window.screenLeft + ', ox:' + offX);

		left = elDims.x + objEl.clientWidth + window.screenLeft - document.body.scrollLeft + offX;
		if (left + width > screen.width)
		{
			left = screen.width - width - 11
		}
		if (left < 0)
		{
			left = 0
		}
	
		top = elDims.y + window.screenTop - document.body.scrollTop + offY;
		if (top + height > screen.height)
		{
			top = screen.height - height - 57
		}
		if (top < 0)
		{
			top = 0
		}
	}
  size = 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left;
  newwindow = window.open(popup_url, name, 'resizable=no, menubar=no, location=no, toolbar=no, status=' + hasStatus +', scrollbars=no, directories=no, ' + size);
  newwindow.focus();
  //newwindow.history.go(0); // refreshes if popup was not closed from previous use
}

function popupResize(popup_url, name, width, height, resize, scroll, hasStatus) {
	var winl = (screen.width - width) / 2; 
	var wint = (screen.height - height) / 2;
	if (resize == undefined){resize = 'no';}
	if (scroll == undefined){scroll = 'no';}
	if (hasStatus == undefined){hasStatus = 'no';}
  size = 'width=' + width + ',height=' + height + ',top='+wint+',left='+winl;
  newwindow = window.open(popup_url, name, 'resizable=' + resize + ', menubar=no, location=no, toolbar=no, status=' + hasStatus + ', scrollbars=' + scroll + ', directories=no, ' + size);
  newwindow.focus();
}

function OpenInOpener(sLocation){
  
  if(opener!=null){
    if(!opener.closed){
      //alert('IE & Mozilla open');
      opener.location.href=sLocation;
      opener.focus();
    }
    else{
      //alert('IE Closed');
      window.open(sLocation);
    }
  }
  else if(opener==null){
    //alert('Mozilla Closed');
    window.open(sLocation);
  }
}
function getDim(el){
	for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

function OpenDateTool(strWindowName, elName, offX, offY, blnDateOnly, blnTimeOnly){
	var popup_url, el;
	el = document.getElementById(elName);
	//alert(el);
	//window.alert(el + "; " + el.value + "; " + el.name);
	popup_url = "../DateTool.asp?dt=" + el.value + "&el=" + el.name;
	if (blnDateOnly)
	{
		popup_url+="&type=d"
	}
	else if (blnTimeOnly)
	{
		popup_url+="&type=t"
	}
	popup(popup_url, 'strWindowName' , 196, 380, elName, offX, offY);
}

function popupAlt(popup_url, name, width, height, resize, scroll) {
	var winl = (screen.width - width) / 2; 
	var wint = (screen.height - height) / 2;
	if (resize == undefined){resize = 'no';}
	if (scroll == undefined){scroll = 'no';}
  size = 'width=' + width + ',height=' + height + ',top='+wint+',left='+winl;
  //alert(popup_url+" "+name+" "+width+" "+height+" "+ resize+" "+ scroll)
  newwindow = window.open(popup_url, name, 'resizable=' + resize + ', menubar=no, location=no, toolbar=no, status=no, scrollbars=' + scroll + ', directories=no, dependent=no, ' + size);
	
}

