    // JScript File
    var popUp; 
    var pUrl;

    function OpenCalendar(idname, postBack)
    {
        popUp = window.open(vRootPath + '/Controls/Common/PopUpCalendar/CalendarPage.aspx?id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		    'popupcal', 
		    'width=180,height=270,left=200,top=250');
    }

    function SetDate(formName, id, newDate, postBack)
    {
	    eval('var theform = document.forms[0];');
	    popUp.close();
	    theform.elements[id].value = newDate;
	    if (postBack)
		    __doPostBack(id,'');
    }		

    function ClearDate(id)
    {
         eval('var theform = document.forms[0];');
	     theform.elements[id].value = "";
    }


    function GetInfo(sPopupFile, bDoPostBack, sBackParams)
    {   
        window.event.returnValue=false;
        window.event.cancelBubble=true;
        ChildWindow = window.open(sPopupFile + '?Mode=1&fct=RetFct&backparam=' + bDoPostBack + ";" + sBackParams, "PopUp", "width=300,height=400,top=200,left=200,toolbars=no,scrollbars=auto,status=auto,resizable=no");   
        return false;
    }  
     
    function RetFct(rId, sText, sBackParams)
    {
        var params = sBackParams.split(";");
        document.forms[0].elements[params[1]].value = sText;
        document.forms[0].elements[params[1] + "H"].value = rId;
        if(params[0] == true)
        {
            __doPostBack(params[0] + "H", rId);
        }
    }    
    
    function OpenTeam(id)
    {
        var varW = (screen.availWidth * .75) ;
        var varH = (screen.availHeight * .75);
        var sUrl = vRootPath + '/Team.aspx?id=' + id;
        openNewWin2(0,1,0,1,0,1,varW,varH,sUrl);
    }
  
    function GetOpenerFunction(ReturnSenderControlId)
    {        
        var controlName = new String(ReturnSenderControlId);
        var functionName = new String();

        if (controlName.indexOf('LookupTeamsControl', 1) > 0)
            functionName = "OpenTeam";
        else 
            functionName = "OpenParticipant";     
                
        return functionName;
    }

    function GetParticipant(CtrlName, CurrValue, sFolder, bDoPostBack)
    {   
        window.event.returnValue=false;
        window.event.cancelBubble=true;
        ChildWindow = window.open(vRootPath + '/Pages/Participants/SelectParticipantsPopup.aspx?Mode=1&fct=RetFct&backparam=' + CtrlName + ";" + bDoPostBack, "PopUpCalendar", "width=300,height=600,top=200,left=200,toolbars=no,scrollbars=yes,status=auto,resizable=no");   
        return false;
    }     
    
    function OpenParticipant(id)
    {
        var varW = (screen.availWidth * .75) ;
        var varH = (screen.availHeight * .75);
        var sUrl = vRootPath + '/Pages/Administration/Participants/EditParticipants.aspx?id=' + id;
        openNewWin2(0,1,0,1,0,1,varW,varH,sUrl);
    }
      
    function RetFct(rId, sText, sBackParams)
    {
        var params = sBackParams.split(";");
        document.forms[0].elements[params[0]].value = sText;
        document.forms[0].elements[params[0] + "H"].value = rId;
        if(params[1] == true)
        {
            __doPostBack(params[0] + "H", rId);
        }
    }

    function CheckWindow()   {      ChildWindow.close();   }
    function CloseWindow()   {      window.close();   }

    var g_flagIsOpened = false;
  	var g_objWin       = null;
 
    //****************************************************************************************
   //***   OPENS A NEW WINDOW WITH SPECIFIC SIZE AND OPTIONS                              ***
   //****************************************************************************************
   function openNewWin(opTool,opStat,opMenu,opScroll,opLoc,opResiz,varLeft,varTop,varW,varH,varsite)
   {
      try
      {
         options = "toolbar="+ opTool +",status="+ opStat +",menubar="+ opMenu +",scrollbars="+ opScroll +",location="+ opLoc + ",resizable="+ opResiz +",left=" + varLeft + ",top=" + varTop + ",width="+ varW +",height="+ varH;
	     myWindow = window.open("", "", options);
         myWindow.location.href = varsite;
      }
      catch(e)
      {
      }
   }

   function openNewWin2(opTool,opStat,opMenu,opScroll,opLoc,opResiz,varW,varH,varsite)
   {
       try
       {
          options = "toolbar="+ opTool +",status="+ opStat +",menubar="+ opMenu +",scrollbars="+ opScroll +",location="+ opLoc + ",resizable="+ opResiz + ",width="+ varW +",height="+ varH;
	      myWindow = window.open(varsite, "", options);
       }
       catch(e)
       {
       }
    }

     //****************************************************************************************
	 //***   OPENS HELP PAGE                                                                ***
	 //****************************************************************************************
    function openHelp(l_strFile)
    {
        var l_strMainWinWidth = 0;
        var l_strHelpWinWidth = 0;
        var screenW = 640, screenH = 480;

        if ((!(g_flagIsOpened)) &&  (g_objWin == null))
        {
           if (parseInt(navigator.appVersion)>3)
          {
             screenW = screen.width;
             screenH = screen.height;
          }
          else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled())
          {
             var jToolkit = java.awt.Toolkit.getDefaultToolkit();
             var jScreenSize = jToolkit.getScreenSize();
             screenW = jScreenSize.width;
             screenH = jScreenSize.height;
          }
          l_strMainWinWidth = (screenW*80)/100;
          l_strHelpWinWidth = (screenW*20)/100;
          window.moveTo(0,0);
          window.resizeTo(l_strMainWinWidth,(screenH-15));
          g_objWin = openNewWin(0,0,0,1,0,1,(l_strMainWinWidth),0,(l_strHelpWinWidth-10),(screenH-25),vRootPath + l_strFile);
          g_flagIsOpened = true;
        }    
    }


function DoClick(searchBoxId, valueBoxId, popupUrl, bReturn)
{
    var ie = document.all;  
    var retValues;   
           
    var currentControl;     
    currentControl = window.document.getElementById(searchBoxId);
   
    if(!currentControl)
    {
        alert('Unable to locate text control.');
        return false;
    }
    
    var sFinalUrl = popupUrl;
    var retValue = new String();
    sFinalUrl = sFinalUrl + '?currentId=' + encodeURI(currentControl.value)+ '&textTargetId=' + searchBoxId + '&valueTargetId=' + valueBoxId;
    var thedate = new Date();
    var theyear = thedate.getYear();
    var themonth = thedate.getMonth() + 1;
    var theday = thedate.getDate();
    var theHours = thedate.getHours();
    var theMinutes = thedate.getMinutes();
    var theSeconds = thedate.getSeconds() ;
    var currenttime = themonth + '/' + theday + '/' + theyear + ' ' + theHours + ':' + theMinutes + ':' + theSeconds; 
    sFinalUrl = sFinalUrl + '&currentTime=' + encodeURI(currenttime);
    
    if (window.showModalDialog) 
    { 
        var sFeatures = "resizable:0;status:0;help:0;scroll:0;dialogWidth:370px;dialogHeight:380px"
        retValue = window.showModalDialog(sFinalUrl, window, sFeatures);
    }
    else
    {
        var sFeatures = "height=380,width=370,resizable=yes,modal=yes";
        retValue = window.open(sFinalUrl, window, sFeatures);               
    }                
        
    if ((retValue != null) && (window.showModalDialog))
    {
        var valueControl = window.document.getElementById(valueBoxId);                
        retValues = retValue.split("@@@");  
      
        currentControl.innerHTML = retValues[1];        
        valueControl.value = retValues;//retValues[0];       
        currentControl.href="javascript:" + GetOpenerFunction(searchBoxId) + "(" + retValues[0] + ");";      
       
        var returnValuesHiddenField = window.document.getElementById(retValues[2]);
        returnValuesHiddenField.value = retValues[0] + '@@@' + retValues[1];
        
        return bReturn;
    }
    
    return false;
}

function DoClickAutoAdd(valueBoxId, popupUrl, bReturn)
{
    var sFinalUrl = popupUrl;
    var retValue = new String();
    sFinalUrl = sFinalUrl + '?valueTargetId=' + valueBoxId;
    var thedate = new Date( );
    var theyear = thedate.getYear( );
    var themonth = thedate.getMonth( ) + 1;
    var theday = thedate.getDate( );
    var theHours = thedate.getHours( );
    var theMinutes = thedate.getMinutes( );
    var theSeconds = thedate.getSeconds( ) ;
    var currenttime = themonth + '/' + theday + '/' + theyear + ' ' + theHours + ':' + theMinutes + ':' + theSeconds; 
    sFinalUrl = sFinalUrl + '&currentTime=' + encodeURI(currenttime);
    var sFeatures = "resizable:0;status:0;help:0;scroll:0;dialogWidth:370px;dialogHeight:380px"
    retValue = window.showModalDialog(sFinalUrl, window, sFeatures);
    if(retValue != null)
    {
        var retValues;
        var valueControl = window.document.all[valueBoxId];
        retValues = retValue.split("@@@");
        valueControl.value = retValues[0];
        return bReturn;
    }
    else
    {
        return false;
    }
}

function UpdateLink(searchBoxId, valueBoxId, linkUrl)
{
    var currentControl = window.document.all[searchBoxId];
    var valueControl = window.document.all[valueBoxId];
    if(!currentControl)
    {
        alert('Unable to locate text control.');
        return;
    }
    var sFinalUrl = linkUrl.replace('{0}', valueControl.value);
    currentControl.href=sFinalUrl;
}


function ReturnLookup(ReturnValue, ReturnText, ReturnSenderControlId, ReturnHiddenValuesControlId)
{   
    if (window.showModalDialog)
    {            
        window.returnValue = ReturnValue + '@@@' + ReturnText + '@@@' + ReturnHiddenValuesControlId;                  
        window.close();
    }
    else
    {
        if ((window.opener != null) && (!window.opener.closed)) 
        {               
            window.opener.document.getElementById(ReturnHiddenValuesControlId).value = ReturnValue + '@@@' + ReturnText + '@@@' + ReturnHiddenValuesControlId;
            window.opener.document.getElementById(ReturnSenderControlId).value = ReturnValue + '@@@' + ReturnText; 
            window.opener.document.getElementById(ReturnSenderControlId).innerHTML = ReturnText; 
            window.opener.document.getElementById(ReturnSenderControlId).href = "javascript:" + GetOpenerFunction(ReturnSenderControlId) + "(" + ReturnValue + ");"; 
        }
          
        window.close();
    }    
}


function autoRefresh()
{
    document.forms[0].submit();
}
