﻿/*****************************************************************
** Common JavaScript AJAX Library
*****************************************************************/

/* Common values for the ReadyState of the XMLHttpRequest object */
var READYSTATE_UNINITIALIZED = 0;
var READYSTATE_LOADING = 1;
var READYSTATE_LOADED = 2;
var READYSTATE_INTERACTIVE = 3;
var READYSTATE_COMPLETE = 4;

/* Common values for HTTP status codes */
var HTTPSTATUS_OK = 200;
	
function newConnection()
{
	var xmlHttp;
	try
	{    
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest(); 
		//alert("Firefox!");
	}
	catch (e)
	{    // Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			//alert("i.e1!");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				//alert("i.e2!");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}    
	}
	return xmlHttp;
}

function clickBtn(btn, e)
{
		//alert("here" + btn);
		
        // process only the Enter key
        //var e = window.event;
        if (e==null) {
			e = window.event;
        }
        if (e.keyCode == 13)
        {
			var theBtn = document.getElementById(btn);
			// cancel the default submit 
            e.returnValue=false;
            e.cancel = true;
            
            // submit the form by programmatically clicking the specified button
            //alert("The btn is " + theBtn.id);
            //window.location = document.getElementById(btn).href;
            try
            {
				document.getElementById(btn).click();
			}
			catch (ex)
			{
				try
				{
					window.location = document.getElementById(btn).href;
				}
				catch (ex)
				{
					alert("Please click the button provided!");
				}
			}
            //document.getElementById(btn).createEvent("click");
        }
}
	