﻿// JScript File

var clientXMLDoc = null;
var resourceValue = null;

function CreateXmlHttp()
{
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}

function HandleResponse()
{
   if(XmlHttp.readyState == 4)
   {
		if(XmlHttp.status == 200)
		{			
			resourceValue = XmlHttp.responseText;
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

function UpdateAttendance(m_Flag)
{
    var m_EventCategory = document.getElementById('hdnEventType').value;
    
    if(m_EventCategory == 2 || m_EventCategory == 3 || m_EventCategory == 6 ||  m_EventCategory == 7)//updating the Registration status as attended for Webcast-Live OR Webcast On-Demand events.
    {
        var m_EventRegistrationID = document.getElementById('hdnRegID').value;
        
	    var requestUrl = "/CUI/Handlers/UpdateAttendance.ashx?RegistrationID=" + m_EventRegistrationID;
    	
	    CreateXmlHttp();
    	
	    if(XmlHttp)
	    {
	        XmlHttp.onreadystatechange = HandleResponse;
	        XmlHttp.open("POST", requestUrl,  m_Flag);
		    XmlHttp.send(null);
	    }
	}
}