//<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
var hint_w    = null;
var reg_w     = null;
var acc_w     = null;
var pay_res_w = null;
var pass_w    = null;
var news_w    = null;
var demo_w    = null;
var sel_w     = null;
var addon_w   = null;
var ti_w   = null;

function set_top(){
  do{
    if(null != hint_w && !hint_w.closed){          
        hint_w.focus();
        break;
    }
    if(null != pay_res_w && !pay_res_w.closed){
      pay_res_w.focus(); 
      break;
    }
    if(null != pass_w && !pass_w.closed){
      pass_w.focus(); 
      break;
    }
    if(null != reg_w && !reg_w.closed){
      reg_w.focus();
      break;
    }
    if(null != acc_w && !acc_w.closed){
      acc_w.focus();
      break;
    }
    if(null != news_w && !news_w.closed){
      news_w.focus();
      break;
    }
    if(null != demo_w && !demo_w.closed){          
        demo_w.focus();
        break;
    }
    if(null != sel_w && !sel_w.closed){          
        sel_w.focus();
        break;
    }
    if(null != addon_w && !addon_w.closed){          
        addon_w.focus();
        break;
    }
    if(null != ti_w && !ti_w.closed){          
        ti_w.focus();
        break;
    }
    return;
  }while(0);
}

window.onfocus=set_top;

// Открываем окно просмотра задания теста
function show_test_item(name){
  sel_w = window.open(name,"test_item","resizable=yes,menubar=no,status=no,location=no,left="+((screen.width-600)/2)+",top="+((screen.height-400)/2)+",width=" + 600 + ",height=" + 400 + ",statusbar=yes,scrollbars=yes,z-lock=yes");
  if(null != ti_w && !ti_w.closed){
    ti_w.focus();
  }
  return false;
}


// Открываем окно выбора группы тестов
function show_selector(name){
  sel_w = window.open("/admin/editor/group-select-win.php?name="+name,"selector","resizable=yes,menubar=no,status=no,location=no,left="+((screen.width-400)/2)+",top="+((screen.height-200)/2)+",width=" + 400 + ",height=" + 200 + ",statusbar=yes,scrollbars=yes,z-lock=yes");
  if(null != sel_w && !sel_w.closed){
    sel_w.focus();
  }
  return false;
}

// Открываем окно выбора группы тестов
function show_test_addon(id){
  addon_w = window.open("show-test-addon.php?id="+id,"addon","resizable=yes,menubar=no,status=no,location=no,left="+(screen.width*0.1)+",top="+(screen.height*0.1)+",width=" + (screen.width*0.8) + ",height=" + (screen.height*0.8) + ",statusbar=yes,scrollbars=yes,z-lock=yes");
  if(null != addon_w && !addon_w.closed){
    addon_w.focus();
  }
  return false;
}


// Открываем окно мини-помощи
function show_hint(hint_id){
  hint_w = window.open("/hint.php?id="+hint_id,"hint","resizable=yes,menubar=no,status=no,location=no,left="+((screen.width-300)/2)+",top="+((screen.height-500)/2)+",width=" + 300 + ",height=" + 500 + ",scrollbars=yes,z-lock=yes");
  if(null != hint_w){
    if(!hint_w.closed){
      hint_w.focus();
    }
  }
  return false;
}

// Открываем окно регистрации нового пользователя
function show_reg(){
  reg_w = window.open("/do-register.php","reg_w","resizable=yes,menubar=no,status=no,location=no,left="+((screen.width-300)/2)+",top="+((screen.height-530)/2)+",width=" + 300 + ",height=" + 530 + ",scrollbars=yes,z-lock=yes");
  if(null != reg_w && !reg_w.closed){
    reg_w.focus();
  }
  return false;
}

// Открываем окно напоминания пароля
function show_reminder(){
  pass_w = window.open("/pass-reminder.php","pass_w","resizable=yes,menubar=no,status=no,location=no,left="+((screen.width-300)/2)+",top="+((screen.height-350)/2)+",width=" + 300 + ",height=" + 250 + ",scrollbars=yes,z-lock=yes");
  if(null != pass_w && !pass_w.closed){
    pass_w.focus();
  }
  return false;
}

// Открываем окно пополнения счета
function show_acc(server){
  acc_w = window.open("http://"+server+"/do-account.php","acc_w","resizable=yes,menubar=no,status=no,location=no,left="+((screen.width-350)/2)+",top="+((screen.height-500)/2)+",width=" + 350 + ",height=" + 500 + ",scrollbars=yes,z-lock=yes");
  if(null != acc_w && !acc_w.closed){
    acc_w.focus();
  }
  return false;
}

function pay_res_w_close(){
//alert();
  if(null != pay_res_w && !pay_res_w.closed){
    pay_res_w.close();
  }
  return false;
}
// Открываем окно пополнения счета
function show_pay_res(){
  pay_res_w = window.open("","pay_res_w","resizable=no,menubar=no,status=no,location=no,left="+((screen.width-300)/2)+",top="+((screen.height-170)/2)+",width=" + 300 + ",height=" + 170 + ",scrollbars=yes,z-lock=yes");
  pay_res_w.document.open();
  pay_res_w.document.write('<html><head><meta name="description" content="Тесты"><title>Обработка операции ...</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"></head><body text-align: center;" onblur="self.focus();"><p style="font-size:14px"><br />Выполняется обработка операции ...<form name="my_form"><input name="my_counter" value="0" style="background-color: #FFFF00; font-size: 10px; color: #FF0000; width: 30px; height: 20px; text-align: center;"></form><br />П О Д О Ж Д И Т Е!</p><script language="javascript">function my_count() { var o=document.my_form.my_counter; var i=parseInt(o.value); {o.value=i+1; setTimeout("my_count()", 1000);} } my_count();</script></body></html>');
  pay_res_w.document.close();
  if(null != pay_res_w && !pay_res_w.closed){
    pay_res_w.focus();
    return pay_res_w;
  }
  return false;
}

// Открываем окно новостей
function show_news(id){
  news_w = window.open("/show-news.php?"+id,"news_w","resizable=yes,menubar=no,status=no,location=no,left="+((screen.width-500)/2)+",top="+((screen.height-400)/2)+",width=" + 500 + ",height=" + 400 + ",scrollbars=yes,z-lock=yes");
  if(null != news_w && !news_w.closed){
    news_w.focus();
  }
  return false;
}

function show_demo(url){
  demo_w = window.open(url,"demo_w","resizable=yes,menubar=no,status=no,location=no,left="+((screen.width-600)/2)+",top="+((screen.height-600)/2)+",width=" + 600 + ",height=" + 600 + ",scrollbars=yes,z-lock=yes");
  if(null != demo_w && !demo_w.closed){
    demo_w.focus();
  }
  return false;
}


