// Global for brower version branching.
var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
var undefined;
// One object tracks the current modal childWin opened from this window.
var childFSWin = new Object()


function jsOpenChildWin(sContentURL, sWinTitle, nWidth, nHeight, sScreenLoc, sBtns, sWinAttrs, oRetFunc) { 
	var sURL = "ChildWinFS.aspx";
	if (sWinTitle  != undefined) sURL += "?windowname=" + sWinTitle;
	if (nWidth     == undefined) nWidth = 500;
	if (nHeight    == undefined) nHeight  = 650;
	if (sScreenLoc == undefined) sScreenLoc   = "ul"; //upper-left
	if (sWinAttrs  == undefined) sWinAttrs = " resizable";
	if (oRetFunc   == undefined) oRetFunc = jsRetChildWin;
	if (sBtns      == undefined) sBtns = "<INPUT TYPE='button' VALUE='Close' CLASS='cRegButtons' onClick='parent.jsCloseCancel()'>&nbsp;";
	sContentHTML = "";
	var sButtonHTML = '<SPAN style="width:100%;" class="cDataEntryR" >';
	sButtonHTML	   +=  sBtns
	sButtonHTML    += '</SPAN>';
	var sArgs       = jsSetParamStr("OpenStr", "?", sKeySep, sValSep);
	sArgs          += jsSetParamStr("PairSep", "=", sKeySep, sValSep);
	sArgs          += jsSetParamStr("GroupSep", "&", sKeySep, sValSep);
	jsOpenChildFS(sURL,nWidth,nHeight,oRetFunc,sContentHTML,sContentURL,sButtonHTML,sArgs,sScreenLoc,sWinAttrs); 
} //jsOpenChildWin
	
function jsRetChildWin() {
	var sRetVal  = dialogWin.returnedValue.substr(1);
	var sReturn  = "";
	var sTmpInr  = String.fromCharCode(61); //special separator used by modaldialog window instead of sKeySep
	var sTmpOutr = String.fromCharCode(38); //special separator used by modaldialog window instead of sValSep
	if(sRetVal!=null && sRetVal != ""){
	}
} //jsRetChildWin()


// Generate a child window.
// Parameters:
//    url -- URL of the page/frameset to be loaded into childWin
//    width -- pixel width of the childWin window
//    height -- pixel height of the childWin window
//    returnFunc -- reference to the function (on this page)
//                  that is to act on the data returned from the childWin
//    contentHTML -- [optional] content for childWin window
//    contentURL  -- [optional] URL for content section of childWin window
//    buttonHTML  -- [optional] HTML for childWin window buttons
//    args -- [optional] any data you need to pass to the childWin
//    screenLoc -- [optional] position on screen for window
//    windowAttrs -- [optional] window attributes (other than height, width, and screen location) 
//    defaultFunc - [optional] reference to function with default behavior
function jsOpenChildFS(url, width, height, returnFunc, contentHTML, contentURL, buttonHTML, args, screenLoc, windowAttrs, defaultFunc) {
	/*
	window.alert("Parameters:"
   + "\nurl = " + url
   + "\nwidth = " + width
   + "\nheight = " + height
   + "\nreturnFunc  = " + returnFunc
   + "\ncontentHTML  = " + contentHTML
   + "\nbuttonHTML  = " + buttonHTML
   + "\nargs  = " + args
   + "\nwindowAttrs  = " + windowAttrs
   + "\nscreenLoc  = " + screenLoc
   + "\ndefaultFunc  = " + defaultFunc
	);
	*/
  if (!childFSWin.win || (childFSWin.win && childFSWin.win.closed)) {
    // Initialize properties of the modal childWin object.
    childFSWin.returnFunc    = returnFunc;
    childFSWin.defaultFunc   = defaultFunc;
    childFSWin.returnedValue = "";
    childFSWin.contentHTML   = contentHTML;
    childFSWin.contentURL    = contentURL;
    childFSWin.buttonHTML    = buttonHTML;
    childFSWin.args          = args;
    childFSWin.windowAttrs   = windowAttrs;
    childFSWin.url           = url;
    childFSWin.width         = width;
    childFSWin.height        = height;
    childFSWin.name          = (new Date()).getSeconds().toString(); //create unique name
    if (screenLoc == "" || screenLoc == undefined) screenLoc = "center";
    screenLoc = screenLoc.toLowerCase();
    switch (screenLoc) {
			case "ul":
				childFSWin.left = 5;
				childFSWin.top  = 5;
			break;
			case "um":
			  childFSWin.left = Nav4? window.screenX + ((window.outerWidth - childFSWin.width) / 2): ((screen.width - childFSWin.width) / 2);
			  childFSWin.top  = 5;
			break;
			case "ur":
				childFSWin.left = Nav4? window.screenX + (window.outerWidth - childFSWin.width) : (screen.width - childFSWin.width);
				childFSWin.left -= 10;
				childFSWin.top  = 5;
			break;
			case "cl":
				childFSWin.left = 5;
				childFSWin.top  = Nav4? window.screenY + ((window.outerHeight - childFSWin.height) / 2): ((screen.height - childFSWin.height) / 2);
			break;
			case "cr":
				childFSWin.left = Nav4? window.screenX + (window.outerWidth - childFSWin.width) : (screen.width - childFSWin.width);
				childFSWin.left -= 10;
				childFSWin.top  = Nav4? window.screenY + ((window.outerHeight - childFSWin.height) / 2): ((screen.height - childFSWin.height) / 2);
			break;
			case "ll":
				childFSWin.left  = 5;
				childFSWin.top   = Nav4? window.screenY + (window.outerHeight - childFSWin.height) : (screen.height - childFSWin.height);
				childFSWin.top  -= 50;
			break;
			case "lm":
				childFSWin.left = Nav4? childFSWin.left = window.screenX + ((window.outerWidth - childFSWin.width) / 2): ((screen.width - childFSWin.width) / 2);
				childFSWin.top  = Nav4? window.screenY + (window.outerHeight - childFSWin.height) : (screen.height - childFSWin.height);
				childFSWin.top  -= 50;
			break;
			case "lr":
				childFSWin.left = Nav4? window.screenX + (window.outerWidth - childFSWin.width) : (screen.width - childFSWin.width);
				childFSWin.left -= 10;
				childFSWin.top  = Nav4? window.screenY + (window.outerHeight - childFSWin.height) : (screen.height - childFSWin.height);
				childFSWin.top  -= 50;
			break;
			default: //case "center":
				childFSWin.left = Nav4? childFSWin.left = window.screenX + ((window.outerWidth - childFSWin.width) / 2): ((screen.width - childFSWin.width) / 2);
				childFSWin.top  = Nav4? window.screenY + ((window.outerHeight - childFSWin.height) / 2): ((screen.height - childFSWin.height) / 2);
				childFSWin.top  -= 50;
			break;
    } //switch
    childFSWin.left = parseInt(childFSWin.left);
    childFSWin.top  = parseInt(childFSWin.top);
    // Assemble window attributes and position the dialog.
    if (Nav4) {
      var attr = "screenX=" + childFSWin.left + ",screenY=" + childFSWin.top + ",width=" + childFSWin.width + ",height=" + childFSWin.height;
      if (childFSWin.windowAttrs != undefined) {
        attr += "," + childFSWin.windowAttrs;
      }
    } else {
      var attr = "left=" + childFSWin.left + ",top=" + childFSWin.top + ",width=" + childFSWin.width + ",height=" + childFSWin.height;
      if (childFSWin.windowAttrs != undefined) {
        attr += "," + childFSWin.windowAttrs;
      }
    }
    // Generate the childWin and make sure it has focus.
    childFSWin.win=window.open(childFSWin.url, childFSWin.name, attr)
    childFSWin.win.focus()
  } else {
    if (childFSWin.url != url || childFSWin.contentHTML != contentHTML || childFSWin.contentURL != contentURL) {
			childFSWin.returnFunc    = returnFunc;
			childFSWin.defaultFunc   = defaultFunc;
			childFSWin.returnedValue = "";
			childFSWin.contentHTML   = contentHTML;
			childFSWin.contentURL    = contentURL;
			childFSWin.buttonHTML    = buttonHTML;
			childFSWin.url           = url;
			childFSWin.win.location  = childFSWin.url;
    } 
    childFSWin.win.focus();
  }
	//Hide the busyBox if necessary
	if (busyBox != null) { window.setTimeout(function(){busyBox.Hide()}, 500); }
} //jsOpenChildFS


      // Generic function converts form element name-value pairs
      // into a URL search string.
      function jsParseReturn(form) {
        var sRetOpenStr;
        var sPairSep;
        var sGroupSep;

        if (top.opener && !top.opener.closed) {
          var sArgs       = top.opener.childFSWin.args;
          if ( sArgs == undefined ) {
            sArgs = "";
          }
          var sRetOpenStr = jsGetParamStr("OpenStr", sArgs, sKeySep, sValSep);
          var sPairSep    = jsGetParamStr("PairSep", sArgs, sKeySep, sValSep);
          var sGroupSep   = jsGetParamStr("GroupSep", sArgs, sKeySep, sValSep);

        }
        if (sRetOpenStr == "" || sRetOpenStr == undefined) sRetOpenStr = "?";
        if (sPairSep    == "" || sPairSep    == undefined) sPairSep    = "=";
        if (sGroupSep   == "" || sGroupSep   == undefined) sGroupSep   = "&";
        var sReturn = sRetOpenStr;
        var onePair;
        // Harvest values for each type of form element
        for (var i = 0; i < form.elements.length; i++) {
          if (sReturn != sRetOpenStr) sReturn += sGroupSep;
					if (form.elements[i].type == "text") {
            onePair  = escape(form.elements[i].name) + sPairSep;
            onePair += escape(form.elements[i].value);
          } else if (form.elements[i].type == "hidden" &&
						form.elements[i].name.substr(0,2) != "__") 
          { //06/13/02 new option
            onePair  = escape(form.elements[i].name) + sPairSep;
	          onePair += escape(form.elements[i].value);
          } else if (form.elements[i].type.indexOf("select") != -1) {
            onePair  = escape(form.elements[i].name) + sPairSep;
            onePair += escape(form.elements[i].options[form.elements[i].selectedIndex].value);
            } else if (form.elements[i].type == "radio") {
            onePair  = escape(form.elements[i].name) + sPairSep;
            onePair += escape(form.elements[i].value);
          } else if (form.elements[i].type == "checkbox") {
            onePair  = escape(form.elements[i].name) + sPairSep;
            onePair += escape(form.elements[i].value);
          } else continue
          sReturn += onePair; // + "&";
        }
        return sReturn
      }  //jsParseReturn

      function jsGetContent() {
        var sContent = "";
        if (top.opener && !top.opener.closed) {
          sContent = top.opener.childFSWin.contentHTML;
        }
        if (sContent == "") {
          sContent = "Sorry, browser passed no data to child window.";
        }
        return sContent;
      } //jsGetContent

      // Send gathered data to the childWin window object's returnedValue property
      function jsTransferData() {
        if (top.opener && !top.opener.closed) {
					var retVal = jsParseReturn(document.forms[0]);
          top.opener.childFSWin.returnedValue = retVal;
        }
      } //jsTransferData

//-----frameset functions
      function jsCloseWin() {
      //  if ( typeof opener.childFSWin.defaultFunc != undefined) {
       //   opener.childFSWin.defaultFunc();
     //   }
        window.close();
      } //jsCloseWin()
      
      function jsRefreshParent() {
        top.cFSwBody.jsTransferData();
        if ( typeof top.opener.childFSWin.returnFunc != undefined) {
          top.opener.childFSWin.returnFunc();
        }
      } //jsRefresh

      // Handle click of OK button
      function jsCloseOK() {
        if (opener && !opener.closed) {
					jsRefreshParent();
        } else {
          window.alert("You have closed the main window.\n\nNo action will be taken on the choices in this child box.");
        }
        jsCloseWin();
        return false;
      } //jsCloseOK

      // Handle click of Cancel button
      function jsCloseCancel() {
        jsCloseWin();
        return false;
      } //jsCloseCancel

       function jsGetFrameContent(sButtonHeight) {
        var sReturn = "";
        if (sButtonHeight == undefined) {
					nButtonHeight = 35;
				} else {
					nButtonHeight = sButtonHeight - 0;
				}
        sReturn    += '<FRAMESET FRAMEBORDER=no FRAMESPACING=0 ROWS="*,' + nButtonHeight + '" BORDER=0 ';
        //sReturn    += ' onLoad="if (opener) opener.blockEvents()" onUnload="if (opener) opener.unblockEvents()"';
        sReturn    += '>';
        sReturn    += '<FRAME NAME="cFSwBody" ID="cFSwBody"    SRC="';
        var sURL    = "";
        if (top.opener && !top.opener.closed)  sURL = top.opener.childFSWin.contentURL;
        if (sURL   == "" || sURL == undefined) sURL = "ChildWinContent.aspx";
        sReturn    +=  sURL + '" FRAMEBORDER=no>';
        sReturn    += '<FRAME NAME="cFSwButtons" ID="cFSwButtons" SRC="ChildWinButtons.aspx" FRAMEBORDER=no SCROLLING=no>';
        sReturn    += '</FRAMESET>';
        return sReturn;
      } //jsGetFrameContent

      /**
       * jsGetButtons returns an HTML string to make the button bar
       *
       * <br><br>
       * @author Robert E. Hoch <br>
       * @version January 26, 2002 <br>
       * @param   none<br>
       * @return  <B>sReturn</B> <I>String</I> HTML String to make the buttons for childWin window.<br>
       */
      function jsGetButtons( ) {
        var sReturn = "";
        if (top.opener && !top.opener.closed) sReturn = top.opener.childFSWin.buttonHTML;
        if ( sReturn == "" || sReturn == undefined) {
					//default buttons
					sReturn  = '<SPAN style="width:100%; text-align:right; vertical-align:center;" >';
          sReturn += '<INPUT TYPE="button" VALUE="Cancel" onClick="parent.jsCloseCancel()">';
          sReturn += '&nbsp;';
          sReturn += '<INPUT TYPE="button" VALUE="&nbsp;&nbsp;OK&nbsp;&nbsp;" onClick="parent.jsCloseOK()">';
          sReturn += '&nbsp;';
          sReturn += '</SPAN>';
        }
        return sReturn;
      }  // jsGetButtons
      
      function jsSubmit(jsForm) {
        document.forms[0].submit();
      } //jsSubmit


