///////////////////////////////// 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 == "id" || Field1 == "Myid" || Field1 == "oldsn" || Field1 == "sleeps"  )
	{return CheckNumber(Field1, Msg1, Msg11);}

	 if (Field1 == "name" || Field1 == "surname" )
	{return CheckName(Field1, Msg1);}

	if (Field1 == "description")
	{ return CheckDescription(Field1);}
	
	if ((Field1 == "address") || (Field1 == "notes"))
	{return CheckLength(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;} 

	 if (Field2 == "id"|| Field2 == "Myid"){
		 if (Rf2.value <10001 || Rf2.value >19999 )  {alert(Msg22); Rf2.focus(); Rf2.select(); return false;}
	 }
	 
	 if (Field2 == "id"){
		var Rd =document.getElementById(Field2);
		var Ri =document.getElementById('initials');
		var Rp =document.getElementById('photocode');
		if (Rd.value !="")  {Rp.value =Ri.value + "_" + Rd.value ;}
	 }
}
////////////////////////////////// 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<66; 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 CheckDescription(Field4)
{
var Rf4 =document.getElementById(Field4);

if ((Rf4.value.length < 5) || (Rf4.value.length > 1300)){
	msg4 = "You have entered " + Rf4.value.length + " character(s)\n"
	msg4 = msg4 + "Valid entries are between 5 and 1300 characters.\n"
	msg4 = msg4 + "Please verify your input and submit again."
	alert(msg4); Rf4.focus(); return false;}
//	  return CheckCharacters(Field4);
}
////////////////////////////////// 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;}    } 	
  	}     
}
/////////////////////////////////////////////////////////////////
function CheckAll()
{ 
var Rn1	=document.getElementById('accepted');
if 		(Rn1.checked == false){alert("Please Check the box of Terms & Conditions to be able to send the BOOKING FORM");  Rn1.focus(); return false;} 
return true;
}