

function xxxAddOption(selectcontrolname,name,id) {
var objSelect;
var objOptions;
var objOpt;

//   objSelect = eval("window.document.all." + selectcontrolname);
   objSelect = document.getElementById(selectcontrolname);
   objOptions = objSelect.options;
   objOpt = new Option(name,id,false,true);   
   objOptions[objOptions.length] = objOpt;


}


function goToTab(tabno) {
//
// updates the Step value and submits the form.
//
var frm;

   if (bVisitServer == true) {
      //alert("Submitting to " + tabno);
      if (document.forms.IssueForm) {
         document.forms.IssueForm.Step.value = tabno;
         document.forms.IssueForm.submit();
      } else {
         if (document.forms.IssueForm) {
            document.forms.IssueForm.Step.value = tabno;
            document.forms.IssueForm.submit();
         } else {
            if ( document.forms.DIF ) {
              document.forms.DIF.Step.value = tabno;
              document.forms.DIF.submit();
            } else {
              if (document.forms.RAR ) {
                 document.forms.RAR.Step.value = tabno;
                 document.forms.RAR.submit();
              }
            }
         }
      }
   } else {
      // just flip to the tab; no changes have been made
      //alert("Flipping to " + tabno);
      flipToTab(tabno);
   }

}

function flipToTab(tabno) {
//////////////////////////////////////////////////////////////////////////
//
// There are no changes made, so we don't have to submit the form; just flip to the new tab...
// in shell.inc, bChanged is true if something has changed...
//
var tab1,tab2,tab3,tab4
var stepcontrol;
var button1,button2,button3;
var current;
var newlinebutton;

   stepcontrol = document.all.Step;

   tab1 = document.all.DIV_TAB_1;
   tab2 = document.all.DIV_TAB_2;   
   tab3 = document.all.DIV_TAB_3;
   tab4 = document.all.DIV_TAB_4;
   
   newlinebutton = document.all.NEWBUTTON;

   switch (tabno) {
   case 1:
      // going to tab 1, so 
      // turn off 2 and 3, turn on controls for tab 1 and turn the others off
      //
      tab1.style.display='block';
      tab2.style.display='none';
      tab3.style.display='none';
      tab4.style.display='none';
      if (newlinebutton) newlinebutton.style.display='none';
      stepcontrol.value = "1";

      break;
   case 2:
      tab1.style.display='none';
      tab2.style.display='block';
      tab3.style.display='none';
      tab4.style.display='none';
      if (newlinebutton) newlinebutton.style.display='none';

      stepcontrol.value = "2";
      break;
   case 3:
      tab1.style.display='none';
      tab2.style.display='none';
      tab3.style.display='block';
      tab4.style.display='none';
      if (newlinebutton) newlinebutton.style.display='block';

      stepcontrol.value = "3";
      break;

   case 4:
      tab1.style.display='none';
      tab2.style.display='none';
      tab3.style.display='none';
      tab4.style.display='block';
      if (newlinebutton) newlinebutton.style.display='none';

      stepcontrol.value = "4";
      break;
   }     

   current = stepcontrol.value;

   // now make sure that the styles for the tabs (Customer, Header, Line Items) is correct
   // 
   button1 = MakeTabButton("Customer","1",current);
   button2 = MakeTabButton("Header","2",current);
   button3 = MakeTabButton("Details","3",current);
   button4 = MakeTabButton("Comments","4",current);

   document.all.NEXTBUTTON.innerHTML = NextButton(parseInt(current));
   document.all.PREVBUTTON.innerHTML = PrevButton(parseInt(current));

   //
   // also control the visibility of the NextButton and PrevButton
   //
   current = stepcontrol.value;
   if ( current == "1" ) {
      // turn off PREV button
      document.all.PREVBUTTON.style.display = 'none';
      document.all.NEXTBUTTON.style.display = 'block';
   } else {
      document.all.PREVBUTTON.style.display = 'block';
      if (current == "2" || current == "3" ) {
         document.all.PREVBUTTON.style.display = 'block';
         document.all.NEXTBUTTON.style.display = 'block';
      } else {
         // current = "4"
         document.all.PREVBUTTON.style.display = 'block';
         document.all.NEXTBUTTON.style.display = 'none';
      }
   }

   document.all.SUBTABS.innerHTML = "<table cellpadding=0 cellspacing=0 ><tr>" + button1 + button2 + button3 + button4 + "</tr></table>"

}


function NextButton(iStep) {
//'''''''''''''''''''''''''''''''''''''''''''''''''''
//'
//'
//'
var resp;
var buttonname;
var disp;
var s;

   resp = "";

   if (iStep < 3) {  
      disp = "block"; 
   } else { 
     disp = "none"; }

   buttonname = " >> ";

   s = "<input type=button onclick=\"goToTab(" + (iStep+1).toString() + ");\" name=\"" + buttonname + "\" value=\"" + buttonname + "\">";
  // alert(s);

   resp = s;
   
   return resp;

}


function PrevButton(iStep) {
//'''''''''''''''''''''''''''''''''''''''''''''''''''
//'
//'
//'
var resp;
var buttonname;
var disp;
var s;

   resp = "";
   if (iStep > 1) { disp = "block"; } else { disp = "none"; }
   buttonname = " << ";
   s = "<input type=button onclick=\"goToTab(" + (iStep-1).toString() + ");\" name=\"" + buttonname + "\" value=\"" + buttonname + "\">";
//   alert(s);
   resp = resp + s;
   
   return resp;

}

function MakeTabButton(tag,tabno,current)
{
//'''''''''''''''''''''''''''''''''''''''''''''''''
var resp;

   resp = "";

   if ( tabno == current ) {
      resp = resp + "<td class=SUBnavbarbuttonON "
      resp = resp + " onMouseOver=\"style.cursor='hand';style.background='#dddddd';\" "
      resp = resp + " onMouseOut=\"style.background='#dddddd';\" "
      resp = resp + " onclick=\"goToTab(" + tabno + ");\" "
      resp = resp + ">" + tag                                      
      resp = resp + "</td>"
   } else {
      resp = resp + "<td class=SUBnavbarbutton "
      resp = resp + " onMouseOver=\"style.cursor='hand';style.color='green';style.background='#dddddd';\" "
      resp = resp + " onMouseOut=\"style.color='#aaaaaa';style.background='#ffffff';\" "
      resp = resp + " onclick=\"goToTab(" + tabno + ");\" "
      resp = resp + ">" + tag  
      resp = resp + "</td>"
   }

   return resp;
   
} 



