
function getInPosition()
{
}

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 showHide(id)
{
	var div = document.getElementById(id);
	if( div.style.display == 'inline' )
	{
		div.style.display = 'none';
	}
	else
	{
		div.style.display = 'inline';
	}
}

function startQuiz()
{
	document.getElementById('viewkurs').style.display='inline';
	document.getElementById('category_1').style.display='inline';
	document.getElementById('startkurs').style.display='none';
}

function resQuiz()
{
	document.getElementById('viewkurs').style.display='inline';
	document.getElementById('startkurs').style.display='none';
}

function nextCat( nr )
{
	var next = nr+1;
	document.getElementById('category_' + nr ).style.display='none';
	document.getElementById('category_' + next ).style.display='inline';
	//self.scrollTo(0,0);
	window.scroll(0,0);
}

function thisCat( nr, total )
{
	var i=1;	
	for(i=1;i<=total;i++)
	{
		document.getElementById('category_' + i ).style.display='none';
	}
	document.getElementById('category_' + nr ).style.display='inline';
	window.scroll(0,0);
}

function leftThisCat( nr, total )
{
  	for(var i=1;i<=total;i++)
	{
		if( document.getElementById('category_' + i ) )
		{
			document.getElementById('category_' + i ).style.display='none';
		}
	}
	document.getElementById('viewkurs').style.display='inline';
	document.getElementById('startkurs').style.display='none';
	document.getElementById('category_' + nr ).style.display='inline';
	window.scroll(0,0);
}

function fixFPBoxes()
{
	if( document.getElementById( 'fpbox-0' ) )
	{
		var heightArr = new Array();
		var heightBArr = new Array();
		var i = 0;
		var len = 0;
		var maxH = 0;
		
		// Top boxes
		var box0 = 	document.getElementById( 'fpbox-0' );
		var box1 = 	document.getElementById( 'fpbox-1' );
		var box2 = 	document.getElementById( 'fpbox-2' );
		var box3 = 	document.getElementById( 'fpbox-3' );
		
		var box0Pos = findPosY(box0);
		var box1Pos = findPosY(box1);
		var box2Pos = findPosY(box2);
		var box3Pos = findPosY(box3);
		
		heightArr[0] = box1Pos - box0Pos;
		heightArr[1] = box2Pos - box0Pos;
		heightArr[2] = box3Pos - box0Pos;

		maxH = heightArr[0];
		len = heightArr.length;
		
		for( i = 0; i < len; i++ ) 
		{
			if( heightArr[i] > maxH )
			{
				maxH = heightArr[i];
			}
		}
		maxH = maxH - 15;
		
		document.getElementById( 'fpbox-1-holder' ).style.height = maxH + "px";
		document.getElementById( 'fpbox-2-holder' ).style.height = maxH + "px";
		document.getElementById( 'fpbox-3-holder' ).style.height = maxH + "px";

		// Bottom boxes
		box0 = 	document.getElementById( 'fpbbox-0' );
		box1 = 	document.getElementById( 'fpbbox-1' );
		box2 = 	document.getElementById( 'fpbbox-2' );
		if( document.getElementById( 'fpbbox-3' ) )
			box3 = 	document.getElementById( 'fpbbox-3' );
		
		box0Pos = findPosY(box0);
		box1Pos = findPosY(box1);
		box2Pos = findPosY(box2);
		if( document.getElementById( 'fpbbox-3' ) )
			box3Pos = findPosY(box3);
		
		heightBArr[0] = box1Pos - box0Pos;
		heightBArr[1] = box2Pos - box0Pos;
		if( document.getElementById( 'fpbbox-3' ) )
			heightBArr[2] = box3Pos - box0Pos;

		maxH = heightBArr[0];
		len = heightBArr.length;
		
		for( i = 0; i < len; i++ ) 
		{
			if( heightBArr[i] > maxH )
			{
				maxH = heightBArr[i];
			}
		}
		maxH = maxH - 10;
		
		document.getElementById( 'fpbbox-1-holder' ).style.height = maxH + "px";
		document.getElementById( 'fpbbox-2-holder' ).style.height = maxH + "px";
		if( document.getElementById( 'fpbbox-3' ) )
			document.getElementById( 'fpbbox-3-holder' ).style.height = maxH + "px";

	}
}

function goToAlert( linken )
{
	var alertus = confirm('Vil du rapportere dette innlegget som upassende?');
	if (alertus)
	{
		window.location = linken+'&confirmed=1';
	}
}
