function toggleDIV (id,className) {
	if ($(id)) {
		el = $(id);
		if (el.hasClassName(className)) {
			el.removeClassName(className);
		} else {
			el.addClassName(className);
		}			
	}
}

function toggleContentBox(id) {
	toggleDIV(id,'contentbox-long');
}

function openPopup (url, windowname,width, height) {
	
	var winl = (screen.width-width)/2;
	var wint = (screen.height-height)/2;
					
	var isNN=(navigator.appName=="Netscape") ? 1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1) ? 1:0;
	
	if (isNN) {
		popup=window.open(url,windowname ,'scrollbars=yes,menubar=no,innerHeight='+height+',innerWidth='+width+',left='+winl+',top='+wint+',resizable=no,toolbar=no,location=no,status=no');
	} else {
		popup=window.open(url,windowname ,'scrollbars=yes,menubar=no,height='+height+',width='+width+',left='+winl+',top='+wint+',resizable=no,toolbar=no,location=no,status=no');
	}
	
	popup.focus();
}

function findPos(obj) {
	var curtop = 0;
	var curleft = 0;
	var curwidth=obj.offsetWidth;
	var curheight=obj.offsetHeight;
	
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) {
		curtop += obj.y;
		curleft += obj.x;
	}
	
	return {x: curleft, y:curtop, width: curwidth, height: curheight};
}

function drawlineMatchlistLine(index) {
	
	var i=0;
	
	jsgraph.clear();
  	jsgraph.setColor("#84A1CC"); 
	
	for (var i=0; i<20; i++) {
		if ($(i) && $('userinput_'+i)) {
			element = $('' + i + ''); 
			userinput = $('userinput_'+i);
			if (userinput.value != 'empty') {  
				pos_element=findPos(element);
				
				if ($('order_' + userinput.value)) { 
					pos_elementdrop=findPos($('order_' + userinput.value));
					box_offset=findPos($('contentbox_questions_line'));
					
					x1=Math.floor(pos_element.x+pos_element.width) - box_offset.x;
					y1=Math.floor(pos_element.y+pos_element.height/2) - box_offset.y;
					x2=Math.floor(pos_elementdrop.x) - box_offset.x;
					y2=Math.floor(pos_elementdrop.y+pos_elementdrop.height/2) - box_offset.y;
					
					if (index && index==i) {
						y1 += 3;
						x1 += 7;
					}
					
					jsgraph.drawLine(x1-7,y1-3,x2,y2);
				}
			}
		}
	}
	jsgraph.paint();
	
	
}

function skillstestCheckIfFinished(finished) {
	
	if (finished) {
		$('NextButton').disabled = false;
		$('NextButton').removeClassName('button-disabled');
		
		if ($('question_proceedinfo'))
			$('question_proceedinfo').style.visibility = 'hidden';
			
	} else {
		$('NextButton').disabled = true;
		$('NextButton').addClassName('button-disabled');
		
		if ($('question_proceedinfo'))
			$('question_proceedinfo').style.visibility = 'visible';
	}
	
}

/*window.onload = function () {
	objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++) {
		objects[i].outerHTML = objects[i].outerHTML;
	}
}*/
