var gcToggle = "#ffff00";
var gcBG = "#CCCCFF";

var ctlObj = new Object();
var winPopupWindow = new Object(); 
N = (document.all) ? 0 : 1;
 
function IgnoreEvents(e)
{
  return false
}
function HandleFocus()
{
  if (winPopupWindow)
  {
    if (!winPopupWindow.win.closed)
    {
      winPopupWindow.win.focus()
    }
    else
    {
      window.top.releaseEvents (Event.CLICK|Event.FOCUS)
    }
  }
  return false
}

function fPopUpCalendarDlg(ctrlobj)
{
	if(N){
	    showx = 220 ; // + deltaX;
	    showy = 220; // + deltaY;
	}else{
	    showx = event.screenX - event.offsetX - 4 - 210 ; // + deltaX;
	    showy = event.screenY - event.offsetY + 18; // + deltaY;
        }
	newWINwidth = 210 + 4 + 18;
	if(N){
	    window.top.captureEvents (Event.CLICK|Event.FOCUS);
    	    window.top.onclick=IgnoreEvents;
            window.top.onfocus=HandleFocus;
            winPopupWindow.args = ctrlobj;
            winPopupWindow.returnedValue = new Array(); 
            // winPopupWindow.returnFunc = PopupRetFunc;
            winPopupWindow.args = ctrlobj;
	    newWINwidth = 202;
            winPopupWindow.win = window.open("./js/common/calendarDlg.html","CalendarDialog","dependent=yes,left="+showx + ",top=" + showy + ",width="+newWINwidth + ",height=182px" )
            winPopupWindow.win.focus()
            return winPopupWindow;
	}else{
	    retval = window.showModalDialog("./js/common/calendarDlg.html", "", "dialogWidth:197px; dialogHeight:210px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no; "  );
        }
	if( retval != null ){
		ctrlobj.value = retval;
	}else{
		//alert("canceled");
	}
}


function IOFFICE_GetSelected(aCell)
{
	if(document.all){
  		window.returnValue = aCell.innerText;
		window.close();
	}else{
		// alert(opener.winPopupWindow.returnFunc);
		// alert(aCell.innerHTML);
		// alert(aCell.childNodes[0].nodeValue);
		// alert(opener.winPopupWindow.args);
		// alert(opener.winPopupWindow.args.value);
	        opener.winPopupWindow.returnedValue = aCell.childNodes[0].nodeValue;
		opener.winPopupWindow.args.value = trim(aCell.childNodes[0].nodeValue);
		if(opener.winPopupWindow.returnFunc) opener.winPopupWindow.returnFunc();
 		window.close();
	}
  
}


