function isEmail(elm) {
  if (elm.value.indexOf("@") != "-1" && elm.value.indexOf(".") != "-1" )
    return true;
    else return false; 
    }

  function isFilled(elm) {
    if (elm.value == "" || elm.value == null)
    return false;
    else return true;
    }
    

function checkFields(csform)  {

  // alert("script check");
   
// return false;

   if (isFilled(csform.firstname) == false) {
        alert("Please enter your First Name.");
       csform.firstname.focus();
        return false;
        }
 
    if (isFilled(csform.lastname) == false) {
        alert("Please enter your Last Name.");
       csform.lastname.focus();
        return false;
        }
        
          if (isEmail(csform.email) == false) {
        alert("Please enter a valid Email address.");
       csform.email.focus();
        return false;
        }
		
      	reqChoice = document.csform.site.selectedIndex;
      	
   		if (document.csform.site[reqChoice].value == "") {
		alert("Please select a Site.");
			return false;
		}
	  
      	reqChoice = document.csform.typeofrequest.selectedIndex;
      	
   		if (document.csform.typeofrequest[reqChoice].value == "") {
		alert("Please select the Type of Request.");
			return false;
		}             
   
		caseTypeOption = -1
		
		for (i=0; i<document.csform.casetype.length; i++) {
		    if (document.csform.casetype[i].checked) {
		       caseTypeOption = i
			}
		}  
		
		    if (caseTypeOption == -1)  {
		    alert("Please select the Case Type.");
		        return false;
		}
		
      if (isFilled(csform.problemdetails) == false) {
        alert("Please enter the Problem Details.");
       csform.site.focus();
        return false;
        } 
        
          return true;
}

 var submitcount = 0;
 
   function checkSubmit(csform) {

      if (submitcount == 0)  {
      submitcount++;
      document.csform.submit();
      }
   }

function textCounter(field, countfield, maxlimit) {

  if (field.value.length > maxlimit)
      { field.value = field.value.substring(0, maxlimit); }
      else
      { countfield.value = maxlimit - field.value.length; }
  }
  
  /*
var textToCount = document.csform.problemdetails.value;
var lengthOfText = textToCount.length;

if (lengthOfText >= 256)  {

        alertWindow = window.open('alert.phtml?numchars=' + lengthOfText , 'alertWin' , 'width=375,height=250');

	return false;
}
           
    */  
      