<!--
/* 29Mai2007 (c) raVZan */

function checkAnswer(pos,value)
{
	answers[pos] = value;
}

function evalAnswers()
{
	collected = false;
	status = true;
	for (i=0; i<answers.length; i++)
		if (answers[i] == '-')
			status = false;
	
	if (status) {
		score = 0;
		entities = new Array( 0, 1, 2, 3 );
		for (i=0; i<answers.length; i++)
			score = score + entities[answers[i]];
		msg = 'Score: ' + score;
		collected = true;
	} else 
		if (xanswers.length != 0) {
			xvalues = new Array();
			x = 0;
			msg = "";
			for (i=0; i<xanswers.length; i++) {
				xsubstatus = false;
				for (j=0; j<document.getElementsByName(xanswers[i]).length; j++)
					if(document.getElementsByName(xanswers[i])[j].checked) {
						xvalues[i] = document.getElementsByName(xanswers[i])[j].value;
						xsubstatus = true;
						break;
					}
				if (!xsubstatus)
					msg = msg + 'Question ' + (i+1) + ' e invalide!\n';
				else
					x += 1;
			}
			if (x == xanswers.length) {
		                score = 0;
                		entities = new Array( 3, 2, 1, 0 );
		                for (i=0; i<xvalues.length; i++)
                		        score = score + entities[xvalues[i]-1];
		                msg = 'Score: ' + score;
			}
		} else {
			msg = "";
			for (i=0; i<answers.length; i++)
				if (answers[i] == '-')
					msg = msg + 'Question ' + (i+1) + ' e invalide!\n';
		}
	
	/* alert(msg);

	if (collected) {
		document.getElementById('Answers').value = answers.toString();
		return true;
	} else
		return false; */

	document.getElementById('Answers').value = answers.toString();
        return true;
}

var newWin = null;

function closeWin()
{
        if (newWin != null){
                if(!newWin.closed)
                        newWin.close();
        }
}

function showPopup(strURL,strName,strType,strHeight,strWidth)
{
        closeWin();

        var strOptions="";
        if (strType=="console")
                strOptions="resizable,height="+strHeight+",width="+strWidth;
        if (strType=="fixed")
                strOptions="status,height="+strHeight+",width="+strWidth;
        if (strType=="elastic")
                strOptions="toolbar=0,menubar=0,scrollbars=1,location=no,resizable=0,height="+strHeight+",width="+strWidth;

        newWin = window.open(strURL, strName, strOptions);
        newWin.focus();
}

function addMpls()
{
	chbxs=document.getElementsByTagName('input');
	mplsinfo = '';
	for (i=0; i<chbxs.length; i++)
		if (chbxs[i].checked)
			mplsinfo = mplsinfo + chbxs[i].value + ',';
	//alert(mplsinfo);
	window.opener.document.getElementById('email').value = mplsinfo;
	window.close();
}

function popupForm(myform,windowname,height,width)
{
	if (!window.focus)
		return true;
	window.open('', windowname, 'height='+height+',width='+width+',scrollbars=1,location=no');
	myform.target=windowname;
	return true;
}

//-->
