//----------------------------------
function mand(obj){
//----------------------------------
	var str = obj.value;
	if(str == null || str.length == 0){
		alert('This field is required.');
		obj.focus();
		return false;
	}
	else{
		return true;	
	}
}
//----------------------------------
function isEmailAddr(obj){
//----------------------------------
	var str = obj.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if(!str.match(re)){
		alert("Email address entered appears to be invalid. Please check to make sure you typed it correctly.");
		return false;
	}else{
		return true;
	}
}

//Validates the zip code is a valid number in the format 12345
//---------------------------------
function ckZip(obj){
//---------------------------------
//check to see if 5 characters are entered
  if((obj.value.length < 5) && (obj.value.length != 0))
  {
    alert("You must enter at least 5 digits of the zip code");
    obj.value = "";
    obj.focus();
    return;
  }

  //Then check to ensure a valid number is entered
  if (isNaN(obj.value))
    {
        alert("The zip code must be numeric");
        obj.value = "";
        obj.focus();
        return;
    }
}

// function to validate email address
//---------------------------------
function ckEmail(obj){
//---------------------------------	
  if(obj.value.length == 0)
  {
    return;
  }
  for(i=0; i< obj.value.length; i++) {
    if (obj.value.substring(i,i+1) == "@")
      break;
  }
  if ( i >= (obj.value.length - 1))
  {
    alert('The email address must contain @ to be valid');
    obj.value = "";
    obj.focus();
    return;
  }
   for (j = i; j< obj.value.length; j++) {
    if (obj.value.substring(j,j+1) == ".")
    break;
  }
  if ( j >= (obj.value.length -1) )
  {
    alert('Missing .com or .net of address');
    obj.value = ""
    obj.focus();
    return;
  }
}
//--------------------------------
function isUrl(obj) {
//--------------------------------
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	if(obj.value.length == 0){
    	return;
	}
	//skip validation with internal links
	if($('extra_type')){
		if($('extra_type').value == 'iLink'){
			return;	
		}
	}
	if(obj.value.length < 3){
		alert('Please enter a valid web address');	
		obj.focus();
	}
	if(regexp.test(obj.value)){
		alert('The web address entered does not appear to be valid.');	
		obj.focus();
	}
	return;
}
//---------------------------------
function ckDate(ev) {
//---------------------------------
  
      isAllValid = false
 
   
   vdt = ev.value
//   if (vdt.length == 0)
//      return
//   if (vdt == "mm/dd/yyyy")
//      return
      
  // parse date
   if (vdt.length > 0)
   {
   dts = vdt.split("/",4)
   j = dts.length
   
   if (j != 3)
   {
      curTarget = ev
      inEvent = true
      alert("Error: Date must be in the format MM/DD/YYYY")
      ev.value='';
      ev.focus()
      isAllValid = false
      return
   }
   else
   {
      mon = dts[0] - 0
      if (isNaN(mon) == true)
      {
         curTarget = ev
         inEvent = true
         alert("Error: Invalid Month")
         ev.value='';
         ev.focus()
         isAllValid = false
         return
      }
      if (mon < 1 || mon > 12)
      {
         curTarget = ev
         inEvent = true
         alert("Error: Invalid Month")
         ev.value='';
         ev.focus()
         isAllValid = false
         return
      }
     
      day = dts[1] - 0
      if (isNaN(day) == true)
      {
         curTarget = ev
         inEvent = true
         alert("Error: Invalid Day")
         ev.value='';
         ev.focus()
         isAllValid = false
         return
      }
      yr = dts[2] - 0
      if (isNaN(yr) == true || yr < 1000)
      {
         curTarget = ev
         inEvent = true
         alert("Error: Invalid Year - Use Date format MM/DD/YYYY");
         ev.value='';
         ev.focus()
         isAllValid = false
         return
      }
      switch(mon)
      {
         case 1:
         case 3:
         case 5:
         case 7:
         case 8:
         case 10:
         case 12:
            if (day < 1 || day > 31)
            {
               curTarget = ev
               inEvent = true
               alert("Error: Invalid Day")
               ev.value='';
               ev.focus()
               isAllValid = false
               return
            }
            break
         case 4:
         case 6:
         case 9:
         case 11:
            if (day < 1 || day > 30)
            {
               curTarget = ev
               inEvent = true
               alert("Error: Invalid Day")
               ev.value='';
               ev.focus()
               isAllValid = false
               return
            }
            break
         default:
            lpyr = 0
            if (yr < 100)
               yr += 1900
            if (yr % 4 == 0)
            {
               if (yr % 100 != 0)
                  lpyr = 1
               else if (yr % 400 == 0)
                  lpyr = 1
            }
            if (day < 1 || day > (28 + lpyr))
            {
               curTarget = ev
               inEvent = true
               alert("Error: Invalid Day")
               ev.value='';
               ev.focus()
               isAllValid = false
               return
            }
      }
   }
   }
}
// --- Code for Board news and Bulletin Board Maintenance ---
//  added: 7/23/04 LP
//  If they enter a date in the past it changes it to tomorrow.
//
//  indate = date entered
//  fldname = name on the search form where they entered the date.
//
function ChkFutDt(indate, effdate)
{
    var today = new Date();
  infield1 = indate.value;
  infield2 = effdate.value;
    sentdate = new Date(indate.value);
    sentdate2 = new Date(effdate.value);
//  var todayms = today.getTime();
    var indatems = sentdate.getTime();
    var effdatems = sentdate2.getTime();
    var mm = today.getMonth() + 1;
    var dd = today.getDate();
    var yyyy = today.getFullYear();
    todaysdt = mm + '/' + dd + '/' + yyyy;
  var todaydt = new Date();
  todaydt.setHours(0);
  todaydt.setMinutes(0);
  todaydt.setSeconds(0);
  todaydt.setMilliseconds(0);
    //When data is in both fields
    //Expire date entered only
    if (infield1 != "" && infield2 == "")
    {
        if (indatems < todaydt)
        {
            alert("Expire Date is in the past, Please enter a future date");
            indate.value = todaysdt;
      setTimeout(function(){indate.focus();},1);
        }
    return;
    }
    //Effective date entered only
    if (infield1 == "" && infield2 != "")
    {
        if (effdatems < todaydt)
        {
            alert("Effective Date is in the past, Please enter a future date");
            effdate.value = todaysdt;
      setTimeout(function(){effdate.focus();},1);
        }
    return;
    }
    if (indatems < todaydt)
        {
            alert("Expire Date is in the past, Please enter a future date");
            indate.value = todaysdt;
      setTimeout(function(){indate.focus();},1);
      return;
        }

    if (effdatems < todaydt)
        {
            alert("Effective Date is in the past, Please enter a future date");
            effdate.value = todaysdt;
      setTimeout(function(){effdate.focus();},1);
      return;
        }

    if (effdatems > indatems)
        {
            alert("Effective Date is after Expire Date");
            indate.value = "";
            effdate.value = "";
      setTimeout(function(){effdate.focus();},1);
        }
return;
}
