var PageNm;
var XmlHttpObj;
var requestURL = 'getServerTime.aspx'; 
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0; 
//netscape, safari, mozilla behave the same??? 
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;

// create an instance of XMLHTTPRequest Object, varies with browser type, try for IE first then Mozilla
function CreateXmlHttpObj()
{
	// try creating for IE (note: we don't know the user's browser type here, just attempting IE first.)
	try
	{
		if (is_ie){ 
			//The object to create depends on version of IE 
			//If it isn't ie5, then default to the Msxml2.XMLHTTP object 
			var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; 
		     
			//Attempt to create the object 
		try{ 
			
				XmlHttpObj = new ActiveXObject(strObjName); 
				//XmlHttpObj.onreadystatechange = handler; 
			} 
			catch(e){ 
			//Object creation errored 
				alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled'); 
				return; 
			} 
		}
		else if (is_opera){ 
			//Opera has some issues with xmlHttp object functionality 
			alert('Opera detected. The page may not behave as expected.'); 
			return; 
		} 
		else{ 
			// Mozilla | Netscape | Safari 
			XmlHttpObj = new XMLHttpRequest(); 
			//	XmlHttpObj.onload = handler; 
			//	XmlHttpObj.onerror = handler;
			}

	   


	}
	catch(e)
	{
		try
		{
			XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttpObj = null;
		}
	}
	// if unable to create using IE specific code then try creating for Mozilla (FireFox) 
	if(!XmlHttpObj && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttpObj = new XMLHttpRequest();
	}

	return XmlHttpObj;
}
//function StateChangeHandler()
//{
//	// state ==4 indicates receiving response data from server is completed
//	if(XmlHttpObj.readyState == 4)
//	{
//		// To make sure valid response is received from the server, 200 means response received is OK
//		if(XmlHttpObj.status == 200)
//		{
//			if ( PageNm == "Generalnotice" )
//			{		
//				var d = document.getElementById('tdGeneralNotice');
//				d.innerHTML = XmlHttpObj.responseText;
//			}
//			else if ( PageNm == "Events" )
//			{
//				var d = document.getElementById('divEvent');
//				d.innerHTML = XmlHttpObj.responseText;
//			}
//			else if ( PageNm == "staff" )
//			{
//				var d = document.getElementById('tdStaff');
//				d.innerHTML = XmlHttpObj.responseText;
//			}
//			else if ( PageNm == "keystage" )
//			{
//				var str = XmlHttpObj.responseText;
//				var a = str.substring(0,str.indexOf('|')).split(','); // make text array
//				var b = str.substring(str.indexOf('|')+ 1 ).split(','); // make value array
//				ShowClass(a , b);
//			}
//		}
//		else
//		{
//			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
//		}
//	}
//}

//// FUNCTION FOR GENERAL NOTICE PAGE
//function onClassChange(lstBox)
//{
//	PageNm = "Generalnotice";
//	//var lstBox = document.getElementById('DropDownList3');
//	var ind = lstBox.selectedIndex; 
//	var value = lstBox.options[ind].value;     //get the teams value
//	if ( value == -2 )
//	{
//		var d = document.getElementById('tdGeneralNotice');
//		d.innerHTML = "";
//		return;
//	}	
//	var temp = document.URL;
//	var strUrl1 = temp.substring(0,temp.lastIndexOf('/') + 1);	
//	var sURL = strUrl1+'ajax.aspx?cid='+value;
//	CreateXmlHttpObj()
//	if(XmlHttpObj)
//	{
//		// assign the StateChangeHandler function ( defined below in this file)
//		// to be called when the state of the XmlHttpObj changes
//		// receiving data back from the server is one such change
//		XmlHttpObj.onreadystatechange = StateChangeHandler;
//		
//		// define the iteraction with the server -- true for as asynchronous.
//		XmlHttpObj.open("GET", sURL,  true);
//		
//		// send request to server, null arg  when using "GET"
//		XmlHttpObj.send(null);		
//	}
//}

//// FUNCTION FOR EVENT CALENDER PAGE
//function getEvents(dt)
//{
//	PageNm = "Events";
//	var temp = document.URL;
//	var strUrl1 = temp.substring(0,temp.lastIndexOf('/') + 1);	
//	var sURL = strUrl1+'ajax.aspx?eid='+dt;
//	CreateXmlHttpObj()
//	if(XmlHttpObj)
//	{
//		// assign the StateChangeHandler function ( defined below in this file)
//		// to be called when the state of the XmlHttpObj changes
//		// receiving data back from the server is one such change
//		XmlHttpObj.onreadystatechange = StateChangeHandler;
//		
//		// define the iteraction with the server -- true for as asynchronous.
//		XmlHttpObj.open("GET", sURL,  true);
//		
//		// send request to server, null arg  when using "GET"
//		XmlHttpObj.send(null);		
//	}
//	return false;
//}

//// FUNCTION FOR STAFF
//function GetStaff(alpha)
//{
//	PageNm = "staff";
//	var temp = document.URL;
//	var strUrl1 = temp.substring(0,temp.lastIndexOf('/') + 1);	
//	var sURL = strUrl1+'ajax.aspx?staffid='+alpha;
//	CreateXmlHttpObj()
//	if(XmlHttpObj)
//	{
//		// assign the StateChangeHandler function ( defined below in this file)
//		// to be called when the state of the XmlHttpObj changes
//		// receiving data back from the server is one such change
//		XmlHttpObj.onreadystatechange = StateChangeHandler;
//		
//		// define the iteraction with the server -- true for as asynchronous.
//		XmlHttpObj.open("GET", sURL,  true);
//		
//		// send request to server, null arg  when using "GET"
//		XmlHttpObj.send(null);
//	}
//}
///*--------------START FUNCTION FOR GENERAL NOTICE ADMIN--------------*/
//// FUNCTION FOR EVENT KEYSTAGE AND CLASS DISPLAY ACCORDING TO KEY STAGE
//function onKeyStageChange()
//{
//	PageNm = "keystage";
//	var lstBox = document.getElementById('ddlType');
//	var ind = lstBox.selectedIndex; 
//	var value = lstBox.options[ind].value;     //get the teams value

//	if ( value == -1 )
//	{
//		document.Form1.ddlClass.length=0; //clear the listbox
//		var newOption = document.createElement("option");  //create a new list <option>			
//		document.Form1.ddlClass.options.add(newOption);
//		newOption.value = -1;           //add the name and value
//		newOption.innerHTML = 'Select Class';
//		return;
//	}
//	var temp = document.URL;
//	var strUrl1 = temp.substring(0,temp.lastIndexOf('/') + 1);
//	var sURL = strUrl1+'../ajax.aspx?keystageid='+value;	
//	CreateXmlHttpObj()
//	if(XmlHttpObj)
//	{
//		// assign the StateChangeHandler function ( defined below in this file)
//		// to be called when the state of the XmlHttpObj changes
//		// receiving data back from the server is one such change
//		XmlHttpObj.onreadystatechange = StateChangeHandler;
//		
//		// define the iteraction with the server -- true for as asynchronous.
//		XmlHttpObj.open("GET", sURL,  true);
//		
//		// send request to server, null arg  when using "GET"
//		XmlHttpObj.send(null);
//	}
//}
//function ShowClass(a,b)
//{
//	document.Form1.ddlClass.length=0; //clear the listbox
//	var newOption = document.createElement("option");  //create a new list <option>			
//	document.Form1.ddlClass.options.add(newOption);
//	newOption.value = -1;           //add the name and value
//	newOption.innerHTML = 'Select Class';

//	var len = a.length;
//	for(i=0;i<len;i++)       //add the cities
//		addClasses(b[i], a[i]);
//}
//function addClasses(value, name)
//{
//	var newOption = document.createElement("option");  //create a new list <option>			
//	document.Form1.ddlClass.options.add(newOption);
//	newOption.value = value;           //add the name and value
//	newOption.innerHTML = name;
//}
///*--------------END FUNCTION FOR GENERAL NOTICE ADMIN--------------*/