// JavaScript Document

addLoadEvent(prepareGallery);

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}



function prepareGallery() {
	if (!document.getElementsByTagName) {
	return false;
	}
	if (!document.getElementById) { 
	return false;
	}
	if (!document.getElementById("imagegallery")) { 
	return false;
	}
	
	var gallery = document.getElementById("imagegallery");
	var links = gallery.getElementsByTagName("a");
	
	for (var i=0; i < links.length; i++) {
		links[i].onclick = function() {
			showPic(this);
			return showPic(this); // get boolean value (T or F) from showPic function 
		}
	}
}


function showPic(whichpic) {
	if (!document.getElementById("placeholder")) {
		return true; // make browser link to image in new window...no javascript called
	}
	var source = whichpic.getAttribute("href");
	var placeholder = document.getElementById("placeholder");
	if (placeholder.nodeName != "IMG") {
		return true;
	}
	placeholder.setAttribute("src", source);
	return false; // cancels browsers default link-clicking behavior
}



// Check for form errors
    function checkForm(){
                 theform=document.contact

                     // Check that the form has a full name specified in the field called "Name"
                 if (theform.Name.value==""){ 
                     alert("Please provide your name.")
                     theform.Name.focus()
                     return false;
                }
                 if (theform.Email.value==""){ 
                     alert("Please provide your Email Address.")
                     theform.Email.focus()
                     return false;
                
                }
                return true;
                }