var xrequest;

function writeit(text,id) {
	txt=text;
	var doc = document;	  	
	if (doc.getElementById){
		x = doc.getElementById(id);
		x.innerHTML = txt;
	}else if (doc.all)	{
		x = doc.all[id];
		x.innerHTML = txt;
	}else if (doc.layers){
		var x = doc.layers[id];
		text2 = '<span name=chatframe2 id=chatframe2 class=chatspan>' + txt +'</span>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

function xmlhttpChangeIE() {
	if (xrequest.readyState==4) {
		if (xrequest.status==200){
		    	writeit(xrequest.responseText,'chatframe2');
		} else {
	  	}
     	}
}

if (window.XMLHttpRequest){
	var xrequest = new XMLHttpRequest();
} else if (window.ActiveXObject){
	var xrequest = new ActiveXObject("Microsoft.XMLHTTP");
}

function getEditForm(params){
	document.location="index.php?"+params;
	//xrequest.open("GET","index.php?type=form&"+params,true);
	//xrequest.onreadystatechange=xmlhttpChangeIE;
	//xrequest.send(null);
}

function previewImg(params){
	writeit('<img src="'+params+'">','imgpreview');
}

function closeEditForm(){
	writeit("","chatframe2");
}

function IWC(PopUrl,PopName,PopWidth,PopHeight){
    window.open(PopUrl,PopName,'toolbar=no,scrollbars=no,resizable=yes,width='+PopWidth+',height='+PopHeight+',top='+((screen.availHeight-PopHeight)/2)+',left='+((screen.availWidth-PopWidth)/2));
}

function datetimelookup(id){
	IWC('tools/datetimepicker/datetime.htm?field='+id,'datetime',157,180);
}
function edit(id){
	IWC('tools/editor/editor.html?field='+id,'editor',800,600);
}

function query(id){
	IWC('querytool.php?field='+id,'queryeditor',870,630);
}

function toggleselection(){
	for (var i=0;i<document.listform.length;i++){
		if(document.listform[i].name=='checkselection[]'){
			document.listform[i].checked=document.listform.toggleselect.checked;
		}
	}
}

var oldDiv="";
function toggleDivOn(id){
	if((oldDiv!=id) & (oldDiv!="")){
		var div=GetObj(oldDiv);
		div.style.display="none";
	}
	oldDiv=id;
	var div=GetObj(id);
	div.style.display="block";
}

function toggleDiv(id){
	var div=GetObj(id);
	div.style.display=(div.style.display=='none')?"block":"none";
}
