// JavaScript Document
function change()
{
var events = "";
var total = 0;


if (document.form1.librarytour.checked == true)
{
events = events + " " + "Toronto Reference Library Tour"  + " , " ;
}
if (document.form1.imaginedcity.checked == true)
{
events = events + " " + "The Imagined City: A Literary Walking Tour of Downtown Toronto"  + " , " ;
total = total + 10;
}

if (document.form1.pubcrawl.checked == true)
{
events = events + " " + "Pub Crawl"  + " , " ;
total = total + 25;
}
if (document.form1.music.checked == true)
{
events = events + " " + "Music and Shakespeare Social, PWAC Only Event"  + " , " ;
}
if (document.form1.houseparty.checked == true)
{
events = events + " " + "House Party @ 326 Rusholme Rd., PWAC Only Event"  + " , " ;
}
if (document.form1.ecowalk.checked == true)
{
events = events + " " + "Toronto Eco-walk"  + " , " ;
}
if(document.form1.cheesetour.checked == true)
{
events = events + " " + "Prince Edward County Wine & Cheese Tour";
total = total + 75;
}

document.form1.event.value = events;
document.form1.total.value = total;
}

function validate_form()
{
valid = true;
/*
if (document.form1.name.value == "" || document.form1.postalcode.value == "" || document.form1.address.value == "" || document.form1.email.value == "" || document.form1.city.value == "")
{
alert("Please fill in the fields with  * ");
valid = false;
}
*/
var emailID=document.form1.email
var clientname = document.form1.name
var clientadd = document.form1.address
var clientcity = document.form1.city
var clientpostal = document.form1.postalcode
var clientphone = document.form1.telephone

		if ((clientname.value==null)||(clientname.value=="")){
		//alert("Please Enter your Name")
		clientname.focus()
		clientname.style.backgroundColor = "#628CB7";
		clientname.style.color = "#FFFFFF";
		valid = false;
	}
	else { clientname.style.backgroundColor = "#FFFFFF";
		clientname.style.color = "#000000"; }
	
			if ((clientadd.value==null)||(clientadd.value=="")){
		//alert("Please Enter your Address")
		clientadd.focus()
		clientadd.style.backgroundColor = "#628CB7";
		clientadd.style.color = "#FFFFFF";
		valid = false;
	}
	else { clientadd.style.backgroundColor = "#FFFFFF";
		clientadd.style.color = "#000000"; }
	
			if ((clientcity.value==null)||(clientcity.value=="")){
		//alert("Please Enter your City")
		clientcity.focus()
		clientcity.style.backgroundColor = "#628CB7";
		clientcity.style.color = "#FFFFFF";
		valid = false;
	}
	else { clientcity.style.backgroundColor = "#FFFFFF";
		clientcity.style.color = "#000000"; }
	
			if ((clientpostal.value==null)||(clientpostal.value=="")){
		//alert("Please Enter your Postal Code")
		clientpostal.focus()
		clientpostal.style.backgroundColor = "#628CB7";
		clientpostal.style.color = "#FFFFFF";

		valid = false;
		}
			else { 		clientpostal.style.backgroundColor = "#FFFFFF";
					clientpostal.style.color = "#000000";
}

			
	
	if ((emailID.value==null)||(emailID.value=="")){
		//alert("Please Enter your Email ID")
		emailID.focus()
		emailID.style.backgroundColor = "#628CB7";
		emailID.style.color = "#FFFFFF";
		valid = false;
	}
else
{
	emailID.style.backgroundColor = "#FFFFFF";
		emailID.style.color = "#000000";
}
	
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		
		valid = false;
	}

	
return valid;
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
	function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
	