function openWindow(URL) {
	remote = window.open(URL, "Games", "width=660, height=500, resizable=0, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1"); 
}

function openWindow550(URL) {
	remote = window.open(URL, "Games", "width=660, height=550, resizable=0, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1"); 
}

//-----------------------------------------------------------------------------------
//-- determine page content and changes menu button to indicate section
//-----------------------------------------------------------------------------------

function pageNavigation() {
	if (pageType == 'kids') {
		document.getElementById('navKids').src = "../../readathon/_images/buttons/en/kidsOvr.gif";
	}
		if (pageType == 'enfants') {
		document.getElementById('navKids').src = "../../readathon/_images/buttons/fr/enfantsOvr.gif";
	}
	if (pageType == 'local') {
		document.getElementById('navContact').src = "../../readathon/_images/buttons/en/contactOvr.gif";
	}
	if (pageType == 'region') {
		document.getElementById('navContact').src = "../../readathon/_images/buttons/fr/coordonneesOvr.gif";
	}	
		if (pageType == 'parents') {
		document.getElementById('navParents').src = "../../readathon/_images/buttons/en/parentsOvr.gif";
	}
	if (pageType == 'parentsFR') {
		document.getElementById('navParents').src = "../../readathon/_images/buttons/fr/parentsOvr-fr.gif";
	}
		if (pageType == 'teachers') {
		document.getElementById('navTeachers').src = "../../readathon/_images/buttons/en/teachersOvr.gif";
	}
	if (pageType == 'enseignants') {
		document.getElementById('navTeachers').src = "../../readathon/_images/buttons/fr/enseignantsOvr.gif";
	}
	else return;
}

//-----------------------------------------------------------------------------------
// validate child registration form fields
//-----------------------------------------------------------------------------------

function checkChildForm() {
	if (document.getElementById('ContactName').value.length < 1) {
		window.alert("Please provide a contact name.");
		return false;
	}
	if (document.getElementById('EmailAddress').value.length < 1) {
		window.alert("Please provide your e-mail address.");
		return false;
	}
	if (document.getElementById('SchoolName').value.length < 1) {
		window.alert("Please provide the name of your school.");
		return false;
	}
	if (document.getElementById('City').value.length < 1) {
		window.alert("Please provide your city.");
		return false;
	}
	if (document.getElementById('Province').value.length < 1) {
		window.alert("Please provide your province.");
		return false;
	}
	else return true;
}

function checkChildFormFR() {
	if (document.getElementById('Nom').value.length < 1) {
		window.alert("Veuillez indiquer le nom d’une personne-ressource.");
		return false;
	}
	if (document.getElementById('Courriel').value.length < 1) {
		window.alert("Veuillez indiquer votre adresse de courriel.");
		return false;
	}
	if (document.getElementById('NomEcole').value.length < 1) {
		window.alert("Veuillez indiquer le nom de votre école.");
		return false;
	}
	if (document.getElementById('Ville').value.length < 1) {
		window.alert("Veuillez indiquer votre municipalité.");
		return false;
	}
	if (document.getElementById('Province').value.length < 1) {
		window.alert("Veuillez indiquer votre province.");
		return false;
	}
	else return true;
}


//-----------------------------------------------------------------------------------
//-- determine staff contact for registration forms
//-----------------------------------------------------------------------------------

function staffContactChild() {
var theProvince = document.RegFormChild.Province.options[document.RegFormChild.Province.selectedIndex].text;
	if (theProvince == "Alberta") { 
		document.RegFormChild.recipient.value = 'trish.vandoornum@mssociety.ca';
	}
	else if (theProvince == "British Columbia") { 
		document.RegFormChild.recipient.value = 'leanne.fisher@mssociety.ca'; 
	}
	else if (theProvince == "Saskatchewan") { 
		document.RegFormChild.recipient.value = 'Bill.Schoepp@mssociety.ca'; 
	}
	else if (theProvince == "Yukon") { 
		document.RegFormChild.recipient.value = 'leanne.fisher@mssociety.ca'; 
	}
	else if (theProvince == "Northwest Territories") { 
		document.RegFormChild.recipient.value = 'trish.vandoornum@mssociety.ca'; 
	}
	else { 
		document.RegFormChild.recipient.value = 'rat@mssociety.ca'; 
	}
}


//-----------------------------------------------------------------------------------
//-- send child registration
//-----------------------------------------------------------------------------------

function closeChildLayer() {
	if (checkChildForm(document.RegFormChild)) {
		document.RegFormChild.redirect.value = location.href + '?childsent=y';
		document.getElementById('ChildForm').className = 'hide';
	}
}

function closeChildLayerFR() {
	if (checkChildFormFR(document.RegFormChild)) {
		document.RegFormChild.redirect.value = location.href + '?childsent=y';
		document.getElementById('ChildForm').className = 'hide';
	}
}

//-----------------------------------------------------------------------------------
// check if child registration was sent and display thank you
//-----------------------------------------------------------------------------------

function checkChildMessageSent() {
	if (document.location.href.indexOf('childsent') != -1) {
		document.getElementById('thanksChild').className = 'showForm';
	}
}
	
//-----------------------------------------------------------------------------------
// validate school registration form fields
//-----------------------------------------------------------------------------------

function checkSchoolForm() {
	if (document.getElementById('ContactName').value.length < 1) {
		window.alert("Please provide a contact name.");
		return false;
	}
	if (document.getElementById('SchoolName').value.length < 1) {
		window.alert("Please provide the name of your school.");
		return false;
	}
	if (document.getElementById('SchoolBoard').value.length < 1) {
		window.alert("Please provide the name of your school board.");
		return false;
	}
	if (document.getElementById('SchoolAddress').value.length < 1) {
		window.alert("Please provide the address of your school.");
		return false;
	}
	if (document.getElementById('City').value.length < 1) {
		window.alert("Please provide your city.");
		return false;
	}
	if (document.getElementById('Province').value.length < 1) {
		window.alert("Please provide your province.");
		return false;
	}
	if (document.getElementById('PostalCode').value.length < 1) {
		window.alert("Please provide your postal code.");
		return false;
	}
	if (document.getElementById('Phone').value.length < 1) {
		window.alert("Please provide your phone number.");
		return false;
	}
	if (document.getElementById('EmailAddress').value.length < 1) {
		window.alert("Please provide your e-mail address.");
		return false;
	}
	else return true;
}

function checkSchoolFormFR() {
	if (document.getElementById('Nom').value.length < 1) {
		window.alert("Veuillez indiquer le nom d’une personne-ressource.");
		return false;
	}
	if (document.getElementById('NomEcole').value.length < 1) {
		window.alert("Veuillez indiquer le nom de votre école.");
		return false;
	}
	if (document.getElementById('Commission').value.length < 1) {
		window.alert("Veuillez indiquer le nom de votre commission scolaire.");
		return false;
	}
	if (document.getElementById('Address').value.length < 1) {
		window.alert("Veuillez indiquer l’adresse de votre école.");
		return false;
	}
	if (document.getElementById('Ville').value.length < 1) {
		window.alert("Veuillez indiquer votre municipalité.");
		return false;
	}
	if (document.getElementById('Province').value.length < 1) {
		window.alert("Veuillez indiquer votre province.");
		return false;
	}
	if (document.getElementById('CodePostal').value.length < 1) {
		window.alert("Veuillez indiquer votre code postal.");
		return false;
	}
	if (document.getElementById('Phone').value.length < 1) {
		window.alert("Veuillez indiquer votre numéro de téléphone.");
		return false;
	}
	if (document.getElementById('Courriel').value.length < 1) {
		window.alert("Veuillez indiquer votre adresse de courriel.");
		return false;
	}
	else return true;
}

//-----------------------------------------------------------------------------------
//-- determine staff contact for registration forms
//-----------------------------------------------------------------------------------

function staffContactSchool() {
var theProvince = document.RegForm.Province.options[document.RegForm.Province.selectedIndex].text;
	if (theProvince == "Alberta") { 
		document.RegForm.recipient.value = 'trish.vandoornum@mssociety.ca';
	}
	else if (theProvince == "British Columbia") { 
		document.RegForm.recipient.value = 'leanne.fisher@mssociety.ca'; 
	}
	else if (theProvince == "Saskatchewan") { 
		document.RegForm.recipient.value = 'Bill.Schoepp@mssociety.ca'; 
	}
	else if (theProvince == "Yukon") { 
		document.RegForm.recipient.value = 'leanne.fisher@mssociety.ca'; 
	}
	else if (theProvince == "Northwest Territories") { 
		document.RegForm.recipient.value = 'trish.vandoornum@mssociety.ca'; 
	}
	else { 
		document.RegForm.recipient.value = 'rat@mssociety.ca'; 
	}
}

//-----------------------------------------------------------------------------------
//-- send school registration
//-----------------------------------------------------------------------------------

function closeSchoolLayer() {
	if (checkSchoolForm(document.RegForm)) {
		document.RegForm.redirect.value = location.href + '?schoolsent=y';
		document.getElementById('school').className = 'hide';
	}
}

function closeSchoolLayerFR() {
	if (checkSchoolFormFR(document.RegForm)) {
		document.RegForm.redirect.value = location.href + '?schoolsent=y';
		document.getElementById('school').className = 'hide';
	}
}

//-----------------------------------------------------------------------------------
// check if school registration was sent and display thank you
//-----------------------------------------------------------------------------------

function checkSchoolMessageSent() {
	if (document.location.href.indexOf('schoolsent') != -1) {
		document.getElementById('thanksSchool').className = 'showForm';
	}
}
	
//-----------------------------------------------------------------------------------
// validate parent registration form fields
//-----------------------------------------------------------------------------------

function checkParentForm() {
	if (document.getElementById('ContactName').value.length < 1) {
		window.alert("Please provide a contact name.");
		return false;
	}
	if (document.getElementById('EmailAddress').value.length < 1) {
		window.alert("Please provide your e-mail address.");
		return false;
	}
	if (document.getElementById('SchoolName').value.length < 1) {
		window.alert("Please provide the name of your school.");
		return false;
	}
	if (document.getElementById('City').value.length < 1) {
		window.alert("Please provide your city.");
		return false;
	}
	if (document.getElementById('Province').value.length < 1) {
		window.alert("Please provide your province.");
		return false;
	}
	else return true;
}

function checkParentFormFR() {
	if (document.getElementById('Nom').value.length < 1) {
		window.alert("Veuillez indiquer le nom d’une personne-ressource.");
		return false;
	}
	if (document.getElementById('Courriel').value.length < 1) {
		window.alert("Veuillez indiquer votre adresse de courriel.");
		return false;
	}
	if (document.getElementById('NomEcole').value.length < 1) {
		window.alert("Veuillez indiquer le nom de votre école.");
		return false;
	}
	if (document.getElementById('Ville').value.length < 1) {
		window.alert("Veuillez indiquer votre municipalité.");
		return false;
	}
	if (document.getElementById('Province').value.length < 1) {
		window.alert("Veuillez indiquer votre province.");
		return false;
	}
	else return true;
}

//-----------------------------------------------------------------------------------
//-- determine staff contact for registration forms
//-----------------------------------------------------------------------------------

function staffContactParent() {
var theProvince = document.RegFormParent.Province.options[document.RegFormParent.Province.selectedIndex].text;
	if (theProvince == "Alberta") { 
		document.RegFormParent.recipient.value = 'trish.vandoornum@mssociety.ca';
	}
	else if (theProvince == "British Columbia") { 
		document.RegFormParent.recipient.value = 'leanne.fisher@mssociety.ca'; 
	}
	else if (theProvince == "Saskatchewan") { 
		document.RegFormParent.recipient.value = 'Bill.Schoepp@mssociety.ca'; 
	}
	else if (theProvince == "Yukon") { 
		document.RegFormParent.recipient.value = 'leanne.fisher@mssociety.ca'; 
	}
	else if (theProvince == "Northwest Territories") { 
		document.RegFormParent.recipient.value = 'trish.vandoornum@mssociety.ca'; 
	}
	else { 
		document.RegFormParent.recipient.value = 'rat@mssociety.ca'; 
	}
}



//-----------------------------------------------------------------------------------
// validate registration form fields
//-----------------------------------------------------------------------------------

function staffContactRegister() {
var theProvince = document.RegisterForm.Province.options[document.RegisterForm.Province.selectedIndex].text;
	if (theProvince == "Alberta") { 
		document.RegisterForm.recipient.value = 'sherri.taylor@mssociety.ca';
	}
	else if (theProvince == "British Columbia") { 
		document.RegisterForm.recipient.value = 'leanne.fisher@mssociety.ca'; 
	}
	else if (theProvince == "Saskatchewan") { 
		document.RegisterForm.recipient.value = 'Bill.Schoepp@mssociety.ca'; 
	}
	else if (theProvince == "Yukon") { 
		document.RegisterForm.recipient.value = 'leanne.fisher@mssociety.ca'; 
	}
	else if (theProvince == "Northwest Territories") { 
		document.RegisterForm.recipient.value = 'sherri.taylor@mssociety.ca'; 
	}
	else { 
		document.RegisterForm.recipient.value = 'rat@mssociety.ca'; 
	}
}

function checkRegisterMessageSent() {
	if (document.location.href.indexOf('registersent') != -1) {
		document.getElementById('thanksRegister').className = 'showForm';
	}
}

//-----------------------------------------------------------------------------------
//-- send registration
//-----------------------------------------------------------------------------------

function closeRegisterLayer() {
			document.RegisterForm.redirect.value = 'http://www.mssociety.ca/readathon/en/default.htm' + '?registersent=y';
}


//-----------------------------------------------------------------------------------
//-- send parent registration
//-----------------------------------------------------------------------------------

function closeParentLayer() {
	if (checkParentForm(document.RegFormParent)) {
		document.RegFormParent.redirect.value = location.href + '?parentsent=y';
		document.getElementById('parentForm').className = 'hide';
	}
}

function closeParentLayerFR() {
	if (checkParentFormFR(document.RegFormParent)) {
		document.RegFormParent.redirect.value = location.href + '?parentsent=y';
		document.getElementById('parentForm').className = 'hide';
	}
}

//-----------------------------------------------------------------------------------
// check if parent registration was sent and display thank you
//-----------------------------------------------------------------------------------

function checkParentMessageSent() {
	if (document.location.href.indexOf('parentsent') != -1) {
		document.getElementById('thanksParent').className = 'showForm';
	}
}


//-----------------------------------------------------------------------------------
// check if golden ticket number is a winner
//-----------------------------------------------------------------------------------

function checkNumber() {
	if (document.getElementById('ticketNumber').value == '29000' || document.getElementById('ticketNumber').value == '26700'){
		document.getElementById('winner').className = 'showWinner';
		document.getElementById('nowinner').className = 'hide';
		document.getElementById('nonumber').className = 'hide';
	}
	else if (document.getElementById('ticketNumber').value.length < 1) {
		document.getElementById('winner').className = 'hide';
		document.getElementById('nowinner').className = 'hide';
		document.getElementById('nonumber').className = 'showWinner';
	}
	else {
		document.getElementById('winner').className = 'hide';
		document.getElementById('nowinner').className = 'showWinner';
		document.getElementById('nonumber').className = 'hide';
	}
}
