/*************************************************************
*  Copyright © iWeBB, 2001-2002                              *
*  Carter BloodCare All rights reserved                      *
**************************************************************/
function checkallschd() 
{
  today = new Date();
  vdateerror = "N";
  fixfocus    = "N";
  missinginfo = "";


  if (document.calform.p_fname.value == "") 
  {
    missinginfo += "\n     -  First Name";
    if (fixfocus == "N")
    {
      document.calform.p_fname.focus();
      fixfocus = "Y";
    }
  }

  if (document.calform.p_lname.value == "") 
  {
    missinginfo += "\n     -  Last Name";
    if (fixfocus == "N")
    {
      document.calform.p_lname.focus();
      fixfocus = "Y";
    }
  }


  if (document.calform.p_phoneh.value == "") 
  {
    missinginfo += "\n     -  Phone";
    if (fixfocus == "N")
    {
      document.calform.p_phoneh.focus();
      fixfocus = "Y";
    }
  }



if (document.calform.p_remind_call.value == "E")
  {
  if (document.calform.p_email.value == "") 
  {
    missinginfo += "\n     -  Email address";
    if (fixfocus == "N")
    {
      document.calform.p_email.focus();
      fixfocus = "Y";
    }
  }
  }
 
 if (document.calform.p_remind_call.value == "T")
  {
  if (document.calform.p_phonea.value == "") 
  {
    missinginfo += "\n     -  Cell Phone";
    if (fixfocus == "N")
    {
      document.calform.p_phonea.focus();
      fixfocus = "Y";
    }
  }
  } 


  if (document.calform.p_center.value == "") 
  {
     missinginfo += "\n     -  Donor Center";
    if (fixfocus == "N")
    {
      document.calform.p_center.focus();
      fixfocus = "Y";
    }
  }

  if (document.calform.p_donation.value == "") 
  {
     missinginfo += "\n     -  Donation Type";
    if (fixfocus == "N")
    {
      document.calform.p_donation.focus();
      fixfocus = "Y";
    }
  }


  if (document.calform.p_apptdate.value == "") 
  {
     missinginfo += "\n     -  Donation Date";
    if (fixfocus == "N")
    {
      document.calform.p_apptdate.focus();
      fixfocus = "Y";
    }
  }
  else
  {
     apptdate = new Date(document.calform.p_apptdate.value);

     if ( apptdate.getYear() < today.getYear() )
     {
	vdateerror = "Y";
     }
     else if ( apptdate.getYear() == today.getYear() )
     {
       if ( apptdate.getMonth() < today.getMonth() )
     	{		
		vdateerror = "Y";
	}
     	else if ( apptdate.getMonth() == today.getMonth() )
	{
		if ( apptdate.getDate() < today.getDate() )
     		{
			vdateerror = "Y";
     		}
	}
     }	
     else
     {
	vdateerror = "N";
     }

     if (vdateerror == "Y") 
     {
	 missinginfo += "\n     -  Past Donation Date Not Allowed";
    	if (fixfocus == "N")
	{
      	document.calform.p_apptdate.focus();
      	fixfocus = "Y";
    	}
     }
  }






  if (missinginfo != "") 
  {
    missinginfo ="_____________________________\n" +
    "The following information is missing:\n" +
    missinginfo + "\n_____________________________" +
    "\nPlease re-enter and submit again!";
    alert(missinginfo);
    return false;
  }
  else return true;
}




function checkalldon() 
{
  today = new Date();
  vdateerror = "N";
  fixfocus    = "N";
  missinginfo = "";

//Last Name
  if (document.calform.p_lname.value == "") 
  {
    missinginfo += "\n     -  Last Name";
    if (fixfocus == "N")
    {
      document.calform.p_lname.focus();
      fixfocus = "Y";
    }
  }

//First Name
  if (document.calform.p_fname.value == "") 
  {
    missinginfo += "\n     -  First Name";
    if (fixfocus == "N")
    {
      document.calform.p_fname.focus();
      fixfocus = "Y";
    }
  }

//Home Phone
  if (document.calform.p_phoneh.value == "")
  {
    missinginfo += "\n     -  Home Phone";
    if (fixfocus == "N")
    {
      document.calform.p_phoneh.focus();
      fixfocus = "Y";
    }
  }
  else
  {
    if (!checkUSPhone(document.calform.p_phoneh))
    {
      document.calform.p_phoneh.focus();
      return false;
    }
  }


//Work Phone
  if ((document.calform.p_phonew.value != "") && 
      (!checkUSPhone(document.calform.p_phonew))
     )
  {
      document.calform.p_phonew.focus();
      return false;
  }

//Work Ext 
  if (document.calform.p_phonewx.value != "")
  {
  	if (document.calform.p_phonew.value == "")
  	{
    	    missinginfo += "\n     -  Work Phone";
	    if (fixfocus == "N")
	    {
	      	document.calform.p_phonew.focus();
      		fixfocus = "Y";
	    }
    	}
	else
	{
  		if (!isInteger(document.calform.p_phonewx.value))
  		{
    	    		missinginfo += "\n     -  Invalid Work Phone Ext";
    	    		if (fixfocus == "N")
			{
      				document.calform.p_phonewx.focus();
      				fixfocus = "Y";
    	    		}
  		}
	}
  }


//Email

  if (document.calform.p_email.value == "") 
  {
    missinginfo += "\n     -  Email address";
    if (fixfocus == "N")
    {
      document.calform.p_email.focus();
      fixfocus = "Y";
    }
  }
  else
  {
    if (!checkEmail(document.calform.p_email)) 
    {
      document.calform.p_email.focus();
      return false;
    }
  }
  
  


//Alt Phone
  if ((document.calform.p_phonea.value != "") && 
      (!checkUSPhone(document.calform.p_phonea))
     )
  {
      document.calform.p_phonea.focus();
      return false;
  }

//Donation
  if (document.calform.p_donation.value == "") 
  {
     missinginfo += "\n     -  Donation Type";
    if (fixfocus == "N")
    {
      document.calform.p_donation.focus();
      fixfocus = "Y";
    }
  }

//Center
  if (document.calform.p_center.value == "") 
  {
     missinginfo += "\n     -  Donor Center";
    if (fixfocus == "N")
    {

   //  	document.links.['llcentername'].focus();
      document.calform.p_centername.focus();
      fixfocus = "Y";
    }
  }

//Appt Date
  if (document.calform.p_apptdate.value == "") 
  {
     missinginfo += "\n     -  Donation Date";
    if (fixfocus == "N")
    {
      document.calform.p_apptdate.focus();
      fixfocus = "Y";
    }
  }

//Appt Time
  if (document.calform.p_appttime.value == "") 
  {
     missinginfo += "\n     -  Donation Time";
    if (fixfocus == "N")
    {
      document.calform.p_appttime.focus();
      fixfocus = "Y";
    }
  }


  if (missinginfo != "") 
  {
    missinginfo ="_____________________________\n" +
    "The following information is missing:\n" +
    missinginfo + "\n_____________________________" +
    "\nPlease re-enter and submit again!";
    alert(missinginfo);
    return false;
  }
  else if (document.calform.p_twice_submit.value == 0)
  {
	document.calform.p_twice_submit.value++;
	return true;
  }
  else
  {
    missinginfo ="_____________________________\n\n" +
    "The appointment is already submited:\n" +
    missinginfo + "\n_____________________________" ;
    alert(missinginfo);
    return false;
  }
}


// Check all Mupliple Appt items on Screen

function checkalldonm() 
{
  var boxLength = document.calform.p_mapptd.length;
  today = new Date();
  vdateerror = "N";
  fixfocus    = "N";
  missinginfo = "";



//Mupliple Appt Last Name
  if (document.calform.p_lname.value == "") 
  {
    missinginfo += "\n     -  Last Name";
    if (fixfocus == "N")
    {
      document.calform.p_lname.focus();
      fixfocus = "Y";
    }
  }

//Mupliple Appt First Name
  if (document.calform.p_fname.value == "") 
  {
    missinginfo += "\n     -  First Name";
    if (fixfocus == "N")
    {
      document.calform.p_fname.focus();
      fixfocus = "Y";
    }
  }

//Mupliple Appt Home Phone
  if (document.calform.p_phoneh.value == "")
  {
    missinginfo += "\n     -  Home Phone";
    if (fixfocus == "N")
    {
      document.calform.p_phoneh.focus();
      fixfocus = "Y";
    }
  }
  else
  {
    if (!checkUSPhone(document.calform.p_phoneh))
    {
      document.calform.p_phoneh.focus();
      return false;
    }
  }


//Mupliple Appt Work Phone
  if ((document.calform.p_phonew.value != "") && 
      (!checkUSPhone(document.calform.p_phonew))
     )
  {
      document.calform.p_phonew.focus();
      return false;
  }

//Mupliple Appt Work Ext 
  if (document.calform.p_phonewx.value != "")
  {
  	if (document.calform.p_phonew.value == "")
  	{
    	    missinginfo += "\n     -  Work Phone";
	    if (fixfocus == "N")
	    {
	      	document.calform.p_phonew.focus();
      		fixfocus = "Y";
	    }
    	}
	else
	{
  		if (!isInteger(document.calform.p_phonewx.value))
  		{
    	    		missinginfo += "\n     -  Invalid Work Phone Ext";
    	    		if (fixfocus == "N")
			{
      				document.calform.p_phonewx.focus();
      				fixfocus = "Y";
    	    		}
  		}
	}
  }


//Mupliple Appt Email

  if (document.calform.p_email.value == "") 
  {
    missinginfo += "\n     -  Email address";
    if (fixfocus == "N")
    {
      document.calform.p_email.focus();
      fixfocus = "Y";
    }
  }
  else
  {
    if (!checkEmail(document.calform.p_email)) 
    {
      document.calform.p_email.focus();
      return false;
    }
  }


//Mupliple Appt Alt Phone
  if ((document.calform.p_phonea.value != "") && 
      (!checkUSPhone(document.calform.p_phonea))
     )
  {
      document.calform.p_phonea.focus();
      return false;
  }

//Mupliple Appt Start Multiple Donation Appt Boxlength
  if (boxLength == 0) 
  {


//Mupliple Appt Center
  if (document.calform.p_center.value == "") 
  {
     missinginfo += "\n     -  Donor Center";
    if (fixfocus == "N")
    {

   //  	document.links.['llcentername'].focus();
      document.calform.p_centername.focus();
      fixfocus = "Y";
    }
  }


//Mupliple Appt Donation
  if (document.calform.p_donation.value == "") 
  {
     missinginfo += "\n     -  Donation Type";
    if (fixfocus == "N")
    {
      document.calform.p_donation.focus();
      fixfocus = "Y";
    }
  }


//Mupliple Appt Appt Date
  if (document.calform.p_apptdate.value == "") 
  {
     missinginfo += "\n     -  Donation Date";
    if (fixfocus == "N")
    {
      document.calform.p_apptdate.focus();
      fixfocus = "Y";
    }
  }

//Mupliple Appt Appt Time
  if (document.calform.p_appttime.value == "") 
  {
     missinginfo += "\n     -  Donation Time";
    if (fixfocus == "N")
    {
      document.calform.p_appttime.focus();
      fixfocus = "Y";
    }
  }

  }
//Mupliple Appt End Multiple Donation Appt Boxlength


  if (missinginfo != "") 
  {
    missinginfo ="_____________________________\n" +
    "The following information is missing:\n" +
    missinginfo + "\n_____________________________" +
    "\nPlease re-enter and submit again!";
    alert(missinginfo);
    return false;
  }
  else if (document.calform.p_twice_submit.value == 0)
  {
	document.calform.p_twice_submit.value++;
	return true;
  }
  else
  {
    missinginfo ="_____________________________\n\n" +
    "The appointment is already submited:\n" +
    missinginfo + "\n_____________________________" ;
    alert(missinginfo);
    return false;
  }
}

