var no_focus;
function w_obj() { 
    var wobj, i; 
    for (i = 0; i < 10; ++i) { 
        wobj = self.parent; 
        if ((wobj && !(wobj === self)) && (wobj.frames.length != 0)) { 
            wobj = self.parent 
        } 
    } 
    return wobj 
} 
 
if (navigator.appName == "Microsoft Internet Explorer") w = w_obj(); 
else w = top; 

w.onblur = function() { 
    no_focus=1;
}; 

w.onfocus = function() { 
    no_focus=0;
    favicon.unscroll();
    favicon.unanimate();
    favicon.change("/img/ibcs.ico");   
};  
   

function ge(id) 
{ 
    return document.getElementById(id); 
} 

function timer(){
    t+=1;
    if(t>60){m+=1;t=0;}
    if(m<10)time='0'+m; else time=m;
    time+=':';
    if(t<10)time+='0'+t; else time+=t;
    ge('chat_time').innerHTML=time;
    setTimeout('timer()',1000); 
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}


function add_message(t1) 
{   
    
if(t1!=''){      
    arr=t1.split('-&nm&-');
    //alert(message_arr);
    for (i=0,len=arr.length;i<len;i++) {
        message_arr=arr[i];
        //alert(arr[i].split('-&8&-')[0]+' - '+i+' - i');
        if(arr[i].split('-&8&-')[0]!='' && arr[i].split('-&8&-')[0]!='undefined')
        {
        if(message_arr.split('-&8&-')[1]!=0 & message_arr.split('-&8&-')[1]!=1 & message_arr.split('-&8&-')[1]!=undefined){
        var all_message=ge('all_messages');  
        
        MessageRow=all_message.insertRow(-1);   
        MessageRow.style.width='100%';    
            
        var PhotoCell = MessageRow.insertCell(0);   
        PhotoCell.id=message_arr.split('-&8&-')[0];
//PhotoCell.style="padding-left:10; line-height:15px; padding-bottom:7px;";        
        PhotoCell.style.paddingLeft='10px';
        PhotoCell.style.width="50px"; 
        PhotoCell.style.height="50px";
        PhotoCell.style.borderLeft=1;
        PhotoCell.style.borderRight=1;
        PhotoCell.style.borderTop=1;
        PhotoCell.style.borderBottom=1;
        PhotoCell.style.borderBottomColor='#dddddd';
        PhotoCell.style.borderLeftColor='#dddddd';
        PhotoCell.style.borderRightColor='#dddddd';
        PhotoCell.style.borderTopColor='#dddddd';
        
        var newBut = document.createElement('img');
        newBut.style.height=50;
        newBut.style.width=50;

        //alert(message_arr.split('-&8&-')[7]);
        /*if(message_arr.split('-&8&-')[7]>1){  
        newBut.style.width=(50*message_arr.split('-&8&-')[7]); 
        newBut.style.height=50;
        }else{
        newBut.style.width=50;
        newBut.style.height=(50*message_arr.split('-&8&-')[7]); 
        }   */
        
        
        newBut.setAttribute('src',message_arr.split('-&8&-')[5]); 
        PhotoCell.appendChild(newBut); 
        
        var MessageCell = MessageRow.insertCell(1);
        MessageCell.id=message_arr.split('-&8&-')[0]+'_message'; 
//MessageCell.style="padding-left:10; line-height:15px; padding-bottom:7px; ";
        MessageCell.style.paddingLeft='10px';
        MessageCell.style.lineHeight='15px';
        MessageCell.style.paddingBottom='7px';
        
        var man_name_label = document.createElement('label');
        man_name_label.id=message_arr.split('-&8&-')[0]+'_man_name_label';
//man_name_label.style="color: #3d76bb; font-size: 10pt; font-weight: bold";          //#3d76bb;
        man_name_label.style.fontSize='8pt';
        man_name_label.style.fontWeight='bold';
        man_name_label.style.color='#3d76bb';
        man_name_label.innerHTML=message_arr.split('-&8&-')[4];
        man_name_label = document.getElementById(message_arr.split('-&8&-')[0]+'_message').appendChild(man_name_label); 
        document.getElementById(message_arr.split('-&8&-')[0]+'_message').appendChild(document.createElement('br'));
        
        var man_posada_label = document.createElement('label'); 
        man_posada_label.id=message_arr.split('-&8&-')[0]+'_man_posada_label';
//man_posada_label.style="color: #7b7b7b; font-size: 6pt;";
        man_posada_label.style.color='#7b7b7b';
        man_posada_label.style.fontSize='7pt';
        man_posada_label.innerHTML=message_arr.split('-&8&-')[6];
        man_posada_label = document.getElementById(message_arr.split('-&8&-')[0]+'_message').appendChild(man_posada_label); 
        document.getElementById(message_arr.split('-&8&-')[0]+'_message').appendChild(document.createElement('br'));
        
        var man_message_label = document.createElement('label');
        man_message_label.id=message_arr.split('-&8&-')[0]+'_man_message_label';   
//man_message_label.style="color: #000000; font-size: 10pt";
        man_message_label.style.color='#000000';
        man_message_label.style.fontSize='10pt';
        man_message_label.innerHTML=message_arr.split('-&8&-')[3];
        man_message_label = document.getElementById(message_arr.split('-&8&-')[0]+'_message').appendChild(man_message_label);  
                                               
        var TimeCell = MessageRow.insertCell(2);
        TimeCell.id=message_arr.split('-&8&-')[0]+'_time'; 
//TimeCell.style="padding-left:10; line-height:15px; padding-bottom:7px; vertical-align:bottom;"
        TimeCell.style.paddingLeft='10px';
        TimeCell.style.paddingBottom='7px';
        TimeCell.style.verticalAlign='bottom';
        
        var man_time_label = document.createElement('label');
        man_time_label.id=message_arr.split('-&8&-')[0]+'_man_time_label'; 
//an_time_label.style="color: #7b7b7b; font-size: 8pt;";
        man_time_label.style.color='#7b7b7b';
        man_time_label.style.fontSize='8pt';
        man_time_label.innerHTML=message_arr.split('-&8&-')[2];
        man_time_label = TimeCell.appendChild(man_time_label); 
            
        } 
        }
        
        if((message_arr.split('-&8&-')[1]==0 || message_arr.split('-&8&-')[1]==1) & message_arr.split('-&8&-')[1]!=undefined){
        var all_message=ge('all_messages');  
        
        MessageRow=all_message.insertRow(-1);   
        MessageRow.style.width='100%';
        
        var MessageCell = MessageRow.insertCell(0); 
        MessageCell.colSpan=2;
        MessageCell.id=message_arr.split('-&8&-')[0]+'_message'; 
//MessageCell.style="padding-left:10; line-height:15px; padding-bottom:7;";    
        MessageCell.style.paddingLeft='10px';
        MessageCell.style.lineHeight='15px';
        MessageCell.style.paddingBottom='7px';
        
        var man_name_label = document.createElement('label');
        man_name_label.id=message_arr.split('-&8&-')[0]+'_man_name_label';
        if(message_arr.split('-&8&-')[1]==0){
//man_name_label.style="color: #7b7b7b; font-size: 8pt; font-weight: bold;";
        man_name_label.style.color='#7b7b7b';
        }
        if(message_arr.split('-&8&-')[1]==1){
//man_name_label.style="color: #3d76bb; font-size: 8pt; font-weight: bold;";
        man_name_label.style.color='#3d76bb';
        }
        man_name_label.style.fontSize='8pt';
        man_name_label.style.fontWeight='bold';
        man_name_label.innerHTML=message_arr.split('-&8&-')[4];
        man_name_label = document.getElementById(message_arr.split('-&8&-')[0]+'_message').appendChild(man_name_label); 
        document.getElementById(message_arr.split('-&8&-')[0]+'_message').appendChild(document.createElement('br'));
        
        var man_message_label = document.createElement('label');
        man_message_label.id=message_arr.split('-&8&-')[0]+'_man_message_label';
//man_message_label.style="color: #000000; font-size: 10pt";
        man_message_label.style.color='#000000';
        man_message_label.style.fontSize='10pt';
        man_message_label.innerHTML=message_arr.split('-&8&-')[3];   
        //man_message_label.innerHTML=message_arr.split('-&8&-')[3];
        man_message_label = document.getElementById(message_arr.split('-&8&-')[0]+'_message').appendChild(man_message_label);  
        
        var TimeCell = MessageRow.insertCell(1);
        TimeCell.id=message_arr.split('-&8&-')[0]+'_time'; 
//TimeCell.style="padding-left:10; line-height:15px; padding-bottom:7px; vertical-align:bottom;"
        TimeCell.style.paddingLeft='10px';
        TimeCell.style.paddingBottom='7px';
        TimeCell.style.verticalAlign='bottom';
        
        var man_time_label = document.createElement('label');
        man_time_label.id=message_arr.split('-&8&-')[0]+'_man_time_label'; 
//an_time_label.style="color: #7b7b7b; font-size: 8pt;";
        man_time_label.style.color='#7b7b7b';
        man_time_label.style.fontSize='8pt';
        man_time_label.innerHTML=message_arr.split('-&8&-')[2];
        man_time_label = TimeCell.appendChild(man_time_label); 
        
        }
        //document.body.appendChild(message_table);
                  
    }
//    );
    
  
var el = document.getElementById('message_div');    //прокрутку в низ                                 
var scroll_height = el.scrollHeight;
var visible_height = el.offsetHeight;
el.scrollTop = ( scroll_height - visible_height );    

}  
}    
    
    
    
           
/*
function Create(){  
if(navigator.appName == "Microsoft Internet Explorer"){  
req3 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req3 = new XMLHttpRequest();  
}  
return req3;  
}  */
//--------------------------------------------------------------------------------------------------------------------------------------------- 
function refresh_0() 
{ 
    if( req0.readyState == 4 ){ 
    //alert(req0.responseText+' - ref');    
    //ge('all_messages').value = req0.responseText; 
    
    
    if(req0.responseText.split('-&8&-')[0]=='WAIT MANAGER'){
    
        ge('servise_message').innerHTML='<label class="s10" style="color:#ff0000">'+req0.responseText.split('-&8&-')[1]+'</label>';    
        
    }else{
    //alert(req0.responseText);
    add_message(req0.responseText);
    }
        
    }
}   
  
function Request(query) 
{ 
    //alert(query);
if(navigator.appName == "Microsoft Internet Explorer"){  
req0 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req0 = new XMLHttpRequest();  
} 
req0.open('post', '/js/chat_consult.php?'+query , true ); 
req0.onreadystatechange = refresh_0; 
req0.send(query);   
setTimeout('Request('+"'"+query+"'"+')',5000);

//alert('OK!!! - 2');
}   
//---------------------------------------------------------------------------------------------------------------------------------------------
function refresh_1(){
    if( req1.readyState == 4 ){
        if(req1.responseText.indexOf("show consult_div")!=-1) {
            $('#consult_div').show('slow');    
            if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 6")!=-1){
            /*ge('consult_div').style.left=(getClientWidth()/100)*60;
            ge('consult_div').style.top=(getClientHeight()/100)*70;*/
            ge('consult_div').style.position='absolute';    
            //$('#consult_div').boxShadow('0 0 15px #a3a3a3'); 
            }    
            ge('man_name').innerHTML=req1.responseText.split('-&8&-')[4];
            ge('posada_name').innerHTML=req1.responseText.split('-&8&-')[1];
            ge('welcome_name').innerHTML=req1.responseText.split('-&8&-')[2];
            ge('foto_manager').src=req1.responseText.split('-&8&-')[3];
            if(req1.responseText.split('-&8&-')[5]>1){
            ge('foto_manager').style.width='50px';
            }else{
            ge('foto_manager').style.height='50px';    
            }
        
        $.stickr({note:req1.responseText.split('-&8&-')[2], className:'classic'});
        
        } 
        if(req1.responseText.indexOf("close consult_div")!=-1) {
          $('#consult_div').animate({ opacity: 'hide' }, 'slow');  
        }
        
        
        if(req1.responseText.indexOf("refresh page")!=-1) {window.location.reload(); } 
        
        } 
}

function Chat_users_in_prod(query){
if(navigator.appName == "Microsoft Internet Explorer"){  
req1 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{                    
req1 = new XMLHttpRequest();  
} 

//alert(query);

req1.open('post', '/js/chat_consult.php?'+query , true ); 
req1.onreadystatechange = refresh_1;
req1.send(query);                                           
setTimeout('Chat_users_in_prod('+"'"+query+"'"+')',10000);  
}
//---------------------------------------------------------------------------------------------------------------------------------------------
function refresh_2(){
    if( req2.readyState == 4 ){ 
        t_2_1=req2.responseText.split('-&mnm&-')[0];
        t_2_2=req2.responseText.split('-&mnm&-')[1];
        t_2_3=req2.responseText.split('-&mnm&-')[2];
        t_2_4=req2.responseText.split('-&mnm&-')[3];

        ge('visitors_div').innerHTML = t_2_1; 
        
        ge('chat_visitors_onlin').innerHTML = t_2_4;
        /*alert(req2.responseText);
        
        alert(t_2_1);
        alert(t_2_2);
        alert(t_2_3); 
        alert(t_2_4); */ 
        
        if(no_focus==1 && t_2_2=='nid concult'){
        favicon.animate(["/img/ibcs.ico", "/img/ibcs3.ico"], {delay: 400} );
        // бегущая строка
        favicon.scrollTitle(t_2_3);    
        }
        }/*else{
        alert("No aswer!!!");   // 
        }  */  
}

function update_visirors_list(query){
    //alert(query);
if(navigator.appName == "Microsoft Internet Explorer"){  
req2 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req2 = new XMLHttpRequest();  
}
req2.open('post', '/js/chat_consult.php?'+query , true ); 
req2.onreadystatechange = refresh_2;
req2.send(query);   
setTimeout('update_visirors_list('+"'"+query+"'"+')',10000);    
}
//---------------------------------------------------------------------------------------------------------------------------------------------

function refresh_3(){
    if( req3.readyState == 4 ){
        //alert(req3.responseText);
        //ge('sel_visitor_div').innerHTML = req3.responseText; 
        t1=req3.responseText.split('-&mnm&-')[0];
        t2=req3.responseText.split('-&mnm&-')[1];
        
        t1.split('-&8&-').forEach(function(visitor_id){          //непрочитанное сообщение
        if(ge("lmv_"+visitor_id.split('-&-&-')[1])) {
            if(ge("lmv_"+visitor_id.split('-&-&-')[1]).src.indexOf('R4')==-1){
            ge("lmv_"+visitor_id.split('-&-&-')[1]).src="/img/site3/left/R5.jpg"; }
             
        }  
        }); 
        
        t2.split('-&8&-').forEach(function(visitor_id){          //посетитель покинул чат
        if(ge("lmv_"+visitor_id)) {
            if(ge("lmv_"+visitor_id)){ge("lmv_"+visitor_id).src="/img/site3/left/R8.jpg";}
        }
        });
        
        
        var td_rows=ge("sel_visitor_tab").getElementsByTagName("tr");
        for (var i=0; i < td_rows.length; i++){
            f=0;
            t1.split('-&8&-').forEach(function(visitor_id){
               
               if(visitor_id.split('-&-&-')[0]==td_rows[i].id.split('tr_')[1]){f=1;
               }
            }); 
            
            if(f==0){
            ge("lmv_"+td_rows[i].id.split('tr_')[1]).src="/img/site3/left/R8.jpg?"+ new Date().getTime();
            }    
            
        }
        
        }
}

function update_visirors_manager_list(query){
    //alert(query);
if(navigator.appName == "Microsoft Internet Explorer"){  
req3 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req3 = new XMLHttpRequest();  
}  
req3.open('post', '/js/chat_consult.php?'+query , true ); 
req3.onreadystatechange = refresh_3;
req3.send(query);
setTimeout('update_visirors_manager_list('+"'"+query+"'"+')',10000);    

//setTimeout('update_visirors_manager_list('+"'"+query+"&sel_visitor="+ge('sel_visitor').value+"'"+')',10000);    
}
//---------------------------------------------------------------------------------------------------------------------------------------------

function refresh_4(){
    if( req4.readyState == 4 ){
        //alert(req4.responseText);
        ge('message_div').innerHTML = req4.responseText; 
        //add_message(req4.responseText);
        }/*else{
        alert("No aswer!!!");   
        }*/
}

function select_visitor(query,visitor_id, update_list){
    //alert(query+' - '+visitor_id+' - '+update_list);          //fid=4&lang=rus&manager_id=3&visitor_id=169&man_visit_id=648
if(navigator.appName == "Microsoft Internet Explorer"){  
req4 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req4 = new XMLHttpRequest();  
}  
req4.open('post', '/js/chat_consult.php?'+query , true ); 
req4.onreadystatechange = refresh_4;
req4.send(query);
  
  var td_rows=ge("sel_visitor_tab").getElementsByTagName("tr");
  for (var i=0; i < td_rows.length; i++){
  cur_v_id=td_rows[i].id.split('tr_')[1];   
  if(td_rows[i].id.indexOf('tr_'+visitor_id)==-1){
     td_rows[i].style.backgroundColor='#ffffff'; 
     ge('lb_'+cur_v_id).style.color='#000000';
  }else{
      td_rows[i].style.backgroundColor='#a4bdd8'; 
      ge('lb_'+cur_v_id).style.color='#ffffff';
  }   
  }   
  

  
if(update_list==1){  
tmp='fid=11&'+query.split('&')[1]+'&'+query.split('&')[2]+'&'+query.split('&')[3];
update_visirors_manager_list_onse(tmp);    
                 }
//setTimeout("update_visirors_manager_list_onse(tmp)",10);    

}
//---------------------------------------------------------------------------------------------------------------------------------------------
function refresh_5() 
{ 
    if( req5.readyState == 4 ){ 
    //alert(req5.responseText);    
    //ge('all_messages').value = req5.responseText; 
    add_message(req5.responseText);
    }
}   
  
function ref_manager_messages(query) 
{ 
    //alert(query);
if(navigator.appName == "Microsoft Internet Explorer"){  
req5 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req5 = new XMLHttpRequest();  
} 
req5.open('post', '/js/chat_consult.php?'+query , true ); 
req5.onreadystatechange = refresh_5; 
req5.send(query);   
setTimeout('ref_manager_messages('+"'"+query+"'"+')',5000);

//alert('OK!!! - 2');
}   
//---------------------------------------------------------------------------------------------------------------------------------------------
function refresh_6() 
{ 
    if( req6.readyState == 4 ){ 
    //alert(req6.responseText);    
    //ge('all_messages').value = req6.responseText; 
    add_message(req6.responseText); 
    }
}   
  
function new_man_message(query) 
{ 
    //alert(query);
if(navigator.appName == "Microsoft Internet Explorer"){  
req6 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req6 = new XMLHttpRequest();  
} 
if(ge('new_message').value){
req6.open('post', '/js/chat_consult.php?'+query+'&message='+encodeURIComponent(ge('new_message').value) , true ); 
ge('new_message').value='';
req6.onreadystatechange = refresh_6; 
req6.send(query);  
} 
//setTimeout('ref_manager_messages('+"'"+query+"'"+')',5000);

//alert('OK!!! - 2');
}   
//---------------------------------------------------------------------------------------------------------------------------------------------
   
function refresh_7() 
{ 
    if( req7.readyState == 4 ){ 
    //alert(req7.responseText);    
    //ge('all_messages').value = req6.responseText; 
    add_message(req7.responseText);
    }
}   
  
function add_all_visit_message(query) 
{ 
    //alert(query);
if(navigator.appName == "Microsoft Internet Explorer"){  
req7 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req7 = new XMLHttpRequest();  
} 

req7.open('post', '/js/chat_consult.php?'+query, true ); 
req7.onreadystatechange = refresh_7; 
req7.send(query);    

//setTimeout('ref_manager_messages('+"'"+query+"'"+')',5000);

//alert('OK!!! - 2');
}        
//---------------------------------------------------------------------------------------------------------------------------------------------

function refresh_8() 
{ 
    if( req8.readyState == 4 ){ 
    //alert(req8.responseText);    
    //ge('all_messages').value = req8.responseText; 
    add_message(req8.responseText); 
    }
}   
  
function new_vis_message(query) 
{ 
    //alert(query);
if(navigator.appName == "Microsoft Internet Explorer"){  
req8 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req8 = new XMLHttpRequest();  
} 
if(ge('new_message').value){
req8.open('post', '/js/chat_consult.php?'+query+'&message='+encodeURIComponent(ge('new_message').value) , true ); 
ge('new_message').value='';
req8.onreadystatechange = refresh_8; 
req8.send(query);  
} 
//setTimeout('ref_manager_messages('+"'"+query+"'"+')',5000);

//alert('OK!!! - 2');
}   
//---------------------------------------------------------------------------------------------------------------------------------------------

function refresh_9() 
{ 
    if( req9.readyState == 4 ){ 
    //alert(req9.responseText);    
    //ge('all_messages').value = req9.responseText; 
    if(req9.responseText!='wait_mahager'){
       //ge('all_messages').innerHTML='<tr><td><img height="40" src="/img/site3/loading.gif"></td></tr>';///img/site3/loading.gif
       window.location.reload( true );
    }
    
    }
}   
  
function wait_manager_v(query) 
{ 
    //alert('/js/chat_consult.php?fid=9&man_visit_id='+query);
if(navigator.appName == "Microsoft Internet Explorer"){  
req9 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req9 = new XMLHttpRequest();  
} 
req9.open('post', '/js/chat_consult.php?fid=9&man_visit_id='+query , true ); 
req9.onreadystatechange = refresh_9; 
req9.send(query);                             
setTimeout('wait_manager_v('+"'"+query+"'"+')',5000); 

//alert('OK!!! - 2');
}  
//---------------------------------------------------------------------------------------------------------------------------------------------

function refresh_10() 
{ 
    if( req10.readyState == 4 ){ 
    //alert(req10.responseText);    
    visitor_id=req10.responseText.split('-&8&-')[1];
    manager_id=req10.responseText.split('-&8&-')[2];
    select_visitor('fid=4&lang=rus&manager_id='+manager_id+'&visitor_id='+visitor_id,visitor_id, 0);
    update_visirors_manager_list_onse('fid=11&lang=rus&manager_id='+manager_id+'&visitor_id='+visitor_id);
    
    //if_redy_select_visitor_10('fid=4&lang=rus&manager_id='+manager_id+'&visitor_id='+visitor_id ,visitor_id);
    
    //ge('all_messages').value = req9.responseText; 
    
    }
}   
  
function close_chat_manager(query) 
{ 
    //alert('query = '+query+' - cloce');      //query=fid=10&manager_id=3&visitor_id=131
if(navigator.appName == "Microsoft Internet Explorer"){  
req10 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req10 = new XMLHttpRequest();  
} 
req10.open('post', '/js/chat_consult.php?'+query , true ); 
req10.onreadystatechange = refresh_10; 
req10.send(query);                             
//setTimeout('close_chat_manager('+"'"+query+"'"+')',5000); 

//fid=11&lang=rus&manager_id=3&visitor_id=128
//update_visirors_manager_list_onse('fid=11&lang=rus&'+query.split('&')[1]+'&'+query.split('&')[2]);

//alert('OK!!! - 2');
}
function if_redy_select_visitor_10(t1,t2){   
if(req12.readyState == 4){
    select_visitor(t1, t2, 1);
}else{
    setTimeout('if_redy_select_visitor(t1,t2);',100);    
}
}   
  
//---------------------------------------------------------------------------------------------------------------------------------------------
function refresh_11(){
    if( req11.readyState == 4 ){
        //alert(req11.responseText);
        ge('sel_visitor_div').innerHTML = req11.responseText; 
        }/*else{
        alert("No aswer!!!");   
        }*/
}

function update_visirors_manager_list_onse(query){        // fid=3
    //alert(query+' - update_visirors_manager_list_onse');
if(navigator.appName == "Microsoft Internet Explorer"){  
req11 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req11 = new XMLHttpRequest();  
}  
req11.open('post', '/js/chat_consult.php?'+query , true ); 
req11.onreadystatechange = refresh_11;
req11.send(query);

//setTimeout('update_visirors_manager_list('+"'"+query+"'"+')',10000);    
}
//---------------------------------------------------------------------------------------------------------------------------------------------
function refresh_12(){
    if( req12.readyState == 4 ){
        //alert(req12.responseText);
        ge('visitors_div').innerHTML = req12.responseText; 
        
        }
}

function add_visiror_to_manager_list(query){  //  fid=12   &tlv_td_1='+tlv_td_1.width+'&tlv_td_2='+tlv_td_2.width+'&tlv_td_3='+tlv_td_3.width+'&tlv_td_4='+tlv_td_4.width
    //alert(query);    //fid=12&lang=rus&manager_id=125&visitor_id=131&man_visit_id=385&company_id=3189
if(navigator.appName == "Microsoft Internet Explorer"){  
req12 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req12 = new XMLHttpRequest();  
}  
req12.open('post', '/js/chat_consult.php?'+query , true ); 
req12.onreadystatechange = refresh_12;
req12.send(query);

t1='fid=4&'+query.split('&')[1]+'&'+query.split('&')[2]+'&'+query.split('&')[3]+'&'+query.split('&')[4];
t2=query.split('&')[3];
if_redy_select_visitor(t1,t2);
//setTimeout('update_visirors_manager_list('+"'"+query+"'"+')',10000);    
}

function if_redy_select_visitor(t1,t2){   
if(req12.readyState == 4){
    select_visitor(t1, t2, 1);
}else{
    setTimeout('if_redy_select_visitor(t1,t2);',100);    
}
}   


//---------------------------------------------------------------------------------------------------------------------------------------------
function refresh_13(){
    if( req13.readyState == 4 ){
        window.location.reload();
        //alert(req13.responseText);
        //alert('OK!!!');
        //ge('visitors_div').innerHTML = req12.responseText; 
        
        }
}

function send_parter_mes(query){
//alert(query);  
if(navigator.appName == "Microsoft Internet Explorer"){  
req13 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req13 = new XMLHttpRequest();  
}  
req13.open('post', '/js/chat_consult.php?'+query , true ); 
req13.onreadystatechange = refresh_13;
req13.send(query);   
}



//---------------------------------------------------------------------------------------------------------------------------------------------

function refresh_14(){
    if( req14.readyState == 4 ){
        window.location.reload();
        //alert(req14.responseText);
        //alert('OK!!!');
        
        }
}

function del_parter_mes(query){ 
//alert(query); 
if(navigator.appName == "Microsoft Internet Explorer"){  
req14 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req14 = new XMLHttpRequest();  
}  
req14.open('post', '/js/chat_consult.php?'+query , true ); 
req14.onreadystatechange = refresh_14;
req14.send(query);   
}
//---------------------------------------------------------------------------------------------------------------------------------------------

function refresh_15(){
    if( req15.readyState == 4 ){
        window.location.reload();
        //alert(req15.responseText);
        //alert('OK!!!');
        
        }
}

function add_parter(query){ 
//alert(query); 
if(navigator.appName == "Microsoft Internet Explorer"){  
req15 = new ActiveXObject("Microsoft.XMLHTTP");  
}else{  
req15 = new XMLHttpRequest();  
}  
req15.open('post', '/js/chat_consult.php?'+query , true ); 
req15.onreadystatechange = refresh_15;
req15.send(query);   
}
//---------------------------------------------------------------------------------------------------------------------------------------------




