function emptyfield(check,err_msg)
{
   if (check.value == "")
	 {
	  alert(err_msg);
	  check.focus();
	  return false;
	}
}

function chkEmail(email)
{
		emailV = email.value;
		var emailsArray = emailV.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
		if (emailsArray == null) 
		{
				alert("Invalid email address !");
				email.focus();
				return 1;
		}
	return 0;	
}

function chkNum(field) 
{
	  var valid = "0123456789"
		var ok = "yes";
		var temp;
		for (var i=0; i<field.value.length; i++) 
		{
			temp = "" + field.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") 
				ok = "no";
		}
		if (ok == "no")
		{
			alert("Invalid entry! Only numbers are accepted!");
			field.focus();
			return false;
		}
	return true;
}

function chkAlpha(field) 
{
	var valid = "abcdefghijklmnopqrstuvwxyz"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++)
	{
		temp = "" + field.value.toLowerCase().substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
			ok = "no";
	}
	if (ok == "no") 
	{
	alert("Invalid entry!  Only characters and numbers are accepted!");
	field.focus();
	field.select();
	return false;
   }
	return true;
}

function chkSpace(ent) 
{
	  var valid = "abcdefghijklmnopqrstuvwxyz0123456789."
		var ok = "yes";
		var temp;
		for (var i=0; i<ent.value.length; i++) 
		{
			temp = "" + (ent.value.toLowerCase()).substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
					ok = "no";			
		}
		if (ok == "no")
		{
			alert("Invalid entry ! Only characters and numbers are accepted, no space allowed!");
			ent.focus();
			return false;
		}
	return true;
}

function chkTel(field) 
{
	  var valid = "0123456789-"
		var ok = "yes";
		var temp;
		for (var i=0; i<field.value.length; i++) 
		{
			temp = "" + field.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") 
				ok = "no";
		}
		if (ok == "no")
		{
			alert("Invalid entry!  Only numbers and - are accepted!");
			field.focus();
			return false;
		}
	return true;
}

function selectlistindex(combobox)
{   
   var checknull=1;
	 
   for(i=0;i<combobox.options.length;i++)
	 {
	 if(combobox.options[i].selected)
		 {
				if(combobox.options[i].value == "")
					checknull=0;
				break;
	 }
   }	
   if (checknull == 0) 
	  return false;     		
   else
	return true;
}


/*function checkBox(check,msg){
  //alert("here at east");
   var counter=0;

   for(var i=0;i<check.length;i++)
   {
	 if(check[i].checked)
	 {
	   counter=counter+1;
	 }
   }
	
   if(check.checked == true) //prevent one checkbox only cannot delete...
   {
	//	alert("true");
	  return true;
	}
		
   //alert("counter no " + counter);
   if(counter < 1 )
   {
	 alert(msg);
	 return false;
   }

}*/

function checkBox(check,msg){
  
   var counter=0;

	if(check == null)
	{
		alert("Sorry there is nothing to be delete");
		return false;
	}
	else
	{
	   for(var i=0;i<check.length;i++)
	   {
		 if(check[i].checked)
		 {
		   counter=counter+1;
		 }
	   }
		
	   if(check.checked == true) //prevent one checkbox only cannot delete...
	   {
		  return true;
	   }

	   if(counter < 1 )
	   {
		 alert(msg);
		 return false;
	   }
	}
}
