//function for changing the style for the current page
function setActiveLink (linkId, clsName) {
 if (document.getElementById) {
  document.getElementById(linkId).className=clsName;
 }
}

//function for opening popup window to display furniture and enquiry form and 100mile map
var leftPos = 0
var tall = 0
if (screen) {
	leftPos = screen.width/2-313;
	tall = screen.height-135;
}
function newWindow(url) {
		popupWindow = window.open(url, 'newWin', 'scrollbars=yes,width=626,height='+tall+',left='+leftPos+',top=5,resizable=yes')
	popupWindow.focus();
	}

//re-route visitor to home page if visitor arrives via a popup link
//for example: from a link in search results
function linkToMainSite() {
	if (window.name != 'newWin') {
	document.location = "http://www.greenwichwoodworks.co.uk/index.shtml";
	}
}

//StreetMap popup window
function popup(){
	win = window.open('http://www.streetmap.co.uk/streetmap.dll?P2M?P=SE137QS&Z=1','','width=800,height=550,scrollbars=yes,resizable=yes,toolbar=yes');
	}

//checking when send button pressed
function formCheck(enquiry) {
	if (enquiry.name.value=="") 
	{alert("Please enter a contact name.");	enquiry.name.focus();	return false;}
	if (enquiry.enquiry.value=="") 
	{alert("Please provide details of you enquiry.");	enquiry.enquiry.focus();	return false;}
	if (enquiry.address.value=="" && enquiry.telephone.value=="" && enquiry.email.value=="" && enquiry.fax.value=="") 
	{alert("Please enter:\n\n - a telephone number\n - email address\n - postal address\n - or fax number \n\nso that we may contact you.\n\nThank you.");	enquiry.address.focus(); return false;}
//THIS BIT OF CODE IS REDUNDANT UNLESS THE "REQUEST A BROCHURE" CHECKBOX IS REINSTATED ON THE CONTACT US FORM	
//	if (enquiry.brochure.checked && enquiry.address.value=="")
//	{alert("You have requested a brochure but not completed the address field.\n\nPlease complete the address field or 'un-check' the brochure request.\n\nThank you."); enquiry.address.focus(); return false;}
	if (enquiry.where.value=="Choose from the list...")
	{alert("Please let us know where you heard about us by selecting from the list.\n\nThank you.");	enquiry.where.focus(); return false;}
}

//checking that visitor really wants to clear form entries
function check() {
    if (!confirm ("Clear all the entries?\n\nClick 'OK' to confirm")) {
        enquiry.elements.Submit.focus();
         return false;
    }
    enquiry.elements.name.focus();
    return true;
}

//Timeout function to close window automatically
function vanish() {
	setTimeout("window.close()", 7000);
	}

//Check visitor really wants to close popup window
function reallyClose(enquiry) {
	if (enquiry.name.value !="" && !confirm("Did you mean to click CLOSE WINDOW instead of SEND?\n\nClick OK if you did\n\nor\n\nCANCEL to return to the form")){
    enquiry.elements.Submit.focus();	
	return true;	
	}
	self.close();
	return false;
}

//image swapper for showing different door panel woods
		// function to pre load images
function preloadImages() {
if (document.images) {
var imgFiles = preloadImages.arguments;
var preloadArray = new Array();
for (var i=0;i<imgFiles.length;i++) {
preloadArray[i]=new Image;
preloadArray[i].src=imgFiles[i];
		}
	}
}
		//function for swapping images
function swap(id, newsrc) {
var theImage = locateImage(id);
if (theImage) {
	theImage.src = newsrc;
}
}	
		//function for locating the image to be used in the swap
function locateImage(name) {
var theImage = false;
if (document.images) {
	theImage = document.images[name];
}
if (theImage) {
	return theImage;
}
return(false);
}
	
