﻿var xmlhttpquotes;
var xmlhttpcomments;
var kelcomment;

function loadQuotes() {
	// code for Mozilla, etc.
	if (window.XMLHttpRequest) {
		xmlhttpquotes=new XMLHttpRequest();
		xmlhttpquotes.onreadystatechange=xmlhttpChangeQuotes;
		xmlhttpquotes.open("GET","quotes.php",true);
		xmlhttpquotes.send(null);
	} else if (window.ActiveXObject) { // code for IE
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		if (xmlhttp) {
			xmlhttpquotes.onreadystatechange=xmlhttpChangeQuotes;
			xmlhttpquotes.open("GET",url,true);
			xmlhttpquotes.send();
		}
	}
	
}

function xmlhttpChangeQuotes() {
	if (xmlhttpquotes.readyState==4) {
		if (xmlhttpquotes.status==200) {
			document.getElementById("quotes").innerHTML = xmlhttpquotes.responseText;
			setTimeout('loadQuotes()', 20000);
		} else {
			alert("Problem retrieving XML data");
		}
	}
}


function loadComments(idc) {
	document.getElementById('textacomment' + idc).value = '';
	// code for Mozilla, etc.
	var url = "/stupidcache.php?idc=" + idc;
	kelcomment = idc;
	if (window.XMLHttpRequest) {
		xmlhttpcomments=new XMLHttpRequest();
		xmlhttpcomments.onreadystatechange=xmlhttpChange2;
		xmlhttpcomments.open("GET",url,true);
		xmlhttpcomments.send(null);
	} else if (window.ActiveXObject) { // code for IE
		xmlhttpcomments=new ActiveXObject("Microsoft.XMLHTTP");
		if (xmlhttpcomments) {
			xmlhttpcomments.onreadystatechange=xmlhttpChange2;
			xmlhttpcomments.open("GET",url,true);
			xmlhttpcomments.send();
		}
	}
}


function xmlhttpChange2() {
	if (xmlhttpcomments.readyState==4) {
		if (xmlhttpcomments.status==200) {
			document.getElementById('comments' + kelcomment).innerHTML = xmlhttpcomments.responseText;
			document.body.style.cursor="auto";
		} else {
			alert("Problem retrieving XML data");
		}
	}
}


function submitComment(id, theform) {
	setTimeout("loadComments('" + id + "')", 1500);
	document.getElementById('comment' + id).style.visibility = 'hidden';
	theform.action = "post1.php";
	document.body.style.cursor="wait";
}


