<!--

document.InputForm.action = "http://sdmines.sdsmt.edu/cgi-bin/global/send_message_2.cgi";

//	Enable the input for JavaScript enabled browsers
	document.InputForm.Submit.disabled = false;

// Variables
var vEvent = 'SD School of Mines Fall 2009 Career Fair Registration';
var vAmt = 0;
var eAmt = 200;
var lAmt = 225;
var deadline = new Date("Sat Sep 5 00:00:01 MDT 2009");
var vDeadline = 'September 4, 2009';
var vPmt = '';
var vEarlyBird = '$' + eAmt + ' Early Bird Registration (received by ' + vDeadline + ')';
var vRegular = '$' + lAmt + ' Regular (received after ' + vDeadline + ')';

function initit()
{
	today = new Date();
	
	if (today < deadline)
	{
		vAmt = eAmt;
	}
	else
	{
		vAmt = lAmt;
	}
	
	document.InputForm.EarlyBird.value = vEarlyBird;
	document.InputForm.Regular.value = vRegular;
	document.InputForm.Fee.value = vAmt.toFixed(2);
	document.InputForm.Event.value = vEvent;
	document.InputForm.Early.value = eAmt.toFixed(2);
	document.InputForm.Deadline.value = vDeadline;

}

function disableCard()
{
	if (document.InputForm.Payment[0].checked)
	{
		document.InputForm.Card[0].disabled = false;
		document.InputForm.Card[1].disabled = false;
		document.InputForm.Card[2].disabled = false;
	}
	if (document.InputForm.Payment[1].checked)
	{
		document.InputForm.Card[0].checked = false;
		document.InputForm.Card[1].checked = false;
		document.InputForm.Card[2].checked = false;
		document.InputForm.Card[0].disabled = true;
		document.InputForm.Card[1].disabled = true;
		document.InputForm.Card[2].disabled = true;
	}
}

function checkForm()
{

//	Timestamp
	stamp = new Date();
	document.InputForm.Stamp.value = stamp;

// Used for not authorized.
	if (document.InputForm.miners.value != '')
		document.InputForm.action = "http://interact.sdsmt.edu/not-authorized.asp";

  if(document.InputForm.Company.value == '')
   {
      alert('Please enter your company/agency name.');
      document.InputForm.Company.focus();
      return false;
   }
   
  if(document.InputForm.Address1.value == '')
   {
      alert('Please enter your address.');
      document.InputForm.Address1.focus();
      return false;
   }

  if(document.InputForm.City.value == '')
   {
      alert('Please enter your city.');
      document.InputForm.City.focus();
      return false;
   }

	vCity = document.InputForm.City.value;

  if (document.InputForm.State.selectedIndex == 0)
  {
    alert("Please select your state.");
    document.InputForm.State.focus();
    return (false);
  }

	vState = document.InputForm.State.value;

  if(document.InputForm.Zip.value == '')
   {
      alert('Please enter your zip code.');
      document.InputForm.Zip.focus();
      return false;
   }

	vCityStateZip = vCity + ', ' + vState + ' ' + document.InputForm.Zip.value;

  if(document.InputForm.Phone.value == '')
   {
      alert('Please enter your phone number.');
      document.InputForm.Phone.focus();
      return false;
   }

  if(document.InputForm.Fax.value == '')
   {
      alert('Please enter your fax number.');
      document.InputForm.Fax.focus();
      return false;
   }

  if(document.InputForm.Contact.value == '')
   {
      alert('Please enter your contact name.');
      document.InputForm.Contact.focus();
      return false;
   }

	if (document.InputForm.Email.value == "")
	{
		alert("Please enter your email address.");
		document.InputForm.Email.focus();
		return false;
	}

	if (document.InputForm.Email.value != "")
	{
		if (document.InputForm.Email.value.indexOf("@") == -1)
		{
			alert('Your email address is invalid it must contain @.');
			document.InputForm.Email.focus();
			return false;
		}  
	}

  var radioSelected = false;
  for (i = 0;  i < document.InputForm.Electricity.length;  i++)
  {
    if (document.InputForm.Electricity[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please tell us if your display requires electricity.");
    document.InputForm.Electricity[0].focus();
    return (false);
  }

  var radioSelected = false;
  for (i = 0;  i < document.InputForm.Payment.length;  i++)
  {
    if (document.InputForm.Payment[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please select payment method.");
    document.InputForm.Payment[0].focus();
    return (false);
  }

	if (document.InputForm.Payment[0].checked)
	{
	  var radioSelected = false;
	  for (i = 0;  i < document.InputForm.Card.length;  i++)
	  {
	    if (document.InputForm.Card[i].checked)
 	       radioSelected = true;
		}
 		if (!radioSelected)
	  {
    alert("Please select which type of card you will be using.");
    document.InputForm.Card[0].focus();
    return (false);
  	}
	}

	if (document.InputForm.Payment[1].checked == true)
		vPmt = 'Mail';
	else
	{
		if (document.InputForm.Card[0].checked == true)
			vPmt = "MasterCard";
		if (document.InputForm.Card[1].checked == true)
			vPmt = "Visa";
		if (document.InputForm.Card[2].checked == true)
			vPmt = "Discover";
	}
		
	document.InputForm.PmtType.value = vPmt;
	
// Email body
 
	em = '<table style="width: 710px; font-family: Verdana; font-size: 10pt; border-collapse: collapse; margin-top: 10px; margin-bottom: 10px;">';
	em += '<tr>';
	em += '<td style="width: 165px">Company/agency name:</td>';
	em += '<td>' + document.InputForm.Company.value + '</td>';
	em += '</tr>';
	em += '<tr>';
	em += '<td style="width: 165px; vertical-align: top">Address: </td>';
	em += '<td>' + document.InputForm.Address1.value + '<br>';
	if (document.InputForm.Address2.value != '')
		em += document.InputForm.Address2.value + '<br>';
	em += vCityStateZip + '</td>';
	em += '</tr>';
	em += '<tr>';
	em += '<td style="width: 165px">Phone:</td>';
	em += '<td>' + document.InputForm.Phone.value + '</td>';
	em += '</tr>';
	em += '<tr>';
	em += '<td style="width: 165px">Fax:</td>';
	em += '<td>' + document.InputForm.Fax.value + '</td>';
	em += '</tr>';
	if (document.InputForm.Website.value != '')
	{
		em += '<tr>';
		em += '<td style="width: 165px">Web Site Address:</td>';
		em += '<td>' + document.InputForm.Website.value + '</td>';
		em += '</tr>';
	}
	em += '<tr>';
	em += '<td style="width: 165px">Contact Name:</td>';
	em += '<td>' + document.InputForm.Contact.value + '</td>';
	em += '</tr>';
	em += '<tr>';
	em += '<td style="width: 165px">Email:</td>';
	em += '<td>' + document.InputForm.Email.value + '</td>';
	em += '</tr>';
	em += '<tr>';
	em += '<td colspan="2">&nbsp;</td>';
	em += '</tr>';
	em += '<tr>';
	em += '<td colspan="2">Our display requires electricity: ';
	if (document.InputForm.Electricity[0].checked)
		em += 'Yes</td>';
	if (document.InputForm.Electricity[1].checked)
		em += 'No</td>';
	em += '</tr>';
	em += '<tr>';
	em += '<td style="width: 165px">Other requirements:</td>';
	em += '<td>' + document.InputForm.Other.value + '</td>';
	em += '</tr>';
	em += '<tr>';
	em += '<td style="width: 165px">Payment Type:</td>';
	em += '<td>' + document.InputForm.PmtType.value + '</td>';
	em += '</tr>';
	em += '</table>';

  document.InputForm.email_body.value = em;

// Passed to payment form
	document.InputForm.Name.value = document.InputForm.Company.value;
	document.InputForm.Amount.value = vAmt;

// Email header information

   subj = 'Career Fair Registration - ' + document.InputForm.Company.value;
   document.InputForm.email_subject.value = subj;
   
   to = 'careercenter@sdsmt.edu';
   document.InputForm.email_to.value = to;
   
   cc = document.InputForm.Email.value;
   document.InputForm.email_cc.value = cc;
   

// Confirmation page

	if(vPmt == 'Mail')
	{
	 	confurl = 'http://interact.sdsmt.edu/career-center/mailconfirm.asp';
	 	document.InputForm.confirm.value = confurl;
	}
	else
	{
	 	confurl = 'http://interact.sdsmt.edu/career-center/onlineconfirm.asp';
	 	document.InputForm.confirm.value = confurl;
	}
	

   return true;
}

//-->
