// Ajax Functions for the page

var ajaxQuotesUrl = "includes/resp_quotes.php"; // The server-side script

var quoteInt = 10000;

function getQuotes(){
  clearTimeout(ChQuSt); ChQuSt=0;
  var ajaxReq = getAjaxObject();
  var rand_no = Math.random();
	// Create a function that will receive data sent from the server
	ajaxReq.onreadystatechange = function()
	{
		if(ajaxReq.readyState == 4  && ajaxReq.status == 200)
		{
			document.getElementById('golfquotestext').innerHTML = ajaxReq.responseText;
			ChQuSt=setTimeout('getQuotes()',quoteInt);
		}
		
		if(ajaxReq.readyState!=4)
		{
			//document.getElementById('golfquotestext').innerHTML = "One moment please ...";
		}
	}
	
	var queryString = "?rannum="+rand_no;
	ajaxReq.open("GET", ajaxQuotesUrl + queryString, true);
	ajaxReq.send(null);
  
}

// start values
var ChQuSt=0;

function ChWpRi(st){
  // pause and unpause switching script
	if(st){clearTimeout(ChQuSt);ChQuSt=0}
	else ChQuSt=setTimeout('getQuotes()',quoteInt);
}

ChQuSt=setTimeout('getQuotes()',quoteInt*2);
