
///////////////////////////////// Function CheckEmpty() ////////////////////////////////////////////////////////////////////////////
function CheckEmpty(A, Field1, Msg, Msg1, Msg11)
{ 
	var Rf =document.getElementById(Field1);
	if (Rf.value.length == 0){alert(Msg);    return false;} 
	
	 if (Field1 == Field1 == "code" || Field1 == "contactno" )
	{return CheckNumber(Field1, Msg1, Msg11);}

	 if (Field1 == "fullname")
	{return CheckName(Field1, Msg1);}
	
	if (Field1 == "require")
	{ return CheckRequire(Field1);}

return true;

}
//////////////////////////// Function CheckNumber() /////////////////////////////////////////////////////////////////////////////////
function CheckNumber(Field2, Msg2, Msg22)
{ 
var Rf2 =document.getElementById(Field2);
if(Rf2.value.length==0){ return false;} 
if(isNaN(Rf2.value)) {alert(Msg2); Rf2.focus(); Rf2.select(); return false;} 
}
////////////////////////////////// Function CheckName() /////////////////////////////////////////////////////////////////////////////
function CheckName(Field3, Msg3)	 
{
var Rf3 =document.getElementById(Field3);
S=Rf3.value;
for( i=0; i<S.length; i++) 
  {	
		R = S.charAt(i); wrong = 1; 
		T="abcdefghijklmnopqrstuvwxyz -ABCDEFGHIJKLMNOPQRSTUVWXYZ-ñáéóíúÑÁÉÓÍÚ"; 
		for( j=0; j<67; j++)	{	if ( T.charAt(j) == R ) {wrong=0;}    } 	
		if (wrong>=1) 			{Rf3.value = alert(Msg3); Rf3.value = S; Rf3.focus(); Rf3.select(); return false;}
  }     
}
////////////////////////////////// Function CheckDescription() //////////////////////////////////////////////////////////
function CheckRequire(Field4)
{
var Rf4 =document.getElementById(Field4);

if ((Rf4.value.length < 5) || (Rf4.value.length > 600)){
	msg4 = "You have entered " + Rf4.value.length + " character(s)\n"
	msg4 = msg4 + "Valid entries are between 5 and 600 characters.\n"
	msg4 = msg4 + "Please verify your input and submit again."
	alert(msg4); Rf4.focus(); return false;}
}
////////////////////////////////// Function CheckDescriptionCharacters() /////////////////////////////////////////////////////////////////////////////
function CheckCharacters(Field5)	 
{
var Rf5 =document.getElementById(Field5);
var Msg5 ="These Characters    ( ) [ ] { } : ;  \'  \"   are NOT allowed\n";
    Msg5 =Msg5 + "Since they can cause conflict with database storage\n";
S	=	Rf5.value;
for( i=0; i<S.length; i++) 
 	{	
		R = S.charAt(i); 
		T="(){}[]:;@#\'\"\\"; 
		for( j=0; j<13; j++)	{	if ( T.charAt(j) == R ) {alert(Msg5); Rf5.focus(); Rf5.select(); return false;}    } 	
  	}     
}
/////////////////////////////// Validate Email /////////////////////////////////////////////////////////////////////////////////////
function ValidateEmail(typing, warning){
with (typing){pos1=value.indexOf("@"); pos2=value.lastIndexOf("."); pos3=value.length-1; 
if (pos1<1 || pos2-pos1<2 || pos3-pos2>3 || pos3-pos2<2) { if (warning) {alert(warning);} return false;} else {return true;}}
} 
/////////////////////////////// Validate Telephone Number ////////////////////////////////////////////////////////////////////////////
function isInteger(L)
{	var x; for (x = 0; x < L.length; x++) 	{var N = L.charAt(x); if (((N < "0") || (N > "9"))) return false; } return true;	}

function StripChrs(L, basket)
{	var x;  var Feedback = ""; for (x = 0; x < L.length; x++) { var N = L.charAt(x); if (basket.indexOf(N) == -1) Feedback += N;} return Feedback;	}

function IsValid(Fone)
{var Extras ="-+()/ ";L=StripChrs(Fone,Extras);return (isInteger(L) && L.length >= 9);}

function Validate()
{	var Tel=document.Store.Input; 	
	if ((Tel.value==null) || (Tel.value=="")) {alert("Phone Number is Empty"); Tel.focus(); return false;}
	if (IsValid(Tel.value)==false) {alert("Phone Number is NOT Valid");	Tel.value=""; 	Tel.focus(); return false;} return true;	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function CheckAll()
{ 
var Rn1	=document.getElementById('fullname');
var Rn2	=document.getElementById('require');
var Rn3	=document.getElementById('code');
var Rn4	=document.getElementById('contactno');

if 		(Rn1.value.length == 0){alert("Please Full Name field Can not be left empty"); 		Rn1.value=""; Rn1.focus(); return false;} 
else if (Rn2.value.length == 0){alert("Please Requirement field Can not be left empty"); 	Rn2.value=""; Rn2.focus(); return false;} 
else if (Rn3.value.length == 0){alert("Please Code field Can not be left empty");  			Rn3.value=""; Rn3.focus(); return false;} 
else if (Rn4.value.length == 0){alert("Please Contact No. field Can not be left empty"); 	Rn4.value=""; Rn4.focus(); return false;} 
else {return true;}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TestNumber(B, Field9, Msg9)
{ 
var Rf9 =document.getElementById(Field9);
if(isNaN(Rf9.value)) {alert(Msg9); Rf9.focus(); Rf9.select(); return false;} else {return true;}
}

