// EatCookieVal
// Get the value of a cookie based on an offset
// Call with an offset to the cookie (from a list of cookies)
// Returns the value of the cookie.
function EatCookieVal(offset) {
   endstr=document.cookie.indexOf(";",offset);
   if (endstr == -1) {endstr=document.cookie.length;}
   return unescape(document.cookie.substring(offset,endstr));
}


// EatCookie
// Returns the value of a cookie base on a cookie name.
// Call with the name of a cookie.
function EatCookie(name) {
alert("called with "+name+" "+document.cookie);
   arg=name+"=";
   alen=arg.length;
   clen=document.cookie.length;
   i=0;
   while (i<clen) {
      j=i+alen;
alert(i+" is i.   j is "+j+" checking "+document.cookie.substring(i,j));
      if (document.cookie.substring(i,j) == arg) {
          return EatCookieVal(j);
          }
      i=document.cookie.indexOf(" ",i) + 1;
      if (i === 0) {break;}
   }
   return 0;
}


function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name +"=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  } 
return "";
}




// AJAX


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try {
	// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
  		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
  	}
	return xmlHttp;
}
function ajax (url,callback) {
	//url = url + '&dummy=' + new Date().getTime();
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	} 
	xmlHttp.onreadystatechange=callback;
	try {
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	} catch (e) {
		// This is when oddsconverter tries to access sportility.net
		// there will be an error.  This is so that there is no error
		// message for the user when ajax tries to check the login 
		// screen.
	}
}


function display_bboard() {
        if(xmlHttp.readyState==4) {
                document.getElementById("bboard").innerHTML = xmlHttp.responseText;
        }
}



// FOR CALLBACK FUNCTIONS

//The readyState Property
//State Description 
// 0 The request is not initialized 
// 1 The request has been set up 
// 2 The request has been sent 
// 3 The request is in process 
// 4 The request is complete 

// for eample 
function callback_test ()  { 
	if (xmlHttp.readyState==4) {
		alert (xmlHttp.responseText); 
		//document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
	}
}

// responseText




