//-----------------------------------------------------------------------------
// Define some constants.
//-----------------------------------------------------------------------------

// Define a list of Microsoft XML HTTP ProgIDs.
var XMLHTTPREQUEST_MS_PROGIDS = new Array(
	"Msxml2.XMLHTTP.7.0",
	"Msxml2.XMLHTTP.6.0",
	"Msxml2.XMLHTTP.5.0",
	"Msxml2.XMLHTTP.4.0",
	"MSXML2.XMLHTTP.3.0",
	"MSXML2.XMLHTTP",
	"Microsoft.XMLHTTP"
);

// Define ready state constants.
var XMLHTTPREQUEST_READY_STATE_UNINITIALIZED = 0;
var XMLHTTPREQUEST_READY_STATE_LOADING       = 1;
var XMLHTTPREQUEST_READY_STATE_LOADED        = 2;
var XMLHTTPREQUEST_READY_STATE_INTERACTIVE   = 3;
var XMLHTTPREQUEST_READY_STATE_COMPLETED     = 4;

//-----------------------------------------------------------------------------
// Returns an XMLHttpRequest object.
//-----------------------------------------------------------------------------
function getXMLHttpRequest()
{
	var httpRequest = null;

	// Create the appropriate HttpRequest object for the browser.
	if (window.XMLHttpRequest != null)
		httpRequest = new window.XMLHttpRequest();
	else if (window.ActiveXObject != null)
	{
		// Must be IE, find the right ActiveXObject.
		var success = false;
		for (var i = 0; i < XMLHTTPREQUEST_MS_PROGIDS.length && !success; i++)
		{
			try
			{
				httpRequest = new ActiveXObject(XMLHTTPREQUEST_MS_PROGIDS[i]);
				success = true;
			}
			catch (ex)
			{}
		}
	}

	// Display an error if we couldn't create one.
	if (httpRequest == null)
		alert("Error in HttpRequest():\n\nCannot create an XMLHttpRequest object.");

	// Return it.
	return httpRequest;
}

//-----------------------------------------------------------------------------
// This code uses an XMLHttpRequest object to look up the city and state of the
// ZIP code entered by the user. That data is then used to populate the
// corresponding form fields.
//-----------------------------------------------------------------------------

var ajax = getXMLHttpRequest();

function Interval(fun,time)
{
	window.setInterval(fun,time);
}


function bookmark(url,title){
	 
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
	
	 
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
	 
  }
}
function callAjax(id,uid,op,divid)
{	 
 
		var url= 'ajax.php?op='+op+'&id='+id+'&divid='+divid+'&uid='+uid;
		//alert(url);
 		var post_data=url;

		document.getElementById(divid).innerHTML = "<FONT SIZE='2' COLOR='red'><img src='images/ajax-loader-clock.gif' border='0'></font>";
		if(window.XMLHttpRequest)
		{
			http_request=new XMLHttpRequest();
		if(http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/html');
			}
			
		}else if(window.ActiveXObject)
		{
			try{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
				}catch(e)
				{
				try{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
					}catch(e){}
				}
		
		}
	
	http_request.onreadystatechange=function(){sendrequest(http_request,divid);};
	http_request.open('GET',url,true);
	http_request.send(null);
	
	}
	
function sendrequest(http_request,divid)
	{
		if(http_request.readyState ==4)
		   { 
			   if(http_request.status ==200)
			   {
				resText=http_request.responseText;
				document.getElementById(divid).innerHTML=resText;
			   }
			    else {
			document.getElementById(divid).innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
					}
		   }
	}