// JavaScript Document - Simon Eade

function pgall(whichpic) {//using an argument to reference when calling the function
	
var source = whichpic.getAttribute("href"); //get the current anchor href link
var placeholder = document.getElementById("placeholder"); //get the id of main image
placeholder.setAttribute("src", source); //change the source of the image 

var text = whichpic.getAttribute("title"); //gets the title attribute of each link thats sent to this function
var galllink = document.getElementById("galllink"); //gets the anchor tag of the main link where the source goes
galllink.firstChild.nodeValue = text; //updates the value of the firstchild node with the value of the text or title text.

galllink.setAttribute("href", text); //takes the galllink variable and sets the href link attribute and defines the attribute taken from the text variable

var destimg = whichpic.firstChild.getAttribute("alt"); //get the firstchild element of the node where function is being called from and get alt attribute
placeholder.setAttribute("alt", destimg); //

//whichpic is an element node. 
//We can extract the path to the image by using the getAttribut method on the whichpic element.By passing href as the argument i can find out what the path is

//We need to update the src of the placeholder element, so we set the src attribute and the path we want the source to have.
}

function formvalid() {

if(document.getElementById("contact_name").value == "") { alert("Please enter your name"); 
	document.getElementById("contact_name").focus();
	return false; 
}
if(document.getElementById("email").value == "") { alert("Please enter your email address"); 
	document.getElementById("email").focus();
	return false; 
}

if(document.getElementById("phone").value == "") { alert("Please enter your phone number"); 
	document.getElementById("phone").focus();
	return false;
}

if(document.getElementById("requirements").value == "") { alert("Please enter your requirements"); 
	document.getElementById("requirements").focus();
	return false; 
}

if(document.getElementById("validkey").value == "") { alert("Please enter code seen in image"); 
	document.getElementById("validkey").focus();
	return false; 
}

else {
	return true;	
}

}


