function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();


function yoxla() {

ID = window.setTimeout("yoxla();", 120000);

 document.getElementById('login_response').innerHTML = "";
var login = encodeURI(document.getElementById('login').value);
var nocache = 0;
nocache = Math.random();

http.open('get', 'index.php?login='+login+'&nocache='+nocache);
http.onreadystatechange = yoxlayaz;
http.send(null);
}
function yoxlayaz() {
if(http.readyState == 4){ 
var response = http.responseText;
  document.getElementById('login_response').innerHTML = '';
}
 }
 
 
 
function vxtint()
{
if(window.document.getElementById('vxf'))
{
//var vxf=window.document.getElementById('vxf').value;
vxf=vxf+1;
window.document.getElementById('vxf').innerHTML=vxf;
if(vxf==60)
{
window.alert("Vaxtiniz bitti!!!");
cavab();
}
}
else
{
vxf=0;	
}
ID = window.setTimeout("vxtint();", 1000);
} 

function sual() {
document.getElementById('bshl2').disabled=true;
var nocache = 0;
nocache = Math.random();

var login = encodeURI(document.getElementById('login').value);
http.open('get', 'inc/sual.php?login='+login+'&nocache='+nocache);
http.onreadystatechange = sualyaz;
http.send(null);
document.getElementById('int').value='';

}  


function sualyaz() {
if(http.readyState == 4){ 
var sualdiv = http.responseText;
    document.getElementById('int').innerHTML = sualdiv;
}
 }  
 
 
 
function cavab() {
document.getElementById('hdhdhdh').disabled=true;
var nocache = 0;
nocache = Math.random();

var login = encodeURI(document.getElementById('login').value);

var sualid = encodeURI(document.getElementById('sualid').value);
var h1 = document.getElementById('h1').value;
h1=h1.toLowerCase();
var c1=h1.charCodeAt(0).toString(10);
var h2 = document.getElementById('h2').value;
h2=h2.toLowerCase();
h2=h2.charCodeAt(0).toString(10);
var h3 = document.getElementById('h3').value;
h3=h3.toLowerCase();
h3=h3.charCodeAt(0).toString(10);
var h4 = document.getElementById('h4').value;
h4=h4.toLowerCase();
h4=h4.charCodeAt(0).toString(10);
var h5 = document.getElementById('h5').value;
h5=h5.toLowerCase();
h5=h5.charCodeAt(0).toString(10);
var h6 = document.getElementById('h6').value;
h6=h6.toLowerCase();
h6=h6.charCodeAt(0).toString(10);
var h7 = document.getElementById('h7').value;
h7=h7.toLowerCase();
h7=h7.charCodeAt(0).toString(10);
var h8 = document.getElementById('h8').value;
h8=h8.toLowerCase();
h8=h8.charCodeAt(0).toString(10);
var h9 = document.getElementById('h9').value;
h9=h9.toLowerCase();
h9=h9.charCodeAt(0).toString(10);
var h10 = document.getElementById('h10').value;
h10=h10.toLowerCase();
h10=h10.charCodeAt(0).toString(10);
var h11 = document.getElementById('h11').value;
h11=h11.toLowerCase();
h11=h11.charCodeAt(0).toString(10);
var h12 = document.getElementById('h12').value;
h12=h12.toLowerCase();
h12=h12.charCodeAt(0).toString(10);
var h13 = document.getElementById('h13').value;
h13=h13.toLowerCase();
h13=h13.charCodeAt(0).toString(10);
var h14 = document.getElementById('h14').value;
h14=h14.toLowerCase();
h14=h14.charCodeAt(0).toString(10);
var h15 = document.getElementById('h15').value;
h15=h15.toLowerCase();
h15=h15.charCodeAt(0).toString(10);

//document.location='inc/sualacavab.php?login='+login+'&sualid='+sualid+'&h1='+c1+'&h2='+h2+'&h3='+h3+'&h4='+h4+'&h5='+h5+'&h6='+h6+'&h7='+h7+'&h8='+h8+'&h9='+h9+'&h10='+h10+'&h11='+h11+'&h12='+h12+'&h13='+h13+'&h14='+h14+'&h15='+h15+'&nocache='+nocache;
http.open('get', 'inc/sualacavab.php?login='+login+'&sualid='+sualid+'&h1='+c1+'&h2='+h2+'&h3='+h3+'&h4='+h4+'&h5='+h5+'&h6='+h6+'&h7='+h7+'&h8='+h8+'&h9='+h9+'&h10='+h10+'&h11='+h11+'&h12='+h12+'&h13='+h13+'&h14='+h14+'&h15='+h15+'&nocache='+nocache);
http.onreadystatechange = cavabyaz;
http.send(null);
document.getElementById('int').value='';
}  

  
function cavabyaz() {
if(http.readyState == 4){ 
var sualdiv = http.responseText;
    document.getElementById('int').innerHTML = sualdiv;
}
 }  
  





  

function chatgiris() {

ID = window.setTimeout("chat();", 10000);

var login = encodeURI(document.getElementById('login').value);
var ctt = encodeURI(document.getElementById('ctt').value);
var nocache = 0;
nocache = Math.random();
now= new Date();
hs= now.getHours();
ms= now.getMinutes();
ss= now.getSeconds();

http.open('get', 'inc/chat.php?login='+login+'&mesaj='+'&ctt='+ctt+'&nocache='+nocache+'&hs='+hs+'&ms='+ms+'&ss='+ss);
http.onreadystatechange = chatyaz;
http.send(null);
}
 
  

function chat() {

ID = window.setTimeout("chat();", 30000);

var login = encodeURI(document.getElementById('login').value);
var ctt = encodeURI(document.getElementById('ctt').value);
var nocache = 0;
nocache = Math.random();
now= new Date();
hs= now.getHours();
ms= now.getMinutes();
ss= now.getSeconds();

http.open('get', 'inc/chat.php?login='+login+'&mesaj='+'&ctt='+ctt+'&nocache='+nocache+'&hs='+hs+'&ms='+ms+'&ss='+ss);
http.onreadystatechange = chatyaz;
http.send(null);
}


function chatyaz() {
if(http.readyState == 4){ 
var s = http.responseText;
var t=s.indexOf('(((???*45*45*5???)))', 0);
var tt=s.indexOf('(((???*45*45*5???)))', t+1);
var tn=s.length;
var ttt1=s.substring(0, t);
var ttt2=s.substring(t+20, tt);
var ttt3=s.substring(tt+20, tn);
var b=document.getElementById('ct').innerHTML + ttt1;
    document.getElementById('ct').innerHTML = b;
    document.getElementById('ct').scrollTop=document.getElementById('ct').scrollHeight+100000; 
    document.getElementById('ctt').value = ttt2;
    document.getElementById('ctonl').innerHTML ='';
    document.getElementById('ctonl').innerHTML = ttt3;
}
 }  
  

function chatilk() {
	
ID = window.setTimeout("chatilk();", 15000);

var ctt = encodeURI(document.getElementById('ctt').value);
var nocache = 0;
nocache = Math.random();
now= new Date();
hs= now.getHours();
ms= now.getMinutes();
ss= now.getSeconds();

http.open('get', 'inc/chat.php?ctt='+ctt+'&nocache='+nocache+'&hs='+hs+'&ms='+ms+'&ss='+ss);
http.onreadystatechange = chatyazilk;
http.send(null);
}  


function chatyazilk() {
if(http.readyState == 4){ 
var s = http.responseText;
var t=s.indexOf('(((???*45*45*5???)))', 0);
var tt=s.indexOf('(((???*45*45*5???)))', t+1);
var ttt1=s.substring(0, t);
var ttt2=s.substring(t+20, tt);
var b=document.getElementById('ct').innerHTML+ttt1;
    document.getElementById('ct').innerHTML = b;
    document.getElementById('ct').scrollTop=document.getElementById('ct').scrollHeight+100000; 
    document.getElementById('ctt').value = ttt2;

}
 }  


function chate() {

var login = encodeURI(document.getElementById('login').value);
var mesaj = encodeURI(document.getElementById('mesaj').value);
var ctt = encodeURI(document.getElementById('ctt').value);
var nocache = 0;
nocache = Math.random();
now= new Date();
hs= now.getHours();
ms= now.getMinutes();
ss= now.getSeconds();

http.open('get', 'inc/chat.php?login='+login+'&mesaj='+mesaj+'&ctt='+ctt+'&nocache='+nocache+'&hs='+hs+'&ms='+ms+'&ss='+ss);
http.onreadystatechange = chatyaz;
http.send(null);
document.getElementById('mesaj').value='';
}
 

 

 
 // moveCaretToEnd(document.getElementById('ct'));  lazim olsa chagiran funksiyaya qoy
function moveCaretToEnd(inputObject)
{
  if (inputObject.createTextRange)
  {
   var r = inputObject.createTextRange();
   r.collapse(false);
   r.select();
  }
}