var pos = 0; 
var msg='';
var rq=false;
window.setTimeout("prave_hrame(2000)",200);

function prave_hrame(cas) {
  document.getElementById('cplay').innerHTML =(msg.length>=35)?msg.substring(pos,35+pos):msg;
  pos++;
  if ( (pos > msg.length) && (rq==false) ) {
    pos = 0;
    rq=true;
    ajax("GET","/prave_hrame.php");
    prave_hrame(2000);
  } else {
    window.setTimeout("prave_hrame(200)",cas);
  }
} 


function email(kam) {
	px=500;
	py=400;
	x=Math.round((screen.width / 2)-(px/2));
  	y=Math.round((screen.height / 2)-(py/2));
	w=window.open ("/email/"+kam,"email","width="+px+", height="+py+", left="+x+", top="+y+", scrollbars=1,resizable=0,location=0,menubar=0,status=0, toolbar=0,leftmargin=0,topmargin=0"); 
	w.focus();
}

function ajax(meth,adr,data) {
  if (window.ActiveXObject) { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
    else { httpRequest = new XMLHttpRequest(); }
    httpRequest.open(meth,adr, true);
    httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    httpRequest.onreadystatechange= function () { processRequest(); } ;
    httpRequest.send(data);
}

function processRequest() {
	if (httpRequest.readyState == 4) {
    if(httpRequest.status == 200) {
        msg=httpRequest.responseText;
        rq=false;
    } 
  }
}

