// $Id: base.js 598 2006-06-07 20:50:00Z jonathan $

window.onload = function() {
	if(!document.getElementById)
  		return;

	if(document.getElementById("callbackForm"))
		document.getElementById("callbackForm").onsubmit = callbackSubmit;
	if(document.getElementById("interestForm"))
		document.getElementById("interestForm").onsubmit = interestSubmit;

	vAnchor = document.createElement("a");
	vAnchor.href = "mailto:enquir";
	vL = "ivemusic.com";
	vSpan = document.getElementById("Ea5");
	vO = "ries@kl";
	vAnchor.appendChild(document.createTextNode("enqui"));
	vAnchor.href += "ies@klivem";
	if(vSpan)
		vSpan.replaceChild(vAnchor, vSpan.firstChild);
	vAnchor.appendChild(document.createTextNode(vO+vL));
	vAnchor.href += "usic.com";
	
	vLinkList = document.getElementById("navigation").getElementsByTagName("a");
	for(i=0;i<vLinkList.length;i++)
	{
		if(vLinkList[i].href == window.location.href)
		{
			vLinkList[i].removeAttribute("href");
			vLinkList[i].className = "current";
		}	
	}
}

function callbackSubmit()
{
	vErrorList = new Array();
	if(!this.Telephone.value.match(/^(\d[-\.,\s]*){8,}$/))
		vErrorList.push("Please enter your telephone number so that we can call you back.");
	if(vErrorList.length)
	{
		alert("Your input has " + (vErrorList.length == 1 ? "an error:" : vErrorList.length + " errors:") 
			+ "\n\n" + vErrorList.join("\n")
			);
		return false;
	}
	return true;
}

function interestSubmit()
{
	vErrorList = new Array();

	if(!this.Name.value.match(/\S/))
		vErrorList.push("Please enter your Name.");
	if( !this.Telephone.value.match(/^(\d[-\.,\s]*){8,}$/) && 
			!this.Email.value.match(/^[^@]+@([^@\.]+\.)+[^@\.]+$/))
	{
		vErrorList.push("Please either enter a Telephone number or an email address, so that we can get back to you.");
	}
	if(vErrorList.length)
	{
		alert("Your input has " + (vErrorList.length == 1 ? "an error:" : vErrorList.length + " errors:") 
			+ "\n\n" + vErrorList.join("\n")
			);
		return false;
	}
	return true;
}