// all pages including this file should define global variables mtn_res,mtn_screen,result_colw,cdlist_colw,cdlist_margin,mtn_thumbsize
mtn_eset=0;mtn_res=0;mtn_showid=-1;mtn_spent=new Array(96);mtn_touched=new Array(96);mtn_touched_any=0;mtn_inmove=false;setTimeout("mtn_scnav(0)",250);aaa=0;mtn_tools='';mtn_sclim=100;grabx=0;graby=0;cdsingle='S';mtn_thumbsize=-1;mtn_insearch=1;
// liquid --------------------------------------------------------
function mtn_stb(size,force) {
	if (typeof(result_colw)=='undefined') return;
    if (!document.getElementById) {return;}
    var ww=mtn_ww();
    if (!ww) {return;}
    var significant=0;
    if (size==-1) { size=mtn_thumbsize; }
    //alert(mtn_res);
    if (mtn_res && (force || mtn_cols(mtn_screen,0,mtn_thumbsize)!=mtn_cols(ww,0,size))) {
        significant=1;var td;
        var cols=mtn_cols(ww,0,size);
        var ntb='<table id="stb" cellspacing="0"><tr>';
        var rows=Math.ceil(mtn_res/cols); 
        for (var y=0;y<rows;y++) { for (var z=0;z<3;z++) { for (var x=0;x<cols;x++) { i=y*cols+x; iht='<div class="y">&nbsp;</div>'; o=find_object('s'+z+''+i); if (o) { iht=o.innerHTML; } ntb+='<td id="s'+z+''+i+'">'+iht+'</td>'; } if (z<2 || y<rows-1) { ntb+="</tr><tr>"; } } }
        ntb+='</tr></table>'; o=find_object('stbb'); o.innerHTML=ntb; mtn_eset=0; mtn_e();  
        for (var i=0;i<mtn_res;i++){mtn_showsw(i,mtn_showicon(i)?1:0);} 
    }
    if (significant) {  mtn_bsess('screen',ww); } mtn_screen=ww;
}
function mtn_cols(swd,cd,size) { var mfit=Math.max(1,Math.floor(swd/result_colw[size]));var rm=99; for(var i=mfit;i>2&&i>mfit-3;i--){var nrm=(i-mtn_res%i)%i; if(nrm<rm){ rm=nrm;bfit=i; } } return bfit; }
// attach events --------------------------------------------------------
function mtn_e() {    
    var c;var x;var y;var n;
    if (mtn_eset){return;}else{mtn_eset=1;}
    for (x=0;x<mtn_res;x++) { c=find_object('s1'+x); if (c) { mtn_attach(c,0); } c=find_object('s0'+x); if (c) { mtn_attach(c,1); } } }
function mtn_attach(c,dri) {
    var y;var n;var s;var r;
    for (y=0;y<c.childNodes.length;y++) { n=c.childNodes[y]; if (n) { if (n.nodeName=='IMG') { 
        if (dri==-4) { s=new String(n.src);n.src=s.replace(/c([0-9][a-z]?.gif)$/,"$1"); } 
        else if (dri==-3) { s=new String(n.src);n.src=s.replace(/([0-9][a-z]?.gif)$/,"c$1"); } 
        else if (dri>1) {dri-=2;s=new String(n.src);r=new RegExp("/"+result_cold[mtn_thumbsize],"i");n.src=s.replace(r,"/"+result_cold[dri]);} 
        else if (dri>0) {n.onmousedown=mtn_grab; n.onmouseover=mtn_showdata; n.onmousemove=l_ex.move;n.onmouseout=l_ex.go;} 
        else { n.onmouseover=mtn_boxon; n.onmouseout=mtn_boxout;if(n.src.search(new RegExp("0.gif$","gi"))>=0){n.onmousemove=l_ex.move;}if(n.src.search(new RegExp("2y?.gif$","gi"))>=0){if(dri==-1){s=new String(n.src);r=new RegExp("2.gif$","i");n.src=s.replace(r,"2y.gif");}else if(dri==-2){s=new String(n.src);r=new RegExp("2y.gif$","i");n.src=s.replace(r,"2.gif");}else{n.onclick=mtn_boxclick;}}if(n.src.search(new RegExp("3[a-z]?.gif$","gi"))>=0){
        n.onclick=l_offer.gogo;n.onmousemove=l_offer.show;
        }} 
    } else { mtn_attach(n,dri) } } } }
// 5 boxes rollovers --------------------------------------------------------
function mtn_boxon(ev) { mtn_box(ev,0); }
function mtn_boxout(ev) { mtn_box(ev,1); }
function mtn_boxclick(ev) { mtn_box(ev,2); }
function mtn_box(ev,out) {
    var e=ev?ev:event; var so; var p=e.target?e.target:e.srcElement; 
    if (p.src.search(new RegExp("0.gif$","gi"))>=0) { l_ex.go(); }
    var pn=p.parentNode; 
    while (pn.parentNode && pn.nodeName!="TD") { pn=pn.parentNode; }
    if (pn.id.search(new RegExp("^s1([0-9]+)$","gi"))>=0){var i=RegExp.$1;if(p.src.search(new RegExp("([0-9])(y?)[a-z]?.gif$","gi"))>=0) {
        if (out==2) { c=find_object('s0'+i); if(c) { var iid='';
          if (c.childNodes[0].childNodes.length) {
 			iid=mtn_escape(c.childNodes[0].childNodes[0].id); }
          else { iid=mtn_escape(c.childNodes[0].id); }
          if (iid=="undefined") { iid=c.childNodes[0].childNodes[1].id; } // Safari...
          if(RegExp.$2=='y') { xmlreq('x_lb.php?box=1&folder_id='+folder_id+'&lb=rm'+mtn_lb+'&image='+cdsingle+iid,mtn_resp); }
          else { xmlreq('x_lb.php?box=1&folder_id='+folder_id+'&lb='+mtn_lb+'&image='+iid+'&cdsingle='+cdsingle,mtn_resp); }
        }}
        else { var ii=RegExp.$1+RegExp.$2; var r=find_object('o'+i); if (r) { mtn_rollm(r,cdsingle,out?'s':ii); } }
    }}}
// floating nav --------------------------------------------------------
function mtn_scnav(i) {
    var scd=0;
    if (document.documentElement.scrollTop) { scd=document.documentElement.scrollTop } else if (document.body) { document.body.scrollTop; }
    var ls='hidden'; var dw=find_object('dw');
    if (dw) { 
    var scex=dw.scrollTop; var sco=find_handle('fixbar');
    if (scex) { scd=scex; } if (scd>mtn_sclim) { ls='visible'; } else { ls='hidden'; if (l_lb.open && l_lb.which=='lbmenufl') {l_lb.go(); } } if (sco) { sco.visibility=ls; }  } // remove the floating nav if we ar high in the page and the lightbox layer on it if it was open.
    i++;setTimeout("mtn_scnav("+i+")",250);if(i%6==0){mtn_stb(-1);}}
// drag & drop --------------------------------------------------------
function mtn_cursor(ev,vis) {
    var x;var y;var d=find_handle('drag');
    y=ev.pageY?ev.pageY:ev.y; x=ev.pageX?ev.pageX:ev.x; y=parseInt(y)+1; x=parseInt(x)+1; if (d) { d.top=y+'px';d.left=x+'px'; if (vis) { if(vis=='visible' && Math.abs(x-grabx)+Math.abs(y-graby)<10){vis='hidden';} d.visibility=vis; } } }
function mtn_showdata(ev) {
    var e=ev?ev:event; var srow; var si; var p=e.target?e.target:e.srcElement;
    si=p.parentNode.id;
    if (!si) { si=p.parentNode.parentNode.id; }
    if (si.search(new RegExp("^s[0-9]([0-9]+)$","gi"))>=0) {
        srow=RegExp.$1;
        if (srow==mtn_showid && mtn_spent[srow]==0) { return; }
        Today = new Date();
        var mtn_prevshow=mtn_showid; mtn_showid=srow;  if (mtn_prevshow>-1) { mtn_hidedata(mtn_prevshow); }
        mtn_showsw(mtn_showid,1); mtn_touched[mtn_showid] = Today.getTime(); mtn_spent[mtn_showid]=0;}
        mtn_revealiconarea();
        mtn_touched_any=1; }
function mtn_revealiconarea() {
    if (mtn_touched_any==0) { 
        for (var i=0;i<mtn_res;i++) {
            if(sh=find_handle('sh'+i)) { sh.display='none'; } else continue;
            if(sh=find_handle('s4'+i)) { sh.display='block'; }
        }
    }
}
function mtn_showsw(i,on,step) {
    if(so=find_handle('s4'+i)) { mtn_showsw_st(so,on,step); }
}
function mtn_hidedata(id) {
    if (mtn_showicon(id)) { return; } if (id==-1) { id=mtn_showid; mtn_showid=-1; } if (id==-1) { return; }
    Today = new Date(); var now=Today.getTime(); var delay=2000;
    if (mtn_spent[id]>0) {
        if (now-mtn_touched[id]>delay && id!=mtn_showid) {
            if (mtn_spent[id]<10) {
                mtn_showsw(id,-1,10-mtn_spent[id]);
                mtn_spent[id]++;
                setTimeout("mtn_hidedata("+id+")",100);
            }
            else {
                mtn_showsw(id,0);
            }
        }
    }
    else {
        mtn_spent[id]=1;
        setTimeout("mtn_hidedata("+id+")",delay);
    }
}
function mtn_showicon(i) {
    if (parseInt(mtn_icons)==1) { return true; }
    var gif=find_object('lb'+i); if (gif) { if(gif.src.search(new RegExp("2y.gif$","gi"))>=0) { return true; } } return false; }
function mtn_grab(ev) {
    var e=ev?ev:event; var so; var p=e.target?e.target:e.srcElement;graby=parseInt(e.pageY?e.pageY:e.y);grabx=parseInt(e.pageX?e.pageX:e.x);
    mtn_drag=p.id; document.onmousemove=mtn_move; document.onmouseup=mtn_up; mtn_inmove=true;
    if (ev) { ev.preventDefault(); }
    var di=find_object('drimg');
    var diw=0;var dih=0;
    if (di) { dih=Math.floor(parseInt(p.height)/3); diw=Math.floor(parseInt(p.width)/3); di.src=p.src; if (diw && dih) { di.width=diw; di.height=dih; } }
    mtn_cursor(e,'visible'); }
function mtn_move(ev) {
    if (!mtn_inmove) { return false; }
    if (ev) { ev.preventDefault(); mtn_cursor(ev,'visible'); }
    else { event.cancelBubble = true; event.returnValue = false; mtn_cursor(event,'visible'); }    }
function mtn_up(ev) { 
    var e=ev?ev:event; var p=e.target?e.target:e.srcElement; var miss=1;
    document.onmousemove=null; document.onmouseup=null; mtn_inmove=false;
    while (p.parentNode && p.id.search(new RegExp("box([0-9])$","gi"))<0) { if (p.id && p.id=='nodrop') { miss=2;} p=p.parentNode; }
    if (p.id){if(p.id.search(new RegExp("box([0-9])$","gi"))>=0 && miss!=2){mtn_send(RegExp.$1);miss=0;}}
    mtn_drag='';
    if (miss){mtn_ping(parseInt(e.pageX?e.pageX:e.x),parseInt(e.pageY?e.pageY:e.y));}else{mtn_cursor(e,'hidden');}}
function mtn_ping (x,y) {
    var d=find_handle('drag');if (!d) return; if (mtn_drag!='') return;
    var dx=grabx-x;var dy=graby-y;var sx=1;var sy=1;if(dx<0){dx=-dx;sx=-1;}if(dy<0){dy=-dy;sy=-1;}
    if (dx<10&&dy<10) {d.visibility='hidden'; return;}
    if (dx>dy) {y+=sy*Math.floor(dy/dx*12);x+=sx*12;}else{x+=sx*Math.floor(dx/dy*12);y+=sy*12;}
    d.left=x;d.top=y;setTimeout("mtn_ping("+x+","+y+")",10); }
function mtn_send (box) {
    mtn_boxtext(box,mtn_lang('lb_adding')+' '+mtn_iname(),0,1);
    xmlreq('x_lb.php?box='+box+'&lb='+mtn_lb+'&image='+escape(mtn_drag)+'&cdsingle='+cdsingle,mtn_resp); }
function mtn_boximg(i1) {
    var obt; obt=find_object('bi1');if (obt){obt.src=i1?i1:mtn_lbd;} }
function mtn_resp (rid,o) {
    var msg; var rsp=mtn_unescape(o.response);var re=rsp.split('|'); var bt=1;
    if (re[0]!='*') { msg='Script error'; }
    else { msg=re[4]; lb_objnum=re[5]; inlbimg=re[6]; if (re[1]<=0) {mtn_lbnum();} bt=re[2]; }
    mtn_boxtext(bt,msg,1,1); var li=find_object(re[3]); { if(li && re[1]<=0){ if(li.parentNode.parentNode.id.search(new RegExp("s0([0-9]+)$","gi"))>=0){ li=find_object('s1'+RegExp.$1); if (li) { mtn_attach(li,re[1]-1); /*switch the bulb*/ }}}}}
function mtn_iname() { 
    return mtn_lang('obj_'+cdsingle); }
// tools onoff ----------------------------------------------------------
function mtn_toolset(state) {
    if (mtn_tools=='') {mtn_tools=state; }
    mtn_tools=mtn_tools=='off'?'on':'off';
    var o=find_handle('tools');if (o){o.display=mtn_tools=='off'?'none':'block';}
    o=find_handle('box2');if (o){o.display=mtn_tools=='off'?'block':'none';}
    o=find_handle('tools2');if (o){o.display=mtn_tools=='off'?'none':'block';}
    o=find_handle('notools2');if (o){o.display=mtn_tools=='off'?'block':'none';}
    mtn_bsess('tools',mtn_tools); }

// tooltip style extended view ----------------------------------------------
function ly_ex() {
    this.open=0;this.touched=0;this.outclose=0;
    this.lid='extip';
    this.xoff=12;
    this.yoff=12;
    this.act='';
    this.ff=false;
    this.fs=0;
    this.fd=0;
    this.obj=false;
    this.iwd=0;
    this.ihg=0;
    this.posx=0;
    this.posy=0;
    this.hh=0;
    this.move=function(e) {
        if (!e) var e = window.event;
        var p=e.target?e.target:e.srcElement;
        if (p) { l_offer.go(); l_ex.go(p.id,1,e); }
    }
    this.go=function(id,on,e) {
        if (parseInt(mtn_ext)!=0) { return; }
        if (on && id!=this.act) {
            if (this.act=='') { var n=document.createElement("DIV");n.id=l_ex.lid;document.body.appendChild(n); }
            this.act=id;
            var tt=find_object(l_ex.lid);
            r=new RegExp("z$","i");if (tt) { 
                if (l_ex.ff) { clearTimeout(l_ex.ff); l_ex.ff=false; }
                l_ex.fs=0;
                l_ex.iwd=0;
                l_ex.ihg=0;
                tt.style.display='none';
                var logdat=id;
                var logsec='images';
                if (typeof(compurl) == 'undefined') compurl = 'http://static.matton.com/bild/';
                if (typeof(compdir) == 'undefined') compdir = '/comp/';
                if (typeof(compurl_add) == 'undefined') compurl_add = '';
                if (id.search(new RegExp("f$","gi"))>=0) {
                    r=new RegExp("f$","i"); 
                    tt.innerHTML="<img id='extipimg' src='" + id.replace(r,"") + "'>"; 
                }
                else {
                    if (id.search(new RegExp("/comp/","gi"))>=0) {
                        tt.innerHTML="<img id='extipimg' src='" + compurl + id.replace(r,"") + compurl_add + "'>"; 
                    }
                    else {
                        tt.innerHTML="<img id='extipimg' src='" + compurl + id.replace("_",compdir).replace(r,"") + compurl_add + "'>"; 
                    }
                }
                //for map_extend page
                if (id.substr(0,7)=="http://") {
                    tt.innerHTML="<img id='extipimg' src='" + id + "'>";
                    logsec='maps';
                }
                if (id.substr(0,6)=="flash:" && id!="flash:") {
                    logsec='footage';
                    id=id.replace("flash:","");
                    logdat=id;
                    l_ex.iwd=230;
                    l_ex.ihg=166;
                    var embed = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,47,0' id='{$plis.pubfile}' name='footage_prev' menu='false' height='"+l_ex.ihg+"' width='"+l_ex.iwd+"'><PARAM NAME=menu VALUE=false><param name='movie' value='g/flvpb.swf?rnd="+Math.floor(Math.random()*11)+"'><param name='Flashvars' value='flvname=";
                    embed = embed + id;
                    embed = embed + "' id='{$plis.objectid}'><param name='loop' value='true'><param name='quality' value='high'><param name='wmode' value='transparent'><param name='autostart' value='true'><embed src='g/flvpb.swf?rnd="+Math.floor(Math.random()*99)+"' Flashvars='flvname=";
                    embed = embed + id;
                    embed = embed + "' quality='high' menu='false' name='footage_prev' loop='true' autostart='true' type='application/x-shockwave-flash'  pluginspage='http://www.macromedia.com/go/getflashplayer' height='"+l_ex.ihg+"' width='"+l_ex.iwd+"'></object>";
                    tt.innerHTML=embed;             
                }
                var rn=Math.floor(Math.random()*301234);
                xmlreq('x_log.php?obj=quick&sect='+logsec+'&dat='+logdat+'&rn='+rn,mtn_noresp);
                l_ex.obj=tt;
            } 
        }
        if (on) {
            if (e.pageX || e.pageY) {
                l_ex.posx = e.pageX;
                l_ex.posy = e.pageY;
                l_ex.hh=window.innerHeight+window.pageYOffset;
            }
            else if (e.clientX || e.clientY) {
                scrolly=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
                l_ex.posx = e.clientX;
                l_ex.posy = e.clientY + scrolly;
                l_ex.hh=(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight) + scrolly; 
            }
            l_ex.dopos();
        }
        l_ex.fd=on?1:-1;
        if (l_ex.ff) return; // plays already, the right direction is set
        if (on && l_ex.fs==10 || !on && l_ex.fs==0) return;  // already where it should be
        var delay=1000;
        if (typeof(compdir) != 'undefined' && compdir=='/') { delay=70; }
        l_ex.ff=setTimeout('l_ex.ft()',on?delay:70);
    }
    this.dopos=function() { // position the layer
        var ttd=l_ex.obj.style;
        if (!ttd) { return; } 
        if (l_ex.posx || l_ex.posy) {
            ntop = l_ex.posy+l_ex.yoff;
            nl=l_ex.posx+l_ex.xoff;
            var ww=mtn_ww();
            if (ww-nl-8<l_ex.iwd) { nl=l_ex.posx-l_ex.iwd-l_ex.xoff*2; }
            if (l_ex.ihg && l_ex.hh && l_ex.ihg+ntop>l_ex.hh) {
                ntop=l_ex.hh-l_ex.ihg-l_ex.yoff;
            }
            if (nl<0) nl=0;
            ttd.left = nl+'px';
            ttd.top = ntop+'px';
        }
    }
    this.ft=function() { // set the fades, do it only if the image is loaded
        if (l_ex.fd==1 && l_ex.fs>=10 || l_ex.fd==-1 && l_ex.fs<=0) { l_ex.ff=false; return; }
        var o=l_ex.obj.style;
        l_ex.fs+=l_ex.fd;
        if (l_ex.fd==1 && o.display=='none') {
            if (this.idat()) { l_ex.dopos(); o.display='block'; } else { l_ex.fs--; }
        }
        if (l_ex.fd==1 && l_ex.fs<10 || l_ex.fd==-1 && l_ex.fs>0) { 
            mtn_showsw_st(o,-1,l_ex.fs);
            l_ex.ff=setTimeout('l_ex.ft()',70); 
        } 
        else { 
            mtn_showsw_st(o,l_ex.fs/10);
            l_ex.ff=false; 
            if (l_ex.fs==0) { o.display='none'; }
        }
    }
    this.idat=function() {
        //return true; // test for Safari, can not detect height, width.
        var img=l_ex.obj.childNodes[0]; 
        if (img.tagName=="OBJECT") return true;
        var b=false;
        if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) { return false; }
        if (img.naturalWidth) { 
            l_ex.iwd=img.naturalWidth; 
            l_ex.ihg=img.naturalHeight; 
            if (l_ex.iwd>500) l_ex.iwd=500;
            if (l_ex.ihg>500) l_ex.ihg=500;            
        }
        else { var i=new Image(); i.src=img.src; if (!i.width) { return false; } l_ex.iwd=i.width; l_ex.ihg=i.height; b=true;}
        if(b==true){
            //if (!i.complete) { return false; }
        }else if (!img.complete) { return false; }
        //alert (l_ex.iwd+'x'+l_ex.ihg);
        return true;
    }
}
l_ex = new ly_ex();

// tooltip-publisher layers
function mtn_e_subs() {    
    var c;
    if (mtn_eset){return;}else{
        mtn_e();
        var x;
        for (x=0;x<mtn_res;x++) { 
            c=find_object('s5'+x); 
            c.onmouseover = mtn_pubover_res;
            c.onmouseout = mtn_pubout_res;
            c.onmousemove = mtn_pubmousemove;
        }
    }
}
var pubover = 0;
var xoffs=12;
var yoffs_low=12;
function mtn_pubover_res(ev) {
    mtn_puboverout(ev,false, true);
}
function mtn_pubout_res(ev) {
    mtn_puboverout(ev, true, true);
}
function mtn_pubover(ev) {
    mtn_puboverout(ev);
}
function mtn_pubout(ev) {
    mtn_puboverout(ev, true);
}
function mtn_puboverout(ev, out, res) {
    if (out == undefined) out = false;
    if (res == undefined) res = false;
    var e = ev ? ev : event;
    var id;
    var p = e.target ? e.target : e.srcElement;
    if (res) {
        while (p && !p.id.match(/^s5(\d+)$/)) p = p.parentNode;
        if (p && RegExp.$1) {
            id = p.className.replace('s5'+RegExp.$1+'_', '');
        }
    } else {
        var pp = p;
        while (p && !(p.id.search(new RegExp("^pubsel_(.+)$", "gi")) >=0)) p = p.parentNode;
        if (p && RegExp.$1) {
            id =  RegExp.$1
        }
    }
    if (id) {
        if ((mtn_subpubs_count > 1) && (o = find_object('tr_'+id))) {
            o.className = out ? "" : 'tr_'+id;        
        }
        pubover = out ? 0 : id;
        setTimeout('mtn_pubonoff()', 300);
    }
}
function mtn_pubonoff() {
    var o;
    if (o = find_object('pubinfo')) {
        if (pubover) {
            var po;
            if (po = find_object('pubinfo_'+pubover)) {
                o.innerHTML = po.innerHTML;
            } else {
                o.innerHTML = '';
            }
        }
        var h;
        if (h = find_handle('pubinfo')) {
            h.display = pubover ? 'block' : 'none';
            if (o = find_object('pubsel_'+pubover)) {
                if (pubover) {
                    o.onmousemove = mtn_pubmousemove;
                } else {
                    o.onmousemove = '';
                }
            }
        }
    }
}
function mtn_pubmousemove(ev) {
    var e=ev?ev:event; 
    var p = e.target ? e.target : e.srcElement;
    while (p && (!p.id || !(p.id.search(new RegExp("^pubsel_(.+)$", "gi")) >=0))) p = p.parentNode;
    if ((h = find_handle('pubinfo'))) {
        var posx = 0;
        var posy = 0;
        var hh = 0;
        if (e.pageX || e.pageY) {
            posx = e.pageX;
            posy = e.pageY;
            hh=window.innerHeight+window.pageYOffset;
        } else if (e.clientX || e.clientY) {//ie
            var scrolly = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
            posx = e.clientX + document.body.scrollLeft;
            posy = e.clientY + scrolly;
            hh = (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight) + scrolly
//            window.status = 'clienty: '+e.clientY + 'scroll:'+scrolly;
        }
        var o;
        var height = 100;
        var width = 400;
        if (o = find_object('pubinfo')) {
            height = o.offsetHeight + 10;
            width = o.offsetWidth+30;
            if (height < 30) height = 60;
        }
        if (((hh-posy) < height) || (p && (p.id == 'pubsel_10005'))) {
            posy -= height;
        }
        posx += xoffs;
        var ww=mtn_ww();
        if (posx + width > ww) posx -= width; 
        if (posx || posy) {
            h.top = posy+'px';
            h.left = posx+'px';
        }
    }
}
var subpub_timer = null;
var subpub_timer2 = null;
function add_subpub(id, section) {
    if (o = find_object('pubsel_'+id)) {
        o.onmouseover = function() {subpub_over(section, id);};
        o.onmouseout = function() {subpub_out(section, id);};
    } 
    if (o = find_object('pubsel2_'+id)) {
        o.onmouseover = function() {subpub_over(section, id);};
        o.onmouseout = function() {subpub_out(section, id);};
    } 
    if (o = find_object('pubsel3_'+id)) {
        o.onmouseover = function() {subpub_over(section, id);};
        o.onmouseout = function() {subpub_out(section, id);};
    } 
}
var last_replaced = 0;
function subpub_replacepromo(section, id, on) {
    var o;
    var h;
    if (last_replaced && (h = find_handle('pubhtml_'+last_replaced))) {
        h.display = 'none';
    }
    if (o = find_handle('promo_body_'+section)) {
        if (on) {
            if (h = find_handle('pubhtml_'+id)) {
                h.display = 'block';
                o.display = 'none';
                last_replaced = id;
                if (pPlayer.fader[section]) {
                    pPlayer.pause(section);
                }
            }
        } else {
            o.display = 'block';
            if (h = find_handle('pubhtml_'+id)) {
                h.display = 'none';
                last_replaced = 0;
            }
            if (pPlayer.fader[section]) {
                subpub_timer2 = setTimeout(function() {pPlayer.play(section);}, 1000);
            }
        }
    }
}
function subpub_over(section, id) {
    clearTimeout(subpub_timer);
    clearTimeout(subpub_timer2);
    subpub_timer = setTimeout(function() {subpub_replacepromo(section, id, true);}, 300);
    if (o = find_object('pubsel2_'+id)) {
        o.className = o.className.replace(/ re/, '');
        o.className += ' re';
    }
    if (o = find_object('pubsel3_'+id)) {
        o.className = o.className.replace(/ re/, '');
        o.className += ' re';
    }
}
function subpub_out(section, id) {
    clearTimeout(subpub_timer);
    clearTimeout(subpub_timer2);
    subpub_timer = setTimeout(function() {subpub_replacepromo(section, id, false);}, 1000);
    if (o = find_object('pubsel2_'+id)) {
        o.className = o.className.replace(/re/, '');
    }
    if (o = find_object('pubsel3_'+id)) {
        o.className = o.className.replace(/re/, '');
    }
}
var mtn_subpubs_count = 0;
function add_pub(id, sel) {
    if (sel == undefined) sel = 0;
    var o;
    if (o = find_object('pubsel_'+id)) {
        o.onmouseover = mtn_pubover;
        o.onmouseout = mtn_pubout;
        o.onmousemove = mtn_pubmousemove;
        o.high = id < 1000 ? false : true;
        mtn_subpubs_count+=sel;
    }
}
var search_tips_count;
var search_tips_selidx;
function init_searchtips(selidx, count) {
    search_tips_selidx = selidx;
    search_tips_count = count;
}
function show_searchtip(show) {
    if (show == undefined) show = 1;
    var ho, hc;
    if ((ho = find_handle('search_tip_open')) && (hc = find_handle('search_tip_close'))) {
        ho.display = show ? 'block' : 'none';
        hc.display = show ? 'none' : 'block';
        mtn_bsess('show_search_tip', show);
    }
}
function next_searchtip() {
    var nextidx = search_tips_selidx+1;
    if (nextidx >= search_tips_count) nextidx = 0;
    var o = find_object('search_tip_'+search_tips_selidx);
    var n = find_object('search_tip_'+nextidx);
    if (o && n) {
        o.style.display = 'none';
        n.style.display = 'inline';
        search_tips_selidx = nextidx;
    }
}


