//  © 2003 Canadian Heritage Information Network/R&eacute;seau canadien
//  d'information sur le patrimoine
//  All rights reserved./Tous droits r&eacute;serv&eacute;s.




/// Old Writing Power outage message.....
//alert(document.location.href);
/*
if (/Francais/.test(document.URL)) {
	document.write('<div id="powerOutage">L\'accès au site sera interrompu à des fins d\'entretien samedi le 3 mars 2007 de 7 h à 16 h (HNE).</div>');
} else {
	document.write('<div id="powerOutage">Site access may be interrupted between 7:00 a.m. and 4:00 pm, Saturday March 03, 2007 (EST), for maintenance.</div>');	
}
*/


/// NEW - Writing Power outage message.....
// To activate the power outage message, uncomment the onDomLoadEvent() function.
// call init() when the DOM is loaded
// COMMENTING OR UNCOMMENTING THE FOLLOWING LINE WILL DEACTIVATE
// OR ACTIVATE THE MESSAGE FROM WEBPAGES
// onDomLoadEvent(init);

function writeOutageMessage() {
	if (document.body.firstChild.id=="powerOutage") return;
	if (!document.createElement || !document.appendChild || !document.insertBefore) return;
	if (/Francais/.test(document.URL)) {
		var message = "L'accès au site sera interrompu à des fins d'entretien du samedi 26 juillet à 7 h, au samedi 26 juillet à 12 h (HNE).";
//		var message = "Due à des difficultés techniques, le site Agora n'est pas disponibles pour l'instant.  Nous sommes désolés des inconvénients et nous travaillons à rétablir la situation.";
	} else {
		var message = "Site access will be interrupted from Saturday July 26, 2008 at 7:00 a.m. to Saturday July 26, 2008 at 12:00 p.m. (EST), for maintenance.";
//		var message = "Due to technical difficulties, the Agora Site is temporarily unavailable. We apologize for the inconvenience and are working to restore access as soon as possible.";
	}
	var messageElement = document.createElement("div");
	messageElement.appendChild(document.createTextNode(message));
	messageElement.id = "powerOutage";
	document.body.insertBefore(messageElement, document.body.firstChild);
}

// add all the functions you want fired once the DOM loads, and before window.onload
function init() {
	// prevent this function from being called twice
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	
	//do stuff  -  in this case, just write the Power Outage Message
	writeOutageMessage();
}

	
// onDomLoadEvent adapted from Dean Edwards/Matthias Miller/John Resig: http://dean.edwards.name/weblog/2006/06/again/?full
// Author: J. Kiss, CHIN, Dec. 08, 2006
// ====================================
function onDomLoadEvent(func){
	/*@cc_on @*/
	/*@if (@_win32)
		var protoc = "src=javascript:void(0)";
		if (location.protocol == "https:") protoc = "src=//0";
	    document.write("<script id=__ie_onload defer " + protoc + "><\/script>");
	    var script = document.getElementById("__ie_onload");
	    script.onreadystatechange = function() {
			if (this.readyState == "complete") {
				func(); // call the function
				//script=null;
			}
	    };
	    return;
	/*@end @*/
	if (/WebKit|KHTML/i.test(navigator.userAgent)) { 
	    var _timer = setInterval(function() {
			if (/loaded|complete/.test(document.readyState)) {
				func();
				clearInterval(_timer);
				delete _timer;
			}
		}, 10);
		return;
	} else if (document.addEventListener) { 
	    document.addEventListener("DOMContentLoaded", func, false);
	} 
	window.onload = func;
}



// SNIFFER CODE


// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.
// Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
// Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
//                      also added support for IE5.5 Opera4&5 HotJava3 AOLTV
// Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4,
//                      correct Opera 5 detection
//                      add support for winME and win2k
//                      synch with browser-type-oo.js
// Revised 26 Mar 01 to correct Opera detection
// Revised 02 Oct 01 to add IE6 detection

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "is_" variables indicating:
// (1) browser vendor:
//     is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
// (2) browser version number:
//     is_major (integer indicating major version number: 2, 3, 4 ...)
//     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,
//     is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
//     is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up
// (4) JavaScript version number:
//     is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k
//     is_os2
//     is_mac, is_mac68k, is_macppc
//     is_unix
//     is_sun, is_sun4, is_sun5, is_suni86
//     is_irix, is_irix5, is_irix6
//     is_hpux, is_hpux9, is_hpux10
//     is_aix, is_aix1, is_aix2, is_aix3, is_aix4
//     is_linux, is_sco, is_unixware, is_mpras, is_reliant
//     is_dec, is_sinix, is_freebsd, is_bsd
//     is_vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when new versions of browsers are released, so
// in conditional code forks, use is_ie5up ("IE 5.0 or greater")
// is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
// to check version in code which you want to work on future
// versions.

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

    var is_webtv = (agt.indexOf("webtv") != -1);

    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1));
    var is_AOLTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));

    // *** JAVASCRIPT VERSION CHECK ***
    var is_js;
    if (is_nav2 || is_ie3) is_js = 1.0;
    else if (is_nav3) is_js = 1.1;
    else if (is_opera5up) is_js = 1.3;
    else if (is_opera) is_js = 1.1;
    else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
    else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
    else if (is_hotjava3up) is_js = 1.4;
    else if (is_nav6 || is_gecko) is_js = 1.5;
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    else if (is_nav6up) is_js = 1.5;
    // NOTE: ie5up on mac is 1.4
    else if (is_ie5up) is_js = 1.3

    // HACK: no idea for other browsers; always check for JS version with > or >=
    else is_js = 0.0;

    // *** PLATFORM ***
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) ||
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
               (agt.indexOf("windows 16-bit")!=-1) );

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
    var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 ||
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var is_os2   = ((agt.indexOf("os/2")!=-1) ||
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);
    // hack ie5 js version for mac
    if (is_mac && is_ie5up) is_js = 1.4;
    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
                               (agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
                                (agt.indexOf("powerpc")!=-1)));

    var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
    var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var is_irix5 = (agt.indexOf("irix 5") !=-1);
    var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
    var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
    var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var is_aix1  = (agt.indexOf("aix 1") !=-1);
    var is_aix2  = (agt.indexOf("aix 2") !=-1);
    var is_aix3  = (agt.indexOf("aix 3") !=-1);
    var is_aix4  = (agt.indexOf("aix 4") !=-1);
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1);
    var is_mpras    = (agt.indexOf("ncr")!=-1);
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
                 is_sco ||is_unixware || is_mpras || is_reliant ||
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

    var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
    
    
 // END OF SNIFFER CODE   

if (is_nav4) {
	location.replace("http://www.virtualmuseum.ca/noNetscape.html");
}





function click(which) {
      document.SEARCHFORM.scope[which].checked = true;
  }

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function doSearch (language) {

var whichLang = document.URL.search(/Francais/);
// -1 if false

//alert(whichLang);

        if (document.SEARCHFORM.terms.value == "") {
                
                if (language == 'Francais' || whichLang != -1) {
                //if (language == 'Francais') {
                
                        alert("Vous devez préciser des critères de recherch");
                } else {
                        alert("Search criteria must be entered");
                }
                
        
                return;
        }
        
        
// added by S.MacCallum 25/08/05
// when landmark is (VMC) Friends there is 2 forms on the page that use
// the same params and both call PM.cgi on submit
// reset the AP and scope params to values relevant to a vmc search
        if (document.SEARCHFORM.LM.value == "Friends") {
	    document.SEARCHFORM.AP.value = "vmc_search";
	    document.SEARCHFORM.scope.value = "Search";
        }
        document.SEARCHFORM.submit();
        return;
}

function noenter() {
  return !(window.event && window.event.keyCode == 13);
}


function VMCAux(URL) 
{
var the_string = /map/;
var map = URL.match(the_string);

if (map == null)
	{
        // make window for others....
        var serv=window.open(URL,'VMCAux','toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=690,height=320');
        }
        else 
	{
	// make window for maps....
	var serv=window.open(URL,'VMCAux','toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=643,height=530');
        }
}



function VMCAux2(URL) {
	
 	var serv=window.open(URL,'VMCAux2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=500,height=330');
}


function VMCAux3(URL) {
	
 	var serv=window.open(URL,'VMCAux3','toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=600,height=400');
}

function VMCAux4(URL) {
	
 	var serv=window.open(URL,'VMCAux4','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=690,height=440');
}




// Set a Cookie to remember the Last VMC URL for the Homepage

/*

var testDomain = document.domain.toLowerCase();
if (testDomain.indexOf('virtualmuseum.') != -1) {
	document.cookie = 'lastVMCLocation=' + escape(document.location) + '; domain=.virtualmuseum.ca; path=/'; 
}
if (testDomain.indexOf('museevirtuel.') != -1) {
	document.cookie = 'lastVMCLocation=' + escape(document.location) + '; domain=.museevirtuel.ca; path=/'; 
}
*/


// For use with VMC Logo
top.name = 'VMCHomePage';

// Focus this Page
top.focus();


//FOR CARRYING SEARCH BOX TERMS

function Get_Terms() {

	var myTerms = "";
	var allChecked = "YES";
	var myCookie = document.cookie;
	if (myCookie == "") return false;
	var pos = myCookie.indexOf("lastVMCLocation=");
	if (pos == -1) return false;
	var start = pos + 16;
	var end = myCookie.indexOf(";", start);
	if (end == -1) end = myCookie.length;
	var cookieString = unescape(myCookie.substring(start, end));
	var names = cookieString.split('&');
	for (var i = 0; i < names.length; i++) {
		names[i] = names[i].split('=');
		if (names[i][0] == "terms") {
			var myTerms = unescape(names[i][1]);
		}
		if (names[i][0] == "searchby") {
			if (names[i][1] == "name") allChecked = "NO";
		}
	}
	myTerms = myTerms.replace(/\+/g, ' ');
	document.SEARCHFORM.terms.value = myTerms;
	for (var i = 0; i < document.SEARCHFORM.length; i++) {
		if (document.SEARCHFORM.elements[i].name == "searchby") {
		if (myTerms != "" && allChecked == "YES") document.SEARCHFORM.searchby[0].checked=true;}
	}
}


//FOR POSTCARD APPLICATION

function history2() {
history.go(-1);
}

function DelText()
	{
	if (document.POSTCARD1.Addressee.value == "<200 characters maximum>")
		{
		document.POSTCARD1.Addressee.value = "";
		}
	}
function DelText2()
	{
	if (document.POSTCARD2.Addressee.value == "<200 characters maximum>")
		{
		document.POSTCARD2.Addressee.value = "";
		}
	}

function DelTextF()
	{
	if (document.POSTCARD1.Addressee.value == "<Maximum de 200 caractères>")
		{
		document.POSTCARD1.Addressee.value = "";
		}
	}
function DelText2F()
	{
	if (document.POSTCARD2.Addressee.value == "<Maximum de 200 caractères>")
		{
		document.POSTCARD2.Addressee.value = "";
		}
	}


//END FOR POSTCARD  APPLICATION

//FOR CARRYING SEARCH BOX TERMS

function Get_Terms() {

	var myTerms = "";
	var allChecked = "YES";
	var myCookie = document.cookie;
	if (myCookie == "") return false;
	var pos = myCookie.indexOf("lastVMCLocation=");
	if (pos == -1) return false;
	var start = pos + 16;
	var end = myCookie.indexOf(";", start);
	if (end == -1) end = myCookie.length;
	var cookieString = unescape(myCookie.substring(start, end));
	var names = cookieString.split('&');
	for (var i = 0; i < names.length; i++) {
		names[i] = names[i].split('=');
		if (names[i][0] == "terms") {
			var myTerms = unescape(names[i][1]);
		}
		if (names[i][0] == "searchby") {
			if (names[i][1] == "name") allChecked = "NO";
		}
	}
	myTerms = myTerms.replace(/\+/g, ' ');
	document.SEARCHFORM.terms.value = myTerms;
	for (var i = 0; i < document.SEARCHFORM.length; i++) {
		if (document.SEARCHFORM.elements[i].name == "searchby") {
		if (myTerms != "" && allChecked == "YES") document.SEARCHFORM.searchby[0].checked=true;}
	}
}




function openWin(link)
{
window.open(link,'printWin');
}




function videoWin()
{
vidWin = window.open('video.html', 'videoWindow', 'resizable=yes,menubar=yes,toolbar=yes,location=yes,scrollbars=yes,width=550,height=550,status=yes');
}

function enterVMC (whichLang) {

var thePathName = document.location.pathname;	

//[Francais]
var server1f = "www.museevirtuel.ca";
var server2f = "museevirtuel.sympatico.ca";
var server3f = "sympatico.museevirtuel.ca";
var server4f = "canada.virtuel.museum";

 if (whichLang=="English") {
 	
 document.location = "English/indexFT.html";
 
 } else {
 
 document.location = "Francais/indexFT.html";
 }

}

function langLinkWriter() {

// Get the currentHost
var theCurrentHost = location.host;

// Get the pathname..
var thePathName = document.location.pathname;
var theSearchName = document.location.search;

var theProtocol = "http://";
var thePM = "/PM.cgi";
var switchedHost = "";
var switchedLink = "";

var personalMuseumLink = "/Personal/cgi-bin/pers_museum.cgi";


// The Alt tags....
var theAlt = "";  // Blank, waiting to be assigned.
var altEng = 'alt="English"';
var altFre = 'alt="Francais"';


// theProtocol+switchedHost+switchLink equals the language link


//  Step 1.  Determine which language we are switching to.

	// If the current static page is English, store the french pathname to switchedLink.
	if (thePathName.indexOf('English') != -1) {
	
		if (thePathName.indexOf('pers_museum.cgi') != -1) {
			var switchedLink = "/Francais/Personal/index.html";
			var theAlt = altFre;
		} else {
	
			var switchedLink = thePathName.replace('/English/', '/Francais/');
			var theAlt = altFre;
		}
		
	
	// If the current dynam page is English, store the french pathname to switchedLink.		
			
	} else if ((theSearchName.indexOf('&LANG=English') != -1) || (theSearchName.indexOf('?LANG=English') != -1)) {
			
			if (theSearchName.indexOf('&LANG=English') != -1) {
				var switchedLinkTemp = thePM.concat(theSearchName.replace('&LANG=English', '&LANG=Francais'));
			} else {
				var switchedLinkTemp = thePM.concat(theSearchName.replace('?LANG=English', '?LANG=Francais'));
			}
			if (theSearchName.indexOf('Language=english') != -1) {
			
			var switchedLink = switchedLinkTemp.replace('Language=english', 'Language=francais');
			
			} else {
			
			var switchedLink = switchedLinkTemp;
			}
	
	// If the current static page is French, store the french pathname to switchedLink.

	
	} else if (thePathName.indexOf('Francais') != -1) {
	
	
			if (thePathName.indexOf('pers_museum.cgi') != -1) {
				var switchedLink = "/English/Personal/index.html";
				var theAlt = altFre;
			} else {
			var switchedLink = thePathName.replace('/Francais/', '/English/');
			var theAlt = altFre;
			}
		
		
	// If the current dynam page is French, store the english pathname to switchedLink.				
	} else if ((theSearchName.indexOf('&LANG=Francais') != -1) || (theSearchName.indexOf('?LANG=Francais') != -1)) {

			if (theSearchName.indexOf('&LANG=Francais') != -1) {
				var switchedLinkTemp = thePM.concat(theSearchName.replace('&LANG=Francais', '&LANG=English'));
			} else {
				var switchedLinkTemp = thePM.concat(theSearchName.replace('?LANG=Francais', '?LANG=English'));
			}
			
			if (theSearchName.indexOf('Language=francais') != -1) {
			
			var switchedLink = switchedLinkTemp.replace('Language=francais', 'Language=english');
			
			} else {
			
			var switchedLink = switchedLinkTemp;
			}
	}




//  Step 1.  Determine which server we are 'on'.

//[English]
var server1e = "www.virtualmuseum.ca";
var server2e = "virtualmuseum.sympatico.ca";
var server3e = "sympatico.virtualmuseum.ca";
var server4e = "canada.virtual.museum";
var server5e = "virtualmuseum.ca";

//[Francais]
var server1f = "www.museevirtuel.ca";
var server2f = "museevirtuel.sympatico.ca";
var server3f = "sympatico.museevirtuel.ca";
var server4f = "canada.virtuel.museum";
var server5f = "museevirtuel.ca";

	if (theCurrentHost.indexOf(server1e) != -1 || theCurrentHost.indexOf(server1f) != -1) {
 		// Means that user is on regular virtualmuseum.ca gateway.
		if (theCurrentHost.indexOf(server1e) != -1) {
			var switchedHost = theCurrentHost.replace(server1e, server1f);
		} else {
			var switchedHost = theCurrentHost.replace(server1f, server1e);
		}
	} else if (theCurrentHost.indexOf(server2e) != -1 || theCurrentHost.indexOf(server2f) != -1) {
 		// Means that user is on sypatico virtualmuseum.ca gateway.
		if (theCurrentHost.indexOf(server2e) != -1) {
			var switchedHost = theCurrentHost.replace(server2e, server2f);
		} else {
			var switchedHost = theCurrentHost.replace(server2f, server2e);
		}

	} else if (theCurrentHost.indexOf(server3e) != -1 || theCurrentHost.indexOf(server3f) != -1) {
 		// Means that user is on canada virtualmuseum.ca gateway.
		if (theCurrentHost.indexOf(server3e) != -1) {
			var switchedHost = theCurrentHost.replace(server3e, server3f);
		} else {
			var switchedHost = theCurrentHost.replace(server3f, server3e);
		}



	} else if (theCurrentHost.indexOf(server4e) != -1 || theCurrentHost.indexOf(server4f) != -1) {
 		// Means that user is on canada virtualmuseum.ca gateway.
		if (theCurrentHost.indexOf(server4e) != -1) {
			var switchedHost = theCurrentHost.replace(server4e, server4f);
		} else {
			var switchedHost = theCurrentHost.replace(server4f, server4e);
		}

	} else if (theCurrentHost.indexOf(server5e) != -1 || theCurrentHost.indexOf(server5f) != -1) {
 		// Means that user is on canada virtualmuseum.ca gateway.
		if (theCurrentHost.indexOf(server5e) != -1) {
			var switchedHost = theCurrentHost.replace(server5e, server5f);
		} else {
			var switchedHost = theCurrentHost.replace(server5f, server5e);
		}

	}



//  Step added to handle flash/non-flash version selection to be carried over
//  when swithing languages in CM landmark.

	if (switchedLink.indexOf('LM=CommunityMemories') != -1) {
		if (switchedLink.indexOf('fl=') == -1) {
			var flashVersion = getVersionFromCookie();
			if (flashVersion < 1) {
				var flashVersion = 0;
			}
			if (switchedLink.indexOf('?') != -1) {
				switchedLink += "&fl=" + flashVersion;
			} else {
				switchedLink += "?fl=" + flashVersion;
			}
		}
	}


var finishedLink = theProtocol.concat(switchedHost,switchedLink);

// Clean up them vars...
var thePathName = "";
var theCurrentHost = "";
var switchedHost = "";
var switchedLink = "";

var server1e = "";
var server2e = "";
var server3e = "";


var server1f = "";
var server2f = "";
var server3f = "";


var hrefTagsStart = '<a href="';
var hrefTagsEnd = '>';


	// If the LM is community memories, write a function call instead...

	if (finishedLink.indexOf('LM=CommunityMemories') != -1) {
		var startPoint = finishedLink.indexOf("fl=") - 1;
		var endPoint = startPoint + 5;
		var removedPortion = finishedLink.substring(startPoint, endPoint);
		var functionUrl = finishedLink.replace(removedPortion, "");
	
		// form the html tag....
		//var htmlTag = hrefTagsStart + "..." + '"' + ' onMouseOver="javascript:cmLangLinkWriter("' + functionUrl + '")"' + theAlt + hrefTagsEnd;
		
		var htmlTag = hrefTagsStart + 'javascript:cmLangLinkWriter('  + "'" + functionUrl + "'" + ')"' +  hrefTagsEnd;
		//alert(htmlTag);
		// write the function call....
		document.write(htmlTag);
		
	} else {
	
	

	document.write(hrefTagsStart.concat(finishedLink,'" ', theAlt, hrefTagsEnd));

	}


}


function cmLangLinkWriter(theBaseLink) {
	// Retrieve the version from the cookie.
	var whichOne = getVersionFromCookie();
	//alert(theBaseLink + "&fl=" + whichOne);
	window.location.href = theBaseLink + "&fl=" + whichOne;
	whichOne = "";
}



//javascript to handle mouseovers for buttons

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// end of javascript to handle mouseovers for buttons

// Function to create an "ALT" type effect for images.
// May 27/04 by michael


function showImageAlt(whichImage) {
	var theObj = eval(whichImage);
	theObj.style.visibility = "visible";
}

function hideImageAlt(whichImage) {
	var theObj = eval(whichImage);
	theObj.style.visibility = "hidden";

}


// Function to create an "ALT" type effect for images.

// Function to submit new search on selection ofrom drop down menu for CM_Wroks pages.
// Feb 28/08 by S. MacCallum

function changePage(newLoc) {
   nextPage = newLoc.options[newLoc.selectedIndex].value;
   if (nextPage != "")
   {
      document.location.href = nextPage;
   }
}


