//Form Error Checking// (From Old Site //
function ValidateForm(form) 
{
   if ( form.LastName.value == "" )
   {
      alert("Last Name is required");
      form.LastName.focus();
      return false;
   }

   if ( form.FirstName.value == "" )
   {
      alert("First Name is required");
      form.FirstName.focus();
      return false;
   }

   if ( form.Address1.value == "" )
   {
      alert("Address is required");
      form.Address1.focus();
      return false;
   }

   if ( form.City.value == "" )
   {
      alert("City is required");
      form.City.focus();
      return false;
   }

   if ( form.PostalCode.value == "" )
   {
      alert("Postal Code is required");
      form.PostalCode.focus();
      return false;
   }

   form.submit();
   return true;
}

// erooms form checking
function checkFormAV (form) {
   if ( form.reg_choice_1.value == "" )
   {
      alert("Room Number field is required");
      return;
   }

  document.form.is_special_request.value = 'no';
  document.form.subject.value = 'Class Application';
  document.form.specialty.value = '';

  // If the instructor's name field is blank, mark as special
  if(form.iname.value == '') {
     document.form.is_special_request.value = 'yes';
     document.form.subject.value = 'Special Class Application';
     document.form.specialty.value += 'Instructor name is blank\n';
  }

  // If the course number field is blank, mark as special
  if(form.courseno.value == '') {
     document.form.is_special_request.value = 'yes';
     document.form.subject.value = 'Special Class Application';
     document.form.specialty.value += 'Course number field is blank\n';
  }

  // If inidividual session was selected, mark as special
  if(form.meeting_type[1].checked) {
     document.form.is_special_request.value = 'yes';
     document.form.subject.value = 'Special Class Application';
     document.form.specialty.value += 'Appointment is an individual session\n';
  }  

  // If the class meets regularly, but is scheduled to begin
  // earlier than 8am, mark as special
  if(form.meeting_type[0].checked && 
     form.reg_sched_begin_ampm.options[0].selected && 
     eval(form.reg_sched_begin_h.value) < 8) 
  {
     document.form.is_special_request.value = 'yes';
     document.form.subject.value = 'Special Class Application';
     document.form.specialty.value += 'Appointment begins before 8am\n';
  }

  // If the request is for an individual session, but is scheduled
  // to begin earlier than 8am, mark as special
  if (form.meeting_type[1].checked && 
      form.ind_session_begin_ampm.options[0].selected && 
      eval(form.ind_session_begin_h.value) < 8) 
  {
     document.form.is_special_request.value = 'yes';
     document.form.subject.value = 'Special Class Application';
     document.form.specialty.value += 'Appointment begins before 8am\n';
  }

  // If the class meets regularly, but ends after 10pm, mark
  // as special
  if(form.meeting_type[0].checked && 
     form.reg_sched_end_ampm.options[1].selected && 
     eval(form.reg_sched_end_h.value) >= 10 && 
     eval(form.reg_sched_end_h.value) != 12) 
  {
     document.form.is_special_request.value = 'yes';
     document.form.subject.value = 'Special Class Application';
     document.form.specialty.value += 'Appointment ends at or after 10pm\n';
  }

  // If the class meets regularly, but ends after 10pm, mark
  // as special
  if(form.meeting_type[1].checked && 
     form.ind_session_end_ampm.options[1].selected && 
     eval(form.ind_session_end_h.value) >= 10  && 
     eval(form.ind_session_end_h.value) != 12) 
  {
     document.form.is_special_request.value = 'yes';
     document.form.subject.value = 'Special Class Application';
     document.form.specialty.value += 'Appointment ends at or after 10pm\n';
  }

  // If the class meets on the weekend, mark as special
  // Note that reg_sched_days.options[7] is 'Saturday' and
  // reg_sched_days[8] is 'Sunday'
  if(form.meeting_type[0].checked && 
     (form.reg_sched_days.options[7].selected || 
      form.reg_sched_days.options[8].selected)) 
  {
     document.form.is_special_request.value = 'yes';
     document.form.subject.value = 'Special Class Application';
     document.form.specialty.value += 'Course meets on the weekend\n';
  }

  form.submit();
}

// Request AV Equipment in non-E-Room
function ValidateEmailAV(form){

var eRooms = new Array("405", "407", "409", "411", "1401");
var FormRooms = new Array(form.Room1.value, form.Room2.value, form.Room3.value,
                form.Room4.value, form.Room5.value, form.Room6.value, 
                form.Room7.value, form.Room8.value, form.Room9.value, form.Room10.value);

for ( i=0; i<FormRooms.length; i++ )
{
   for ( j=0; j<eRooms.length; j++ )
   {
       if ( FormRooms[i].indexOf(eRooms[j]) == 0 )
       {
           alert("Room " + eRooms[j] + " is an electronic classroom. Please use the form for electronic classrooms at http://www.columbia.edu/cu/sipa/av/resform.html");
           return;
       }
   }
}

var EmailText = "MIME-Version: 1.0\n";
EmailText += "Content-type: text/html; charset=iso-8859-1\n\n";
EmailText += "<HTML><BODY><H3><CENTER>SIPA Computing Audio-Visual Request Form</CENTER></H3>\n";
EmailText += "<P><CENTER><B>Please complete <U>all fields</U> and submit the completed form to 510 IAB.\n";
EmailText += "<BR><I>Incomplete forms will be rejected</I>.\n";
EmailText += "<BR>Borrower must sign each time equipment is setup and CUID must be left with the Consultant!</B></CENTER>\n";

dNow = new Date();
EmailText += "<P><B>Today's Date:</B> " + (dNow.getMonth() + 1) + "/";
EmailText += dNow.getDate() + "/" + dNow.getYear() + "<BR>\n"; 

EmailText += "<B>Name:</B> " + form.Name.value + "<BR>\n"; 
EmailText += "<B>Address or Office:</B> " + form.Address.value + "<BR>\n"; 
EmailText += "<B>Phone Number:</B> " + form.Phone.value + "<BR>\n"; 
EmailText += "<B>Email:</B> " + form.Email.value + "\n"; 

var nIndex = form.Affiliation.selectedIndex;
var Affiliation = form.Affiliation.options[nIndex].text
EmailText += "<P><B>Affiliation with SIPA:</B> " + Affiliation + "<BR>\n"; 

EmailText += "<B>Course Title or Event: </B>" + form.CourseTitle.value + "<BR>\n"; 
EmailText += "<B>Course No.:</B> " + form.CourseNo.value + "<BR>\n"; 
EmailText += "<B>Professor or Organization:</B> " + form.Professor.value + "\n"; 

EmailText += "<P><B>Name of person(s) who will be responsible for borrowing the equipment:</B><BR>\n";
EmailText += form.BorrowingEquipment.value + "\n"; 

EmailText += "<CENTER><H3>Equipment Required:</H3></CENTER><UL>\n";

if ( form.LcdProjector.checked )
{
   EmailText += "<LI>I will need the LCD Projector (for PowerPoint presentation).\n";
}

if ( form.InternetConnection.checked )
{
   EmailText += "<LI>I will need the Internet connection (for Internet presentation).\n";
}

if ( form.Laptop.checked )
{
   EmailText += "<LI>I will need a Laptop computer\n";
}

if ( form.OwnLaptop.checked )
{
   EmailText += "<LI>I am supplying my own Laptop<UL>\n";
   EmailText += "<LI>Manufacturer: " + form.Manufacturer.value + "\n";
   EmailText += "<LI>Operating System: " + form.OperatingSystem.value + "\n";
   EmailText += "<LI>Model: " + form.Model.value + "</UL>\n";
}

if ( form.Media.checked )
{
   EmailText += "<LI>Media that you will use for your presentation: ";
   var nIndex = form.MediaType.selectedIndex;
   EmailText += form.MediaType.options[nIndex].text + "\n";
}
	
if ( form.Mouse.checked )
{
   EmailText += "<LI>I will need remote wireless mouse\n";
}

if ( form.VCR.checked )
{
   EmailText += "<LI>I will need the TV and VCR\n";
}

if ( form.Overhead.checked )
{
   EmailText += "<LI>I will need the overhead projector (for transparencies)\n";
}

if ( form.SlideProjector.checked )   
{
   EmailText += "<LI>I will need the Slide Projector (35 mm slides)\n";
}

if ( form.ProjectionScreen.checked )
{
   EmailText += "<LI>I will need a projection screen\n";
}

EmailText += "</UL>\n<P><CENTER><B>Please specify when you need this equipment</B></CENTER>\n";
EmailText += "<TABLE CELLPADDING=5 BORDER=2><TR>\n";
EmailText += "<TH>Date Equipment Required<TH>IAB Room<TH>Time for Setup<TH>Time for Retrieval\n";
EmailText += "<TH>Borrower's Signature (when checking out equipment)\n";
EmailText += "<TH><U>Office Use Only</U><BR>Consultant's Name, Date & Time (Certify all equipment returned.)</TR>\n";
EmailText += "<TR><TD align=center>" + form.Date1.value + "<TD align=center>" + form.Room1.value + "<TD align=center>" + form.Setup1.value + "<TD align=center>" + form.Retrieval1.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "<TR><TD align=center>" + form.Date2.value + "<TD align=center>" + form.Room2.value + "<TD align=center>" + form.Setup2.value + "<TD align=center>" + form.Retrieval2.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "<TR><TD align=center>" + form.Date3.value + "<TD align=center>" + form.Room3.value + "<TD align=center>" + form.Setup3.value + "<TD align=center>" + form.Retrieval3.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "<TR><TD align=center>" + form.Date4.value + "<TD align=center>" + form.Room4.value + "<TD align=center>" + form.Setup4.value + "<TD align=center>" + form.Retrieval4.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "<TR><TD align=center>" + form.Date5.value + "<TD align=center>" + form.Room5.value + "<TD align=center>" + form.Setup5.value + "<TD align=center>" + form.Retrieval5.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "<TR><TD align=center>" + form.Date6.value + "<TD align=center>" + form.Room6.value + "<TD align=center>" + form.Setup6.value + "<TD align=center>" + form.Retrieval6.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "<TR><TD align=center>" + form.Date7.value + "<TD align=center>" + form.Room7.value + "<TD align=center>" + form.Setup7.value + "<TD align=center>" + form.Retrieval7.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "<TR><TD align=center>" + form.Date8.value + "<TD align=center>" + form.Room8.value + "<TD align=center>" + form.Setup8.value + "<TD align=center>" + form.Retrieval8.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "<TR><TD align=center>" + form.Date9.value + "<TD align=center>" + form.Room9.value + "<TD align=center>" + form.Setup9.value + "<TD align=center>" + form.Retrieval9.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "<TR><TD align=center>" + form.Date10.value + "<TD align=center>" + form.Room10.value + "<TD align=center>" + form.Setup10.value + "<TD align=center>" + form.Retrieval10.value + "<TD> </TD><TD> </TD></TR>\n"; 
EmailText += "</TABLE>\n<P><B>Borrower must sign each time equipment is setup and CUID must be left with the Consultant!</B>\n";
EmailText += "<P><U>Notes</U>: " + form.Comments.value + "<BR><BR><BR>\n";

EmailText += "<B><U>Terms of Service</U></B><UL>\n";
EmailText += "<LI>You must request equipment <B>at least 2 business days</B> in advance.\n"; 
EmailText += "<LI>Equipment is available only for <B>SIPA U-courses held inside IAB</B>.\n";
EmailText += "Equipment may be borrowed for non-SIPA courses and events in IAB for a fee charged to the relevant department. The departmental administrator must email Harpreet Mahajan (mahajan@columbia.edu) with written acceptance and the account number for billing before the request is approved.\n"; 
EmailText += "<LI><B>If you are using your own laptop computer</B>, then you must make an appointment with the SIPAC staff to test your laptop with our projector at least several hours in advance of your presentation. <B>Otherwise, we cannot guarantee compatibility between your laptop and our equipment</B>.\n";
EmailText += "<LI><B>If you are using a CD-RW</B>, then you must make an appointment with the SIPAC staff to test your CD-RW with our laptop computer. <B>Otherwise, we cannot guarantee compatibility between your CD-RW and our equipment</B>.\n";
EmailText += "<LI><B>Setups and pickups may be delayed by 15 minutes due to concurrent AV jobs and delays caused by elevator traffic</B>.\n";
EmailText += "<LI>Please meet the consultant on time at the specified location with your Columbia ID. Please note that if you fail to meet the consultant on time, then we cannot guarantee AV support.\n"; 
EmailText += "<LI><B>DO NOT leave the equipment unattended at any time!</B> Wait for the consultant to pick up the equipment when you are finished. If you finish early, please contact the consultant in 510 IAB or call x4-1575, but DO NOT leave the equipment unguarded. Equipment must be returned immediately after class/event.\n";
EmailText += "<LI><B>We do not support rooms 403, 410, or Altschul Auditorium</B>. Go to www.columbia.edu/acis/classrooms/ for information and to make reservations. Email Nick DiMaria of AcIS (nick@columbia.edu) in case of problems.\n";
EmailText += "<LI>We do not have any microphones or speakers. These can be rented separately from the University's AV department directly (x4-4175). All audio support is restricted to the instructional system in 510A.\n";
EmailText += "<LI><U>Support Hours</U>: Monday-Thursday 8:45am - 10:00pm, Friday 8:45am - 7:00pm. Weekend support is provided on case-by-case basis.\n";
EmailText += "<LI>If you wish to cancel an AV request, please give at least 1-hour notice by calling the SIPA Computer Lab at x4-1575.\n";
EmailText += "</UL><P><B>I have read and agree to the Terms of Service. I understand that I am responsible for any damage or loss of all borrowed equipment.</B>\n"
EmailText += "<P><B>Signature (required)</B> ____________________________________________\n";
EmailText += "</BODY></HTML>\n";	

//alert(EmailText);
document.Email.emailtext.value = EmailText + "\n";
document.Email.rmail.value = form.Email.value;
document.Email.submit();
}



