// JavaScript Document
//Script for the validation of the callMe check box in the primary contact form
function checkNumber() {
	var callMe=document.contactForm.callMe.checked;
	if (callMe==true){
					alert("You have asked us to telephone you regarding your enquiry. Please ensure you have\n supplied the correct telephone number and that you indicate a suitable time for us\n to call you.");
	}
}


//Image gallery script
function showPic(whichpic) {
	var source = whichpic.getAttribute("href");
	var placeholder=document.getElementById("placeholder");
	placeholder.setAttribute("src",source);
	var text = whichpic.getAttribute("title");
	var description = document.getElementById("pictureDescription");
	description.firstChild.nodeValue = text;
}

//function to swap images on mainNav onmouseover
var W3CDOM = (document.createElement && document.getElementsByTagName);

var mouseOvers = new Array();
var mouseOuts = new Array();

window.onload = init;

function init()
{
	if (!W3CDOM) return;
	var nav = document.getElementById('mainNav');
	var imgs = nav.getElementsByTagName('img');
	for (var i=0;i<imgs.length;i++)
	{
		imgs[i].onmouseover = mouseGoesOver;
		imgs[i].onmouseout = mouseGoesOut;
		var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
		mouseOuts[i] = new Image();
		mouseOuts[i].src = imgs[i].src;
		mouseOvers[i] = new Image();
		mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('.')) + "_omo" + suffix;
		imgs[i].number = i;
	}
}

function mouseGoesOver()
{
	this.src = mouseOvers[this.number].src;
}

function mouseGoesOut()
{
	this.src = mouseOuts[this.number].src;
}

//function to change enquiry form if subject is weddings
function weddingEnq(form) { 
	var subject=contactForm.enquiryType.selectedIndex; 
	if (subject==2) { 
		window.location="weddingContact.html"; 

	}
}

/*//function to change enquiry form if subject is not weddings
function notWeddingEnq(form) {
	var subject=weddingContactForm.weddingSubject.selectedIndex;
	if (subject!=2) {
		window.location="index.html";
	}
}*/

//Get directions
function getDirections() {
	var from=document.getDir.homePostCode.value;
	newWindow=window.open('http://maps.google.co.uk/maps?saddr='+from+'&daddr=LA116ET','newWin','height=600,width=800,resizable=yes,scrollbars=yes,menubar=no,addressbar=no');
}

//Open new windows for virtual tours
function newWin(URL) {
	window.open(URL,'_blank','status=no,width=500,height=420')
	}
