///////////////////////////////// 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 This box to be able to send booking form");  Rn1.focus(); return false;} 

/*
var Rn2	=document.getElementById('sleeps');
var Rn3	=document.getElementById('description');
var Rn4	=document.getElementById('shortlet');
				var R1 =document.getElementById('lowrent');
				var R2 =document.getElementById('midrent');
				var R3 =document.getElementById('highrent');
				var R4 =document.getElementById('peakrent');
				var R5 =document.getElementById('monthlyrent');
				var R6 =document.getElementById('inclusiverent');
var Rn5	=document.getElementById('longlet');
var Rn6	=document.getElementById('inclusivelet');
				var K1 =document.getElementById('L1a');
				var K2 =document.getElementById('M1a');
				var K3 =document.getElementById('H1a');
				var K4 =document.getElementById('P1a');
				var K5 =document.getElementById('Btn1');



else if (Rn2.value.length == 0){alert("Please Sleeps field Can not be left empty");  			Rn2.value=""; Rn2.focus(); return false;} 
else if (Rn3.value.length == 0){alert("Please Description field Can not be left empty"); 		Rn3.value=""; Rn3.focus(); return false;} 



if 		(Rn4.checked == false && Rn5.checked == false ){alert("     Please Choose at least ONE Rental Type\n Short Let & Long Let fields CAN NOT, BOTH, Be Left Empty");  Rn4.focus(); return false;} 


if 		(Rn4.checked == false && ((R1.value > 0 )|| (R2.value > 0) || (R3.value > 0) || (R4.value > 0))){alert("As Some Seasons Have VALUES, Please Check Short Let Rental Type!!");  Rn4.focus(); return false;} 
if 		(Rn4.checked == false && ((K1.value > 0 )|| (K2.value > 0) || (K3.value > 0) || (K4.value > 0))){alert("As Some Seasons Have DATES, Please Check Short Let Rental Type!!");  Rn4.focus(); return false;} 
if 		(Rn5.checked == false && (R5.value > 0)){alert("As Long Let Monthly Rate Have VALUE, Please Check Long Let Rental Type!!"); Rn5.focus(); return false;} 
if 		(Rn6.checked == false && (R6.value > 0)){alert("As Winter Letting Monthly Rate Have VALUE, Please Check Winter Letting Rental Type!!"); Rn6.focus(); return false;} 


//if 		(Rn4.checked == true && (R1.value.length == 0 || R2.value.length == 0 || R3.value.length == 0 || R4.value.length == 0 || R1.value <= 0 || R2.value <= 0 || R3.value <= 0 || R4.value <= 0  ))	{alert("Please Fill ALL RATES for Different Seasons as These fields CAN NOT Be Left Empty!!"); R1.focus(); return false;} 
//if 		(Rn4.checked == true && (K1.value.length == 0 || K2.value.length == 0 || K3.value.length == 0 || K4.value.length == 0 || K1.value <= 0 || K2.value <= 0 || K3.value <= 0 || K4.value <= 0  ))	{alert("Please Fill ALL DATES for Different Seasons as These fields CAN NOT Be Left Empty!!"); K5.focus(); return false;} 
if 		(Rn4.checked == true && (R1.value.length == 0 || R2.value.length == 0 || R4.value.length == 0 || R1.value <= 0 || R2.value <= 0 || R3.value < 0 || R4.value <= 0  ))	{alert("Please Fill ALL RATES for Different Seasons as These fields CAN NOT Be Left Empty!!"); R1.focus(); return false;} 
if 		(Rn4.checked == true && (K1.value.length == 0 || K2.value.length == 0 || K4.value.length == 0 || K1.value <= 0 || K2.value <= 0  || K4.value <= 0  ))	{alert("Please Fill ALL DATES for Different Seasons as These fields CAN NOT Be Left Empty!!"); K5.focus(); return false;} 
if 		(Rn5.checked == true && ((R5.value.length == 0) || (R5.value <= 0))){alert("Please Fill Long Let Monthly Rate as This field CAN NOT Be Left Empty!!"); R5.focus(); return false;} 
if 		(Rn6.checked == true && ((R6.value.length == 0) || (R6.value <= 0))){alert("Please Fill Winter Letting Monthly Rate as This field CAN NOT Be Left Empty!!"); R6.focus(); return false;} 

if 		(Rn4.checked == false && Rn6.checked == true ){alert("      If You Check Winter Letting Rental Type\n You Have to Check, Also, Short Let Rental Type");  Rn4.focus(); return false;} 
*/
return true;
}