// Opera
if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";

// Internet Explorer e.g. IE4 upwards :
if (document.all) type="IE";

// For Netscape version 4 :
if (document.layers) type="NN";

// Mozila e.g. Netscape 6 upwards
if (!document.all && document.getElementById) type="MO"; 


function ChangeContent(id, str) {
	if (type=="IE") {
		document.all[id].innerHTML = str;
	}
	if (type=="NN") {
		document.layers[id].document.open();
		document.layers[id].document.write(str);
		document.layers[id].document.close();
	}
	if (type=="MO" || type=="OP") {
		document.getElementById(id).innerHTML = str;
	}
}


function Visibility(id,state) {
	// Controls the visibility of an element (DIV)
	// Three states: on, off, toggle
	if (document.getElementById) {
		target = document.getElementById( id );
		if (state == 'on') {
			target.style.display = "";
		} else if (state == 'off') {
			target.style.display = "none";
		} else if (state == 'toggle') {
			if (target.style.display == "none") {
				target.style.display = "";
			} else {
				target.style.display = "none";
			}
		}
     }
}


function ShowResponse(msg) {
	ChangeContent('response', msg);
	Visibility('response','on');
}

function ShowDebug(msg) {
	ChangeContent('debug', msg);
	Visibility('debug','on');
}