function forgotPassword(){
  var email = $('forgot_email').value;
  var req = new Subsys_JsHttpRequest_Js('utf-8');
  req.onreadystatechange = function() {
    if (req.readyState == 4) {
      var htmlResult = req.responseJS.htmlResult;
      alert(htmlResult);
      if(req.responseJS.success == 1){
        $('forgot_password').style.display = 'none'
        $('_floginbutton').style.display = '';
      }
    }
  }
  req.open(null, '/forgot', true);
  req.send({forgot_email:email});
}

function setCookie (name, value, path, expires, domain, secure)
{
  document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function getCookie (name)
{
  var cookie = " " + document.cookie;
  var search = " " + name + "=";
  var setStr = null;
  var offset = 0;
  var end = 0;
  if (cookie.length > 0) {
    offset = cookie.indexOf(search);
    if (offset != -1) {
      offset += search.length;
      end = cookie.indexOf(";", offset)
      if (end == -1) {
        end = cookie.length;
      }
      setStr = unescape(cookie.substring(offset, end));
    }
  }
  return setStr;
}

function FlashTag(src, width, height)
{
    this.src       = src;
    this.width     = width;
    this.height    = height;
    this.id        = null;
    this.bgcolor   = 'ffffff';
    this.flashVars = null;
    this.version   = '6.0.0.0';
    this.params    = null;
    this.opaque    = 1;
}


FlashTag.prototype.setParams = function(p)
{
    this.params = p;
}

FlashTag.prototype.setVersion = function(v)
{
    this.version = v;
}

FlashTag.prototype.setOpaque = function(o)
{
    this.opaque = o;
}


FlashTag.prototype.setId = function(id)
{
    this.id = id;
}
FlashTag.prototype.setBgcolor = function(bgc)
{
    this.bgcolor = bgc;
}
FlashTag.prototype.setFlashvars = function(fv)
{
    this.flashVars = fv;
}
FlashTag.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var flashTag = new String();
    if (ie)
    {
        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';
        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';
        if (this.opaque) {
          flashTag += '<param name="wmode" value="transparent">';
        }
        flashTag += '<param name="quality" value="high"/>';
        flashTag += '<param name="bgcolor" value="#'+this.bgcolor+'"/>';
        if(this.params != null){
          flashTag += this.params;
        }
        if (this.flashVars != null)
        {
            flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>';
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'" ';
        if (this.opaque) {
          flashTag += 'wmode="transparent"';
        }
        flashTag += 'quality="high" ';
        flashTag += 'bgcolor="#'+this.bgcolor+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'" ';
        flashTag += 'type="application/x-shockwave-flash" ';
        if (this.flashVars != null)
        {
            flashTag += 'flashvars="'+this.flashVars+'" ';
        }
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
    return flashTag;
}
FlashTag.prototype.write = function(doc)
{
    doc.write(this.toString());
}

var Login_FormShowHide = function(setVisibilityState)
{
  var _form = $('loginForm');
  if (!_form) {
    return true;
  }
  if (setVisibilityState) {
    _form.removeClassName('hidden');
  } else {
    _form.addClassName('hidden');
  }
  return false;
}

var Login_Submit = function()
{

  //$('login-ajax').show();
  var login = $F('_flogin');
  var password = $F('_fpassword');
  var remember = $('id__remember').checked ? 1 : 0;
  
  if (!Login_ValidateForm(login, password)) {
    return false;
  }  
  
  var url = '/login';
  var req = new Ajax.Request(url, {
    method: 'post',
    parameters: {_login: login, _password: password, _remember: remember, _ajax: 1},
    onCreate: function (t) {
      var b = $('_floginbutton')
      b.style.background = 'gray';
      b.onclick = function() {
        alert('Подождите, запрос обрабатывается');
        return false;
      }
    },
    onComplete: function (t) {
    
    $('_floginbutton').onclick = null;
    // process result
      //$('login-ajax').hide();
      var result = t.responseText;
      if (result == "+logged") {
        var b = $('_floginbutton')
        b.style.background = 'white';
        b.disabled = true;
        // document.location.reload();        
        /*Forum_Submit(login, password, remember, 0);*/
        location.href = '/' + login;
      } else if (result == "-login") {
        alert('Неправильное имя пользователя');
      } else if (result == "-password") {
        alert('Неправильный пароль!');
      } else if (result == '-banned') {
        alert('Ваш аккаунт заблокирован!');
      } else {
        alert('Вход невозможен!');
        alert(result);
      }},
    onSuccess: function (t) {
    
      // process result
      //$('login-ajax').hide();
      var result = t.responseText;
      if (result == "+logged") {
        var b = $('_floginbutton')
        b.style.background = 'white';
        b.disabled = true;
        // document.location.reload();
        /*Forum_Submit(login, password, remember, 0);*/  
        location.href = '/' + login;
      } else if (result == "-login") {
        //alert('Если вы уверены в его правильности пожалуйста пройдите регистрацию еще раз');
      } else if (result == "-password") {
        //alert('Неправильный пароль!');
      } else if (result == '-banned') {
        //alert('Ваш аккаунт заблокирован!');
      } else {
        //alert('Вход невозможен!');
        //alert(result);
      }
    }
  });
  return false;
}

var Forum_Submit = function(login, password, remember, togo)
{
  location.href = '/forum/login.php?username=' + login + '&password=' + password + '&gotome=1&login=1&autologin=' + remember;
  
  /*var url = '/forum/login.php';
  var req = new Ajax.Request(url, {
    method: 'post',
    parameters: {login: 1, username: login, password: password, autologin: remember, _ajax: 1},
    onSuccess: function (t) {
      // process result
      var result = t.responseText;
      if (result == "+logged") {
        //в форум зашел
        location.href = '/' + login;
      }
      if (result == "-logged") {          
        Forum_Submit(login, password, remember, 1);
        //в форум не зашел        
      }
      // тут, если фарш, а что то делать нужно      
      if (togo) {       
        location.href = '/' + login;
      }      
    },
    onComplete: function (t) {
      // process result
      var result = t.responseText;
      if (result == "+logged") {
        location.href = '/' + login;
      }
      if (result == "-logged") {        
        Forum_Submit(login, password, remember, 1);
        //в форум не зашел        
      }
      if (togo) {
        location.href = '/' + login;
      }
    }
  });*/
  return false;
}
var Forum_Logout = function()
{  
  var url = '/forum/login.php?logout=true&gotomain=1&sid=' + getCookie('phpbb2mysql_sid');
  location.href = url;
  /*var req = new Ajax.Request(url, {
    method: 'post',
    parameters: {_ajax: 1},
    onSuccess: function (t) {
      document.location = '/';
    }
  });*/
  return false;
}

var Login_Logout = function()
{
  if (confirm('Вы действительно хотите выйти?')) {
    var url = '/login';
    var req = new Ajax.Request(url, {
      method: 'post',
      parameters: {_logout: 'yes', _ajax: 1},
      onSuccess: function (t) {
        //еще выйдем из форума
        /*Forum_Logout();*/
        document.location = '/';
        /*document.location.reload();*/
      }
    });
  }
  return false;
}

var Login_ValidateForm = function(login, password)
{
  //$('login-ajax').hide();  
  if (login.length < 1) {
    alert('Введите имя пользователя!');
    return false;
  }
  if (password.length < 1) {
    alert('Введите пароль');
    return false;
  }
  if (!login.match(/^[a-z][a-z0-9\-\_\.\@]+$/)) {
    alert('Возможно ваш логин имеет недопустимые символы. Если вы уверены в его правильности то пройдите регистрацию еще раз.');
    return false;
  }  
  setCookie('test', 1);
  var test = getCookie('test');
  if (!test) {
    alert('Внимание! В вашем браузере отключена поддержка Cookie! Включите ее.');
    //return false;
  }
  return true;
}

var Custom_Interest_Add = function(value)
{
  if (value.replace(/\s/g, '') == '') {
    return false;
  }
  var _input = $('id__custom_interest');
  // retrieve index
  var _ints = $$('input[id^="id___Interest__title:"]');
  var index = parseInt(_ints[_ints.length - 1].id.substring("id___Interest__title:".length)) + 1;
  for (var i = 0; i < _ints.length; i++) {
    if (_ints[i].value.toLowerCase() == value.toLowerCase()) {
      _ints[i].checked = true;
      _input.value = '';
      _input.blur();

      return false;
    }
  }
  var d = document.createElement('div');
  var c = document.createElement('input');
  var l = document.createElement('label');

  c.id = 'id___Interest__title:' + index;
  c.name = '__Interest__title:' + index;
  c.type = 'checkbox';
  c.checked = true;
  c.value = value;

  l.setAttribute('for', c.id);
  l.innerHTML = value;
  d.appendChild(c);
  d.appendChild(document.createTextNode(' '));
  d.appendChild(l);

  $('custom_interest_place').insert({before: d});

  _input.value = '';
  _input.blur();

  setCookie ('interests[' + index + ']', value);

  return false;
}
/*PictureNews section*/
var picturenews = new Array();
function changePictureNews(id, rand)
{
  $('picturenews_inside_'+rand).innerHTML = picturenews[rand][id];
}
/*DoubleNews section*/
var news_images = new Array();
var second_news = new Array();
var num_news = new Array();
var min_news = new Array();
var max_news = new Array();
function changeNewsImage(id, rand)
{
  $('news_image_'+rand).innerHTML = '<img src="'+news_images[rand][id]+'" height="172" width="231" alt="" />';
}
function addNews(rand)
{
  if (num_news[rand] + 1 > max_news[rand])
    return;
  num_news[rand]++;

  setCookie ('_news_cookie_'+rand, num_news[rand], '/', 'Mon, 06-Jan-2020 00:00:00 GMT', 'radiokarnaval.ru', false);

  changePlusMinusRand(rand);

  changeNews(rand);
}
function delNews(rand)
{
  if (num_news[rand] - 1 < min_news[rand])
    return;
  num_news[rand] = num_news[rand] - 1;

  setCookie ('_news_cookie_'+rand, num_news[rand], '/', 'Mon, 06-Jan-2020 00:00:00 GMT', 'radiokarnaval.ru', false);

  changePlusMinusRand(rand);

  changeNews(rand);
}
function changePlusMinusRand(rand)
{
  if (num_news[rand] == max_news[rand])
    $('_news_plus_'+rand).style.visibility = 'hidden';
  else
    $('_news_plus_'+rand).style.visibility = 'visible';
  if (num_news[rand] == 1)
    $('_news_minus_'+rand).style.visibility = 'hidden';
  else
    $('_news_minus_'+rand).style.visibility = 'visible';
}
function changeNews(rand)
{
  var outer_html = '';
  for (var i = 0; i < num_news[rand]; i++) {
    outer_html += second_news[rand][i];
  }
  $('secondary_news_'+rand).innerHTML = outer_html;
}
/*Watch'n'listen section*/
var _watch = new Array();
var _listen = new Array();
function _wnl_Watch(rand)
{
  last_subdesc_id[1][rand] = first_subdesc_id[1][rand];
  $('watch_n_listen_'+rand).innerHTML = _watch[rand];
  $('_wnl_listen_l'+rand).className = 'g-inact-tab-l';
  $('_wnl_listen'+rand).className = 'g-inact-tab';
  $('_wnl_listen_r'+rand).className = 'g-inact-tab-r';
  $('_wnl_watch_l'+rand).className = 'g-act-tab-l';
  $('_wnl_watch'+rand).className = 'g-act-tab';
  $('_wnl_watch_r'+rand).className = 'g-act-tab-r';
  $('_wnl_listen'+rand).innerHTML = '<h3><a href="javascript:_wnl_Listen('+rand+')">Слушаем</a></h3>';
  $('_wnl_watch'+rand).innerHTML = '<h3>Смотрим</h3>';
}
function _wnl_Listen(rand)
{
  last_subdesc_id[0][rand] = first_subdesc_id[0][rand];
  $('watch_n_listen_'+rand).innerHTML = _listen[rand];
  $('_wnl_listen_l'+rand).className = 'g-act-tab-l';
  $('_wnl_listen'+rand).className = 'g-act-tab';
  $('_wnl_listen_r'+rand).className = 'g-act-tab-r';
  $('_wnl_watch_l'+rand).className = 'g-inact-tab-l';
  $('_wnl_watch'+rand).className = 'g-inact-tab';
  $('_wnl_watch_r'+rand).className = 'g-inact-tab-r';
  $('_wnl_listen'+rand).innerHTML = '<h3>Слушаем</h3>';
  $('_wnl_watch'+rand).innerHTML = '<h3><a href="javascript:_wnl_Watch('+rand+')">Смотрим</a></h3>';
}
/*Listen section*/
var first_subdesc_id = new Array();
first_subdesc_id[0] = new Array();
first_subdesc_id[1] = new Array();
var last_subdesc_id = new Array();
last_subdesc_id[0] = new Array();
last_subdesc_id[1] = new Array();
function showSubdesc(id, type, rand)
{
  if (rand) {
    var _id = 'about_sub_' + id + '_' + type + '_' + rand;
    var _last = last_subdesc_id[type][rand];
  } else {
    var _id = 'about_sub_' + id + '_' + type;
    if (last_subdesc_id[type])
      var _last = last_subdesc_id[type];
  }
  if (_last != '')
    hideSubdesc(_last, type, rand);
  if (rand)
    last_subdesc_id[type][rand] = id;
  else
    last_subdesc_id[type] = id;
  $(_id).style.display = 'block';
}
function hideSubdesc(id, type, rand)
{
  if (rand)
    var _id = 'about_sub_' + id + '_' + type + '_' + rand;
  else
    var _id = 'about_sub_' + id + '_' + type;
  $(_id).style.display = 'none';
}
var _mp_fav_cur = 0;
function mp_fav_show(id)
{
  $('mp_fav_show_'+id).style.display = 'inline';
  if (id != _mp_fav_cur) {
    mp_fav_hide(_mp_fav_cur);
    _mp_fav_cur = id;
  }
}
function mp_fav_hide(id)
{
  $('mp_fav_show_'+id).style.display = 'none';
}
/*Programs section*/
var prev_program_id = 0;
var programs_list = new Array();
function changeProgram(id, rand)
{
  $('program_'+prev_program_id+'_'+rand).className = '';
  $('program_'+id+'_'+rand).className = 'sel';
  prev_program_id = id;

  $('program_info_'+rand+'_link').setAttribute('href', '/shedule/active/?program_id='+id);
  $('program_info_'+rand+'_link2').setAttribute('href', '/shedule/active/?program_id='+id);
  
  if (programs_list[id]) {
    $('program_info_'+rand).innerHTML = programs_list[id];    
    return;
  }

  var req = new Subsys_JsHttpRequest_Js('utf-8');
  req.onreadystatechange = function () {
    if (req.readyState == 4) {
      var htmlResult = req.responseJS['default'].htmlResult;
      $('program_info_'+rand).innerHTML = htmlResult;
      programs_list[id] = htmlResult;
    }
  }
  req.open (null, '/shedule/getprogram/', true);
  req.send ({id: id});
}
function changeProgramF(id, rand)
{
  $('program_'+prev_program_id+'_'+rand).className = '';
  $('program_'+id+'_'+rand).className = 'sel';
  prev_program_id = id;

  if (programs_list[id]) {
    $('program_info_'+rand).innerHTML = programs_list[id];
    return;
  }

  var req = new Subsys_JsHttpRequest_Js('utf-8');
  req.onreadystatechange = function () {
    if (req.readyState == 4) {
      var htmlResult = req.responseJS['default'].htmlResult;
      $('program_info_'+rand).innerHTML = htmlResult;
      programs_list[id] = htmlResult;
    }
  }
  req.open (null, '/shedule/getprogram/', true);
  req.send ({id: id, full: 1});
}


var curVac=0;
function showVacancy(id,vac_id,vac_title)
{
  document.getElementById("big_" + curVac).style.display="none";
  document.getElementById("big_" + id).style.display="";
  document.getElementById("small_" + curVac).style.display="";
  document.getElementById("small_" + id).style.display="none";
  document.getElementById("id__id_vac").value=vac_id;
  document.getElementById("id__vac_title").value=vac_title;
  curVac = id;
}

/*Video/Audio iframes*/
function showAudio(id, rand)
{
  if (rand)
    var obj = 'pl_container_' + rand;
  else
    var obj = 'pl_container';
  $(obj).innerHTML = '<iframe src="/audio/show/'+id+'" frameborder="0" width="366" height="43" scrolling="no"></iframe>';
}
function showVideo(id, rand)
{
  if (rand)
    var obj = 'pl_container_' + rand;
  else
    var obj = 'pl_container';
  $(obj).innerHTML = '<iframe src="/video/show/'+id+'" frameborder="0" width="425" height="355" scrolling="no"></iframe>';
}

var fid;
var ansid = new Array();
function FaqShow(id)
{
/*
  var req = new Ajax.Request('/faq/show/', {
      method: 'post',
      //evalJSON: 'force',
      parameters: {cid: id},
      onSuccess: function (t) {
        document.getElementById("ajax_res_" + id).innerHTML=t.responseJSON.htmlResult;
       // if(fid){
      //    document.getElementById("header_" + fid).style.display="";
      //  }
      ansid[id] = t.responseJSON.fid;
*/

      //document.getElementById("ajax_res_" + id).style.display="";
      if(ansid[id]){
        document.getElementById("text_" + id).style.display="none";
        ansid[id]=0;
      }else{
        document.getElementById("text_" + id).style.display="";
        ansid[id]=1;
      }
}


function ShowFaqAnswer(id,cid)
{
  document.getElementById("ftext_" + ansid[cid]).style.display="none";
  document.getElementById("ftext_" + id).style.display="";
  document.getElementById("link_" + ansid[cid]).style.display="";
  document.getElementById("link_" + ansid[cid] + "_cur").style.display="none";
  document.getElementById("link_" + id).style.display="none";
  document.getElementById("link_" + id + "_cur").style.display="";
  ansid[cid] = id;
}


function closeFaq(id)
{
  document.getElementById("ajax_res_" + id).style.display="none";
  document.getElementById("header_" + id).style.display="";
}

/*News_Show*/
var News = Class.create({
  obj: '',
  images_list: [],
  initialize: function(obj)
  {
    this.obj = obj;
  },
  addPhoto: function(id, file)
  {
    this.images_list[id] = file;
  },
  showPhoto: function(id)
  {
    $(this.obj).innerHTML = '<img src="'+this.images_list[id]+'" alt="" />';
  }
});

__LastCommentObj = null;
function Comment_Reply(href, commentId)
{
  var commentObj = commentId != null ? $('comment' + commentId) : $('comments_add_wrapper');
  if (!commentObj) {
    return true;
  }
  if (commentId != null) {
    $('comments_add_title').hide();
  } else {
    $('comments_add_title').show();
  }

  var commentForm = $('comments_add');
  if (!commentForm) {
    return true;
  }
  if ((!commentId && __LastCommentObj == null) || (commentId && __LastCommentObj != null && __LastCommentObj.id == 'comment' + commentId)) {
    commentForm.scrollTo();
    return false;
  }

  oForm = $('comments_add_form');
  if (!oForm) {
    return true;
  }
  oForm.action = href.replace(/#.*$/gi, '');

  if (__LastCommentObj != null) {
    __LastCommentObj.setStyle({paddingBottom: '10px'});
  }
  if (commentId != null) {
    var xy = commentObj.cumulativeOffset();
    commentForm.setStyle({
      position: 'absolute',
      left: xy.left + 'px',
      top: (xy.top + commentObj.getHeight() + 10) + 'px',
      width: commentObj.getWidth() - 20 + 'px'
    });
    commentObj.setStyle({
      paddingBottom: (commentForm.getHeight() + 15 + 10) + 'px'
    });
    __LastCommentObj = commentObj;
  } else {
    commentForm.setStyle({
      position: 'static',
      left: 'auto',
      top: 'auto',
      width: 'auto'
    });
    __LastCommentObj = null;
  }

  return false;
}

function Comment_Delete(deleteHref, commentId, choice)
{
  choice = choice != null ? choice : false;
  p1 = confirm('Вы уверены, что хотите удалить комментарий?');
  if (!p1) {
    return false;
  }
  var thread = 0;
  if (choice) {
    p2 = confirm('Удалить также всю ветвь дискуссии?');
    if (p2) {
      thread = 1;
    }
  }

  new Ajax.Request(deleteHref, {
    method: 'post',
    parameters: {_ajax: 1, _thread: thread},
    onComplete: function(transport) {
      var msg = transport.responseText;
      if (msg == '-notfound') {}
      if (msg == '-forbidden') {alert('У вас не хватает прав для удаления этого комментария');}
      if (msg.indexOf('+deleted:') == 0) {
        var _ids = msg.substr(9).split(',');
        for (var i = 0; i < _ids.length; i++) {
          var _co = $('comment' + _ids[i]);
          if (_co) {
            _co.replace('<div class="removed-" style="margin-left:' + _co.getStyle('margin-left') + '">комментарий удалён <br /></div>');
          }
        }
      }
    }
  });

  return false;
}

var ListenMp3 = Class.create({
  prefix: '',
  prev_id: 0,
  initialize: function(prefix)
  {
    this.prefix = prefix;
  },
  open: function(id)
  {
    if (this.prev_id == id) {
      switch ($(this.prefix + id).style.display) {
        case 'block':
          $(this.prefix + id).style.display = 'none';
      $(this.prefix + id).innerHTML = '';
          break;
        case 'none':
          $(this.prefix + id).style.display = 'block';
          $(this.prefix + id).innerHTML = '<iframe src="/audio/show/'+id+'" frameborder="0" width="366" height="43" scrolling="no"></iframe>';
          break;
      }
    } else {
      $(this.prefix + id).style.display = 'block';
    $(this.prefix + id).innerHTML = '<iframe src="/audio/show/'+id+'" frameborder="0" width="366" height="43" scrolling="no"></iframe>';
      if (this.prev_id) {
        $(this.prefix + this.prev_id).style.display = 'none';
    $(this.prefix + this.prev_id).innerHTML = '';
    }
    }
    this.prev_id = id;
  }
});

var Podcast_Page = Class.create({
  initialize: function()
  {

  },
  switchSub: function(id)
  {
    switch ($('podcast_sub_'+id).style.display) {
      case 'none':
        this.openSub(id);
        break;
      case 'block':
        this.closeSub(id);
        break;
    }
  },
  openSub: function(id)
  {
    $('podcast_sub_'+id).style.display = 'block';
  },
  closeSub: function(id)
  {
    $('podcast_sub_'+id).style.display = 'none';
  },
  getList: function(cat_id, type)
  {
    var req = new Subsys_JsHttpRequest_Js('utf-8');
    req.onreadystatechange = function() {
      if (req.readyState == 4) {
        var htmlResult = req.responseJS["default"].htmlResult;
        $('podcast_list').innerHTML = htmlResult;
      }
    }
    req.open(null, '/podcast/getlist/', true);
    req.send({type: type, cat_id: cat_id});
  }
});

var Shedule_Full = Class.create({
  prev_w: 0,
  initialize: function(w)
  {
    this.prev_w = w;
  },
  switchW: function(w)
  {
    $('w_'+this.prev_w).className = '';
    $('w_'+w).className = 'sel';
    this.prev_w = w;
    this.printW(w);
  },
  printW: function(w)
  {
    var req = new Subsys_JsHttpRequest_Js('utf-8');
    req.onreadystatechange = function() {
      if (req.readyState == 4) {
        var htmlResult = req.responseJS["default"].htmlResult;
        $('shedule_full').innerHTML = htmlResult;
      }
    }
    req.open(null, '/shedule/full/'+w+'/ajax/', true);
    req.send({});
  }
});


var curVote=0;
function open_vote(id)
{
  document.getElementById("open_vote_" + curVote).style.display="none";
  document.getElementById("open_vote_" + id).style.display="";
  document.getElementById("closed_vote_" + curVote).style.display="";
  document.getElementById("closed_vote_" + id).style.display="none";
  curVote = id;
}

/*DoublePhoto section*/
function show_dj(current_dj) {
  var djs = $$('div[id^="_dj_"]');
  var djs1 = $$('img[id^="pic_dj_"]');
  for(var i=0;i<djs.length;i++) {
    djs[i].hide();
    //djs1[i].show();
    djs1[i].removeClassName('addboarder');
  }

  $(current_dj).show();
  //$('pic' + current_dj).hide();
  $('pic' + current_dj).addClassName('addboarder');

}
function moveDjPhotosLeft(max, offset)
{
  var width = $('_djblogs_photos').offsetWidth;
  var pos = parseInt($('_djblogs_photos').style.left);
  if (pos > -max + width) {
    $('_djblogs_photos').style.left = pos - offset + 'px';
  }
}
function moveDjPhotosRight(offset)
{
  var width = $('_djblogs_photos').offsetWidth;
  var pos = parseInt($('_djblogs_photos').style.left);
  if (pos < 0) {
    $('_djblogs_photos').style.left = pos + offset + 'px';
  }
}


var photo_images = new Array();
function changePhotoImage(id, rand, count)
{
  $('photo_image_'+rand+'_'+count).style.backgroundImage = 'url('+photo_images[rand][id]+')';
  $('photo_link_'+rand+'_'+count).href = '/photo/show/' + id;
}
function movePhotosLeft(max, offset, id)
{ 
	if (!id) {
	 var id = '';
	}
    var width = parseInt($('_photos_parent'+id).offsetWidth);
	var pos = parseInt($('_photos'+id).style.left);
	/*+ width*/	
	//alert(pos +' '+ max +' '+width);
	if (pos > -max + width) {
	  $('_photos'+id).style.left = pos - offset + 'px';
	}  
}
function movePhotosRight(offset, id)
{
  if (!id) {
	 var id = '';
  }
  var width = $('_photos'+id).offsetWidth;
  var pos = parseInt($('_photos'+id).style.left);
  if (pos < 0) {
    $('_photos'+id).style.left = pos + offset + 'px';
  }
}
function dropMove()
{
  $('_photos').style.left = '0px';
}
var _next_photo_file = new Array();
var _next_photo_cur_id = 0;
function changePhotoFile(file, obj, id)
{
  _next_photo_cur_id = id;
  $(obj).innerHTML = '<a href="javascript: nextPhoto();"><img src='+file+' alt="" /></a><br /><i>'+$('_photo_thumb_'+id).alt+'</i>';
}
function nextPhoto()
{
  var _next = _next_photo_file[_next_photo_cur_id];
  changePhotoFile(_next[1], 'main_photo', _next[0]);
  changePhotoThumb(_next[0]);
  if (!_next[2]) {
    movePhotosLeft(940, 94, false);
  } else {
    dropMove();
  }
}

function getRadioGroupValue(radioGroupObj)
{
  for (var i=0; i < radioGroupObj.length; i++)
    if (radioGroupObj[i].checked) return radioGroupObj[i].value;

  return null;
}


function doVote(id)
{
  //var value = getRadioGroupValue(document.voteform.votevar);
  var value = getRadioGroupValue($('voteform_' + id).votevar);
  if (!value){
    return document.getElementById("notselect").style.display="";
  }
  var req = new Ajax.Request('/vote/do/', {
      method: 'post',
      parameters: {qid: id , aid: value},
      onSuccess: function (t) {
      if(t.responseJSON.res != 3){
        document.getElementById("poll").innerHTML=t.responseJSON.res;
      }else{
        document.getElementById("already2").style.display="";
      }
      }
    });
}


function chartVote()
{
  var form = $('chart');
  var input = form['chartvote'];
  var value = $F(input);
   var req = new Ajax.Request('/vote/chart/do/', {
      method: 'post',
      parameters: {id: value},
      onSuccess: function (t) {
        document.getElementById("vote_ok").style.display="none";
        document.getElementById("unreg").style.display="none";
        document.getElementById("already").style.display="none";
        //alert(t.responseJSON.res);
        switch (t.responseJSON.res) {
          case '1':
            document.getElementById("vote_ok").style.display="block";
            break;
          case '2':
            document.getElementById("unreg").style.display="block";
            break;
          case '3':
            document.getElementById("already").style.display="block";
            break;
          }
        }
    });
}

var hccur = 0;
function hideContinue()
{
 var el = document.getElementById("carnival-in-cont");
 var pic1 = document.getElementById("cc_hide");
 var pic2 = document.getElementById("cc_show");
 if(hccur){
   el.style.display="";
   pic2.style.display="none";
   pic1.style.display="";
   hccur = 0;
 }else{
   el.style.display="none";
   pic1.style.display="none";
   pic2.style.display="";
   hccur = 1;
 }
}

function mustest_display()
{
  var _display = $('mustest_instructions').style.display;
  switch(_display) {
    case 'block':
      $('mustest_instructions').style.display = 'none';
      break;
    case 'none':
      $('mustest_instructions').style.display = 'block';
      break;
  }
}

function mt_changeVar(id)
{
  $('answer_1').value = id;
  if (id == 1 || id == 4 || id == 5 || id == 6) {
    $('sublist').style.display = 'block';
    $('sublist_ar').style.display = 'inline';
  } else {
    $('sublist').style.display = 'none';
    $('sublist_ar').style.display = 'none';
  }
  mt_checkSend();
}
function mt_changeSubvar(id)
{
  $('answer_2').value = id;
  mt_checkSend();
}
function mt_checkSend()
{
  var id = $('answer_1').value;
  if (id == 1 || id == 4 || id == 5 || id == 6) {
    var sub_id = $('answer_2').value;
    if (sub_id != '' && sub_id != 0)
      $('_mt_submit').disabled = false;
    else
      $('_mt_submit').disabled = true;
  } else {
    $('_mt_submit').disabled = false;
  }
}


var _mails_num = 1;
var _mails_arr = new Array();
var _mails_max = 6;
function mt_addMail()
{
  for (var i = 1; i <= _mails_num; i++) {
    _mails_arr[i] = $('mt_email_'+i).value;
  }
  if (_mails_num < _mails_max) {
    _mails_num++;
  }
  mt_renderMail();
}
function mt_delMail()
{
  for (var i = 1; i <= _mails_num; i++) {
    _mails_arr[i] = $('mt_email_'+i).value;
  }
  if (_mails_num > 1) {
    _mails_num--;
  }
  mt_renderMail();
}
function mt_renderMail()
{
  var _html = '';
  for (var i = 1; i <= _mails_num; i++) {
    var value = '';
    if (_mails_arr[i])
      value = _mails_arr[i];
    else
      value = 'Введите e-mail друга';
    if (i == _mails_num)
      _html += '<input class="text" type="text" size="48" value="'+value+'" id="mt_email_'+i+'" name="email['+i+']" /><a href="javascript: mt_addMail();"><img src="/themes/site/images/plus.gif" height="10" width="10" alt="Добавить" style="float: none; margin: 0; margin-left: 5px; margin-right: 5px;" /></a><a href="javascript: mt_addMail();">Добавить</a>';
    else
      _html += '<input class="text" type="text" size="48" value="'+value+'" id="mt_email_'+i+'" name="email['+i+']" />';
    if (_mails_num > 1 && i == _mails_num) {
      _html += '&nbsp;&nbsp;<a href="javascript: mt_delMail();">Удалить</a>';
    }
    _html += '<br />';
    $('_mt_m').innerHTML = _html;
  }
}
function mt_send()
{
  for (var i = 1; i <= _mails_num; i++) {
    _mails_arr[i] = $('mt_email_'+i).value;
  }
  var req = new Subsys_JsHttpRequest_Js('utf-8');
  req.onreadystatechange = function () {
    if (req.readyState == 4) {
      var answer = req.responseJS['default'].answer;
      alert(answer);
    }
  }
  req.open (null, '/mustest/invite/', true);
  req.send ({emails: _mails_arr});

}

var _mpo_link = 'mms://212.49.102.9/pilotfm';

function _mpo_32()
{
  _mpo_link = 'mms://212.49.102.9/pilotfm32';
  //mpo_stop();
  mpo_play();
  $('_mpo128_on').style.display = 'none';
  $('_mpo70_on').style.display = 'none';
  $('_mpo32_on').style.display = 'block';
  //$('_mpo_70_a').className = 'op';
  //$('_mpo_128_a').className = 'op-dash';
}

function _mpo_70()
{
  _mpo_link = 'mms://212.49.102.9/pilotfm64';
  //mpo_stop();
  mpo_play();
  $('_mpo128_on').style.display = 'none';
  $('_mpo70_on').style.display = 'block';
  $('_mpo32_on').style.display = 'none';
  //$('_mpo_70_a').className = 'op';
  //$('_mpo_128_a').className = 'op-dash';
}
function _mpo_128()
{
  _mpo_link = 'mms://212.49.102.9/pilotfm';
  //mpo_stop();
  mpo_play();
  $('_mpo128_on').style.display = 'block';
  $('_mpo70_on').style.display = 'none';
  $('_mpo32_on').style.display = 'none';
  //$('_mpo_70_a').className = 'op-dash';
  //$('_mpo_128_a').className = 'op';
}

function mpo_play()
{
  //$('_mpo_1').style.display = 'none';
  //$('_mpo_2').style.display = 'block';
  $('_wm_player').style.display = 'block';
  $('_wm_player').innerHTML = '<OBJECT width="430" height="65" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">'+
  '<param name="autoStart" value="True" /><param name="URL" value="'+_mpo_link+'" />'+
  '<param name="uiMode" value="mini" />'+
  '<EMBED type="application/x-mplayer2"'+
  'pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"'+
  'SRC="'+_mpo_link+'"'+
  'align="top" width="430" height="70" autostart="True" autosize="0" showcontrols="1" showdisplay="0"'+
  'EnableContextMenu="0"'+
  'ShowStatusBar="1">'+
  '</EMBED>'+
  '</OBJECT>';
}
function mpo_stop()
{
  $('_mpo_1').style.display = 'block';
  $('_mpo_2').style.display = 'none';
  $('_wm_player').style.display = 'none';
  $('_wm_player').innerHTML = '';
}
var _photo_thumb_prev_id = 0;
function changePhotoThumb(id)
{
  $('_photo_thumb_'+id).className = 'active';
  if (_photo_thumb_prev_id && _photo_thumb_prev_id != id)
    $('_photo_thumb_'+_photo_thumb_prev_id).className = '';
  _photo_thumb_prev_id = id;
}
var _pn_thumb_prev_id = new Array();
function gadget_ChangeThumb(id, rand)
{
  $('_pn_thumb_'+id+'_'+rand).className = 'active';
  if (_pn_thumb_prev_id[rand] != id) {
    $('_pn_thumb_'+_pn_thumb_prev_id[rand] + '_' + rand).className = '';
  }
  _pn_thumb_prev_id[rand] = id;
}

var default_search = 'Поиск';
function login_fild()
{
  var login_fild = document.getElementById('top-search');
  if (login_fild.value == default_search) {
    login_fild.value = '';
  }
}
function login_blur()
{
  var login_fild = document.getElementById('top-search');
  if (!login_fild.value) {
    login_fild.value = default_search;
  }
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}





