function validateForm(frm1)
{

  pass = 1; //assume everything is ok
  msg = "The following problems were found when trying to submit this form:\n\n";

  //make sure required fields are not empty

  
  
  	if (isEmpty(frm1.fname.value))
  		{
  		  msg = msg + "- First Name cannot be empty\n";
   		 pass = 0;
  		}
  
  
  
   			if (isEmpty(frm1.lname.value))
  			{
  			  msg = msg + "- Last Name cannot be empty\n";
   			 pass = 0;
 			 }
  
   
   if (isEmpty(frm1.email.value))
  {
    msg = msg + "- Email cannot be empty\n";
    pass = 0;
 }
 
 
  if (!(isEmail(frm1.email.value)))
 {
    msg = msg + "- Please enter a valid email address\n";
    pass = 0;
  }
  
  
  
  			 if (isEmpty(frm1.add1.value))
  			{
			 msg = msg + "- Address cannot be empty\n";
   			 pass = 0;
 			 }
  
  

   	if (isEmpty(frm1.title.value))
  		{
  		  msg = msg + "- Video name cannot be empty\n";
   		 pass = 0;
  		}
			if (isEmpty(frm1.video.value))
  		{
  		  msg = msg + "- Please select video file to upload\n";
   		 pass = 0;
  		}
		if(frm1.add4.value!="")
		{
			
			if(!isNum(frm1.add4.value))
   {
   
    msg = msg + "- Please enter a valid zip code\n";
    pass = 0;
   
   }
   if(frm1.add4.value.length < 4)
   {
   
  msg = msg + "- Please enter a valid zip code of minimum 4 digits\n";
    pass = 0;
   }
   
   
			
			}
  
   if(frm1.phone1.value!="")
{
  var phone1=frm1.phone1.value;
   var phone2=frm1.phone2.value;
   var phone3=frm1.phone3.value;
 
    phone=phone1+phone2+phone3;
	
  if(!isNum(phone))
   {
   
    msg = msg + "-Please enter a valid phone number\n";
    pass = 0;
   
   }
   if(phone.length < 10)
   {
   
  msg = msg + "-Please enter  10 digit phone number\n";
    pass = 0;
   }


  }
   
  
  if(frm1.title.value!="")
{
 var str=frm1.title.value;
  
  var pos1 = str.indexOf (">");
   
  if (pos1>-1)
  {
  
  alert("invalid character >");
  return false;
  }
  var pos2 =str.indexOf("<");
  if (pos2>-1)
  {
  
  alert("invalid character <");
  return false;
  }
  var pos3 =str.indexOf("%20");
  if (pos3>-1)
  {
  
  alert("invalid character %20");
  return false;
  }
  
  
   var pos4 =str.indexOf("'");
  if (pos4>-1)
  {
  
  alert("invalid character '");
  return false;
  }
   var pos5 =str.indexOf("=");
  if (pos5>-1)
  {
  
  alert("invalid character =");
  return false;
  }
   var pos6 =str.indexOf("*");
  if (pos6>-1)
  {
  
  alert("invalid character *");
  return false;
  }
   var pos7 =str.indexOf("%");
  if (pos7>-1)
  {
  
  alert("invalid character %");
  return false;
  }
  
  
  
  }
  
  
  
  
  
  
   if (frm1.terms.checked==false)
  {
	   msg = msg + "- Please agree by selecting checkbox !\n";
   		 pass = 0;
	// alert("Please agree by selecting checkbox !"); 
	  //return false;
	  }
	  
	  
	 
	  
   if (pass == 1)
  {
    return true;
  }
  else
  {
    alert(msg);
    return false;
  }
  
  
 
	  
	  
 

}

// validators ------------------------------------------------------------------

	
function isEmpty (s) {
	var p = /\S+/;
	return !p.test(s);
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}


function isNum(string) {
    if (string.search(/^[0-9]+$/) != -1)
        return true;
    else
        return false;

}
  function ex()
  {
  
  var sValue=document.getElementById('file_input').value;
   var aParts = sValue.split( "/" );
  var iParts = aParts.length;
  if( iParts >= 1 )
  {
    var sFile = aParts [iParts - 1 ];
    var aFile = sFile.split( "." );
    if( aFile.length == 2 )
    {
      sName = aFile[0];
      sExt = aFile[1];
     // alert("Filename is: "+sName+" extension is: "+sExt);
    }
	
	
	  }
	  
	  if(sExt!="avi" && sExt!="AVI" && sExt!="mpeg" && sExt!="MPEG" && sExt!="wmv" && sExt!="WMV" && sExt!="mov" && sExt!="MOV" )
	  {
		//msg = msg + "- Please upload video files only";
   		// pass = 0;  
		alert("Please upload video files only");
return false;
		  
	  }
	  
	  }
