
//
//
//=========================================================
function show_texts (mode){

  if(mode){

    jQuery('a#anavi2').addClass('mnactive');
    jQuery('a#anavi1').removeClass('mnactive');
    jQuery('div.book_short').hide();
    jQuery('div.book_short').slideDown('slow');

  }else{

    jQuery('a#anavi1').addClass('mnactive');
    jQuery('a#anavi2').removeClass('mnactive');
    jQuery('div.book_short').hide();
    jQuery('div.book_short.texts_available').slideDown('slow');

  }

  return false;

}

// watch the mouse
//============================================================
var px, py;
document.onmousemove = get_mouse_xy;

//
function get_mouse_xy(e) {

  if (! document.all){
    px = e.pageX;
    py = e.pageY;
  }else{
    px = event.clientX;
    py = event.clientY;
  }

}


//
//
//=========================================================
function init_text_page(){
  jQuery('a.note').mouseover(show_footnote).mouseout(hide_footnote);
}

//
//
//=========================================================
function show_footnote(xx){

  hide_footnote();
  
  jQuery('body').append("<div id='footnote-popup'>" + jQuery(xx.target).attr('title') +"</div>");

  var bl = jQuery('#footnote-popup');
  baloon_location(bl);

}

//
//============================================================
function baloon_location(bl){

  var offy,ppy;
  if ((document.all?true:false) && !window.opera) {
    offy = document.documentElement.scrollTop;
    ppy = py;
  }else{
    offy = window.pageYOffset;
    ppy = py-offy;
  }
  if (px>(2*jQuery(window).width()/3)) bl.css('left', (px-bl.width()-30));
  else bl.css('left', (px+30));

  if (ppy>(bl.height()+25)) bl.css('top', ppy-bl.height()-25 + offy + "px");
  else bl.css('top', -5 + ppy + offy + "px");

}


//
//
//=========================================================
function hide_footnote(){
  try { jQuery('#footnote-popup').remove();  }
  catch(e) {}
}



//
//
//=========================================================
function close_pixa() {
  try { jQuery('#pixapop').remove();  }
  catch(e) {}
}

//
//
//=========================================================
function show_pixa(url, w, h, label){

  //
  var ww = w;
  var hh = h;
  var winW = jQuery(window).width();
  var winH = jQuery(window).height();

  if ((w/1.5+40)>winW || (h/1.5+40)>winH) { ww=w/2; hh=h/2;}
  else if (w>winW-40 || h>winH-40) { ww=w/1.5; hh=h/1.5;} 

  close_pixa();

  jQuery('body').append("<div id='pixapop'><a href='javascript:close_pixa();'>закрыть [&times;]</a><img src=\'" + url + "\' width='" + ww + "' height='" + hh +"'/><span>" + label +"</span></div>");

  var offy = 0;
  var IE = document.all?true:false;
  //if (IE && !window.opera) offy = document.documentElement.scrollTop;
  //else offy = window.pageYOffset;

  //
  jQuery('#pixapop')
    .css('top', (offy + (winH - hh - 50)/2) + 'px')
    .css('right', ((winW - ww)/2) + 'px')
    .css('width', ww + 'px')
    .click(close_pixa)
    .fadeIn("slow");

}

//
function init_jammer () {

  var winW = jQuery(window).width();

  if (winW>1160+60){

    var j = jQuery("<div id='jammer'><a href='" + jammer[1] + "' title='" + jammer[0] + "'><img src='/" + jammer[2] +"' alt='" + jammer[0] + "' title='" + jammer[0] + "' /></a></div>");
    j.css({"visibility": "visible", "left": -100});
    jQuery('body').append(j);
    jQuery('#jammer img').ready(function(){j.animate({"left": -1}, 800, 'swing');});

  }

}


