var globalEvent;
function showAnswer(topic,subtopic,questNr,event1)
{
	if(http.readyState == 1)
		return false;
	http.open('get', '/vadybos-apskaita/tema/'+topic+'/s/atsakymas/dalis/'+subtopic+'/klausimas/'+
	+ questNr);
	http.setRequestHeader("Content-type", "text/html; charset=windows-1257");
	http.onreadystatechange = handleAnswer;
	http.send(null);
	 globalEvent = event1;
	//return false;
}
function handleAnswer()
{
	if(http.readyState == 1)
	{
	 	//;
	}
	if(http.readyState == 4)
	{
	 var response = http.responseText;
	 var divWidth = 70;
	 if(response.length > divWidth)
		divWidth = response.length;
	 var hidDiv =  document.getElementById('answerText');
	 hidDiv.style.display =""
	 hidDiv.style.top = (findPosY(globalEvent)) + 'px';
	 hidDiv.style.left = (findPosX(globalEvent)-200) + 'px';
	 hidDiv.style.height = divWidth + 'px';
	 hidDiv.innerHTML = '<a href="JavaScript:closeDiv();">[x] Uždaryt</a><p/>' + response;
	 return false;
	}
}
function closeDiv()
{ 
    document.getElementById('answerText').style.display ="none";
}
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function popUpProperties(inobj) {
	op = window.open();
	op.document.open('text/plain');
	for (objprop in inobj) {
	op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
	}
	op.document.close();
}
function showExtended(topic,subtopic,popupId,width,height)
{
	var newWindow;
	var trueWidth;
	var trueHeight;
	if(width)
		trueWidth = width;
	else
		trueWidth = 450
    if(height)
		trueHeight = height;
	else
		trueHeight = 350	
	newWindow=window.open('/vadybos-apskaita/tema/'+ topic +'/s/detaliau/dalis/'+subtopic +'/tekstas/'+popupId,'zinaPopup','width='+trueWidth+',height='+trueHeight+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
}
function showLargeImg(topic,subtopic,img)
{
	//openPerfectPopup(300,'Detalesnė informacija','<img src="/gaidiene/images/lenteles/'+img+'"/>');
	newWindow=window.open('/vadybos-apskaita/tema/'+ topic +'/s/paveiksliukas/rodyti/'+img,'zinaPopup','width=350,height=450,toolbar=0,location=0,directories=0,statusbar=0,menuBar=0,scrollBars=1,resizable=1');
	newWindow.focus();
	
}
function resizeWindow()
{

var iWidth = document.images[0].width;
var iHeight = document.images[0].height;
window.resizeTo(iWidth+50,iHeight+50);

}

