function fblock_close(q) {layer('fblock_'+q).style.display = 'none';}
function ablock_close(q,h)
{
 layer('ablock_'+q).style.display = 'none';
 layer('ablock_'+h).style.zIndex = 1;
 for (var k in zmap)
 {
  if (typeof zmap[k][h] != 'undefined')
  {
   var m = 0;
   var mk = null;
   for (var kk in zmap[k])
   {
    if (zmap[k][kk] > m && kk != h && (typeof (zmap_open[h]) != 'undefined') && zmap_open[h] == true) {m = zmap[k][kk]; mk = kk;}
   }
   //console.log('mk='+mk);
   if (mk != null)
   {
    setTimeout('ablock_setfocus(\''+mk+'\',0);',200);
   }
  }
 }
 zmap_open[h] = false;
}
var zmap = new Array();
zmap[0] = {_top: 'bookmarks', bookmarks: 6, mediaplayer: 5};
var zmap_open = {};
function ablock_setfocus(l,g)
{
 zmap_open[l] = true;
 var o = zmap[g][l];
 zmap[g][l] = zmap[g][zmap[g]['_top']];
 if (layer('ablock_'+l).exists()) layer('ablock_'+l).style.zIndex = zmap[g][zmap[g]['_top']];
 //console.log('set '+l+' to '+layer('ablock_'+l).style.zIndex);
 zmap[g][zmap[g]['_top']] = o;
 if (layer('ablock_'+zmap[g]['_top']).exists()) layer('ablock_'+zmap[g]['_top']).style.zIndex = o;
 //console.log('set '+zmap[g]['_top']+' to '+layer('ablock_'+zmap[g]['_top']).style.zIndex);
 zmap[g]['_top'] = l;
}
setInterval(calc_positions_onscroll,50);
document.onclick_callbacks = new Array();
if (top.frames.length != 0) {top.location = self.document.location;}
function calc_positions_onscroll()
{
 var l = layer('ajax_loading_message');
 if (!l.exists()) {return;}
 var x = getWindowWidth()/2-100+getScrollX();
 var y = getWindowHeight()/2+getScrollY();
 l.moveTo(x,y);
}
function htmlspecialchars(s)
{
 var r = s;
 r = r.replace(new RegExp('&','g'),'&amp;');
 r = r.replace(new RegExp('"','g'),'&quot;');
 r = r.replace(new RegExp('\'','g'),'&#039;');
 r = r.replace(new RegExp('<','g'),'&lt;');
 r = r.replace(new RegExp('>','g'),'&gt;');
 return r;
}
function myescape(s)
{
 if (typeof encodeURIComponent != 'undefined') {return encodeURIComponent(s);}
 return escape(s).replace(new RegExp('\\+','g'), '%2B');
}
function addslashes(s)
{
 var r = s;
 r = r.replace(new RegExp('\\\\','g'),'\\\\');
 r = r.replace(new RegExp('\'','g'),'\\\'');
 r = r.replace(new RegExp('"','g'),'\\\"');
 r = r.replace(new RegExp('\n','g'),'\\n');
 r = r.replace(new RegExp('\r','g'),'\\r');
 return r;
}
function Dump(d,l) {
    if (l == null) l = 1;
    var s = '';
    if (typeof(d) == "object") {
        s += typeof(d) + " {\n";
        for (var k in d) {
            for (var i=0; i<l; i++) s += "  ";
            s += k+": " + Dump(d[k],l+1);
        }
        for (var i=0; i<l-1; i++) s += "  ";
        s += "}\n"
    } else {
        s += "" + d + "\n";
    }
    return s;
}
function Dump_small(d,l) {
    if (l == null) l = 1;
    var s = '';
    if (typeof(d) == "object") {
        s += typeof(d) + " {\n";
        for (var k in d) {
            for (var i=0; i<l; i++) s += "  ";
            s += k+": " +d[k];
        }
        for (var i=0; i<l-1; i++) s += "  ";
        s += "}\n"
    } else {
        s += "" + d + "\n";
    }
    return s;
}
document.onkeydown_callbacks = new Array();
document.onkeydown_callbacks['top_search_query'] = function(e,code)
{
 /* ctrl + up	 */ if ((code == 38) && (e.ctrlKey == true)) {if (layer('top_search_query').exists()) {layer('top_search_query').object.focus();}}
}
document.onkeydown = function(e) 
{
 var code;
 if (!e) {var e = window.event;}
 if (e.keyCode) {code = e.keyCode;}
 else if (e.which) {code = e.which;}
 for (var k in document.onkeydown_callbacks) {document.onkeydown_callbacks[k](e,code);}
}

document.onkeyup_callbacks = new Array();
document.onkeyup = function(e) 
{
 var code;
 if (!e) {var e = window.event;}
 if (e.keyCode) {code = e.keyCode;}
 else if (e.which) {code = e.which;}
 for (var k in document.onkeyup_callbacks) {document.onkeyup_callbacks[k](e,code);}
}
setTimeout(function()
{
 document.onclick = function(e) 
 {
  for (var k in document.onclick_callbacks) {if (document.onclick_callbacks[k] != null) {document.onclick_callbacks[k](e);}}
 }
},300);
function myGetSelection(Field)
{
 if (typeof(Field.selectionStart) != 'undefined') {return Field.value.substring(Field.selectionStart,Field.selectionEnd);}
 else if (document.selection && document.selection.createRange) {return document.selection.createRange().text;}
 else if (window.getSelection) {return window.getSelection() + '';}
 else {return false;}
}
function insertAtCursor(myField, myValue)
{
 if (document.selection) {myField.focus(); document.selection.createRange().text = myValue;}
 else if (myField.selectionStart || myField.selectionStart == '0') {myField.value = myField.value.substring(0,myField.selectionStart) + myValue + myField.value.substring(myField.selectionEnd,myField.value.length);}
 else {myField.value += myValue;}
}
/************************************************\
| KLayers 2.97                                   |
| DHTML Library for Internet Explorer 4.* - 6.*, |
| Netscape 4.* - 7.*, Mozilla, Opera 5.* - 7.*   |
| Copyright by Kruglov S. A. (kruglov.ru) 2003   |
\************************************************/

/***  See for description and latest version  ***\
\***  http://www.kruglov.ru/klayers/          ***/

function initKLayers(){
  isDOM=document.getElementById?true:false
  isOpera=isOpera5=window.opera && isDOM
  isOpera6=isOpera && window.print
  isOpera7=isOpera && document.readyState
  isMSIE=isIE=document.all && document.all.item && !isOpera
  isStrict=document.compatMode=='CSS1Compat'
  isNN=isNC=navigator.appName=="Netscape"
  isNN4=isNC4=isNN && !isDOM
  isMozilla=isNN6=isNN && isDOM

  if(!isDOM && !isNC && !isMSIE && !isOpera){
    KLayers=false
    return false
  }

  pageLeft=0
  pageTop=0

  KL_imgCount=0
  KL_imgArray=new Array()

  KL_imageRef="document.images[\""
  KL_imagePostfix="\"]"
  KL_styleSwitch=".style"
  KL_layerPostfix="\"]"

  if(isNN4){
    KL_layerRef="document.layers[\""
    KL_styleSwitch=""
  }

  if(isMSIE){
    KL_layerRef="document.all[\""
  }

  if(isDOM){
    KL_layerRef="document.getElementById(\""
    KL_layerPostfix="\")"
  }

  KLayers=true
  return true
}

initKLayers()

// document and window functions:

function KL_getBody(w){
  if(!w) w=window
  if(isStrict){
    return w.document.documentElement
  }else{
    return w.document.body
  }
}

function getWindowLeft(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return w.screenLeft
  if(isNN || isOpera) return w.screenX
}

function getWindowTop(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return w.screenTop
  if(isNN || isOpera) return w.screenY
}

function getWindowWidth(w){
  if(!w) w=window
  if(isMSIE) return KL_getBody(w).clientWidth
  if(isNN || isOpera) return w.innerWidth
}

function getWindowHeight(w){
  if(!w) w=window
  if(isMSIE) return KL_getBody(w).clientHeight
  if(isNN || isOpera) return w.innerHeight
}

function getDocumentWidth(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return KL_getBody(w).scrollWidth
  if(isNN) return w.document.width
  if(isOpera) return w.document.body.style.pixelWidth
}

function getDocumentHeight(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return KL_getBody(w).scrollHeight
  if(isNN) return w.document.height
  if(isOpera) return w.document.body.style.pixelHeight
}

function getScrollX(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return KL_getBody(w).scrollLeft
  if(isNN || isOpera) return w.pageXOffset
}

function getScrollY(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return KL_getBody(w).scrollTop
  if(isNN || isOpera) return w.pageYOffset
}

function preloadImage(imageFile){
  KL_imgArray[KL_imgCount]=new Image()
  KL_imgArray[KL_imgCount++].src=imageFile
}

var KL_LAYER=0
var KL_IMAGE=1

function KL_findObject(what,where,type){
  var i,j,l,s
  var len=eval(where+".length")
  for(j=0;j<len;j++){
    s=where+"["+j+"].document.layers"
    if(type==KL_LAYER){
      l=s+"[\""+what+"\"]"
    }
    if(type==KL_IMAGE){
      i=where+"["+j+"].document.images"
      l=i+"[\""+what+"\"]"
    }
    if(eval(l)) return l
    l=KL_findObject(what,s,type)
    if(l!="null") return l
  }
  return "null"
}

function KL_getObjectPath(name,parent,type){
  var l=((parent && isNN4)?(parent+"."):(""))+((type==KL_LAYER)?KL_layerRef:KL_imageRef)+name+((type==KL_LAYER)?KL_layerPostfix:KL_imagePostfix)
  if(eval(l))return l
  if(!isNN4){
    return l
  }else{
    return KL_findObject(name,"document.layers",type)
  }
}

function layer(name){
  return new KLayer(name,null)
}

function layerFrom(name,parent){
  if(parent.indexOf("document.")<0) parent=layer(parent).path
  return new KLayer(name,parent)
}

function image(name){
  return new KImage(name,null)
}

function imageFrom(name,parent){
  if(parent.indexOf("document.")<0) parent=layer(parent).path
  return new KImage(name,parent)
}

// class "KLayer":

function KLayer(name,parent){
  this.path=KL_getObjectPath(name,parent,KL_LAYER)
  this.object=eval(this.path)
  if(!this.object)return
  this.style=this.css=eval(this.path+KL_styleSwitch)
}

KLP=KLayer.prototype

KLP.isExist=KLP.exists=function(){
  return (this.object)?true:false
}

function KL_getPageOffset(o){ 
  var KL_left=0
  var KL_top=0
  do{
    KL_left+=o.offsetLeft
    KL_top+=o.offsetTop
  }while(o=o.offsetParent)
  return [KL_left, KL_top]
}

KLP.getLeft=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera) return o.offsetLeft-pageLeft
  if(isNN4) return o.x-pageLeft
}

KLP.getTop=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera) return o.offsetTop-pageTop
  if(isNN4) return o.y-pageTop
}

KLP.getAbsoluteLeft=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera) return KL_getPageOffset(o)[0]-pageLeft
  if(isNN4) return o.pageX-pageLeft
}

KLP.getAbsoluteTop=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera) return KL_getPageOffset(o)[1]-pageTop
  if(isNN4) return o.pageY-pageTop
}

KLP.getWidth=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera7) return o.offsetWidth
  if(isOpera) return this.css.pixelWidth
  if(isNN4) return o.document.width
}

KLP.getHeight=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera7) return o.offsetHeight
  if(isOpera) return this.css.pixelHeight
  if(isNN4) return o.document.height
}

KLP.getZIndex=function(){ //deprecated
  return this.css.zIndex
}

KLP.setLeft=KLP.moveX=function(x){
  x+=pageLeft
  if(isOpera){
    this.css.pixelLeft=x
  }else if(isNN4){
    this.object.x=x
  }else{
    this.css.left=x+"px"
  }
}

KLP.setTop=KLP.moveY=function(y){
  y+=pageTop
  if(isOpera){
    this.css.pixelTop=y
  }else if(isNN4){
    this.object.y=y
  }else{
    this.css.top=y+"px"
  }
}

KLP.moveTo=KLP.move=function(x,y){
  this.setLeft(x)
  this.setTop(y)
}

KLP.moveBy=function(x,y){
  this.moveTo(this.getLeft()+x,this.getTop()+y)
}

KLP.setZIndex=KLP.moveZ=function(z){ //deprecated
  this.css.zIndex=z
}

KLP.setVisibility=function(v){
  this.css.visibility=(v)?(isNN4?"show":"visible"):(isNN4?"hide":"hidden")
}

KLP.show=function(){
  this.setVisibility(true)
}

KLP.hide=function(){
  this.setVisibility(false)
}

KLP.isVisible=KLP.getVisibility=function(){
  return (this.css.visibility.toLowerCase().charAt(0)=='h')?false:true
}

KLP.setBgColor=function(c){
  if(isMSIE || isMozilla || isOpera7){
    this.css.backgroundColor=c
  }else if(isOpera){
    this.css.background=c
  }else if(isNN4){
    this.css.bgColor=c
  }
}

KLP.setBgImage=function(url){
  if(isMSIE || isMozilla || isOpera6){
    this.css.backgroundImage="url("+url+")"
  }else if(isNN4){
    this.css.background.src=url
  }
}

KLP.setClip=KLP.clip=function(top,right,bottom,left){
  if(isMSIE || isMozilla || isOpera7){
    this.css.clip="rect("+top+"px "+right+"px "+bottom+"px "+left+"px)"
  }else if(isNN4){
    var c=this.css.clip
    c.top=top
    c.right=right
    c.bottom=bottom
    c.left=left
  }
}

KLP.scrollTo=KLP.scroll=function(windowLeft,windowTop,windowWidth,windowHeight,scrollX,scrollY){
  if(scrollX>this.getWidth()-windowWidth) scrollX=this.getWidth()-windowWidth
  if(scrollY>this.getHeight()-windowHeight) scrollY=this.getHeight()-windowHeight
  if(scrollX<0)scrollX=0
  if(scrollY<0)scrollY=0
  var top=0
  var right=windowWidth
  var bottom=windowHeight
  var left=0
  left=left+scrollX
  right=right+scrollX
  top=top+scrollY
  bottom=bottom+scrollY
  this.moveTo(windowLeft-scrollX,windowTop-scrollY)
  this.setClip(top,right,bottom,left)
}

KLP.scrollBy=KLP.scrollByOffset=function(windowLeft,windowTop,windowWidth,windowHeight,scrollX,scrollY){
  var X=-parseInt(this.css.left)+windowLeft+scrollX
  var Y=-parseInt(this.css.top)+windowTop+scrollY
  this.scroll(windowLeft,windowTop,windowWidth,windowHeight,X,Y)
}

KLP.scrollByPercentage=function(windowLeft,windowTop,windowWidth,windowHeight,scrollX,scrollY){
  var X=(this.getWidth()-windowWidth)*scrollX/100
  var Y=(this.getHeight()-windowHeight)*scrollY/100
  this.scroll(windowLeft,windowTop,windowWidth,windowHeight,X,Y)
}

KLP.write=function(str){
  var o=this.object
  if(isNN4){
    var d=o.document
    d.open()
    d.write(str)
    d.close()
  }else{
    o.innerHTML=str
  }
}
KLP.swrite=function(str)
{
 this.write('');
 this.sadd(str);
}
KLP.sadd=function(str)
{
 var el = document.createElement('span');
 el.innerHTML = str;
 var a = new Array();
 for (var k = 0; k < el.childNodes.length; k++) {a[k] = el.childNodes[k];}
 for (var k in a)
 {
  if (a[k].tagName == 'SCRIPT') {eval(a[k].innerHTML);}
  else {this.object.appendChild(a[k]);}
 }
}
KLP.add=function(str){
  var o=this.object
  if(isNN4){
    o.document.write(str)
  }else{
    o.innerHTML+=str
  }
}

// class "KImage":

KIP=KImage.prototype

function KImage(name){
  this.path=KL_getObjectPath(name,false,KL_IMAGE)
  this.object=eval(this.path)
}

KIP.isExist=KIP.exists=function(){
  return (this.object)?true:false
}

KIP.getSrc=KIP.src=function(){
  return this.object.src
}

KIP.setSrc=KIP.load=function(url){
  this.object.src=url
}
mousex = 0
mousey = 0
mouseFollower = function() {}
mouseFollower_ext = function() {}
setTimeout(function() {
if(isNC4) document.captureEvents(Event.MOUSEMOVE)
if(isMSIE || isOpera7){
 document.onmousemove=function(){
   mousex=event.clientX+document.body.scrollLeft
   mousey=event.clientY+document.body.scrollTop
   mouseFollower()
   mouseFollower_ext()
   return true
 }
}else if(isOpera){
 document.onmousemove=function(){
   mousex=event.clientX
   mousey=event.clientY
   mouseFollower()
   mouseFollower_ext()
   return true
 }
}else if(isNC){
 document.onmousemove=function(e){
   mousex = e.pageX
   mousey = e.pageY
   mouseFollower()
   mouseFollower_ext()
   return true
 }  
}
},100);
function enlarge_media(id)
{
 var ln = 'media_'+id+'_player';
 var p = layer(ln);
 if (layer('media_'+id+'_head_details').style.display != 'none')
 {
  p.className = '';
  
  p.style.position = 'static';
  p.style.left = '0px';
  p.style.top = '0px';
  p.style.border = '';

  p.moveTo(0,0);
  p.style.width = '100%';
  p.style.height = '';
  layer('media_'+id+'_plugin_embed').style.height = isMSIE?'247px':'';
  layer('media_'+id+'_plugin_embed').style.width = '';
  p.style.border = '';
  layer('media_'+id+'_head_details').style.display = 'none';
  layer('media_'+id+'_move').style.display = 'none';
  return;
 }
 m_obj_x = m_obj_x_s = 100;
 m_obj_y = m_obj_y_s = 300;
 window.mpwindow = mpwindow = p;
 p.className = 'mpwindow';
 if (!isMSIE)
 {
  p.style.position = 'fixed';
  p.style.left = '300px';
  p.style.top = '100px';
 }
 else {p.style.position = 'absolute';}
 p.style.width = '500px';
 p.style.height = '420px';
 p.style.border = '1px solid #a2d41b';
 layer('media_'+id+'_plugin_embed').style.height = p.style.height;
 layer('media_'+id+'_head_details').style.display = '';
 layer('media_'+id+'_move').style.display = '';
 setDragAndDrop(layer('media_'+id+'_move').object,p);
 return;
}
function close_media(id)
{
 var p = layer('media_'+id+'_player');
 if (layer('media_'+id+'_head_details').style.display != 'none')
 {
  p.style.position = '';
  p.moveTo(0,0);
  p.style.width = '100%';
  p.style.height = '';
  layer('media_'+id+'_plugin_embed').style.height = isMSIE?'247px':'';
  layer('media_'+id+'_plugin_embed').style.width = '';
  layer('media_'+id+'_head_details').style.display = 'none';
  layer('media_'+id+'_move').style.display = 'none';
  p.style.border = '';
 }
 layer('media_'+id+'_plugin').write('');
 layer('media_'+id+'_player').style.display = 'none';
 if (layer('media_'+id+'_thumb').exists()) layer('media_'+id+'_thumb').style.display = '';
 layer('media_'+id+'_playbutton').style.display = '';
 return;
}
function play_media(id,url,video,l)
{
 layer('media_'+id+'_player').style.display = '';
 if (isMSIE)
 {
  layer('media_'+id+'_plugin').write(
   '<object id="media_'+id+'_plugin_embed" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" style="cursor:hand" width="100%"'+(!video?' height="45"':'')+'>'
   +'<param name="URL" value="'+htmlspecialchars(url)+'" />'
   +'<param name="SendPlayStateChangeEvents" value="True" />'
   +'<param name="autoplay" value="true" />'
   +'<'+'/object><br />');
 }
 else
 {
  layer('media_'+id+'_plugin').write(
   '<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" standby="Loading Microsoft® Windows® Media Player components..." type="application/x-oleobject"'+'>'
   +'<param name="FileName" value="'+htmlspecialchars(url)+'" />'
   +'<param name="SendPlayStateChangeEvents" value="True" />'
   +'<param name="AutoStart" value="true" />'
   +'<param name="ShowControls" value="true" />'
   +'<param name="ShowStatusBar" value="true" />'
   +'<embed src="'+htmlspecialchars(url)+'" id="media_'+id+'_plugin_embed" autostart="1"	showcontrols="1" style="cursor:hand" width="100%"'+(!video?' height="40"':'')+' name="plugin" type="application/x-mplayer2"; />'
   +'<'+'/object><br />');
 }
 l.style.display = 'none';
 if (layer('media_'+id+'_thumb').exists()) layer('media_'+id+'_thumb').style.display = 'none';
 return false;
}
helpcursor_active = false;
function activate_helpcursor()
{
 document.body.style.cursor = 'help';
 helpcursor_active = true;
 setTimeout(function()
 {
  onclick_callbacks['un_helpcursor'] = function()
  {
   document.body.style.cursor = 'default';
   helpmsg_hide();
   onclick_callbacks['un_helpcursor'] = null;
   helpcursor_active = false;
  }
 },100);
}
function helpmsg_show(msg)
{
 if (!helpcursor_active) {return;}
 var l = layer('span_helpmsg');
 l.write('<fieldset><table border="0"><tr><td><font size="20">?</font><td>'+msg+'</td></tr></table></fieldset>');
 l.moveTo(mousex+40,mousey);
 l.show();
}
function helpmsg_hide()
{
 if (!helpcursor_active) {return;}
 layer('span_helpmsg').hide();
}