// JavaScript Document

/*  preload images  */

	var abt_hh = new Image();
	var abt_hh_s = new Image();
	var abt_reg = new Image();
	var abt_reg_s = new Image();
	var accom = new Image();
	var accom_s = new Image();
	var book = new Image();
	var book_s = new Image();
	var contact = new Image();
	var contact_s = new Image();
	var wed = new Image();
	var wed_s = new Image();	
	
	var name01="Mark and Erin";
	var comment01="The perfect tonic! Great setting - hospitality with the extra touches to make it special - can't wait to return and finish the books.";
	var name02="Neville and Maxine";
	var comment02="Great weekend, beautiful setting , \"The Perfect Hosts\" David and Helen. Can't wait to tell our friends how great it is.  Till next time.";
	var name03="Chris and Arthur (Sydney NSW)";
	var comment03="Thanks for the wonderful time. Your little 'surprise touches' made it more special. Hope it continues to grow. - Good Luck - Will tell everyone on the East Coast how fantastic it is and to make sure they stay here.";
	var name04="Trevor and Glenda (Gold Coast)";
	var comment04="Helen and David. Thank god we chose you!!. Our stay with you has been the highlight of our trip to WA. You made us feel very special, with your little treats and amazing attention to detail. Loved the feeling of privacy.  The beautiful gardens are a credit to you. You will be recommended to our family and friends.";
	var name05="Christie and Calvon";
	var comment05="A very beautiful place. We had a wonderful relaxing time. Thank you both.";
	var name06="Paul and Margaret (Sydney NSW)";
	var comment06="We absolutely loved it here - please enjoy many years here. We will be back.";
	var name07="Richard and Jane (Malaysia)";
	var comment07="Very good, everything is so organised, clean and neat.  We will be back here if we travel to WA again.  Well done keep it up.";
	var name08="Allan (USA)";
	var comment08=" If you need a good rest, then \"Honeymoon Hill\" is the place, for you will find Peace and God. Thanks.";
	var name09="Martin and Deb";
	var comment09="A truly relaxing place with very special touches - thank youHelen and David.";
	var name10="Ian and Fiona";
	var comment10="Just what we needed - serenity after a very rushed few months. Thank you so much - especially for the extra touches. We will recommend this to all.";
	var name11="Bill and Jaqui";
	var comment11="I have waited 7 years for my honeymoon. It was worth the wait!. See I'm so relaxed I can't think how to spell \"Thank you.\"";
	var name12="David and Lorraine";
	var comment12="A night of luxury for our honeymoon. So many special touches. Thank you.";
	var name13="Anthony and Natasha";
	var comment13="A wonderful experience. Just what we needed. Many thanks.";
	var name14="Liam and Robbie";
	var comment14="An absolutely beautiful backdrop for an unforgettable weekend .....WE'RE GETTING MARRIED.";
	var name15="Ben and Donelle";
	var comment15="What a fantastic hideaway. So perfect, so quiet, so relaxing and romantic. Just the think we needed. We will be back to enjoy the serenity once again and will be telling all our friends.";
	var name16="Richard and Justine";
	var comment16="So wonderful! Thank you for all the special little touches. We will be back very soon (for longer).";
	var name17="Martin and Deb";
	var comment17="Once again a fantastic stay. Such a relaxing place to come to. Thank you Helen and David, you are such lovely hosts.  We will definitely be back for our third visit.";
	var name18="Eyal and Lital (Israel)";
	var comment18="Thanks for making our honeymoon so special. It was so nice finding new surprises everyday - Thanks so much.";
	var name19="John and Angela";
	var comment19="Some places fairydust falls from the trees, some places music sings through the breeze, some place love floats like a harp, some place will always remain in my heart. Honeymoon Hill you are one of the some places. Thank you.";
	var name20="Kevin and Sharon";
	var comment20="Grow old along with me, the best is yet to be. (R Browning) 20th Wedding anniversary. A charming restful moment to catch our breathe and count our blessings.";
	var name21="Stewart and Sue (New Zealand)";
	var comment21="Thank you Helen and David - all those thoughtful touches. Our stay was truly relaxing.";
	var name22="Josh and Sandra";
	var comment22="Delightful! We hope to come again soon. Thank you David and Helen and pets.";
	var theRandomNumber=getRandomNumber();
	

	abt_hh.src = "includes/images/buttons/abt_hh.gif";
	abt_hh_s.src = "includes/images/buttons/abt_hh_s.gif";
	abt_reg.src = "includes/images/buttons/abt_reg.gif";
	abt_reg_s.src = "includes/images/buttons/abt_reg_s.gif";
	accom.src = "includes/images/buttons/accom.gif";
	accom_s.src = "includes/images/buttons/accom_s.gif";
	book.src = "includes/images/buttons/book.gif";
	book_s.src = "includes/images/buttons/book_s.gif";
	wed.src = "includes/images/buttons/wed.gif";
	wed_s.src = "includes/images/buttons/wed_s.gif";	
	contact.src = "includes/images/buttons/contact.gif";
	contact_s.src = "includes/images/buttons/contact_s.gif";

function RolloverImage(ImageName, ImageState){

	<!-- Assign the new colour to the named row object -->
	eval("document.images."+ImageName+".src="+ImageName+ImageState+".src");

}

function showHideLayers(divName,visible) {
  var obj = document.getElementById(divName);
	if (obj.style.visibility == 'hidden'){
		obj.style.visibility = 'visible';
	}else{
		obj.style.visibility = 'hidden';
	}
}

function getRandomNumber(){
	var num = Math.round(Math.random()*10)+1;
	if (num < 10){
		return "0"+num;
	}
	return num;
}

function getQuote(){
	return "<p>\""+eval("comment"+theRandomNumber)+"\"</p>";
}

function getQuoted(){
	return "<h1>"+eval("name"+theRandomNumber)+"</h1>";
}

function populate_form() {
	var formObject;
	
	this.setFormObject = function (var_obj) {
		this.formObject = var_obj;
	}
	
	this.getFormObject = function () {
		return this.formObject;
	}
	
	this.findElement = function (var_element) {
		for(var i = 0; i < this.getFormObject().elements.length-1;i++) {
			if (this.getFormObject().elements[i].name == var_element) {
				return this.getFormObject().elements[i];
			}
		}
	}
	
	this.setValue = function (var_item,var_value) {
		if (var_item != 'Submit'){
			var the_element = this.findElement(var_item.toLowerCase());
		}else{
			var the_element = this.findElement(var_item);
		}
		
		if (the_element.type == 'select-one'){
			for(var i = 0; i < the_element.options.length;i++) {
				if (the_element.options[i].value == var_value){
					the_element.options[i].selected = true;
				}
			}
		} else {
			the_element.value = var_value;
		}
		
		if (var_item.indexOf('DATE') != -1) {
				var x = document.getElementById(var_item+'_div').childNodes[0];
				x.innerHTML = var_value.substring(8,10)+'/'+var_value.substring(5,7)+'/'+var_value.substring(0,4);
		}
	}
	
	this.Init = function (var_object) {
		this.setFormObject(var_object);
	}
}

function validate_form() {

	var formObject;
	var errorItem;
	
	this.setFormObject = function (var_obj) {
		this.formObject = var_obj;
	}
	
	this.getFormObject = function () {
		return this.formObject;
	}
	
	this.setErrorItem = function (var_item) {
		this.errorItem = var_item;
	}
	
	this.getErrorItem = function () {
		return this.errorItem;
	}
	
	this.checkElements = function () {
		for(var i = 0; i < this.getFormObject().elements.length-1;i++) {
			if (this.getFormObject().elements[i].type != 'hidden') {
				if (this.getFormObject().elements[i].value == ''){
					this.setErrorItem(this.getFormObject().elements[i].name);
					return false;
				}
			}
		}
		return true;
	}
	
	this.findElement = function (var_element) {
		for(var i = 0; i < this.getFormObject().elements.length;i++) {
			if (this.getFormObject().elements[i].name == var_element) {
				return this.getFormObject().elements[i];
			}
		}
	}
	
	this.Submit = function (var_object) {
		this.setFormObject(var_object);
		if (this.checkElements()) {
			this.getFormObject().submit();
		}else{
			this.findElement(this.getErrorItem()).focus();
			alert('You haven\'t supplied a value for \n  - '+this.getErrorItem().replace('_',' ')+' -\n the page cannot submit.');
		}
	}
}



