function setFF(){
	if(document.getElementById('right-nav')){
		var ffContainer = document.createElement('div');
		ffContainer.id = "fast-fact-container";
		document.getElementById('right-nav').appendChild(ffContainer);
		
		var ff = document.createElement('div');
		ff.id = "fast-fact";
		ffContainer.appendChild(ff);
		
		var ffLink = document.createElement('a');
		ffLink.appendChild(document.createTextNode('Learn More'));
		ffLink.id = "fast-fact-link";
		ffContainer.appendChild(ffLink);
		
		//var ffContainer = document.getElementById('fast-fact-container');
		//var ffLink = document.getElementById('fast-fact-link');
		//var ff = document.getElementById('fast-fact');

		// <sup><a href=\"#ref#refNum\">#refNum</a></sup> = reference number
		var ffList = [//no backend, AJAX not really warranted
		 /* 1*/{txt:"IVIG contains antibodies collected from the plasma of healthy donors.",url:"/patients-and-families/ivig-therapy/how-ivig-works.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:93."},
		 /* 2*/{txt:"IVIG is given intravenously, which means through a needle directly into a vein.",url:"/patients-and-families/ivig-therapy/how-ivig-works.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:94."},
		 /* 3*/{txt:"IVIG can be administered in a hospital outpatient unit or your home.",url:"/patients-and-families/ivig-therapy/how-ivig-works.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:94."},
		 /* 4*/{txt:"A typical IVIG infusion takes 2-4 hours.",url:"/patients-and-families/ivig-therapy/how-ivig-works.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:94."},
		 /* 5*/{txt:"Repeat doses of IVIG are needed every 3-4 weeks.",url:"/patients-and-families/ivig-therapy/how-ivig-works.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:93."},
		 /* 6*/{txt:"PI patients who rely on IVIG usually need infusions throughout their lives.",url:"/patients-and-families/ivig-therapy/how-ivig-works.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:93."},
		 /* 7*/{txt:"Primary immune deficiencies are not contagious.",url:"/patients-and-families/about-pi/ask-the-pi-panel/medical-topics.html#q1",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:10."},
		 /* 8*/{txt:"Differences in IVIG brand formulas may make one product more suitable for you than another.",url:"/patients-and-families/ivig-therapy/how-ivig-works.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:94."},
		 /* 9*/{txt:"IVIG temporarily replaces missing antibodies that people with primary immune deficiencies are missing.",url:"/patients-and-families/ivig-therapy/how-ivig-works.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:93."},
		 /*10*/{txt:"Slowing down the rate of infusion may help reduce IVIG side effects.",url:"/patients-and-families/ivig-therapy/ivig-side-effects.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:94."},
		 /*11*/{txt:"Primary immune deficiencies result from a defect in one of the functions of the body's normal immune system.",url:"/patients-and-families/about-pi/",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:10."},
		 /*12*/{txt:"People with PI may experience repeated infections, infections that won't clear up, or unusually severe infections.",url:"/patients-and-families/about-pi/",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:10."},
		 /*13*/{txt:"Although the first PI diseases were diagnosed in children, many patients aren't diagnosed until they're adults.",url:"/patients-and-families/about-pi/diagnosing-pi/",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:10."},
		 /*14*/{txt:"Most patients with CVID have a history of recurrent infections involving ears, sinuses, bronchi, and lungs.",url:"/patients-and-families/about-pi/types-of-pi/common-variable-immunodeficiency-cvid.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:12."},
		 /*15*/{txt:"XLA is a genetic disease that affects only males, but females may be carriers of the gene.",url:"/patients-and-families/about-pi/types-of-pi/x-linked-agammaglobulinemia-xla.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:18."},
		 /*16*/{txt:"Selective IgA deficiency is one of the most common forms of PI.",url:"/patients-and-families/about-pi/types-of-pi/selective-iga-deficiency.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:20."},
		 /*17*/{txt:"Laws regarding health insurance can differ from state to state.",url:"/patients-and-families/help-and-support/insurance-assistance/idf-insurance-primer.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:126."},
		 /*18*/{txt:"More than half of states provide coverage to medically uninsurable people through high-risk pools.",url:"/patients-and-families/help-and-support/insurance-assistance/idf-insurance-primer.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:127."},
		 /*19*/{txt:"Most patients with DiGeorge Syndrome usually do not suffer from recurrent infections in adulthood.",url:"/patients-and-families/about-pi/types-of-pi/digeorge-syndrome.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:49."},
		 /*20*/{txt:"Recurrent ear infections, sinusitis, bronchitis and pneumonia are often observed in patients with IgG subclass deficiencies",url:"/patients-and-families/about-pi/types-of-pi/igg-subclass-deficiency.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:51."},
		 /*21*/{txt:"Some children may \"outgrow\" their IgG subclass deficiencies.",url:"/patients-and-families/about-pi/types-of-pi/igg-subclass-deficiency.html",ref:"Blaese RM, Winkelstein J. <em>Patient &amp; Family Handbook for Primary Immunodeficiency Diseases</em>. Towson, MD: Immune Deficiency Foundation; 2007:52."}
		]
		
		/*
		if(/^\/patients-and-families\//.test(document.location.pathname)){
			var subset = [1,5,10,15,24,25]; //etc.
		} else {*/
			subset = null;
		//}
		var id = subset!=null?subset[Math.floor(Math.random()*subset.length)]:Math.floor(Math.random()*ffList.length);
		var ffText = "<span>FAST FACT</span>"+ffList[id].txt;
		ffLink.href = ffList[id].url
		ffLink.onclick = function(){
			//offset by 1 for analyst
			dcsMultiTrack('DCS.dcsuri',this.href+"?WT.ff="+(id+1));
			window.open(this.href+"?WT.ff="+(id+1),"_self");
			return false;
		}
		
		//if(ffList[id].ref && /#refNum/.test(ffList[id].txt)){//if FF has a reference
			var refNum = 1;
			//determine reference number
			if(document.getElementById('ref')){
				//number of current references + 1;
				refNum = document.getElementById('ref').getElementsByTagName('li').length+1;
			} else if(document.getElementById('content')){
					//create ref at bottom of page
					var ref = document.getElementById('content').appendChild(document.createElement('ol'));
					ref.id = "ref";
			} else {
				return;//can't find containers?	
			}
			//add new li
			var li = document.getElementById('ref').appendChild(document.createElement('li'));
			li.id = "ref"+refNum;
			li.innerHTML = ffList[id].ref;
			ffText += "<sup><a href=\"#ref"+refNum+"\">"+refNum+"</a></sup>"
			//ffText = ffText.replace(/#refNum/g,refNum);
		//}
		

		//display text
		ff.innerHTML = ffText;
		ffContainer.style.display = "block";
	}
}


function removeClassName(ele){
	if(document.all){
		for(var i = 0; i < ele.attributes.length; i++){
			if(ele.attributes[i].name.toLowerCase() == 'class'){
				ele.attributes[i].value = "";
			}
		}
	} else {
		ele.removeAttribute("class");	
	}
}

function panelExpander(){
	if(('Tween' in window) && document.getElementById('pipanel')){
		var ast = document.getElementsByTagName('a');
		for(a in ast){
			if(/show-answer/.test(ast[a].className)){
				var p = ast[a].parentNode.parentNode;
				while(!(/div/i.test(p.nodeName) && /answer-text/i.test(p.className))){p = p.nextSibling;}
				var h = document.location.hash;
				ast[a].ans = p;
				ast[a].toggle = false;
				if(/^#q\d+/.test(h)&&ast[a].parentNode.parentNode.id.match(h.match(/^#(q\d+)/)[1])){
					p.style.height = 'auto';
					removeClassName(ast[a]);
					ast[a].firstChild.nodeValue = "Hide Answer";
					ast[a].className = "hide-answer";
					ast[a].ans.hTween = new Tween(ast[a].ans,"height",ast[a].ans.scrollHeight,0,250,'px','',"easeSin");
					ast[a].ans.mTween = new Tween(ast[a].ans,"marginBottom",18,0,250,'px','',"easeSin");
				} else {
					p.style.height = '0';
					ast[a].ans.hTween = new Tween(ast[a].ans,"height",0,ast[a].ans.scrollHeight,250,'px','',"easeSin");
					ast[a].ans.mTween = new Tween(ast[a].ans,"marginBottom",0,18,250,'px','',"easeSin");
				}
				ast[a].onclick = function(){
					if(this.ans.hTween.playing){return false;}
					this.ans.hTween.play();
					this.ans.mTween.play();
					removeClassName(this);
					if(this.toggle){
						this.firstChild.nodeValue = "Show Answer";
						this.className = "show-answer";
					} else {
						this.firstChild.nodeValue = "Hide Answer";
						this.className = "hide-answer";
						
					}
					this.toggle = !this.toggle;
					return false;
				}
			}
		}
	}
}

function initScrollmatic4000(){
	
	if(document.getElementById('paf-home-wrapper')){
		//var sw = new ScrollWindow(document.getElementById('home-gallery-list'),document.getElementById('home-selector-list'),document.getElementById('home-message-list'),document.getElementById('home-description-list'),document.getElementById('home-link-list'),500,5);
	} else if(document.getElementById('hcp-home-wrapper')){
		//var sw = new ScrollWindow(document.getElementById('home-gallery-list'),document.getElementById('home-selector-list'),document.getElementById('home-message-list'),document.getElementById('home-description-list'),document.getElementById('home-link-list'),500,4);
	} else if(document.getElementById('nrs-home-wrapper')){
		//var sw = new ScrollWindow(document.getElementById('home-gallery-list'),document.getElementById('home-selector-list'),document.getElementById('home-message-list'),document.getElementById('home-description-list'),document.getElementById('home-link-list'),500,4);		
	}
	/*if(sw){
		sw.init();
	}*/
	/*
	var h1 = document.getElementById('home-message').getElementsByTagName('h1');
	len = h1.length;
	for(var k=0;k<len;k++){
		
		if(h1[k].className == "shadow"){continue;}
		n = h1[k].cloneNode(true);
		shd = document.createElement('div');
		shd.innerHTML = n.innerHTML
		shd.className = "shadow";
		h1[k].parentNode.insertBefore(shd,h1[k]);
		h1[k].className = "shadowed";
	}
	var descLi = document.getElementById('home-description-list').getElementsByTagName('li');
	len = descLi.length;
	for(var x=0;x<len;x++){
		for(var node = descLi[x].firstChild;node!=null;node = node.nextSibling){
			if(node.nodeType == 1){
				var s = document.createElement('span');
				s.innerHTML = node.innerHTML;
				node.insertBefore(s,node.firstChild);
				node.className = "shadowed";
			}
		}
	}
	*/
}

function preloadImages(){
	var dropdown = new Image();
	if(/MSIE 6/.test(navigator.userAgent)){
		dropdown.src = "/images/ui/drop-down.gif";
	} else {
		dropdown.src = "/images/ui/drop-down.png";
	}
	var sectionHover = new Image();
	sectionHover.src = "/images/ui/section-nav-bg-rollover.gif";
}

function insertScrollWindow(){
	if(document.getElementById('immune-system-container')){
		var sw = new ScrollWindow(document.getElementById('immune-system-container'),document.getElementById('pihandbooknav'),500,6);
		sw.init();
	}
	if(document.getElementById('site-map-container')){
		var sw = new ScrollWindow(document.getElementById('site-map-container'),document.getElementById('pihandbooknav'),940,3);
		sw.init();
	}
}

function ieMenuFix(){
	var n = document.getElementById('header-nav');
	var a = n.getElementsByTagName('li');
	for(var k=0;k<a.length;k++){
		if(/paf-nav|hcp-nav|nrs-nav/.test(a[k].parentNode.className)){
			if(a[k].lastChild.nodeName.toLowerCase() == 'ul'){
				a[k].onmouseover = function(){
					this.lastChild.style.display = "block";
				}
				a[k].onmouseout = function(){
					this.lastChild.style.display = "none";
				}
			}
		}
	}
}

function insertFlash(){
	var flash = {
		"chart-movie":{swf:"/swf/chart.swf",w:180,h:400,v:8,c:false},
		"ivig-video":{swf:"/swf/brandon_ivig.swf",w:400,h:345,v:8,c:true},
		"parts-movie":{swf:"/swf/Parts.swf",w:380,h:400,v:8,c:false},
		"b-cells-movie":{swf:"/swf/B_CELLS.swf",w:290,h:275,v:8,c:false},
		"t-cells-movie":{swf:"/swf/T_CELLS.swf",w:350,h:255,v:8,c:false},
		"phagocyte-movie":{swf:"/swf/Phagocytes.swf",w:350,h:255,v:8,c:false},
		"complement-movie":{swf:"/swf/Complement.swf",w:350,h:305,v:8,c:false},
		"gallery-content-paf":{swf:"/swf/paf-gallery.swf",w:960,h:324,v:8,c:true},
		"gallery-content-hcp":{swf:"/swf/hcp-gallery.swf",w:960,h:324,v:8,c:true},
		"gallery-content-nrs":{swf:"/swf/nrs-gallery.swf",w:960,h:324,v:8,c:true}
	}
	for(m in flash){
		if(document.getElementById(m)){
			flash[m].m = new Flash(document.getElementById(m),flash[m].swf,flash[m].w,flash[m].h,flash[m].v,flash[m].c);
			flash[m].m.insert();
		}
	}
}

function initSIFR(){
	if(document.getElementsByTagName('h1')[0] && document.getElementsByTagName('h1')[0].lastChild.nodeName.toLowerCase() == 'span'){
		document.getElementsByTagName('h1')[0].lastChild.className = "subheader";
		document.getElementsByTagName('h1')[0].lastChild.insertBefore(document.createElement('br'),document.getElementsByTagName('h1')[0].lastChild.firstChild);
	}
	if(document.getElementsByTagName('h1')[0] && document.getElementsByTagName('h1')[0].getElementsByTagName('a'))
	{
		var linktags = document.getElementsByTagName('h1')[0].getElementsByTagName('a');
		for (i=0;i<linktags.length;i++)
		{
			var thesup = linktags[i].firstChild.nodeValue;
			if (!isNaN(thesup))
				linktags[i].innerHTML = "&sup"+thesup+";";
		}
	}	
	sIFR.replace(universcond, {selector: 'h1',css: ['.sIFR-root{font-size:22px;leading:-4;color:#ffffff;margin:0;padding:0;font-weight:bold;}','.subheader{font-size:75%;leading:-9;}','a{color:#ffffff;text-decoration:none;}','a:hover{color:#ffffff;}'], wmode: 'transparent'});
	
}

function initRefs(){
	if(!/#ref/.test(document.location.toString())){document.getElementById('ref').style.display = "none";}
	refs = document.getElementById('content').getElementsByTagName('sup');
	for(var r=0;r<refs.length;r++){
		var a = refs[r].getElementsByTagName('a');
		for(var k=0;k<a.length;k++){
			a[k].onclick = function(){
				document.getElementById('ref').style.display = "block";
			}
		}
	}
}

function findLinks(){
	var a = document.getElementsByTagName('a');
	for(var k=0;k<a.length;k++){
		if(/external/.test(a[k].className)){
			
			if(/MSIE/.test(navigator.userAgent)){
				a[k].className = "external no-bg";
				var sp = document.createElement('span')
				sp.appendChild(document.createTextNode(' '));
				sp.className="external";
				a[k].appendChild(sp);
			}
			
			a[k].href = '/external/external_site.html?url=' + a[k].href;
		} else if(/xlink/.test(a[k].className)){
			a[k].onclick = function(){
				dcsMultiTrack('DCS.dcsuri',this.href);	
			}
		} else if(/pdf/.test(a[k].className)){
			
			if(/MSIE/.test(navigator.userAgent)){
				a[k].className = "pdf no-bg";
				var sp = document.createElement('span')
				sp.appendChild(document.createTextNode(' '));
				sp.className="pdf";
				a[k].appendChild(sp);
			}
			
			if(/baxter.com/.test(a[k].href)){
				a[k].onclick = function(){
					dcsMultiTrack('DCS.dcsuri',this.href+"?WT.svl=BiosciencePIs&site="+document.location.host);
					window.open(this.href+"?WT.svl=BiosciencePIs&site="+document.location.host);
					return false;
				}
			} else {
				a[k].onclick = function(){
					dcsMultiTrack('DCS.dcsuri',this.href+"?WT.svl=PDF&site="+document.location.host);
				}
			}
		} else if(/movie/.test(a[k].className)){
			a[k].onclick = function(){
				dcsMultiTrack('DCS.dcsuri',this.href+"?WT.svl=BioscienceMovies&site="+document.location.host);
				window.open(this.href+"?WT.svl=BioscienceMovies&site="+document.location.host,'video','width=400,height=300,resizable=yes');
				return false;
			}
		} else if(/flipchart/.test(a[k].className)){
			a[k].onclick = function(){window.open(this.href,'flipchart','width=675,height=595,resizable=yes');return false;}
		} else if(/ggg/.test(a[k].className)){
			a[k].onclick = function(){window.open(this.href,'ggg','width=540,height=450,resizable=yes');return false;}
		} else if(/web-form|order-form|ask-the-pi-panel|ask-a-question-text/.test(a[k].className)){
			a[k].onclick = function(){window.open(this.href,'form','width=750,resizable=yes,scrollbars=yes');return false;}
		}
	}
}
function init(){
	if(arguments.callee.doOnce){return;}
	arguments.callee.doOnce=true;
	if(document.getElementById('home-gallery')){
		initScrollmatic4000();
	}
	if(document.getElementById('left-nav') && 'Nav' in window){
		var nav = new Nav('left-nav','header-nav');
		nav.init();
	} else if('Nav' in window){
		var nav = new Nav(null,'header-nav');
		nav.init();
	}
	if(document.getElementById("search-field")){
		document.getElementById("search-field").onfocus = function(){
			if(this.value = "Search"){
				this.value = "";
			}
		}
	}
	setFF();
	findLinks();
	preloadImages();
	panelExpander()
	if(/MSIE 6/.test(navigator.userAgent)){ieMenuFix();}
	//initRefs();
	if('Flash' in window){insertFlash();}
	if('ScrollWindow' in window){insertScrollWindow();}

	if('sIFR' in window){
		initSIFR();
	}
	if('Cufon' in window){Cufon.now();}
}

if(document.addEventListener){document.addEventListener("DOMContentLoaded",init,null);}
window.onload=init;


if('Cufon' in window){
	Cufon.replace('#hcp-home-list strong,#paf-home-list strong,#nrs-home-list strong');
	Cufon.replace('#main #content h1');
}