﻿
var subForm = '';
var previous = 'MDFFormI';
var previous2 = '';
var fields = 6;
var alertform = 'Please check that all required fields are filled in the form.';
                  
function showOption(id){
    subForm = id;
	document.getElementById(previous2).style.display='none';
    document.getElementById(id).style.display='';
    previous2 = id;
}				
function showForm(id){
	document.getElementById(previous).style.display='none';
	document.getElementById('lnk' + previous).className = '';
	document.getElementById(id).style.display='';
	document.getElementById(id).style.display='';
	document.getElementById('lnk' + id).className = 'viewed';
	previous = id;
}

$(document).ready(function() {
	var validator = $("#mainform").validate({
	});
	$('#registrationNumber').keyup(function(){
		$('#registrationNumber').val(
			$('#registrationNumber').val().replace(/^(\d{5,5})(\d{4,4})(\d{4,4})$/, "$1 $2 RR $3")
		)
	})
	$("#next1").click(function() {
		if (checkForm("MDFFormI")){
			scroll(0,0)
			showForm("MDFFormII");
		}else{alert(alertform);}
		if( specValidFields.length > 0 )
		alertError(specValidFields, 'alert');
		//alertError(specValidFields, 'confirm');
		
		return false;
	});
	
	$("#next2").click(function() {
		if (checkForm("MDFFormII")){
			scroll(0,0)
			showForm("MDFFormIII");
		}else{alert(alertform);}
		return false;
	});
	$("#next3").click(function() {
		if (checkForm("MDFFormIII")){
			scroll(0,0)
			showForm("MDFFormIV");
		}else{alert(alertform);}
		return false;
	});
	$("#next4").click(function() {
			return submitClick("MDFFormIV")
	});
});
function focusShow(id) {
	if(id == ""){
		document.getElementById('healthycommunities').style.display = "none";
		document.getElementById('activelifestyles').style.display = "none";
		document.getElementById('skillsdevelopment').style.display = "none";
		document.getElementById('note').style.display = "none";
		$('input[@value= "0"]').click()
	} else if(id == "0"){
		document.getElementById('healthycommunities').style.display = "block";
		document.getElementById('activelifestyles').style.display = "none";
		document.getElementById('skillsdevelopment').style.display = "none";
		document.getElementById('note').style.display = "none";
	} else if(id == "1"){
		document.getElementById('healthycommunities').style.display = "none";
		document.getElementById('activelifestyles').style.display = "block";
		document.getElementById('skillsdevelopment').style.display = "none";
		document.getElementById('note').style.display = "none";
	} else if(id == "2"){
		document.getElementById('healthycommunities').style.display = "none";
		document.getElementById('activelifestyles').style.display = "none";
		document.getElementById('skillsdevelopment').style.display = "block";
		document.getElementById('note').style.display = "none";
	} else if(id == "3" || id == ""){
		document.getElementById('healthycommunities').style.display = "none";
		document.getElementById('activelifestyles').style.display = "none";
		document.getElementById('skillsdevelopment').style.display = "none";
		document.getElementById('note').style.display = "block";
	}
};

function directProvPopEn()
{
	state_elem = document.getElementById("provOrg")

	state_elem.options[0] = new Option('Select a province', '');
	state_elem.options[1] = new Option('Alberta','AB' );
	state_elem.options[2] = new Option('British Columbia','BC' );
	state_elem.options[3] = new Option('Manitoba','MB' );
	state_elem.options[4] = new Option('New Brunswick','NB' );
	state_elem.options[5] = new Option('Newfoundland and Labrador','NL' );
	state_elem.options[6] = new Option('Northwest Territories','NT' );
	state_elem.options[7] = new Option('Nova Scotia','NS' );
	state_elem.options[8] = new Option('Nunavut','NU' );
	state_elem.options[9] = new Option('Ontario','ON' );
	state_elem.options[10] = new Option('Prince Edward Island','PE' );
	state_elem.options[11] = new Option('Quebec','QC' );
	state_elem.options[12] = new Option('Saskatchewan','SK' );
	state_elem.options[13] = new Option('Yukon','YT' );
}
function directProvPopFr()
{
	state_elem = document.getElementById("provOrg")
	
	eval(state_elem.options[0] = new Option('Sélectionnez une province', ''));
	state_elem.options[1] = new Option('Alberta','AB' );
	state_elem.options[2] = new Option('Colombie-Britannique','BC' );
	state_elem.options[3] = new Option('Île-du-Prince-Édouard','PE' );
	state_elem.options[4] = new Option('Manitoba','MB' );
	state_elem.options[5] = new Option('Nouveau-Brunswick','NB' );
	state_elem.options[6] = new Option('Nouvelle-Écosse','NS' );
	state_elem.options[7] = new Option('Nunavut','NU' );
	state_elem.options[8] = new Option('Ontario','ON' );
	state_elem.options[9] = new Option('Québec','QC' );
	state_elem.options[10] = new Option('Saskatchewan','SK' );
	state_elem.options[11] = new Option('Territoires du Nord-Ouest','NT' );
	state_elem.options[12] = new Option('Terre-Neuve et Labrador','NL' );
	state_elem.options[13] = new Option('Yukon','YT' );
}
function transfer(){
	var p1 = document.getElementById('regNumP1').value
	var p2 = document.getElementById('regNumP2').value;
/*	document.getElementById('registrationNumber').innerHTML = p1 + 'RR' + p2;*/
	document.getElementById('registrationNumber').value = p1 + 'RR' + p2;
}

String.prototype.wordCount = function () {return this.split(/\b[\s,\.-:;]*/).length}