﻿var tick = {'testmove1': 0, 'testmove2': 0, 'testmove3': 0, 'testmove4': 0, 'testmove5': 0, 'menumove': 5000, 'bmenumove': 5000, 'innermove': 0, 'gr_opac': 0};
var mvItems = {};
var ntids = ['','comp','cat','map','act','exp'];
var btids = ['','atloc','tihoc','uvoc','',''];
var tids = [];
var mv_hds = [];

var go_link_first = 0;
var ia180 = 180;
var ia896 = 896;

var need_cat = 0;
var need_map = 0;
var need_doc = 0;
var need_first = 1;

function gtimer () {
  var preok = 1;

  for (var grp in mvItems) {
    if (grp.match('menu')) {

    if (grp == 'menumove') {
      tids = ntids;
    }
    if (grp == 'bmenumove') {
      tids = btids;
    }



    tick[grp] += mvItems[grp]['duration'];
    var progress = tick[grp]/10000;
    var pr_orig = progress;
    if (progress > 2) {
      progress = 2;
      pr_orig = 2;
      tick[grp] -= mvItems[grp]['duration'];
    }

    if (in_move[grp]) {
      var value = 0;

      if (progress < 0.5) {
        progress *= 2;
        value = 1-delta(progress);

        if (mv_act_prev[grp]) {
          var el = __el(mvItems[grp]['items'][mv_act_prev[grp]-1]['id']);
          var elo = __el(mvItems[grp]['items'][mv_act_prev[grp]-1]['id']+'opa');
          elo.className = 'menulink';
          el.className = 'sprite '+tids[mv_act_prev[grp]]+' pngfix';
          if (1 || navigator.userAgent.indexOf('MSIE') >= 0) {}
          else { elo.style.opacity = value; }
        }
        if (mv_act_now[grp]) {
          var el = __el(mvItems[grp]['items'][mv_act_now[grp]-1]['id']);
          var elo = __el(mvItems[grp]['items'][mv_act_now[grp]-1]['id']+'opa');
          elo.className = 'menulink_a';
          el.className = 'sprite '+tids[mv_act_now[grp]]+'_a pngfix';
          if (1 || navigator.userAgent.indexOf('MSIE') >= 0) {}
          else { elo.style.opacity = value; }
        }

      } else if (progress >= 0.5 && progress < 1.5) {
        progress -= 0.5;
        value = delta(progress);

        for (var i=0;i<mvItems[grp]['items'].length;i++) {
          mvItems[grp]['items'][i]['current'] = parseInt(mvItems[grp]['items'][i]['from'] + value*(mvItems[grp]['items'][i]['to'] - mvItems[grp]['items'][i]['from']));
          __el(mvItems[grp]['items'][i]['id']+'opa').style.left = mvItems[grp]['items'][i]['current'] + 'px';
        }

      } else if (progress >= 1.5) {
        progress = (progress - 1.5) * 2;
        value = delta(progress);

        if (mv_act_prev[grp]) {
          var el = __el(mvItems[grp]['items'][mv_act_prev[grp]-1]['id']);
          var elo = __el(mvItems[grp]['items'][mv_act_prev[grp]-1]['id']+'opa');
          elo.className = 'menulink';
          el.className = 'sprite '+tids[mv_act_prev[grp]]+' pngfix';
          if (1 || navigator.userAgent.indexOf('MSIE') >= 0) {}
          else { elo.style.opacity = value; }
        }
        if (mv_act_now[grp]) {
          var el = __el(mvItems[grp]['items'][mv_act_now[grp]-1]['id']);
          var elo = __el(mvItems[grp]['items'][mv_act_now[grp]-1]['id']+'opa');
          elo.className = 'menulink_a';
          el.className = 'sprite '+tids[mv_act_now[grp]]+'_a pngfix';
          if (1 || navigator.userAgent.indexOf('MSIE') >= 0) {}
          else { elo.style.opacity = value; }
        }

      }



    }




    if (pr_orig == 2) {
      in_move[grp] = 0;
      if (grp == 'menumove') {
        if (go_link_first) {
          if (mv_act_now[grp] == 1) {
            LoadLink ('/pages/company/');
          }
          if (mv_act_now[grp] == 2) {
            LoadLink ('/pages/catalog/');
          }
          if (mv_act_now[grp] == 3) {
            LoadLink ('/pages/map/');
          }
          if (mv_act_now[grp] == 4) {
            LoadLink ('/pages/act/');
          }
          if (mv_act_now[grp] == 5) {
            LoadLink ('/pages/experts/');
          }
        }
        go_link_first = 1;
      }
    } else {
      preok = 0;
    }




    }






    if (grp.match('inner')) {


      tick[grp] += mvItems[grp]['duration'];
      var progress = tick[grp]/10000;
      var pr_orig = progress;
      if (progress > 1) {
        progress = 1;
        pr_orig = 1;
        tick[grp] -= mvItems[grp]['duration'];
      }

      if (in_move[grp]) {
        if (in_move[grp] == 1) {
          var from = -1 * (mv_act_prev[grp]-1)*mvItems[grp]['total'];
          var to = -1 * (mv_act_now[grp]-1)*mvItems[grp]['total'];

          var ps = from + delta(progress)*(to - from);

          __el('innercont').style.top = (ps?ps:0) - ((navigator.userAgent.indexOf('MSIE') >= 0)?(mv_act_now[grp]-1):0) + 'px';
        } else {
          var from = ia180 - 1 * (mv_act_prev1[grp]-scrolllength)*ia896;
          var to = ia180 - 1 * (mv_act_now1[grp]-scrolllength)*ia896;

          var ps = from + delta(progress)*(to - from);

          __el('innercont').style.left = (ps?ps:0) + 'px';
        }
      }




      if (pr_orig == 1) {
        in_move[grp] = 0;

      } else {
        preok = 0;
      }




    }






    if (grp.match('opac')) {


      tick[grp] += mvItems[grp]['duration'];
      var progress = tick[grp]/10000;
      var pr_orig = progress;
      if (progress > 3) {
        progress = 3;
        pr_orig = 3;
        tick[grp] -= mvItems[grp]['duration'];
      }

      if (progress < 2) {}
      else {
        progress -= 2;
      if (in_move[grp]) {
        var itm = mvItems[grp]['items'];
        for (var i=0;i<itm.length;i++) {
          if (itm[i]['id'] == 'gr_opa'+mv_act_now[grp] && progress > 0.5) {
              var dd = delta((progress-0.5)*2);
              if (dd*100 < 10) {
                __el(itm[i]['id']).style.display = 'none';
              } else {
                __el(itm[i]['id']).style.display = 'block';              
              }
              __el(itm[i]['id']).style.opacity = 1*dd;
              __el(itm[i]['id']).style.filter = 'alpha(opacity='+parseInt(dd*100)+')';
          }
          if (itm[i]['id'] == 'gr_opa'+mv_act_prev[grp] && progress <= 0.5) {
              var dd = 1 - delta(2*progress);
              if (dd*100 < 10) {
                __el(itm[i]['id']).style.display = 'none';
              } else {
                __el(itm[i]['id']).style.display = 'block';              
              }
              __el(itm[i]['id']).style.opacity = 1*dd;
              __el(itm[i]['id']).style.filter = 'alpha(opacity='+parseInt(dd*100)+')';
          }
          if (itm[i]['id'] != 'gr_opa'+mv_act_prev[grp] && itm[i]['id'] != 'gr_opa'+mv_act_now[grp]) {

              __el(itm[i]['id']).style.display = 'none';

              __el(itm[i]['id']).style.opacity = 0;
              __el(itm[i]['id']).style.filter = 'alpha(opacity=0)';
          }
        }
      }
        progress += 2;

      }




      if (pr_orig == 3) {
        in_move[grp] = 0;

      } else {
        preok = 0;
      }




    }







    if (grp.match('test')) {

      tick[grp] += mvItems[grp]['duration'];
      var progress_total = tick[grp]/10000;
      var pr_orig = progress_total;
      if (progress_total > 3) {
        progress_total = 3;
        pr_orig = 3;
        tick[grp] -= mvItems[grp]['duration'];
      }




      var pr_to = 0;
      var pr_do = 0;
      var pr_mv = 0;
      var pr_ti = 0;
      var pr_di = 0;

      if (progress_total >= 0 && progress_total < 0.5) {
        pr_to = progress_total * 2;
        pr_do = 0;
        pr_mv = 0;
        pr_ti = 0;
        pr_di = 0;
      }
      if (progress_total >= 0.5 && progress_total < 1) {
        pr_to = 1;
        pr_do = (progress_total - 0.5) * 2;
        pr_mv = 0;
        pr_ti = 0;
        pr_di = 0;

        if (in_next[grp] &&  mv_act_now[grp] != in_next[grp]) {
              in_move[grp] = 0;
                 mvShowItem (grp,in_next[grp],1);
          in_next[grp] = null;
        }
      }
      if (progress_total >= 1 && progress_total < 2) {
	        for (var ii=0;ii<mv_hds.length;ii++) {
	          if (__el(mv_hds[ii])) {
	            __el(mv_hds[ii]).style.overflow = 'hidden';
	            __el(mv_hds[ii]).style.overflowX = 'hidden';
	          }
	        }
        pr_to = 1;
        pr_do = 1;
        pr_mv = progress_total - 1;
        pr_ti = 0;
        pr_di = 0;
      }
      if (progress_total >= 2 && progress_total < 2.5) {
        mv_act_opened[grp] = mv_act_next[grp];

        pr_to = 1;
        pr_do = 1;
        pr_mv = 1;
        pr_di = (progress_total - 2)*2;
        pr_ti = 0;
      }
      if (progress_total >= 2.5 && progress_total < 3) {
        pr_to = 1;
        pr_do = 1;
        pr_mv = 1;
        pr_di = 1;
        pr_ti = (progress_total - 2.5)*2;
      }
      if (progress_total >= 3) {
        pr_to = 1;
        pr_do = 1;
        pr_mv = 1;
        pr_ti = 1;
        pr_di = 1;
      } else {


        for (var i=0;i<3;i++) {
          if (mvItems[grp]['items'][i] && __el(mvItems[grp]['items'][i]['id']+'it')) {
            if (pr_mv == 0) {
              var dd = 1 - 1*delta(pr_do);

              

              if (dd*100 < 10) {
                __el(mvItems[grp]['items'][i]['id']+'it').style.display = 'none';
              __el(mvItems[grp]['items'][i]['id']+'it').style.filter = 'alpha(opacity=0)';
              } else {
                __el(mvItems[grp]['items'][i]['id']+'it').style.display = 'block';              
              __el(mvItems[grp]['items'][i]['id']+'it').style.opacity = 1*dd;
              __el(mvItems[grp]['items'][i]['id']+'it').style.filter = 'alpha(opacity='+parseInt(dd*100)+')';
              }


            }

            if (pr_mv == 1) {
              var dd = 1*delta(pr_di);
              
              if (dd*100 < 10) {
                __el(mvItems[grp]['items'][i]['id']+'it').style.display = 'none';
              __el(mvItems[grp]['items'][i]['id']+'it').style.filter = 'alpha(opacity=0)';
              } else if (mv_act_next[grp] == mvItems[grp]['items'][i]['id']) {
                __el(mvItems[grp]['items'][i]['id']+'it').style.display = 'block';              
              __el(mvItems[grp]['items'][i]['id']+'it').style.opacity = 1*dd;
              __el(mvItems[grp]['items'][i]['id']+'it').style.filter = 'alpha(opacity='+parseInt(dd*100)+')';

              }

            }
          }
        }

      }


      if (in_move[grp]) {
        var maxv = 0;
        var maxi = -1;
        var total = 0;
        var itm = mvItems[grp]['items'];
        for (var i=0;i<itm.length;i++) {
          var r = Math.floor ((itm[i]['to'] - itm[i]['from']) * delta(pr_mv) + itm[i]['from']);
          itm[i]['current'] = r;
          if (r > maxv) {
            maxv = r;
            maxi = i;
          }
          total += r;
        }

        if (total != mvItems[grp]['total']) {
          itm[maxi]['current'] += mvItems[grp]['total'] - total;
        }

        for (var i=0;i<itm.length;i++) {
          var el = __el(itm[i]['id']);
          if (el) {
            el.style.width = itm[i]['current']+'px';
            if (__el(itm[i]['id']+'ic')) {
//              __el(itm[i]['id']+'i').style.left = -mvItems[grp]['max_width'] + mvItems[grp]['max_width'] * ((itm[i]['current'] - mvItems[grp]['min_width']) / (mvItems[grp]['max_width'] - mvItems[grp]['min_width'])) + 'px';
              __el(itm[i]['id']+'i').style.left = mvItems[grp]['max_width'] * ((itm[i]['current'] - mvItems[grp]['min_width']) / (mvItems[grp]['max_width'] - mvItems[grp]['min_width'])) + 'px';
              __el(itm[i]['id']+'ic').style.left = - mvItems[grp]['max_width'] * ((itm[i]['current'] - mvItems[grp]['min_width']) / (mvItems[grp]['max_width'] - mvItems[grp]['min_width'])) + 'px';
            }
          }
        }
      }




      if (progress_total >= 3) {
        in_move[grp] = 0;

        if (in_next[grp] &&  mv_act_now[grp] != in_next[grp]) {
          mv_act_now[grp] = 0;
          mvShowItem (grp,in_next[grp],1);
          in_next[grp] = null;
        }

      } else {
        preok = 0;
      }





    }




  }

  if (preok) {
        for (var ii=0;ii<mv_hds.length;ii++) {
          if (__el(mv_hds[ii])) {
            __el(mv_hds[ii]).style.overflow = 'scroll';
            __el(mv_hds[ii]).style.overflowX = 'hidden';
          }
        }

    if (__el('loader')) __el('loader').style.display = 'none';
    
    if (need_first) {
      need_first = 0;
      if (need_cat) { 
        LoadFish (need_cat);
      }
      if (need_map) {
        LoadMap (need_map);
      }
      if (need_doc) {
        LoadDoc (need_doc);
      }
    }

  } else {
    setTimeout(arguments.callee,(navigator.userAgent.indexOf('Mozilla') >= 0)?25:15);
  }
}

function d(progress) {
    return 1 - Math.sin((1 - progress) * Math.PI/2);
}
function delta(progress) {
    if (progress < .5)
        return d(2 * progress) / 2;
    else
        return (2 - d(2 * (1 - progress))) / 2;
}

function mvAddGroup (id,width,duration,min_width,max_width) {
  mvItems[id] = {};
  mvItems[id]['items'] = [];
  mvItems[id]['total'] = width;
  mvItems[id]['min_width'] = min_width;
  mvItems[id]['max_width'] = max_width;
  mvItems[id]['duration'] = duration;
  mvItems[id]['start'] = 0;
}

function mvAddItem (grp,id,cr) {
  mvItems[grp]['items'].push ({
    id: id,
    current: cr?cr:mvItems[grp]['min_width'],
    from: cr?cr:mvItems[grp]['min_width'],
    to: cr?cr:mvItems[grp]['min_width']
  });
  if (cr) {
    mv_act_now[grp] = id;
  }
}

var mv_act_now = { 'innermove': 1,'gr_opac': 1 };
var mv_act_prev = {'menumove': 1, 'bmenumove': 1, 'innermove': 1, 'gr_opac': 2};
var mv_act_now1 = { 'innermove': 5 };
var mv_act_prev1 = {'menumove': 1, 'bmenumove': 1, 'innermove': 5};
var in_move = {};
var mv_act_opened = {};
var mv_act_next = {};
var in_next = {};
var canmove = {};
canmove['testmove1'] = 1;
canmove['testmove2'] = 1;
canmove['testmove3'] = 1;
canmove['testmove4'] = 1;
canmove['testmove5'] = 1;

function mvShowItem (grp,id,auto) {
  if (grp.match('menu')) {
    if (in_move[grp]) return;
    if (mv_act_now[grp] == id.replace('[b]?tab','')) return;

    in_move[grp] = 1;
    mv_act_prev[grp] = mv_act_now[grp];

    var first = 0;
    id.replace (/[b]?tab(\d)/i,function ($1,$2) { first = $2 });
    mv_act_now[grp] = first;

    var ord_sort = {1: 1, 2: 1, 3: 1, 4: 1, 5: 1};
    ord_sort[first] = 0;

    var new_order = [];
    new_order.push (0);
    new_order.push (first);
    for (var i=1;i<=mvItems[grp]['items'].length;i++) {
      if (ord_sort[i] == 1) {
        new_order.push (i);
      }
    }

    var cp = 0;
    for (var i=1;i<=mvItems[grp]['items'].length;i++) {
  //    mvItems[grp]['items'][new_order[i]-1]['current'] = mvItems[grp]['items'][new_order[i]-1]['to'];
      mvItems[grp]['items'][new_order[i]-1]['from'] = mvItems[grp]['items'][new_order[i]-1]['to'];
      mvItems[grp]['items'][new_order[i]-1]['to'] = cp;

      cp += parseInt(__el(mvItems[grp]['items'][new_order[i]-1]['id']+'opa').style.width) + 6;
    }

    tab_order = new_order;


    tick[grp] = 0;
  //  for (var i=0;i<mvItems[grp]['items'].length;i++) {
  //  }
  }



  if (grp.match('test')) {


    in_next[grp] = id;
    if (in_move[grp]) return;
    if (mv_act_now[grp] == id) return;
    if (1) {
  	  mv_act_next[grp] = id;
  	  mv_act_prev[grp] = mv_act_now[grp];
  	  mv_act_now[grp] = id;
  	  in_move[grp] = 1;
  	  canmove[grp] = 0;


    var sub = 0;



  	  mvItems[grp]['start'] = 0; // new Date().getTime() - parseInt(sub);
  	 tick[grp] = 0;
  	  for (var i=0;i<mvItems[grp]['items'].length;i++) {
  	    mvItems[grp]['items'][i]['from'] = mvItems[grp]['items'][i]['current'];
  	    if (mvItems[grp]['items'][i]['id'] == id) {
  	      mvItems[grp]['items'][i]['to'] = mvItems[grp]['max_width'];
  	    } else {
  	      mvItems[grp]['items'][i]['to'] = mvItems[grp]['min_width'];
  	    }
  	  }
    }





  }




  if (grp.match('inner')) {

    if (in_move[grp]) return;

    id = id.replace('innc','');

    if (id < scrolllength) {
      if (mv_act_now[grp] == id) return;

      in_move[grp] = 1;
      mv_act_prev[grp] = mv_act_now[grp];

      mv_act_now[grp] = id;

      tick[grp] = 0;
    } else {
      if (mv_act_now1[grp] == id) return;

      in_move[grp] = 2;
      mv_act_prev1[grp] = mv_act_now1[grp];

      mv_act_now1[grp] = id;

      tick[grp] = 0;
    }


  }



  if (grp.match('opac')) {

    if (in_move[grp]) return;

    id = id.replace('gr_opa','');

      if (mv_act_now[grp] == id) return;

      in_move[grp] = 1;
      mv_act_prev[grp] = mv_act_now[grp];
      mv_act_now[grp] = id;

      tick[grp] = 0;
  }


  if (! grp.match('test')) {

        for (var ii=0;ii<mv_hds.length;ii++) {
          if (__el(mv_hds[ii])) {
            __el(mv_hds[ii]).style.overflow = 'hidden';
            __el(mv_hds[ii]).style.overflowX = 'hidden';
          }
        }
  }

  setTimeout(gtimer,15);
}


var needscroll = 0;
function trygo (id) {
  if (mv_act_now1['innermove'] > scrolllength) {
    for (var i=1;i<=10;i++) {
      if (__el('lm_'+i)) {
        __el('lm_'+i).className = __el('lm_'+i).className.replace ('-a pngfix',' pngfix');
      }
    }
    __el('lm_'+id).className = __el('lm_'+id).className.replace (' pngfix','-a pngfix');

    mvShowItem ('innermove','innc'+scrolllength);
    needscroll = id;
    setTimeout (function () {
      if (in_move['innermove']) {
        setTimeout (arguments.callee,100);
      } else {
        if (needscroll) {
          mvShowItem ('innermove','innc'+needscroll);
          needscroll = 0;
        }
      }
    },100);
  } else {
    for (var i=1;i<=10;i++) {
      if (__el('lm_'+i)) {
        __el('lm_'+i).className = __el('lm_'+i).className.replace ('-a pngfix',' pngfix');
      }
    }
    __el('lm_'+id).className = __el('lm_'+id).className.replace (' pngfix','-a pngfix');
    mvShowItem ('innermove','innc'+id);
  }
}

function ShowFaq (id) {
  if (__el(id)) {
    if (__el(id).style.display == 'block') {
      __el(id).style.display = 'none';
    } else {
      __el(id).style.display = 'block';
    }
  }
}

function LoadLink (lnk) {
  __el('load_frame').src = lnk;
}

var load_linki_wait;
function LoadLinkI (lnk) {
  window.parent.load_linki_wait = lnk;
  window.parent.__el('ifr_frame').src = lnk;
  window.parent.__el('ifr_loader1').style.display = 'block';
  window.parent.__el('ifr_loader2').style.display = 'none';
}
function loadi_completed () {
  if (load_linki_wait) {
    __el('ifr_loader2').style.display = 'block';
    load_linki_wait = null;
  }
}

function HideI () {
//  window.parent.__el('ifr_frame').src = "/pages/blank/";
  window.parent.__el('ifr_loader1').style.display = 'none';
  window.parent.__el('ifr_loader2').style.display = 'none';
}
function HideII () {
//  __el('ifr_frame').src = "/pages/blank/";
  __el('ifr_loader1').style.display = 'none';
  __el('ifr_loader2').style.display = 'none';
}

function LoadFish (id) {
  sendQRequest ('ajax_page',{id: id},function (result) {
    var f_capt;
    var f_capt_lat;
    var f_icon;
    var f_img;
    var f_map;
    result = (''+result).replace (/<p>(.*?)<\/p>/,function ($1,$2) { f_capt = $2; return ''; });
    result = (''+result).replace (/<p>(.*?)<\/p>/,function ($1,$2) { f_capt_lat = $2; return ''; });
    result = (''+result).replace (/<p>(.*?)<\/p>/,function ($1,$2) { f_icon = $2; return ''; });
    result = (''+result).replace (/<p>(.*?)<\/p>/,function ($1,$2) { f_img = $2; return ''; });
    result = (''+result).replace (/<p>(.*?)<\/p>/,function ($1,$2) { f_map = $2; return ''; });
    
   (''+f_img).replace (/src="(.+?)"/,function ($1,$2) { f_img = $2; return ''; });

    var ind = mv_act_now['innermove'];
    __el('innt'+ind+'_1it').innerHTML = '<h1>'+f_capt+'</h1>'+'<h3>'+f_capt_lat+'</h3>'+result;
    __el('innt'+ind+'_2i').style.background = "url('"+f_img+"')";
    mvShowItem ('innermove','innc6');

    if (ammaps['ammap'+ind])  {
       amwait['ammap'+ind] = null
       ammaps['ammap'+ind].reloadData("/pages/map_data/?data="+encodeURIComponent(f_map));
    } else {
       amwait['ammap'+ind] = "/pages/map_data/?data="+encodeURIComponent(f_map);
    }

  });
}

var ammaps = {};
var amwait = {};
function amMapCompleted(map_id) {
  ammaps[map_id] = __el(map_id);
  if (amwait[map_id]) {
    ammaps[map_id].reloadData (amwait[map_id]);
    amwait[map_id] = null;
  }
}


function LoadMap (id) {
  sendQRequest ('ajax_page',{id: id},function (result) {
    var f_icon;
    var f_img;
    result = (''+result).replace (/<p>(.*?)<\/p>/,function ($1,$2) { f_icon = $2; return ''; });
    result = (''+result).replace (/<p>(.*?)<\/p>/,function ($1,$2) { f_img = $2; return ''; });
    
   (''+f_img).replace (/src="(.+?)"/,function ($1,$2) { f_img = $2; return ''; });

    var ind = mv_act_now['innermove'];
  
    var res1 = result;
    var res2;

    result.replace (/([\s\S]+)<p>~<\/p>([\s\S]+)/i,function ($1,$2,$3) { res1 = $2; res2 = $3; } );

    __el('innt'+ind+'_1it').innerHTML = res1;
    __el('innt'+ind+'_3it').innerHTML = res2;
    __el('innt'+ind+'_2i').style.background = "url('"+f_img+"')";
    mvShowItem ('innermove','innc3');

  });
}


function LoadDoc (id,capt) {
  sendQRequest ('ajax_page',{id: id, comments: 1},function (result) {

    var ind = mv_act_now['innermove'];
    __el('innt'+ind+'_1ita').innerHTML = result;

    mvShowItem ('innermove','innc6');

  });
}

function LoadMapBack () {

    mvShowItem ('innermove','innc2');
}

function LoadCatBack () {

    mvShowItem ('innermove','innc5');
}



function pager_next (el) {
  var ol = el.parentNode.parentNode;
  var li = ol.getElementsByTagName ('li');
  var l = li.length - 1;
  
  var b = 1;
  while (b < l && li[b].style.display == 'none') { b++; }
  var e = b;
  while (e < l && li[e].style.display == 'block') { e++; }
  e--;

  if (e+1 < l) {
    li[b].style.display = 'none';
    li[e+1].style.display = 'block';
  }
}


function pager_prev (el) {
  var ol = el.parentNode.parentNode;
  var li = ol.getElementsByTagName ('li');
  var l = li.length - 1;
  
  var b = 1;
  while (b < l && li[b].style.display == 'none') { b++; }
  var e = b;
  while (e < l && li[e].style.display == 'block') { e++; }
  e--;
  
  if (b > 1) {
    li[b-1].style.display = 'block';
    li[e].style.display = 'none';
  }
}

function FindEnter (e,v) {
  var ev = null;
  window.event ? ev = window.event : ev = e;
  if (ev && ev.keyCode == 13) {
    LoadLink ('/pages/search/?text='+encodeURIComponent(v));
  }
}

