function findPosX(obj)
{
var curleft=0;
if(obj.offsetParent){
	while(1){
		curleft += obj.offsetLeft;
		if(!obj.offsetParent)break;
		obj = obj.offsetParent;
		}
	}
else if(obj.x)curleft+=obj.x;
return curleft;
}

function findPosY(obj)
{
var curtop=0;
if(obj.offsetParent){
	while(1){
		curtop += obj.offsetTop;
		if(!obj.offsetParent)break;
		obj = obj.offsetParent;
		}
	}
else if(obj.y)curtop+=obj.y;
return curtop;
}

function showPopup(hoverName,hoverOwner)
{
hp = document.getElementById(hoverName);
hp.style.left = ""+(findPosX(hoverOwner)+20)+"px";
hp.style.top =""+(findPosY(hoverOwner)+15)+"px";
hp.style.visibility = "Visible";
}

function hidePopup(hoverName)
{
hp = document.getElementById(hoverName);
hp.style.visibility = "Hidden";
}

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth(){return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;}
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;}
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;}
function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}
                    
function showCenteredPopup(pw,ph,popupName)
{
  var myWidth = document.body.clientWidth, myHeight =  document.body.clientHeight;
 //var myWidth = pageWidth(), myHeight =  pageHeight();
//alert(""+((myWidth-pw)/2)+"px"+", "+((myHeight-ph)/2)+"px");
hp = document.getElementById(popupName);
hp.style.left = ""+((myWidth-pw)/2)+"px";
hp.style.top =""+((myHeight-ph)/2)+"px";
hp.style.visibility = "Visible"; 
 }

function xchgVisible(id)
{
	e=document.getElementById(id)
	ed=e.style.display
	e.style.display=ed=="block"?"none":"block";
	return ed=="block"?0:1;
}

function setVisibilityAndClass(id,v,idLink,cls)
{
	document.getElementById(id).style.display=v
	document.getElementById(idLink).setAttribute('class',cls);
}

var imgOvers=[];
var imgNormals=[];

function preload1(img,x,y)
{
imgNormals[img]=new Image(x,y);
imgNormals[img].src=img;
}

function preload(name,x,y,normal,over)
{
imgOvers[name]=new Image(x,y);
imgOvers[name].src=over;
imgNormals[name]=new Image(x,y);
imgNormals[name].src=normal;
}

function swapQuestionHeader(qid)
{
v=xchgVisible('tAnswers'+qid);
if(v){
	document.getElementById('tQuestionPlus'+qid).style.display='none';
	document.getElementById('tQuestionMinus'+qid).style.display='block';
	}else{
	document.getElementById('tQuestionPlus'+qid).style.display='block';
	document.getElementById('tQuestionMinus'+qid).style.display='none';					
	}
}

function overOn(name)
{
document.getElementById(name).src=imgOvers[name].src;
//document[name].src=imgOvers[name].src;
}

function overOff(name)
{
document.getElementById(name).src=imgNormals[name].src;
//document[name].src=imgNormals[name].src;
}

function overOnIdx(name,idx)
{
document.getElementById(name+idx).src=imgOvers[name].src;
//document[name+idx].src=imgOvers[name].src;
}

function overOffIdx(name,idx)
{
document.getElementById(name+idx).src=imgNormals[name].src;
//document[name+idx].src=imgNormals[name].src;
}

function setCheckboxDependentObj(cbName,objName)
{
//alert(document.getElementById(cbName));
fc=document.getElementById(cbName).checked==true;
document.getElementById(objName).style.display=fc?'block':'none';
}

