function riddle(){
	var emailarray5128= new Array(105,110,102,111,64,108,101,102,107,97,45,97,112,97,114,116,109,101,110,116,115,46,103,114);
	var postemail5128='';
	for (i=0;i<emailarray5128.length;i++)
		postemail5128+=String.fromCharCode(emailarray5128[i]);
	return postemail5128;
}
function VF_booking(){

<!--type,text,name,imgverify,required,true,errMsg,Please type the text you see in the verification image-->
<!--type,text,name,email,required,true,isEmail,errMsg,Please type your e-mail address-->
<!--type,text,name,fullname,required,true,errMsg,Please type your full name-->
<!--end_of_saved_settings-->
	var theForm = document.booking;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var errMsg = "";
	var setfocus = "";

	if (theForm['imgverify'].value == ""){
		errMsg = "Please type the text you see in the verification image";
		setfocus = "['imgverify']";
	}
	if (!emailRE.test(theForm['email'].value)){
		errMsg = "Please type your e\-mail address";
		setfocus = "['email']";
	}
	if (theForm['fullname'].value == ""){
		errMsg = "Please type your full name";
		setfocus = "['fullname']";
	}
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	else theForm.submit();
}

function VF_gbook(){ //v2.0
<!--start_of_saved_settings-->
<!--type,text,name,imgverify,required,true,errMsg,Please type the text you see in the verification image-->
<!--type,text,name,email,required,true,isEmail,errMsg,Please type your e-mail address-->
<!--type,text,name,fullname,required,true,errMsg,Please type your full name-->
<!--end_of_saved_settings-->
	var theForm = document.gbook;
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var errMsg = "";
	var setfocus = "";

	if (theForm['imgverify'].value == ""){
		errMsg = "Please type the text you see in the verification image";
		setfocus = "['imgverify']";
	}
	if (!emailRE.test(theForm['email'].value)){
		errMsg = "Please type your e\-mail address";
		setfocus = "['email']";
	}
	if (theForm['fullname'].value == ""){
		errMsg = "Please type your full name";
		setfocus = "['fullname']";
	}
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}
	else theForm.submit();
}

var nReload = 5;
function NewVerifyImage()
{
    if (nReload <= 2)
        if (nReload <= 0)
        {
            alert("Sorry, too many reloads.");
            return;
        }
        else
            alert("Only " + nReload + " more reloads are allowed");
    nReload--;

        //
        // This code now works in both IE and FireFox
        //
    var         e_img;

    e_img = document.getElementById("vimg");
    if (e_img)
                //
                // FireFox attempts to "optimize" by not reloading
                // the image if the URL value doesn't actually change.
                // So, we make it change by adding a different
                // count parameter for each reload.
                //
        e_img.setAttribute("src",e_img.src+'?count='+nReload);
}


function Calculate(){
	var theform=document.booking
	var checkin=theform.checkin
	var checkout=theform.checkout
	var roomdata=new Array()
	var adults
	var kids,sumpernight
	var numberofrooms, temp
	var personsNo, adultsNo,kidsNo,i,j, k, nights,ratepernight, total
	var day,sum, checkoutday, checkinday
	var rates=[[35,40,50,50,40,35],[45,50,60,60,50,45],[50,55,65,65,55,50],[55,60,70,70,60,55],[55,60,70,70,60,55],[60,65,75,75,65,60]]
	var nodiscount=[[40,45,55,55,45,40],[50,55,65,65,55,50],[55,60,70,70,60,55],[60,65,75,75,65,60],[60,65,75,75,65,60],[65,70,80,80,70,65]]
	var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
	
	daystr=checkin.value.substring(5)
	var daystr = daystr.split("-")
	var dd, mm, yyyy
	
	//Format check in date correctly
	dd=daystr[0]
	for(j=0;j<months.length;j++)
	{
		if (months[j]==daystr[1])
		break
	}
	mm=j
	yyyy=daystr[2]	
	checkinday= new Date(yyyy, mm, dd)
	
	//Format check out date correctly
	daystr=checkout.value.substring(5)
	daystr = daystr.split("-")
	dd=daystr[0]
	for(j=0;j<months.length;j++)
	{
		if (months[j]==daystr[1])
		break
	}
	mm=j
	yyyy=daystr[2]	
	checkoutday= new Date(yyyy, mm, dd)
	
	nights=Math.ceil((checkoutday.getTime()-checkinday.getTime())/(1000*60*60*24))
	
	
	roomdata[0]= new Array()
	roomdata[0][0]=theform.unitype1.value
	roomdata[0][1]=theform.numberofadults1.value
	roomdata[0][2]=theform.numberofchildren1.value
	
	
	roomdata[1]= new Array()
	roomdata[1][0]=theform.unitype2.value
	roomdata[1][1]=theform.numberofadults2.value
	roomdata[1][2]=theform.numberofchildren2.value
	
	roomdata[2]= new Array()
	roomdata[2][0]=theform.unitype3.value
	roomdata[2][1]=theform.numberofadults3.value
	roomdata[2][2]=theform.numberofchildren3.value
	
	roomdata[3]= new Array()
	roomdata[3][0]=theform.unitype4.value
	roomdata[3][1]=theform.numberofadults4.value
	roomdata[3][2]=theform.numberofchildren4.value
	
	for(i=0;i<4;i++)
	{
		j=i+1
		if (roomdata[i][0]=="-")
		{
			temp="numberofadults"+j
			theform.elements[temp].value="-"
			temp="numberofchildren"+j
			theform.elements[temp].value="-"
			temp="costpernight"+j
			theform.elements[temp].value="-"
		}
		
		
	}
	
	sum=0
	numberofrooms=0
	adults=0
	kids=0
	for (i=0;i<4;i++)
	{
		day=new Date(checkinday.getTime())
		
		if (roomdata[i][0]!="-")
		{
			if(roomdata[i][1]=="-")
				adultsNo=0
			else
			{
				adultsNo=roomdata[i][1]*1
				adults=adults+adultsNo
			}
	
			if(roomdata[i][2]=="-")
				kidsNo=0
			else
			{
				kidsNo=roomdata[i][2]*1
				kids=kids+kidsNo
			}
			
			personsNo=adultsNo+kidsNo
			
			if (personsNo>0)
			{
				if (roomdata[i][0]=="Studio")
				{
					switch(personsNo)
					{		
						case 1: k=0; break
						case 2: k=1; break
						case 3: k=2; break
						case 4: alert("A studio can't accommodate 4 persons. Please change your selection to a one bedroom apartment instead.")
					}
				}
				if (roomdata[i][0]=="Apartment")
				{
					switch(personsNo)
					{
						case 1: alert("For 1 person, a one bedroom apartment is not available. Please, select a studio instead.")
						case 2:k=3; break
						case 3:k=4; break
						case 4:k=5; break
					}
				}
				if (personsNo>4)
				{
					alert("A studio can accommodate 3 persons at maximum. A one bedroom apartment can accommodate 4 persons at maximum. We don't have any units that can accommodate more than 4 persons at maximum. Please consider selecting more units.")
					j=i+1
					temp="numberofadults"+j
					theform.elements[temp].value="-"
					temp="numberofchildren"+j
					theform.elements[temp].value="-"
					temp="costpernight"+j
					theform.elements[temp].value="-"
				}
				numberofrooms++
				sumpernight=0
				j=day.getMonth()-4
				do
				{
					if (nights<7)
					{
						sum += nodiscount[k][j]
						sumpernight+= nodiscount[k][j]
					}
					else
					{
						sum += rates[k][j]
						sumpernight+= rates[k][j]
					}
					day.setDate(day.getDate()+1)
					j=day.getMonth()-4
				}while(day<checkoutday)
				j=i+1
				temp="costpernight"+j
				theform.elements[temp].value=(sumpernight/nights).toFixed(2)
			}
		}
		
	}
	theform.total.value=sum.toFixed(2) + " Euros"
	theform.totalrooms.value=numberofrooms
	theform.totaladults.value=adults
	theform.totalchildren.value=kids
	theform.nights.value=nights
	theform.ratepernight.value=(sum/nights).toFixed(2) +" Euros"
}

function Calculate_gr(){
	var theform=document.booking
	var checkin=theform.checkin
	var checkout=theform.checkout
	var room=theform.room
	var adults=theform.adults
	var kids=theform.kids
	var numberofrooms=theform.numberofrooms
	var personsNo, adultsNo,kidsNo,i,j, nights,ratepernight, total
	var day,sum, checkoutday
	var rates=[[35,40,50,50,40,35],[45,50,60,60,50,45],[50,55,65,65,55,50],[55,60,70,70,60,55],[55,60,70,70,60,55],[60,65,75,75,65,60]]
	var nodiscount=[[40,45,55,55,45,40],[50,55,65,65,55,50],[55,60,70,70,60,55],[60,65,75,75,65,60],[60,65,75,75,65,60],[65,70,80,80,70,65]]
	var months=["ΙΑΝ","ΦΕΒ","ΜΑΡ","ΑΠΡ","ΜΑΙ","ΙΟΥΝ","ΙΟΥΛ","ΑΥΓ","ΣΕΠ","ΟΚΤ","ΝΟΕ","ΔΕΚ"]
	
	var daystr = checkin.value.split("-")
	var dd, mm, yyyy
	
	//Format check in date correctly
	dd=daystr[0]
	for(j=0;j<months.length;j++)
	{
		if (months[j]==daystr[1])
		break
	}
	mm=j
	yyyy=daystr[2]	
	day= new Date(yyyy, mm, dd)
	
	//Format check out date correctly
	daystr = checkout.value.split("-")
	dd=daystr[0]
	for(j=0;j<months.length;j++)
	{
		if (months[j]==daystr[1])
		break
	}
	mm=j
	yyyy=daystr[2]	
	checkoutday= new Date(yyyy, mm, dd)
	
	nights=Math.ceil((checkoutday.getTime()-day.getTime())/(1000*60*60*24))
	
	if (day.getMonth()<=3 || day.getMonth()>=10)
	{
		alert("We are open only from May to October; please check your dates.")
		theform.total.value="-"
		theform.nights.value="-"
		theform.ratepernight.value="-"
		return;
	}
	if (checkoutday.getMonth()<=3 || checkoutday.getMonth()>=10)
	{
		alert("We are open only from May to October; please check your dates.")
		theform.total.value="-"
		theform.nights.value="-"
		theform.ratepernight.value="-"
		return;
	}
	
	if(nights<=0)
	{
		alert("Check in date is after check out date; please check the dates you supplied.")
		theform.total.value="-"
		theform.nights.value="-"
		theform.ratepernight.value="-"
		return;
	}
		
	if(adults.value=="-")
		adultsNo=0
	else
		adultsNo=adults.value*1
	
	if(kids.value=="-")
		kidsNo=0
	else
		kidsNo=kids.value*1
	
	personsNo=adultsNo+kidsNo
	
	if (personsNo==0)
		{
		alert("Please specify the number of adults and children.")
		theform.total.value="-"
		theform.nights.value="-"
		theform.ratepernight.value="-"
		return;
	}
	if (room.value=="-")
	{
		alert("Please specify type of room")
		theform.total.value="-"
		theform.nights.value="-"
		theform.ratepernight.value="-"
		return;
	}
	if (personsNo>3 && room.value=="Studio")
	{
		alert("A studio can accommodate 3 persons maximum.")
		theform.total.value="-"
		theform.nights.value="-"
		theform.ratepernight.value="-"
		return;
	}
	if (personsNo==1 && room.value=="Apartment")
	{
		alert("For 1 person, a one bedroom apartment is not available. Please, select a studio instead.")
		theform.total.value="-"
		theform.nights.value="-"
		theform.ratepernight.value="-"
		return;
		
	}
	
	if (adultsNo==4 && room.value=="Apartment")
	{
		alert("Unfortunately, an apartment can not accommodate 4 adults. Please consider taking 2 units.")
		theform.total.value="-"
		theform.nights.value="-"
		theform.ratepernight.value="-"
		return;
	}
	if (personsNo>4 && room.value=="Apartment")
	{
		alert("A one bedroom apartment can accommodate 4 persons (2 adults + 2 children) maximum. Please consider taking more than 1 units.")
		theform.total.value="-"
		theform.nights.value="-"
		theform.ratepernight.value="-"
		return;
	}
	if (room.value=="Studio")
	{
		switch(personsNo)
		{		
			case 1: i=0; break
			case 2: i=1; break
			case 3: i=2; break
		}
	}
	else if (room.value=="Apartment")
	{
		switch(personsNo)
		{
			case 2:i=3; break
			case 3:i=4; break
			case 4:i=5; break
		}
	}

	j=day.getMonth()-4
	sum=0
	do
	{
		if (nights<7)
			sum += nodiscount[i][j]
		else
			sum += rates[i][j]

		day.setDate(day.getDate()+1)
		j=day.getMonth()-4
	}while(day<checkoutday)
	roomsNo=numberofrooms.value*1
	theform.total.value=roomsNo*sum.toFixed(2) + " Euros"
	theform.nights.value=nights
	theform.ratepernight.value=(sum/nights).toFixed(2) +" Euros"
}
