//opera Netscape 6 Netscape 4x Mozilla
if (window.innerWidth || window.innerHeight){
docwidth = window.innerWidth; 
docheight = window.innerHeight; 
} 
//IE Mozilla
if (document.body.clientWidth || document.body.clientHeight){ 
docwidth = document.body.clientWidth; 
docheight = document.body.clientHeight;
}



// POPUP EXAMPLE 1
new popUp(100, 50, 600, 200,
          "WinID1",
          '<br><b>Your browser isn\'t saying files are attached to this form.</b><br><br> ' +
          'Did you remember to drag and drop files onto the form?<br><br><br>' +
           '<center><input type="button" onclick="HandleYesBtn()" value="Yes, The files are attached.">' +
           '<input type="button" onclick="HandleOopsBtn()" value="Oops, Return to the order form"><br>' +
           '<input type="checkbox" onclick="setAttachWarn( this )" style="margin-top:5px" value="off" />Don\'t remind me to attach files again.</center>',
          "white",
          "#00385c",
          "12pt Helvetica",
          "Alert!",
          "#ff0000",
          "white", 
          "lightgrey",
          "#00568c",
          "black", 
          false,
          true,
          false,
          true,
          false, 
          false,
          '/sd/images/min.gif','/sd/images/max.gif','/sd/images/close.gif','/sd/images/resize.gif');

// POPUP EXAMPLE 1
new popUp(100, 50, 200, 200,
          "WinID2",
           '<br><br><br>' +
           '<center>Mode: ' +
           '<select size="1" id="FtpModeSelect" onchange="setFtpXferMode( this )">' +
				   '<option>active</option>' +
				   '<option>passive</option>' +
           '</select>' +
           '</center>',
          "white",
          "#00385c",
          "12pt Helvetica",
          "Set FTP Transfer Mode",
          "#1018CC",
          "white", 
          "lightgrey",
          "#00568c", 
          "black", 
          false,
          true,
          false,
          true,
          false, 
          false,
          '/sd/images/min.gif','/sd/images/max.gif','/sd/images/close.gif','/sd/images/resize.gif');

// POPUP EXAMPLE 1
new popUp(100, 200, 400, 200,
          "FileUpload",
           '<br><br><br>' + '<center>' + 'Please wait....' + '</center>',
          "white",
          "#00385c",
          "12pt Helvetica",
          "Uploading Files",
          "#1018CC",
          "white", 
          "lightgrey",
          "#00568c", 
          "black", 
          false,
          true,
          false,
          true,
          false, 
          false,
          '/sd/images/min.gif','/sd/images/max.gif','/sd/images/close.gif','/sd/images/resize.gif');

function HandleOopsBtn()
{
  fadeboxout( 'WinID1' );
}
function HandleYesBtn()
{
  fadeboxout( 'WinID1' );
  QueuedFiles = true;
  SDOFSubmit();
}
function Require(obForm,szFields)
{
      var fields = szFields.split(",")
      var szMissing= new Array();
      for (x=0;x<fields.length;x++) {
        if (obForm.elements[fields[x]].value.length==0){
           szMissing[szMissing.length]=new String(fields[x]);
        }
      }
      if (szMissing.length) {
        alert("The field"+((szMissing.length>1)?"s ":" ")+szMissing.join(",")+" must be filled in first");
        return false
      }
      return true;
}
// set the value of the sdfromtext field that populates the
// order monitor to give internal staff more input.
function setFromText()
{
	document.OrderForm.sdfromtext.value = document.OrderForm.name.value;
}
// no validation on Exclusive Pickup yet  
// rename this function to FormValid to validate
function FormValid()
{
    if( ! Require( document.OrderForm, "name,company,emailaddr,phone,quantity,datedue,projectname" ) ){
      return false;
      }

    if( document.OrderForm.timedue.selectedIndex == 0 ){
      alert( "Please select a time by which your project needs to be returned!" );
      return false;
      }

    if( document.OrderForm.delivervia.selectedIndex == 0 ){
      alert( "Please select a delivery method!" );
      return false;
      }

    if( document.OrderForm.department.selectedIndex == 0 ){
      alert( "Please select a department!" );
      return false;
      }
    
	setFromText();
  // the form is valid return true
  return true;
}

function setFtpXferMode( oElement )
{
   if( oElement.selectedIndex == 0 ){
     document.getElementById( 'sdftpmode' ).value = 'active';
    }
  else {
    document.getElementById( 'sdftpmode' ).value = 'passive';
    }
}

function showModeSelectDialog()
{

  if( document.getElementById( 'sdftpmode' ).value == 'passive' ){
      document.getElementById( 'FtpModeSelect' ).selectedIndex = 1;
    }
  else{
    document.getElementById( 'FtpModeSelect' ).selectedIndex = 0;
  }
  
  var loc = dpfindPos( document.getElementById('sddroptarget') );
  movePopup( 'WinID2', loc[0] + 50, loc[1] - 220 );
  fadeboxin( 'WinID2' );
}

function setAttachWarn( chkBox )
{
   if( chkBox.checked ){
      document.getElementById( 'sdnoattachwarn' ).value = 'no';
   }
  else{
    document.getElementById( 'sdnoattachwarn' ).value = 'yes';
  }

}

function toggleUpRequired( chkbox )
{

  if( chkbox.checked ){
        document.getElementById( 'sdrequireuploads' ).value = "no";
      }
   else {
         document.getElementById( 'sdrequireuploads' ).value = "yes";
         }
}
