function OpenChat(customerlang, sourcepage){
	var newurl = "http://142.46.205.131/qhd/accounts/inac/quickhelpdesk.phtml";
	newurl += "?clang=" + customerlang + "&sourcepage=" + sourcepage;
	var NewWinName = customerlang + "ChatWindow";
	var ExtraParams = "toolbar=no,scrollbars=no, menubar=no, maximize=no, resizeable=no,";
	ExtraParams += " status=no,width=553,height=328,menu=no,location=no";
	chatwindow=window.open(newurl,NewWinName,ExtraParams);
}

function GoToProvince(SearchLang) {
// SearchLang will intentionally be blank except after a search or when on the index_xx.html splash pages

var FileName_Doc = window.document.forms['DocTypeProvince'].DocType.value;
var CurrentProvince = window.document.forms['DocTypeProvince'].province.value;
var CurrentLang = window.document.forms['DocTypeProvince'].Lang.value;
var WebPath = window.document.forms['DocTypeProvince'].WebPath.value;


if (FileName_Doc == "" || CurrentProvince == "" ){
	if (CurrentLang == "fr")
		{alert('Vous devez choisir une province ou utiliser la « Recherche par nom ».')}
	else if (CurrentLang == "iu")
		{alert('ᑲᓇᑕᐅᑉ ᐊᕕᒃᑐᖅᓯᒪᓂᕆᔭᖓᓂᒃ ᖃᓪᓗᓈᓂ ᓇᕿᑦᑕᕆᐊᖃᖅᑐᑎᑦ ᐅᕝᕙᓘᓐᓃᑦ ᐊᑐᕆᐊᖃᖅᑕᑦ ᕿᓂᕈᑎᐅᔪᖅ « ᐊᑎᕆᔭᐅᔪᖅ ᕿᓂᕐᓗᒍ ».')}
	else
		{alert('You must enter a province or use the « Search By Name » feature.')}
	}
else if (SearchLang == "")
	{window.location= FileName_Doc;}
else if (WebPath == null || WebPath == "")
	{window.location='./' + SearchLang + '/' + FileName_Doc;}
else
	{window.location = WebPath + SearchLang + '/' + FileName_Doc;}
}

function changeProvince(Lang, ProvinceCode)
{
// This function runs when either the body "onLoad" event or the "onchange" event for the province picklist is triggered

// update the DocType picklist with the province specific DocType picklist
var NextProvince; 
var CommunityTypeLabel;
var numCommunityTypes = 0;
var CurrentFileName_Doc;
var NextFile;


// Get the file name from the current url .substring(demoString.length - 4)
var CurrentPath = location.pathname ;
CurrentFileName_Doc = CurrentPath.substring(CurrentPath.lastIndexOf("/") + 1);

// determine the current province
if (ProvinceCode == "") {ProvinceCode = window.document.forms['DocTypeProvince'].province.value; }

// Create an array of valid files
var ProvinceFiles = new Array("ab-all-b.html" , "ab-fn-b.html" , "ab-me-b.html" , "ab-fn-r.html" , "bc-all-b.html" , "bc-fn-b.html" , "bc-fn-r.html" , "mb-all-b.html" , "mb-fn-b.html" , "mb-me-b.html" , "mb-fn-r.html" , "nb-all-b.html" , "nb-fn-b.html" , "nb-fn-r.html" , "nf-all-b.html" , "nf-fn-b.html" , "nf-me-b.html" , "nf-in-b.html" , "nf-fn-r.html" , "ns-all-b.html" ,"ns-fn-b.html" , "ns-fn-r.html" , "nt-all-b.html" , "nt-fn-b.html" , "nt-me-b.html" , "nt-in-b.html" , "nt-fn-r.html" , "nu-in-b.html" , "on-all-b.html" , "on-fn-b.html" , "on-me-b.html" , "on-fn-r.html" , "pe-all-b.html" ,"pe-fn-b.html" , "pe-fn-r.html" , "qc-all-b.html" , "qc-fn-b.html" , "qc-in-b.html" , "qc-fn-r.html" , "sk-all-b.html" , "sk-fn-b.html " , "sk-me-b.html" , "sk-fn-r.html" , "yt-all-b.html" ,"yt-fn-b.html" , "yt-fn-r.html");

// Remove all the DocType options except the first one
document.forms['DocTypeProvince'].DocType.options.length = 1;

for (var x=0; x < ProvinceFiles.length; x++) { 

NextFile = ProvinceFiles[x];
NextProvince = NextFile.substring(0,2) ;

if (NextProvince == ProvinceCode) {
	
   if (Lang == 'en') {
	if (ProvinceFiles[x].indexOf("-all-b.") > -1)
		{CommunityTypeLabel = "All";}
	else if (ProvinceFiles[x].indexOf("-fn-b.") > -1)
		{CommunityTypeLabel = "First Nations";}
	else if (ProvinceFiles[x].indexOf("-me-b.") > -1)
		{CommunityTypeLabel = "Métis";}
	else if (ProvinceFiles[x].indexOf("-in-b.") > -1)
		{CommunityTypeLabel = "Inuit";}
	else if (ProvinceFiles[x].indexOf("-fn-r.") > -1)
		{CommunityTypeLabel = "Reserves";}
			}
   else if (Lang == 'fr') {
	if (ProvinceFiles[x].indexOf("-all-b.") > -1)
		{CommunityTypeLabel = "Toutes";}
	else if (ProvinceFiles[x].indexOf("-fn-b.") > -1)
		{CommunityTypeLabel = "Premières nations";}
	else if (ProvinceFiles[x].indexOf("-me-b.") > -1)
		{CommunityTypeLabel = "Métisses";}
	else if (ProvinceFiles[x].indexOf("-in-b.") > -1)
		{CommunityTypeLabel = "Inuites";}
	else if (ProvinceFiles[x].indexOf("-fn-r.") > -1)
		{CommunityTypeLabel = "Réserves";}
			}
     else if (Lang == 'iu') {
	if (ProvinceFiles[x].indexOf("-all-b.") > -1)
		{CommunityTypeLabel = "ᓄᓇᖃᖅᑳᖅᓯᒪᔪᓕᒫᑦ ᓄᓇᖏᑦ";}
	else if (ProvinceFiles[x].indexOf("-fn-b.") > -1)
		{CommunityTypeLabel = "ᐊᓪᓚᐃᑦ ᓄᓇᖏᑦ";}
	else if (ProvinceFiles[x].indexOf("-me-b.") > -1)
		{CommunityTypeLabel = "ᐊᓪᓚᐃᖓᔪᑦ ᓄᓇᖏᑦ";}
	else if (ProvinceFiles[x].indexOf("-in-b.") > -1)
		{CommunityTypeLabel = "ᐃᓄᐃᑦ ᓄᓇᖏᑦ";}
	else if (ProvinceFiles[x].indexOf("-fn-r.") > -1)
		{CommunityTypeLabel = "ᐊᓪᓚᐃᑦ ᓄᓇᓕᕋᓚᖏᑦ";}
			}

	// Add a new option
	document.forms['DocTypeProvince'].DocType.options[numCommunityTypes] = new Option(CommunityTypeLabel,ProvinceFiles[x]);

	// Make the current file the selected file (e.g. "All Aboriginal", "Inuit" ...)
	// This condition can only be true when the routine is called via the onLoad event
	if (ProvinceFiles[x] == CurrentFileName_Doc)
	   {document.forms['DocTypeProvince'].DocType.options[numCommunityTypes].selected = true;}

	numCommunityTypes = numCommunityTypes + 1;
}

}

// Make the current province the selected province
for (var x=0; x < document.forms['DocTypeProvince'].province.length; x++) {
	if (ProvinceCode == document.forms['DocTypeProvince'].province[x].value)
	{document.forms['DocTypeProvince'].province.options[x].selected = true;}
}



}
