var ajax = new sack();
var ajax2 = new sack();
var lastid = 0;

function whenLoading(){
	
	var e = document.getElementById('statusbox'); 
	e.innerHTML = '<p><img src="/images/imchatstatus.gif"></p>';
	
}

function whenLoaded(){

	var e = document.getElementById('statusbox'); 
	e.innerHTML = '<p><img src="/images/imstatusdone.gif"></p>';
	

}

function whenInteractive(){
	var e = document.getElementById('sackdata'); 
	e.innerHTML += "<p>getting data...</p>";
}

function whenCompleted(){
	var e = document.getElementById('sackdata'); 
	if (ajax.responseStatus){
		//alert ("before inserting...");
		var string = ""; // "<p>Status Code: " + ajax.responseStatus[0] + "</p><p>Status Message: " + ajax.responseStatus[1] + "</p><p>URLString Sent: " + ajax.URLString + "</p>";
	} else {
		var string = ""; // "<p>URLString Sent: " + ajax.URLString + "</p>";
	}

//	var string = e.innerHTML + "<br>"+responseStatus[1];
	e.innerHTML = string;	
}

function cron (f) {
	fetch (f);
	// alert ("boo!");
	window.setTimeout("cron('"+f+"')", 2000);

}

function boo () {

}

function fetch(f){
	var form = document.getElementById('imform');
	ajax.setVar("myTextBox", ""); // recomended method of setting data to be parsed.
	ajax.setVar("do", ""); // recomended method of setting data to be parsed.
	ajax.setVar("abid", document.imform.abid.value); // recomended method of setting data to be parsed.
	ajax.requestFile = f;
	// ajax.method = form.method.value;
	ajax.method = "POST";
	ajax.element = 'replaceme';
	ajax.onLoading = whenLoading;
	ajax.onLoaded = whenLoaded; 
	ajax.onInteractive = whenInteractive;
	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();


	// alert ("boo!");
	// document.imform.mytext.value='';
	// document.imform.mytext.focus ();

}





function doit2(f){

	if (document.imform.mytext.value ==''){
		return false;
	}

	var form = document.getElementById('imform');
	var temptext = form.mytext.value;
	temptext = escape (temptext);
	ajax2.setVar("myTextBox", temptext); // recomended method of setting data to be parsed.
	ajax2.setVar("do", "write"); // recomended method of setting data to be parsed.
	ajax2.setVar("abid", document.imform.abid.value); // recomended method of setting data to be parsed.
	ajax2.requestFile = f;
	// ajax.method = form.method.value;
	ajax2.method = "POST";
	ajax2.element = 'replaceme';
	ajax2.onLoading = whenLoading;
	ajax2.onLoaded = whenLoaded; 

	

	ajax2.onInteractive = whenInteractive;
	ajax2.onCompletion = whenCompleted;
	ajax2.runAJAX();

	

	//fetch (f);
	document.imform.mytext.value='';
	document.imform.mytext.focus ();
	// alert ("boo!");
	// document.imform.mytext.value='';
	// document.imform.mytext.focus ();

}
