  var type;
  var inputx;
   var GlobId=0;
    var Xdater=0;
     var GlobIdX=0;
   var xe=0;
    var xy=0;
     var paramsx;
//===============================[]

    function CheckNaviator(APN) {
    if(APN!=='Microsoft Internet Explorer') {alert('Данный блок корректно работает только с Microsoft Internet Explorer 5.5 и выше!'); return false;}
     return true;
      }

function loadUpInfo(text,disp) {
document.getElementById('UPINFO').style.display=disp;
document.getElementById('UPINFO').innerHTML=text;
document.getElementById('UPINFO').style.top=document.body.scrollTop;
window.status = text;
}


function  SendFormRequest(str, type)  {

  var  rnd982g  =  Math.random();
  if(type==1){  paramsx='?'+str+'&rnd982g='+rnd982g;   InsertGbMess(paramsx, '', 'InsertGbMess');  }
  if(type==2){  paramsx='?'+str+'&rnd982g='+rnd982g;   MegaAuth(paramsx, '', 'MegaAuth');  }
  if(type==3){  paramsx='?'+str+'&rnd982g='+rnd982g;   MegaAuthCSS(paramsx, '', 'MegaAuthCSS');  }

    //alert(str);
   }


function MegaAuth(input, response, type)
{
  if(response != '')  {
  if(response >  '0') {MESY_show(0,'none'); }
  if(response == '0') { alert('Ошибка! Не могу авторизироваться!'); }
  }else{
    url  = 'css/AJAX_combo_edit.php'+input+'&type='+ type+'&res=MegaAuth';//
    //alert(url);
    loadXMLDoc(url);
       }
}


function MegaAuthCSS(input, response, type)
{
  if(response != '')  {
  if(response >  '0') {MESY_show(0,'none'); }
  if(response == '0') { alert('Ошибка! Не могу авторизироваться!'); }
  }else{
    url  = 'AJAX_combo_edit.php'+input+'&type='+ type+'&res=MegaAuthCSS';//
    //alert(url);
    loadXMLDoc(url);
       }
}



function InsertGbMess(input, response, type)
{
  if(response != '')  {
  if(response >  '0') {MESY_show(0,'none'); }
  if(response == '0') { alert('Ошибка! Сообщенение не отправленно!'); }
  }else{
    url  = 'css/AJAX_combo_edit.php'+input+'&type='+ type+'&res=InsertGbMess';//
    //alert(url);
    loadXMLDoc(url);
       }
}


function MESY(top,text,time,disp)
 {
document.getElementById('MESY').style.display=disp;
if(text=='bugs'){
top=' Bugs Tracks сообщение';
text='<form name="frm" action="index.php?gb" method="post"> &nbsp;<select class=speach_ru size="1" name="_type"><option value="1" style="color:blue;">Информационное сообщение</option><option value="2" style="color:red;">Найдена ошибка</option><option value="3" style="color:green;">Проведено обновление</option><option value="4" style="color:orange;">Внимание всем!</option></select><br><div align="center"><textarea name="_bugs" rows=5 cols=70 class=speach_ru></textarea><input name="_uri" type="hidden" value="'+document.location.href+'"></div><br><div align="right"><BUTTON class=btn onclick="SendFormRequest(getForm(this.form),1);" type="BUTTON"><img src="img/admin/_bugs.gif" class=save><span>Отправить сообщение</span></BUTTON>&nbsp;&nbsp;&nbsp;&nbsp;</div></form>';
}
if(text=='diz'){
top='Выбор гаммы';
text='<div align="center"><ol><li><a href="?diz=_v&admin"><img border="0" src="img/admin/bg_top_v.gif" width="27" height="25"></a></li><li><a href="?diz=10&admin"><img border="0" src="img/admin/bg_top10.gif" width="27" height="25"></a></li><li><a href="?diz=9&admin"><img border="0" src="img/admin/bg_top9.gif" width="27" height="25"></a></li><li><a href="?diz=8&admin"><img border="0" src="img/admin/bg_top8.gif" width="27" height="25"></a></li><li><a href="?diz=7&admin"><img border="0" src="img/admin/bg_top7.gif" width="27" height="25"></a></li><li><a href="?diz&admin"><img border="0" src="img/admin/bg_top.gif" width="27" height="25"></a></li></ol></div></form>';
}

if(text=='auth'){
top='Требуется авторизация!';
text='<form name="frm" action="'+document.location.href+'" method="post"><div align=center><P><img onLoad="LP();" src="img/login.gif" alt="Логин" border=0><input class=speach name="u_login" type="text"><br><br><img src="img/pass.gif" alt="Пароль" border=0><input class=speach name="u_pass" type="password"></div><br><div align=right><BUTTON class=btng onclick="SendFormRequest(getForm(this.form),2);" type="BUTTON"><span>   Войти  </span></BUTTON>&nbsp;&nbsp;&nbsp;&nbsp;</div></form>';
}

if(text=='q_order_reply'){

text='<form name="frmxx" action="css\_edit_order.php" method="post"><input name="_type" type="hidden" value="q_order_reply"><input name="edit" type="hidden" value="'+top+'"> &nbsp;<select class=speach_ru size="1" name="_statusm" style="font-size:7pt;"><option value="0" style="color:blue;">Активно</option><option value="1" style="color:red;">Доработать</option><option value="2" style="color:green;">Отправлено</option></select> | <input style="margin:0;" onclick="if(this.checked==true){document.frmxx._statusm.selectedIndex=2; document.frmxx._status.selectedIndex=3;}"  name="_sender"  type="checkbox" value="1" id=c1n><label for=c1n style="cursor:pointer;"> <b style="font-size:7.5pt">Отправить ответ</b></label> | <select class=speach_ru size="1" name="_status" style="font-size:7pt;"><option value="999" style=" color:gray">Оставить как есть</option><option value="5" style=" color:#F4E200">Ожидание подтверждения</option> <option value="0" style=" color:#2291FF">Активен</option> <option value="4" style=" color:#1633D6">Переписка</option> <option value="6" style=" color:#CE00CE">Забронировано</option> <option value="7" style=" color:#00FFCC">Отправлена партнёрам</option> <option value="1" style=" color:#00D269">Выполнена</option> <option value="2" style=" color:#FF0000">Закрыта</option> <option value="3" style=" color:#E96A03">Дубликат</option> <option value="8" style=" color:#FF4860">Отложеная заявка</option><option value="9">! Отказник</option></select><br><div align="center"><textarea name="mes_reply" rows=5 cols=70 class=speach_ru></textarea></div><br><div align="right"><BUTTON class=btn onclick="SendFormRequest(getForm(this.form),1);" type="BUTTON"><span>Отправить сообщение</span></BUTTON>&nbsp;&nbsp;&nbsp;&nbsp;</div></form>';
top=' Отправка быстрого ответа';
}

document.getElementById('MESY').innerHTML='<table borde=0 cellspacing="0" cellpadding="0" width=400><tr bgcolor=#FFD7B9><td width=20 align=center> <img width=16 src="img/admin/newmess.gif"  alt="'+(time/1000)+'сек" border=0> </td><td> <font color=#2F1400 face=verdana size=2 color=#707070> <b>'+top+'</b></font></td><td align=right> <img onclick="document.location.href=\'?admin=7&qmesys\';" style="cursor:pointer;" src="img/admin/_log7.gif" width="18" height="16" alt="Перейти в qmessys" border=0> <img onclick="document.location.href=\'?gb#mes\';" style="cursor:pointer;" src="img/admin/_home.gif" width="18" height="16" alt="Перейити в багтрек" border=0> <img onclick="document.location.href=\'?admin=help&uic=7\';" style="cursor:pointer;" src="img/admin/_help.gif" width="18" height="18" alt="Помощь" border=0> <img onclick="MESY_show(0,\'none\');" style="cursor:pointer;" src="img/admin/_exit.gif" width="18" height="18" alt="Закрыть" border=0>&nbsp;</td></tr><tr bgcolor=#FFFFFF><td colspan="3" valign=top><table width=100%><tr><td><p align="justify"><font size=2 face=tahoma> '+text+'</font></p></tr></td></table></td></tr></table>';



document.getElementById('MESY').style.top=document.body.scrollTop+15;
document.getElementById('MESY').style.left=document.body.scrollleft-20;
window.status = text;

if(time>0)window.setTimeout("MESY_show(0,'none');", time);
}
//====
function MESY_show(time,disp) {
        if(disp==0)disp='none';
document.getElementById('MESY').style.display=disp;
if(time>0)window.setTimeout("MESY_show(0,'none');", time);
        }
//==============================================================================
//==============================================================================
//==============================================================================
function loadXMLDoc(url) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}

//===============================[]
function processReqChange()
{
window.status= stat(req.readyState);

 if(req.readyState!=4){loadUpInfo('Загрузка...','block');} else{loadUpInfo('','none');}
 //ab = window.setTimeout("req.abort();", 5000);
    // only if req shows "complete"
    if (req.readyState == 4) {// clearTimeout(ab);

        // only if "OK"
        try {
        if ((req.status == 200)||(req.status == 0)) {
            // ...processing statements go here...
      response = req.responseXML.documentElement;
      method = response.getElementsByTagName('method')[0].firstChild.data;
      result = response.getElementsByTagName('result')[0].firstChild.data;
      //alert(result+'!'+GlobId);
      eval(method + '(\'\', result, GlobId)');
        } else {
            alert("Не удалось получить данные XML:\n" + req.statusText);
        }
        } catch(e) {
  // var  fv  =  "";
              //  fv=e;
//fv=fv.replace('/"/', '***');

                loadUpInfo('<anycron title="'+encodeURI(e)+'" onclick="document.title=\''+encodeURI(e)+'\';">Ошибка...</anycron>','block');}
    }
}

//===============================[]
function ComboDell(input, response, type)
{
     if(response != ''){
     if(response > '0') {
     if((GlobId=='td')||(GlobId=='tdx')) document.getElementById(GlobId+response).style.display='none';
                 else document.getElementById(GlobId).style.display='none';
           }
     if(response == '0') {alert('Ошибка удаления!');}
  }else{
    url  = 'css/AJAX_combo_dell.php?dell='+input+'&type='+ type+'&res=ComboDell';//alert(url);
    loadXMLDoc(url);
  }
}
//===============================[]
function ComboEdit(input, response, type)
{
  if(response != '')  {
  if(response >  '0') { if((GlobId=='td')||(GlobId=='tdx')) document.getElementById(GlobId+response).style.display='none';
   else document.getElementById(GlobId).style.display='none';}
  if(response == '0') { alert('Ошибка изменения!'); }
  }else{
    url  = 'css/AJAX_combo_edit.php?edit='+input+'&type='+ type+'&res=ComboEdit';//alert(url);
    loadXMLDoc(url);
 }
}

//===============================[]
function ComboChangeBannerActive(input, response, type)
{ if(input != '')inputx=input;
  if(response != '')  {
  if(response >  '0') { document.getElementById('Change'+inputx).innerHTML ='<font color=green>On</font>';  }
  if(response == '0') { document.getElementById('Change'+inputx).innerHTML ='<font color=red>Off</font>'; }
    }else{
    url  = 'css/AJAX_combo_edit.php?edit='+input+'&type='+ type+'&res=ComboChangeBannerActive';//alert(url);
    loadXMLDoc(url);
 }
}
//===
function ComboLabel(input, response, type,_edit)
{ if(input != ''){inputx=input+''+_edit; }

  if(response != '')  {
    if(response == '2') { document.getElementById('Ch'+inputx).innerHTML ='<font color=blue>•</font>';}
    if(response == '1') { document.getElementById('Ch'+inputx).innerHTML ='<font color=red>•</font>';}
  //  if(response >  '0') { document.getElementById('Ch'+inputx).innerHTML ='<font color=green>•</font>'; }
    if(response == '0') { document.getElementById('Ch'+inputx).innerHTML ='<font color=silver>•</font>';}
     }else{
    url  = 'css/AJAX_combo_edit.php?edit='+input+'&edit_='+_edit+'&type='+ type+'&res=ComboLabel';//alert(url);
    loadXMLDoc(url);
 }
}
//============================[]
function SendMassage(input, response, type)
{
  if(response != '')  {
  if(response >  '0') { document.bgColor='#F0FFF0'; document.getElementById('bnx').disabled= 0;  document.getElementById('bnx').value='послать письмо с инструкциями >>> (Успешно!)'; }
  if(response == '0') { document.bgColor='#FFF2F2'; alert('Ошибка! Письмо не отправлено!'); document.getElementById('bnx').disabled= 0;
  document.getElementById('bnx').value='послать письмо с инструкциями >>> (Ошибка!)';
 }
  }else{
    url  = 'AJAX_SendMassage.php?mail='+input+'&type='+ type+'&res=SendMassage';//alert(url);
    loadXMLDoc(url);
 }

}

function SendMassage_order(input, response, type)
{
  if(response != '')  {
  if(response >  '0') { document.bgColor='#F0FFF0'; document.getElementById('bnx').disabled= 0;  document.getElementById('bnx').value='послать подтверждение >>> (Успешно!)'; }
  if(response == '0') { document.bgColor='#FFF2F2'; alert('Ошибка! Письмо не отправлено!'); document.getElementById('bnx').disabled= 0;
  document.getElementById('bnx').value='послать подтверждение >>> (Ошибка!)';
 }
  }else{
    url  = 'AJAX_SendMassage_order.php?order='+input+'&type='+ type+'&res=SendMassage_order';//alert(url);
    loadXMLDoc(url);
 }

}


function clone_order(input, response, type)
{
  if(response != '')  {
  if(response >  '0') { document.bgColor='#F0FFF0'; document.getElementById('bnxc').disabled= 0;  document.getElementById('bnxc').value='Создать копию заявки >> (Успешно! #'+response+')'; }
  if(response == '0') { document.bgColor='#FFF2F2'; alert('Ошибка! Заявка не клонирована!'); document.getElementById('bnxc').disabled= 0;
  document.getElementById('bnxс').value='Создать копию заявки >> (Ошибка!)';
 }
  }else{
    url  = 'AJAX_clone_order.php?order='+input+'&type='+ type+'&res=clone_order';//alert(url);
    loadXMLDoc(url);
 }

}





//===============================[]
//===============================[]
function CheckAuthMain(input, response, type)
{
     if(response != ''){ if(response > 0) { document.frm.submit(); window.focus();} else { MESY('auth','auth',0,'block'); window.open('css/_tracker_auth.php', 'newWinA', 'Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbars=0, Resizable=0, modal=yes, Copyhistory=0, Width=500, Height=400');}  //alert(response);
     }
     else{
    url  = 'css/AJAX_auth.php?res=CheckAuthMain';//alert(url);
    loadXMLDoc(url);
  }
}
//===============================[]
function CheckAuth(input, response, type)
{//alert(3);
     if(response != ''){ if(response > 0) { document.frm.submit();window.opener.focus();} else { MESY('auth','auth',0,'block'); window.open('_tracker_auth.php', 'newWinA', 'Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbars=0, Resizable=0, modal=yes, Copyhistory=0, Width=500, Height=400');}  //alert(response);
     }
     else{
    url  = 'AJAX_auth.php?res=CheckAuth';//alert(url);
    loadXMLDoc(url);
  }
}
function CheckAuthIframe(input, response, type)
{//alert(3);
     if(response != ''){ if(response > 0) { document.frm.submit();} else { MESY('auth','auth',0,'block'); window.open('_tracker_auth.php', 'newWinA', 'Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbars=0, Resizable=0, modal=yes, Copyhistory=0, Width=500, Height=400');}  //alert(response);
     }
     else{
    url  = 'AJAX_auth.php?res=CheckAuthIframe';//alert(url);
    loadXMLDoc(url);
  }
}
function CheckAuthFrame1(input, response, type)
{//alert(3);
     if(response != ''){ if(response > 0) { document.frm.submit();} else { MESY('auth','auth',0,'block'); window.open('_tracker_auth.php', 'newWinA', 'Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbars=0, Resizable=0, modal=yes, Copyhistory=0, Width=500, Height=400');}  //alert(response);
     }
     else{
    url  = 'AJAX_auth.php?res=CheckAuthFrame1';//alert(url);
    loadXMLDoc(url);
  }
}


function CheckAuthFrame(input, response, type)
{//alert(3);
 if(input != ''){inputx=input;  inputxx='RM'+input;}
     if(response != ''){ if(response > 0) { return true;} else {return false; MESY('auth','auth',0,'block'); window.open('_tracker_auth.php', 'newWinA', 'Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbars=0, Resizable=0, modal=yes, Copyhistory=0, Width=500, Height=400');}  //alert(response);
     }
     else{
    url  = 'AJAX_auth.php?res=CheckAuthFrame';//alert(url);
    loadXMLDoc(url);
  }
} //top.getElementById('RM4036').document.frm.submit();
//==============================================================================
//==============================================================================
//==============================================================================
function stat(n)
{
  switch (n) {
    case 0:
      return "Не инициализирован";
    break;

    case 1:
      return "Загрузка...";
    break;

    case 2:
      return "Загружено";
    break;

    case 3:
      return "В процессе...";
    break;

    case 4:
      return "Готово";
    break;

    default:
      return "Неизвестное состояние";
  }
}
//===============================[]







//==============================================================================
function checkName(input, response, type)
{
  if (response != ''){
    // Response mode
    message   = document.getElementById('nameCheckFailed_' + document.getElementById('_temp_name').value);
    if (response == '1'){
      message.className = 'error';
    }else{
      message.className = 'hidden';
    }
  }else{
    // Input mode
    url  = 'css/AJAX_checkdata.php?q='+ input+'&type='+ type+'&res=checkName';
    loadXMLDoc(url);
  }
}
