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 faqExpander(){
	if(('Tween' in window) && document.getElementById('faq-list')){
		var ast = document.getElementById('faq-list').getElementsByTagName('a');
		for(a in ast){
			if(/show-answer/.test(ast[a].className)){
				ast[a].style.display = "inline";
				var p = ast[a].nextSibling;
				while(!(/div/i.test(p.nodeName) && /answer-text/i.test(p.className))){p = p.nextSibling;}
				p.style.height = 0;
				ast[a].ans = p;
				ast[a].onclick = function(){
					if(!this.ans.hTween){
						this.ans.hTween = new Tween(this.ans,"height",0,this.ans.scrollHeight,250,'','px',"easeSin");
						this.toggle = false;
					}
					if(this.ans.hTween.playing){return false;}
					this.ans.hTween.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 findLinks(){
	var a = document.getElementsByTagName('a');
	
	for(var k=0;k<a.length;k++){
		if(a[k].className.indexOf('external') != -1){
			a[k].href = '/external_site.html?url=' + a[k].href;
		} else if(a[k].className.indexOf('popupLink') != -1){
			a[k].onclick = function(){
				window.opener.open(this.href,"_self");
				window.opener.focus();
				return false;
			}
		} else if(a[k].className.indexOf('pdf') != -1){
			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 if(a[k].className.indexOf('formlink') != -1){
			a[k].onclick = function(){
				newWindow = window.open(this.href,"at_form","width=600,height=490,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=yes,location=no");
				return false;
			}
		}
	}
}

function init(){
	if(arguments.callee.doOnce){return;}
	arguments.callee.doOnce=true;
	if(document.getElementById && document.getElementById('slideshow_box')){
		document.getElementById('slideshow_text').style.height = "248px";
		document.getElementById('slideshow_btns').style.display = "block";
		document.getElementById('slideshow_btn1').style.backgroundPosition = "0 0";
		function collector(data){
			var show = new SlideShow(data,8500);
			show.start();
		}
		var r = new Request("/includes/slideshow.xml",null,collector);
	}
	findLinks();
	faqExpander();
}

if(document.addEventListener){document.addEventListener("DOMContentLoaded",init,null);}
window.onload=init;