function ValidateAnswer(userSelection)
{
	if(userSelection && userSelection=='D')
	{
		document.getElementById('output_msg').innerHTML = '<span class="text_condensed_border"><font color="green">Correct</font>: Dry conditions are more favorable to creating and conserving fossils!</span>' ;
	}
	else if(userSelection && userSelection != 'D')
	{
		document.getElementById('output_msg').innerHTML = '<span class="text_condensed_border"><font color="red">Wrong</font>: Dry conditions are more favorable to creating and conserving fossils!</span>' ;
	}
	else
	{
		document.getElementById('output_msg').innerHTML = '<span class="text_condensed_border">Please, make your selection!</span>' ;
	}
}
function ValidateAnswers(qid,lid)
{
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var fnWhenDone = function (oXML) { 
		document.getElementById('output_msg_qid-'+qid+'_lid-'+lid).innerHTML = '<span class="text">'+ oXML.responseText+'</span>'; 
	};

	var myStr = "";
	var mySeparator = "";
	var i = 0;
	while(document.getElementById('ans_qid-'+qid+'_lid-'+lid+'_aCounter-'+i))
	{
		//alert(document.getElementById('ans_qid-'+qid+'_lid-'+lid+'_aCounter-'+i).checked);
		if(document.getElementById('ans_qid-'+qid+'_lid-'+lid+'_aCounter-'+i).checked)
		{
			myStr = myStr+mySeparator+document.getElementById('ans_qid-'+qid+'_lid-'+lid+'_aCounter-'+i).value;
			mySeparator	= ",";
		}
		i++;
	}
	//alert(myStr);
	myConn.connect("question_validation_msg.php", "GET", "qid="+qid+"&strAid="+myStr+"&lid="+lid, fnWhenDone);	
}
function ProcessQuestion(fid,qid,ctid,tqid,lid,actionType)
{
	var myConn = new XHConn();
	
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
		
	var fnWhenDone = function (oXML) { 
		//document.getElementById('debug').value = oXML.responseText; 
		document.getElementById('QuestionContentDivId').innerHTML = oXML.responseText;
	};
	
	var myStr = "";
	var mySeparator = "";
	var i = 0;
	while(document.getElementById('ans_qid-'+qid+'_aCounter-'+i))//
	{
		//alert('ans_qid-'+qid+'_aCounter-'+i + document.getElementById('ans_qid-'+qid+'_aCounter-'+i));
		if(document.getElementById('ans_qid-'+qid+'_aCounter-'+i).checked)
		{
			myStr = myStr+mySeparator+document.getElementById('ans_qid-'+qid+'_aCounter-'+i).value;
			mySeparator	= ",";
		}
		i++;
	}
	//alert('Out of the while with str : '+myStr);
	myConn.connect("question_process.php", "GET", "action="+actionType+"&fid="+fid+"&qid="+qid+"&tqid="+tqid+"&ctid="+ctid+"&lid="+lid+"&strAid="+myStr, fnWhenDone);	
}
function ProcessQuiz(action,ctid,fid)
{
	var myConn = new XHConn();
	
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
		
	var fnWhenDone = function (oXML) { 
		//document.getElementById('debug').value = oXML.responseText;
		if(action && action=='complete')
			window.location = './home.php?sid=user&pid=quiz';
	};

	//if(!tmpDateTime)
		dateTime = new Date();
	//else
	//	dateTime = new Date(tmpDateTime);
		
	var y = dateTime.getFullYear();
	var m = dateTime.getMonth()+1;
	var d = dateTime.getDate();
	var h = dateTime.getHours();
	var min = dateTime.getMinutes();
	var s = dateTime.getSeconds();
	myConn.connect("quiz_process.php", "GET", "action="+action+"&y="+y+"&m="+m+"&d="+d+"&h="+h+"&min="+min+"&s="+s+"&ctid="+ctid+"&fid="+fid, fnWhenDone);	
	
}

function StoreAnswer(fid,qid,ctid,lid,actionType)
{
	var myConn = new XHConn();
	//alert(qid);
	
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
		
	var fnWhenDone = function (oXML) { 
		//document.getElementById('debug').value = oXML.responseText;
		document.getElementById('QuizPaging').innerHTML = oXML.responseText;
	};
	
	var myStr = "";
	var mySeparator = "";
	var i = 0;
	while(document.getElementById('ans_qid-'+qid+'_aCounter-'+i))//
	{
		//alert('ans_qid-'+qid+'_aCounter-'+i + document.getElementById('ans_qid-'+qid+'_aCounter-'+i));
		if(document.getElementById('ans_qid-'+qid+'_aCounter-'+i).checked)
		{
			myStr = myStr+mySeparator+document.getElementById('ans_qid-'+qid+'_aCounter-'+i).value;
			mySeparator	= ",";
		}
		i++;
	}
	//alert('Out of the while with str : '+myStr);
	myConn.connect("question_process.php", "GET", "action="+actionType+"&fid="+fid+"&qid="+qid+"&tqid=-1&ctid="+ctid+"&lid="+lid+"&strAid="+myStr, fnWhenDone);	
}
function ConfirmSubmit(label)
{
	var agree=confirm(label);
	if (agree)
		return true ;
	else
		return false ;
}
function HideShowDiv(whichDivId,attribute)
{
	//alert('HideShowDiv');
	if (document.all) 
	{ //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + whichDivId + ".style.visibility = attribute");
	}
	if (document.layers) 
	{ //IS NETSCAPE 4 or below
		document.layers[whichDivId].visibility = attribute;
	}
	if (document.getElementById && !document.all) 
	{
		theDiv = document.getElementById(whichDivId);
		theDiv.style.visibility = attribute;
	}
}

