// rollover functions
function swap(imgName,newImgName) {

	if (document.images) {
		document.images[imgName].src = eval(newImgName + ".src");
	}
}


//Determine Browser Version
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
if ((bName=="Netscape" && bVer >=3))
	br = "n3";
else
{
	if(bName == "Microsoft Internet Explorer" && bVer >=4)
		br="ie4"
	else
		br = "n2";
}

//Function to open new windows
function openWin(URL)
{
	width=700;
	height=650;

	//If resolution is 640x480
	if(screen.width < 800) {
		width=500;
		height=400;
	}

	//If resolution is 800x600
	else if(screen.width < 1024) {
		width=600
		height=500;
	}

	aWindow = window.open(URL,"PopUp","width="+width+",height="+height+",resizable=yes,scrollbars=yes,left=10,top=10");

	aWindow.resizeTo(width, height);

	aWindow.focus();
	if(aWindow.opener == null)
	{
		aWindow.opener = window;
		aWindow.opener.name = "opener";
	}
}

function WM_netscapeCssFix() {
  /*
    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)

    Author: Taylor
    Author Email: taylor@wired.com
    Author URL: http://www.taylor.org/
    */

  // This part was inspired by Matthew_Baird@wayfarer.com
  // It gets around another unfortunate bug whereby Netscape
  // fires a resize event when the scrollbars pop up. This
  // checks to make sure that the window's available size
  // has actually changed.
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function WM_netscapeCssFixCheckIn() {
  // This function checks to make sure the version of Netscape
  // in use contains the bug; if so, it records the window's
  // width and height and sets all resize events to be handled
  // by the WM_netscapeCssFix() function.
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn()

function reloadIt() {
  document.location = document.location;
}

function changeURL(winName, newURL) {
  win = window.open("", winName);
  win.location.href = newURL;
}

//Function for Dynamic Pop Ups
function DynaPop(szTitle,szImgSource,szDescription,nCopyrightNum,level)
{
	popTitle = szTitle;
	popSource = szImgSource;
	popDescription = szDescription;
	popCopyright = nCopyrightNum;

	if (popDescription == "description")
		popDescription = "";

	if (popTitle == "title")
		popTitle = "";

	width=500;
	height=600;

	//If resolution is 640x480
	if(screen.width < 800)
		height=380;
	//If resolution is 800x600
	else if(screen.width < 1024)
		height=500;

	if(level==0)
		openWin("popup_dynamic.html",width,height);
	else
		openWin("../popup_dynamic.html",width,height);
}

//Copyright text for Demographics section under perspectives heading
function copyright() {

	var copyright = '<div class="copyright"><i>Excerpts reprinted from</i> <b>State of the West: Western Canadian Demographic and Economic Trends</b> <i>with permission from the</i> <a href="http://www.cwf.ca" target="_blank">Canada West Foundation</a>.</div>'

	document.write(copyright);
}




