/************************************************************************************************************
(C) www.dhtmlgoodies.com, November 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/
/* This code has been *heavily* modified by liquidweb.com */

<!--
var dhtmlgoodies_slideSpeed = 30;	// Higher value = faster
var dhtmlgoodies_timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;

function showContent(e,inputId) {
	if(dhtmlgoodies_slideInProgress)return;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		showHideContent(e, inputId);
	}
}

function showHideContent(elem,inputId) {
	clog("elem: " + elem);
	clog("inputId: " + inputId);
	if(dhtmlgoodies_slideInProgress)return;
	dhtmlgoodies_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	clog("inputId: " + inputId);
	var scroll = 1;
	if (this.className == "dhtmlgoodies_question_noscroll") {
		scroll = 0;
	}
	clog("scroll: " + scroll);
	
	var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

	objectIdToSlideDown = false;
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1),scroll);
		}else{
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			slideContent(numericId,dhtmlgoodies_slideSpeed,scroll);
		}
	}else{
		slideContent(numericId,(dhtmlgoodies_slideSpeed*-1),scroll);
		dhtmlgoodies_activeId = false;
	}	
}

var onemore = 0;
function slideContent(inputId,direction,scroll) {
	var obj =document.getElementById('dhtmlgoodies_a' + inputId);
	var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		if (onemore) {
			onemore = 0;
			rerunFunction = false;
		} else {
			onemore = 1;
		}
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}
	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ',' + scroll + ')',dhtmlgoodies_timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed,scroll);				
			}else{
				dhtmlgoodies_slideInProgress = false;
			}
		}else{
			dhtmlgoodies_activeId = inputId;
			dhtmlgoodies_slideInProgress = false;
		}
		if (direction == Math.abs(direction)) {
			if(scroll) {
				ssmoothScroll(inputId);	
			}
		}
	}
}


var posDiv = new Array();
function initShowHideDivs() {
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if((divs[no].className=='dhtmlgoodies_question') || (divs[no].className=='dhtmlgoodies_question_noscroll')) {
			var divId = divs[no].id;
			divs[no].onclick = showHideContent;
			divs[no].id = 'dhtmlgoodies_q'+divId;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'dhtmlgoodies_a'+divId;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='dhtmlgoodies_answer_content';
			contentDiv.id = 'dhtmlgoodies_ac' + divId;
			answer.style.display='none';
			answer.style.height='1px';
			var anchor = document.getElementById("anc" + divId);
			clog(anchor.id);
			//var array = findPos(anchor);
			//var ypos = findPosY(anchor);
			var ypos = YAHOO.util.Dom.getY(anchor);
			clog("POS: " + divId + " Value: " + ypos);
			var yValue = ypos;
			//yValue = yValue - 25;
			//yValue = yValue - 235;
			//if (yValue < 0) {
			//	yValue = 0;
			//}
			posDiv[divId] = yValue;
			divCounter++;
		}		
	}	
}

function hidejsdiv() {
	clog('nojs');
	var el = document.getElementById('nojs');
	if (el) {
		clog('nojsdo');
		el.style.display='none';
	}
}

function init() {
	initShowHideDivs();
	hidejsdiv();
	doBodyOnLoad()
}

YAHOO.util.Event.onDOMReady(init);

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.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];}
}

var scrollActive = false;
var scrollLastY = -100000;
var scrollcount = 0;
function ssmoothScroll(name) {
	if (scrollActive) return;
	scrollLastY = -100000;
	scrollcount = 0;
	smoothScroll(name);
}

function getViewportScrollY()  {
	var scrollY = 0;
	if( document.documentElement && document.documentElement.scrollTop ) {
		scrollY = document.documentElement.scrollTop;
	}
	else if( document.body && document.body.scrollTop ) {
		scrollY = document.body.scrollTop;
	}
	else if( window.pageYOffset ) {
		scrollY = window.pageYOffset;
	}
	else if( window.scrollY ) {
		scrollY = window.scrollY;
	}
	return scrollY;
}

function smoothScroll(name) {
	var scrollSpeed = 100;
	var XY={x:0, y:0};
	XY.x = 0
	var anchor = document.getElementById("anc" + name);
	XY.y = YAHOO.util.Dom.getY(anchor);
	XY.y = XY.y - 15;
	if(XY.y < 0)
		XY.y = 0;
	clog("------\n");
	clog("ancX: "+XY.x+"\n");
	clog("ancY: "+XY.y+"\n");
	var curX = window.scrollX;
	curY = getViewportScrollY();
	var diffX = Math.floor((curX - XY.x) / 2);
	var diffY = Math.floor((curY - XY.y) / 2);
	if (Math.abs(diffX) > scrollSpeed)
		diffX = scrollSpeed * (diffX/Math.abs(diffX));
	if (Math.abs(diffY) > scrollSpeed)
		diffY = scrollSpeed * (diffY/Math.abs(diffY));
	var newX = curX - diffX;
	var newY = curY - diffY;
	clog("diffX: "+diffX+"\n");
	clog("diffY: "+diffY+"\n");
	clog("NewX: "+newX+"\n");
	clog("NewY: "+newY+"\n");
	clog("CurX: "+curX+"\n");
	clog("CurY: "+curY+"\n");
	if (curY == scrollLastY) {
		scrollcount++;
	}
	if (scrollcount<3) {
		if (!((curY == XY.y) || (diffY == 0))) {
			clog("Setting timeout\n");
			window.setTimeout("smoothScroll(" + name +")", 35);
			scrollLastY = curY;
			window.scrollTo(newX, newY);
		}
	} else {
		scrollActive = false;
	}
}

//-->

