// JavaScript Document

function swapPainting(painting) {
	if(painting) {
		gPaintingImg.src = painting[0];
		gDesc.innerHTML = painting[1];
	}
}

function swapImg(sImg, elImg) {
	elImg.src = sImg;
}

function isEmailAddr(email) {
	var result = false;
	var theStr = new String(email);
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	}
	return result;
}

function validateForm(elForm) {

	if(elForm.elname.value == "") {
		alert("Please enter your name");
		elForm.elname.focus();
		return false;
	}
	
	if(elForm.email.value == "" || !isEmailAddr(elForm.email.value)) {
		alert("Please enter a valid email");
		elForm.email.focus();
		return false;
	}
	
	if(elForm.subject.value == "") {
		alert("Please enter a subject");
		elForm.subject.focus();
		return false;
	}
	
	
	return true;
}