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_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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// sIFR (Scalable Inman Flash Replacement) version 1.1.3
// Contributions by Mike Davidson (yo da man - md), Shaun Inman (yo too - md), and Tomas Jogin (I do not know you :))
// Associated Article: http://www.mikeindustries.com/blog/archive/2004/08/sifr

/******************************************************************************
 This is the flash detection script.
 ******************************************************************************/
var required = 6;
var hasFlash = false;
if (navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") != -1) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('hasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & required))) \n');  
	document.write('<'+'/scr' + 'ipt\> \n');
} else {
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])?navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin:0;
	if (plugin) {
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		hasFlash = flashVersion >= required;
	}
}
if (hasFlash && document.getElementsByTagName && document.getElementsByTagName('html')[0]) {
	document.getElementsByTagName('html')[0].className += (document.getElementsByTagName('html')[0].className=='')?'hasFlash':' hasFlash';
}	
function SI_normalizeWhiteSpace(txt) {
	var rE = /\s+/gi;
	return txt.replace(rE,' ');
}
function SI_forceRedraw() {
	var d = document;
	if (d.body && d.body.style) {
		d.body.style.height = "1px";
		d.body.style.height = "auto";
	}
}	
function TJ_replaceElement(elem,swf,w,h,textcolor,bgcolor,afv) {
	if (!hasFlash) {
		return;
	}

	var d = document;
	elemarr = elem.split(">");
	PE = new Object();
	RE = new Object();
	has_parent = elemarr.length > 1;
	for (i=0; i<elemarr.length; i++)
	{
		es = elemarr[i];
		E = new Object();

		E.id = false;
		E.tagName = false;
		E.className = false;

		if (es.indexOf("#") >= 0) {
			E.id = es.substr(es.indexOf("#")+1, es.length);
			E.tagName = es.substr(0, es.indexOf("#"));
		} else if (es.indexOf(".")>=0) {
			E.className = es.substr(es.indexOf(".")+1, es.length);
			E.tagName = es.substr(0, es.indexOf("."));
		} else {
			E.tagName = es;
		}
		
		if (has_parent && i == 0) {
			PE = E;
		} else {
			RE = E;
		}	
	}


	if (afv != '') {
		afv = SI_normalizeWhiteSpace(afv);
		afv = '&'+afv;
	}
	var elems = d.getElementsByTagName(RE.tagName);
	var count = elems.length;

	if (!count) {
		return;
	}	
	
	i = 0;
	
	switches = 0;
	skips = 0;
	total = count;

		if (!h) {
			var noheight = true;
		}
		if (!w) {
			var nowidth = true;
		}

	while (count)
	{
		e = elems[i];
		i++;
		if (has_parent) {
			if (PE.className) {
				if (PE.className != e.parentNode.className) {
					count--; skips++; continue;
				}	
				if (PE.id) {
					if (PE.id != e.parentNode.id) {
						count--; skips++; continue;
					}
				}
			}		
		}
		if (RE.className) {
			if (e.className != RE.className) {
				count--; skips++; continue;
			}
			if (RE.id) {
				if(e.id != RE.id) {
					count--; skips++; continue;
				}
			}
		}
		if(e.getAttribute("ifrskip"))
		{	continue;	}

		if (noheight) {
			h = e.offsetHeight;
		}
		if (nowidth) {
			w = e.offsetWidth;
		}
		
		var txt;
		txt = SI_normalizeWhiteSpace(e.innerHTML);
		var c = d.createElement('div');
		c.className = 'replaced-'+RE.tagName;
		e.parentNode.replaceChild(c,e);
		if(RE.tagName == "div")
			i++;
		count--;
		switches++;
		var wmode = (bgcolor == 'transparent') ? 'transparent' : 'opaque';
		var fv = 'txt='+escape(txt)+afv+'&w='+w+'&h='+h+'&textcolor='+textcolor;
		var swfHTML;
		swfHTML  = '<object class="sIFRobject" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+w+'" height="'+h+'">';
		swfHTML += '	<param name="movie" value="'+swf+'" />';
		swfHTML += '	<param name="wmode" value="'+wmode+'" />';		
		swfHTML += '	<param name="bgcolor" value="'+bgcolor+'" />';		
		swfHTML += '	<param name="flashvars" value="'+fv+'" />';
		swfHTML += '	<embed class="sIFRobject" src="'+swf+'" flashvars="'+fv+'" width="'+w+'" height="'+h+'" TYPE="application/x-shockwave-flash" wmode="'+wmode+'" bgcolor="'+bgcolor+'" />';
		swfHTML += '<'+'/object>';
		swfHTML += '<'+e.nodeName.toLowerCase()+((e.id)?' id="'+e.id+'"':'')+((e.className)?' class="'+e.className+'"':'')+' style="display: none" ifrskip="1">'+txt+'<'+'/'+e.nodeName.toLowerCase()+'>';
		c.innerHTML = swfHTML;
		txt='';
	}

}

function sIFR () {
/******************************************************************************
	elem (string) :
		`div#header` will replace the `div` with the id of header
		`div#primary-content>h1` will replace any `h1` tag whose direct parent is a `div` with an id of `primary-content`
		`h2.replaceme` will replace any `h2` tag with a className of `replaceme`
	swf (string) :
		full path to the swf
	w (number) :
		desired width of Flash movie... use empty single quotes ('') to let the browser decide
	h (number) :
		desired height of Flash movie... use empty single quotes ('') to let the browser decide				
	afv (string) :
		used to pass additional flashVars to the movie (e.g. 'fruit=apple&vegetable=onion')
	textcolor (hexcolor) :
		determines color of headline text in Flash... use empty single quotes ('') to use default black		
	bgcolor (hexcolor or the string 'transparent') :
		determines background color of Flash movie (used in object/embed tags)...
		use empty single quotes ('') to default to none or use ('transparent') for a transparent background		
	 
 The new replaced element will be placed in a div 
 with a className of `'replaced-'+r.e.tagName`
	// Parameters: item_to_replace , swf_filename, width, height, textcolor, bgcolor, additional_vars
	// All are optional except first two parameters
 ******************************************************************************/
	TJ_replaceElement('h1','http://www.unbf.ca/unbsu/images/meta.swf','','','#E03827','#FFFFFF','');
	TJ_replaceElement('h2','http://www.unbf.ca/unbsu/images/meta.swf','','','#666666','#FFFFFF','');
	TJ_replaceElement('h3','http://www.unbf.ca/unbsu/images/meta.swf','','','#666666','#FFFFFF','');
	
	SI_forceRedraw();
}
window.onload=sIFR;
