function trim(s) {
var maxlength = 1000;
if (s.value.length > maxlength) 
s.value = s.value.substring(0,maxlength);
}


function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
   try { return new XMLHttpRequest();          } catch(e) {}
   alert("XMLHttpRequest not supported");
   return null;
};


function boardchange(src, board_cat) {
     var req = Inint_AJAX();
     req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
                    document.getElementById(src).innerHTML=req.responseText;
               } 
          }
     };
     req.open("GET", "ajax/cats.php?"+CatView+"ident="+src+"&board_cat="+board_cat);
     req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset="+CatChapset);
     req.send(null);
}

window.onLoad=boardchange('board_cat', -1);

function createObject() {
	var req;
	if(window.XMLHttpRequest){
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert('Problem creating the XMLHttpRequest object');
	}
	return req;

}


function catalog() {
	var textOut = http.responseText;
	document.getElementById('all-'+cid).innerHTML = textOut;
}

function useHttpResponse() {
  if (http.readyState == 4) {
	setTimeout("catalog()",1000);
  }
}

function sendopen(id) {
	cid = id;
	var newLoad = '<div align="center" style="margin:5px;"><img src="images/wait.gif" alt="" /></div>';
	document.getElementById('all-'+cid).innerHTML = newLoad;
	http.open('get', 'ajax/board.php?action=open&id='+cid+'&rand='+Math.random(), true);
	
	http.onreadystatechange = useHttpResponse;
	http.send(null);
}

function sendclose(id) {
	cid = id;
	var newLoad = '<div align="center" style="margin:5px;"><img src="images/wait.gif" alt="" /></div>';
	document.getElementById('all-'+cid).innerHTML = newLoad;
	http.open('get', 'ajax/board.php?action=cansel&rand='+Math.random(), true);
	
	http.onreadystatechange = useHttpResponse;
	http.send(null);
}