// Creating Ajax Object
function createAjaxObj()
{
	var httprequest = false
	
	if (window.XMLHttpRequest)
	{ // if Mozilla, Safari etc  Non-IE browsers
		httprequest=new XMLHttpRequest()
		
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml')
	} 
	else if (window.ActiveXObject)
	{ // if IE
		try 
		{
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e)
		{
			try
			{
				httprequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
		}
	}			
	return httprequest
}

function mark_answer(questionid, questiontype, answer, timers, mockexamid, studentid)
{	
	if(mockexamid != "" && studentid != "")
	{
		if(timers == "")
		{
			//reloadpoages();
		}
		else
		{
			ajaxinstance_markanswer = createAjaxObj();
			xmlindicator = (arguments.length>0)? 1 : 0;
			ajaxinstance_markanswer.onreadystatechange = fetchresult;	
			ajaxinstance_markanswer.open('GET', "../Ajax/examdetail.aspx?questionid="+questionid+"&questiontype="+questiontype+"&answer="+answer+"&timetaken="+timers+"&for=MarkAnswer", true);
			ajaxinstance_markanswer.send(null)	
		}
	}
	else
	{	
		//window.parent.location="signout.aspx?for=session"
	}
}
function fetchresult()
{
	var mstr_text = new String();
	if (ajaxinstance_markanswer.readyState==4)
	{
		mstr_text = ajaxinstance_markanswer.responseText;	
		var answers = mstr_text;
		var totalquestions;
		var total;
		var attempted;	
		var marked;
		totalquestions = answers.split('~');		
		total = totalquestions[0];		
		attempted = totalquestions[1];	
		marked = totalquestions[2];		
		fetchquestionsattempted(total, attempted, marked);
	}
}
function mark_question_number(from, questionid, timers, mockexamid, studentid)
{	
	if(mockexamid != "" && studentid != "")
	{		
		if(timers == "")
		{
			//reloadpoages();
		}
		else
		{
			ajaxinstance_markanswer = createAjaxObj();
			xmlindicator = (arguments.length>0)? 1 : 0;
			ajaxinstance_markanswer.onreadystatechange = fetchmarkedquestion;	
			ajaxinstance_markanswer.open('GET', "../Ajax/examdetail.aspx?markid="+from+"&questionid="+questionid+"&timetaken="+timers+"&for=MarkQuestion", true);
			ajaxinstance_markanswer.send(null)	
		}
	}
	else
	{
		//window.parent.location="signout.aspx?for=session"
	}
}
function fetchmarkedquestion()
{
	var mstr_text = new String();
	if (ajaxinstance_markanswer.readyState==4)
	{
		mstr_text = ajaxinstance_markanswer.responseText;	
		var answers = mstr_text;
		var totalquestions;
		var total;
		var attempted;	
		var marked;
		totalquestions = answers.split('~');		
		total = totalquestions[0];		
		attempted = totalquestions[1];	
		marked = totalquestions[2];		
		fetchquestionsattempted(total, attempted, marked);
	}
}

function countquestion(mockexamid, studentid)
{	
	if(mockexamid != "" && studentid != "")
	{		
		ajaxinstance_countquestion = createAjaxObj();
		xmlindicator = (arguments.length>0)? 1 : 0;
		ajaxinstance_countquestion.onreadystatechange = fetchcountquestion;	
		ajaxinstance_countquestion.open('GET', "../Ajax/examdetail.aspx?mockexamid="+mockexamid+"&for=CountQuestion", true);
		ajaxinstance_countquestion.send(null)	
		return false;
	}
	else
	{
		//window.parent.location="signout.aspx?for=session"
	}
}
function fetchcountquestion()
{
	var mstr_text = new String();
	if (ajaxinstance_countquestion.readyState==4)
	{
		mstr_text = ajaxinstance_countquestion.responseText;			
		var answers = mstr_text;
		var totalquestions;
		var total;
		var attempted;	
		var marked;
		totalquestions = answers.split('~');		
		total = totalquestions[0];		
		attempted = totalquestions[1];	
		marked = totalquestions[2];		
		fetchquestionsattempted(total, attempted, marked);
	}
}
function updatelogintime(studentid)
{	
	if(studentid != "")
	{		
		ajaxinstance_logintime = createAjaxObj();
		xmlindicator = (arguments.length>0)? 1 : 0;
		ajaxinstance_logintime.onreadystatechange = updatelogintimejs;	
		ajaxinstance_logintime.open('GET', "../Ajax/examdetail.aspx?for=savelogintime", true);
		ajaxinstance_logintime.send(null)	
		return false;
	}
}
function updatelogintimejs()
{}
