var submit = 1;
var usersOrigVal = new Array;
var usrparts = new Array;
var notchecked = 1;

function defVal(id, val) {
    usersOrigVal[id]=val;
}

function show_glyph(id) {
    document.getElementById('picid').value = id; 
    //setTimeout("show_glyph_d()", 500);
    show_glyph_d(id);
}

function findPos(obj) {
	var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
    }
	return [curleft,curtop];
}

function show_glyph_d() {
    var picid = document.getElementById('picid');
    if (picid.value) {
        var id = picid.value;

        var img = document.getElementById(id);
        var w = img.parentNode.clientWidth;
        var h = img.parentNode.clientHeight;        

        obj = document.getElementById(id);

        var pos = findPos(obj);

        var topp = Math.ceil(h/2)+pos[1];
        	
        var leftp = Math.ceil(w/2)+pos[0];
        
        var divid = document.getElementById('div'+id);

        divid.style.width=(w*3)+'px';
        divid.style.top=topp+'px';
        divid.style.left=leftp+'px';
        divid.style.display="inline";		
    }
}

function hide_glyph(id) {
    document.getElementById('div'+id).style.display="none";
    document.getElementById('picid').value = '';
}	

function show_popup(name) {
    var popup;
    var q;
    var popuptop;

    popup = document.getElementById(name+'popup');
    q = document.getElementById(name+'q');
    popuptop = q.offsetTop - popup.clientHeight - (-6);
    popup.style.top = popuptop+'px';
    popup.style.visibility = 'visible';    
}

function modify_urls() {
    var size = document.getElementById('size').value;
    var styleident = document.getElementById('identnr').value;
    var owntext = document.getElementById('owntext').value;
    var own = document.getElementById('sample').value;
    var tabs = new Array('styles','text','glyphs','purchase');
    var bgcolor = document.getElementById('bg_color_val').value;
	bgcolor = bgcolor.replace("#","");
    var tfcolor = document.getElementById('tf_color_val').value;
	tfcolor = tfcolor.replace("#","");
    var sample = document.getElementById('sample').value;
    var predef = document.getElementById('predef').options[document.getElementById('predef').selectedIndex].value;;
    var paramlist = styleident+'|'+size+'|'+sample+'|'+predef+'|'+bgcolor+'|'+tfcolor+'|'+owntext;

    for (var i=0; i<4; ++i) {
        var tab = tabs[i];
        var tabitem = document.getElementById(tab+'_url');
        var url = tabitem.getAttribute('href').replace(/.html/,'');
        var url_parts = url.split('/paramlist-');  

        var newurl = url_parts[0]+'/paramlist-'+paramlist+'.html';
        /*if (url_parts[0] != undefined) var newurl = url_parts[0]+'/paramlist-'+paramlist+'.html';
        else var newurl = url+'/styleident-'+styleident+'/size-'+size+'.html';*/

        tabitem.setAttribute('href', newurl);
    }
}

function pdf_url(styleident) {
    gburl = document.getElementById('gburl').value;
    var new_url = gburl+styleident+'/'+styleident+'.pdf';
    document.getElementById('pdfurl1').setAttribute('href', new_url);
    document.getElementById('pdfurl2').setAttribute('href', new_url);
}

function reset_urls(site) {
    var tabs = new Array('styles','text','glyphs','purchase');
    for (var i=0; i<4; ++i) {
        var tab = tabs[i];
        //alert(tab);
        var tabitem = document.getElementById(tab+'_url');
        var url = tabitem.getAttribute('href');
        var url_parts = url.split('&styleident=');  

        if (url_parts[0] != undefined) var newurl = url_parts[0];
        else var newurl = url;

        tabitem.setAttribute('href', newurl);

        if (site == 'g') pdf_url_reset();
    }
}

function pdf_url_reset() {
    document.getElementById('pdfurl1').setAttribute('href', document.getElementById('ogburl').value);
    document.getElementById('pdfurl2').setAttribute('href', document.getElementById('ogburl').value);
}

function hide_popup(name) {
    document.getElementById(name+'popup').style.visibility = 'hidden';
}

/*function licence_message(nofu) {
    if (usrparts[0] == undefined && usrparts[1] == undefined) {
        lic_mess = document.getElementById('licence_message').innerHTML;
        usrparts = lic_mess.split("5");
    }
    else document.getElementById('licence_message').innerHTML = usrparts[0]+nofu+usrparts[1];
}*/

// cookie test ---------------------------------------
if (document.cookie.length == 0) { window.open("cookie_explain.html","cookie_explain","location=no,dependent=no,directories=no,scrollbars=no,resizable=yes,width=400,height=200,status=no,toolbar=no,menubar=no");  }
// ---------------------------------------
inlbimg=0;lb_objnum=0;mtn_loaded=0;mtn_drag='';mtn_background='x';mtn_nodrop=0;
function find_object(id) {
    if (document.getElementById) { if (!(document.getElementById(id))) { return false; } return document.getElementById(id); } else return false; }
function find_handle(id) {
    if (document.getElementById) { if (!(document.getElementById(id))) { return false; } return document.getElementById(id).style; } else if (document.layers) return document.layers[id]; else if (document.all) return document.all[id].style; else return false; }
function mtn_ww() {
    return document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth; 
}
function mtn_dw() {
   /* if (plng=='lng'){
        return;
    }
    var dw=mtn_ww(); 
    var b=find_handle('dw');
    if (b) { 
        var cwd=b.width; 
        if (dw<988 && cwd!='100%') { 
            b.width="100%"; 
        } 
        if (dw>=988 && cwd=='100%') { 
            b.width="988px"; 
        } 
    } */
}
// xmlreq ------------------------------------------------------------
mtn_request=new Array();
mtn_request_c=0;
function xmlreq(url,fresp,obj) { 
    r_c=mtn_request_c++; mtn_request[r_c] = new xmlhttp_request (url, fresp, r_c, obj); return r_c; }
function xmlhttp_request (url, e, id, obj) {
    this.target = document; this.url = url; this.id = id;this.obj=obj==undefined?this:obj;this.obj.event=e;this.xmlhttp = false; this.method = "GET"; this.doRequest(); }
xmlhttp_request.prototype.init_xmlhttp = function () {
    try { this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { this.xmlhttp = false; } } if (!this.xmlhttp && typeof XMLHttpRequest!='undefined') { this.xmlhttp = new XMLHttpRequest(); }
}
xmlhttp_request.prototype.doRequest = function () {
    if (!this.xmlhttp) { this.init_xmlhttp(); }
    //this.xmlhttp=false;
    var xworks=0;
    if (this.xmlhttp) {
        var o = this;
        xworks=1;
        try { o.xmlhttp.open(this.method, this.url, true); } catch(e) { xworks=0; }
//        alert ("xworks="+xworks);
        if (xworks==1) {
          o.xmlhttp.onreadystatechange = function() {
            if (o.xmlhttp.readyState==4) { 
              if (o.xmlhttp.status == 200) {
//              alert ("status="+o.xmlhttp.status);
                o.response = o.xmlhttp.responseText;                 
//              alert ("response="+o.response);
                if (o.response) { o.obj.event(o.id,o); }
                else { var iid=(o.id && o.id=='sgy')?'sgy':o.id+1; lbf=find_object('lbf'); 
                       uconc=(o.url.indexOf('?')>0)?'&':'?'; 
                       lbf.src=baseurl+o.url+uconc+'iframe='+iid; 
                       lbf.location=baseurl+o.url+uconc+'iframe='+iid; }
                } } }
            o.xmlhttp.send(null);
        }
    }
    if (xworks==0) { var iid=(this.id && this.id=='sgy')?'sgy':this.id+1; lbf=find_object('lbf');
           uconc=(this.url.indexOf('?')>0)?'&':'?'; 
           lbf.src=baseurl+this.url+uconc+'iframe='+iid;  // src for Safari, location for Explorer
           lbf.location=baseurl+this.url+uconc+'iframe='+iid; }
}
// background sessions -----------------------------------------------
function mtn_bsess(bsvar,bsval) {
    var rn=Math.floor(Math.random()*301234);
    xmlreq('bsess.php?bsvar='+bsvar+'&bsval='+bsval+'&rn='+rn,mtn_noresp); }
function mtn_noresp() { }
// hide email --------------------------------------------------------
function drotposta(user,host) {
    host = getMailHost(host); user = getMailUser(user); window.location='mailto:'+user+'\@'+host; }
function drotpostaHTML (id, user, host) {
    host = getMailHost(host); user = getMailUser(user); if ((host != '') && (user !='') && (o = find_object(id))) { o.innerHTML = user+"@"+host; }
}
function getMailUser(user) {
    if (user == '') return user; else return decode64(user); }
function getMailHost(host) {
    if (host==1) host='matton.se'; else if (host==2) host='matton.se'; else if (host=='') host=''; else host=decode64(host);
    return host; }
var hlpc_lastid = "";
function hlpc_markselected(id) {
    if (o = parent.find_object(parent.hlpc_lastid)) { o.style.color=""; }
    parent.hlpc_lastid = id;
    if (o = parent.find_object(id)) { o.style.color="orange"; } }
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function decode64(input) {
   var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0;
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
   do {
      enc1 = keyStr.indexOf(input.charAt(i++)); enc2 = keyStr.indexOf(input.charAt(i++)); enc3 = keyStr.indexOf(input.charAt(i++)); enc4 = keyStr.indexOf(input.charAt(i++));
      chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4;
      output = output + String.fromCharCode(chr1); 
      if (enc3 != 64) { output = output + String.fromCharCode(chr2); }
      if (enc4 != 64) { output = output + String.fromCharCode(chr3); }
   } while (i < input.length); return output; }

// language resources ---------------------------------------------------
lrl=0;lrs=new Array();
function mtn_lang(res) {
    if (lrl) { if (lrs[res]) { return lrs[res]} } return " "; }

// Filter layer ----------------------------------------
function ly_filt() {
    this.load=0;this.open=0;this.touched=0;this.outclose=0;
    this.lid='filters';this.lid2='';
    this.lheight=0;
    this.first_go = true;
    this.go=function(sect,obj,setehs, _persec) { 
        if (_persec == undefined) _persec = '';
        persec = _persec;
        mtn_touch(this);
        if (this.first_go && setehs && this.load<2) {this.load=2; this.open=1;} // the filters were already loaded and open
        this.first_go = false;
        if (this.load==1) { return; }
        var h;
        if (h = find_handle('inpage_filters_image')) {
            h.display = this.open?'block':'none';
        }
        if (this.open==1 || this.load==2) { this.show(this.open); return; }
        if ((typeof(filters_deleted) != 'undefined')) {
            if (filters_deleted) {//Would you like to load previously used filters?
                if( !confirm(lrs['sfilt_useprev'])) {
                //if (true) {
                    mtn_clearfilt(); 
                } else {
                    filters_deleted = false;
                }
            }
        }
        this.load=1;this.open=1;
        var n=find_object(this.lid);
        n.innerHTML=loadingtext(0);
	    var rn=Math.floor(Math.random()*301234);
        var self = this;
        setTimeout(function() {xmlreq('x_filter.php?section='+sect+'&obj='+obj+'&persec='+_persec+'&rn='+rn,self.resp);}, 500)
    }
    this.resp=function(rid,o) { 
        var el=find_object(l_filt.lid); if(el){
            el.innerHTML=mtn_unescape(o.response);l_filt.show(0);l_filt.load=2;}add_pub(10004);add_pub(10005);}
    this.bind=function() {
        var wd=parseInt(getstyle('dw','width'));
        mtn_bind(find_handle(this.lid),'content',0,0,wd); }
    this.show=function(hide) {
        var l=find_handle(this.lid);
        if (hide) { 
            if (isfset()) { 
                if (!confirm(mtn_lang('flclose_dontremove'))) return; 
                else {
                    filters_deleted = 1;
//                    mtn_clearfilt(); 
                } 
            }
//            this.load=2; 
            this.load=0; 
        } 
        l.display=hide?'none':'block';
        var lc=find_handle('fcl0'); if (lc) { lc.display=hide?'none':'block'; }
        var lc=find_handle('fcl1'); if (lc) { lc.display=hide?'block':'none'; }
        this.open=1-hide;
        mtn_fsave('fopen:'+this.open);    
        var o=find_object('filtersp');o.innerHTML=this.open?'x':'+'; }
}
l_filt = new ly_filt();
// FAQs ----------------------------------------------
function ly_faq() {
    this.load=0;this.open=0;this.touched=0;this.outclose=1;
    this.lid='elayer2';this.lid2='';
	this.rn=Math.floor(Math.random()*30123);
    this.go=function(pg) { 
        mtn_touch(this);
        if (this.load==1) { return; }
        if (this.open==1 || this.load==2) { var l=find_handle(this.lid);if(this.open){l.display='none';this.open=0;}else{l.display='block';this.open=1;this.bind();} hide_maincontent(this.open); return; }
        var lo=find_object('faqload'); if (lo) { lo.innerHTML=mtn_lang('langt_loading_1')+"..."; }
        this.load=1;this.open=1;var n=document.createElement("DIV");n.id=this.lid;
        document.body.appendChild(n);this.bind();xmlreq('x_qfaq.php?pg='+pg+'&vsz='+this.rn,this.resp); }
    this.resp=function(rid,o) { 
        var lo=find_object('faqload'); if (lo) { lo.innerHTML='&nbsp;'; }
        var el=find_object(l_faq.lid);if(el){el.innerHTML=mtn_unescape(o.response);l_faq.load=2;} hide_maincontent(l_faq.open); }
    this.bind=function() {
        mtn_bind(find_handle(this.lid),'ehs2',-7,0,920); }
}
l_faq = new ly_faq();
// offer layers ------------------------------------------------------------
moff=new Array();
function ly_offer() {
    this.load=0;this.open=0;this.touched=0;this.outclose=1;
    this.lid='offlay';this.lid2='';
    this.offact='';
    this.nodeact='';
    this.ttd=false;
    this.gogo=function(ev) { l_offer.go(ev?ev:event,1);  }
    this.go=function(e,on) {
        mtn_touch(l_offer); 
        if (e==undefined) { try { e=event } catch(ee) { e=null; } } 
        if (on==undefined) { on=0; }
        if (on && e) { l_offer.show(e,1); return false; }		
        var l=find_handle(l_offer.lid); if (l) { l.visibility='hidden'; l_offer.open=0; return false; } }
    this.show=function(ev,ext) {
        if (ext!=1) { return; }
        if (l_offer.load==0) { var d=document.createElement("DIV"); d.id=l_offer.lid; document.body.appendChild(d); var b=find_object('dw'); if (b) { /*b.onscroll=l_offer.go();*/ } l_offer.load=2; }
        var e=ev?ev:event; 
        var p=e.target?e.target:e.srcElement;
        if (p && p.id.search(new RegExp("^o(.+)$","gi"))>=0) { var nodeid=p.parentNode.parentNode.id;
        var id=RegExp.$1; l_offer.ttd=find_handle(l_offer.lid); var tt=find_object(l_offer.lid);
        if (moff[id]) {
            if (id!=l_offer.offact) {
                idlink=id;
                if (id.search(new RegExp("^([A-Z0-9]+)","gi"))>=0) { idlink=RegExp.$1; }
                l_offer.offact=id; var oh=''; var mpa=moff[id].split("<>");
                var sok=''; var sso=find_object('sok'); 
                for (var i=0;i<mpa.length;i+=5) { oh+="<div>"+mpa[i]+"<br><a href='"+mpa[i+4]+"'>"+mtn_lang('offer_read_more')+"</a></div><p>"+mpa[i+1]+"</p><p><a href='"+mpa[i+3]+sok+"'>"+mpa[i+2]+"</a></p>"; }
                tt.innerHTML=oh;
                l_offer.bind(p,tt);l_offer.ttd.visibility='visible';l_offer.open=1;
            }
            else { if (l_offer.ttd.visibility=='hidden' || l_offer.nodeact!=nodeid){l_offer.bind(p,tt);l_offer.ttd.visibility='visible';l_offer.open=1;}else{l_offer.go();l_offer.open=0;} } 
            l_offer.nodeact=nodeid;
    }}}
    this.bind=function(p,tt) {
        var posx=sg_ofs(p,"offsetLeft"); var posy=sg_ofs(p,"offsetTop");
        var hh=0;
        if (window.pageYOffset) { hh=window.innerHeight+window.pageYOffset; }
        else { var scrolly=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
               hh=(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight) + scrolly; }
        var b=find_object('dw'); if (b) { posy-=b.scrollTop; }
        var hg=tt.offsetHeight;
        if (!hg) { hg=200; } 
        if (hh && hh-posy<hg+25) { posy=posy-hg-20; }
        if (posy<-22) {posy=-22;}
        if (posx || posy) { l_offer.ttd.top = (posy+22)+'px'; nl=posx-125; var ttend=mtn_ww()-16; if (nl+350>ttend) {nl=ttend-356;} if (nl<6) {nl=6;} l_offer.ttd.left = nl+'px'; }
    }
}
l_offer = new ly_offer();
// Country select ----------------------------------------------
function ly_site() {
    this.load=0;this.open=0;this.touched=0;this.outclose=1;
    this.lid='elayer3';this.lid2='';
	this.rn=Math.floor(Math.random()*30123);
    this.lastclick=0;
    this.footgo=function() {
        window.scrollTo(0,0);
        this.go(0);
    }
    this.go=function(fromreg,fwurl) { 
        mtn_touch(this);
        if (typeof(fwurl)=='undefined') { fwurl=''; } 
        if (this.load==1) { return; }
        var t=new Date(); var now=t.getTime();
        if (fromreg && now-this.lastclick<30000) { location=baseurl+'register.php'+(fwurl=='affiliate'?'?affiliate=1':(fwurl=='aff_splash'?'?aff_splash=1':'')); return; }
        if (!fromreg && !this.open) { this.lastclick=now; }
        if (this.load==2) { var l=find_handle(this.lid);if(this.open){l.display='none';this.open=0; this.load=0; var n=find_object(this.lid); if (n) { document.body.removeChild(n); }}else{l.display='block';this.open=1;this.bind();} hide_maincontent(this.open); return; }
        this.load=1;this.open=1;var n=document.createElement("DIV");n.id=this.lid;n.innerHTML=loadingtext(-40);
        document.body.appendChild(n);this.bind();xmlreq('x_lang.php?rn='+this.rn+(fromreg?'&register=1':'')+(fwurl?'&fwurl='+escape(fwurl):''),this.resp); }
    this.resp=function(rid,o) { 
        var el=find_object(l_site.lid);if(el){el.innerHTML=mtn_unescape(o.response);l_site.load=2;} hide_maincontent(l_site.open); }
    this.bind=function() {
        var wd=getstyle('dw','width'); if (wd=='100%') { wd=mtn_ww()-28; } else { wd=parseInt(wd); } if (wd<988) { wd=988; }
        mtn_bind(find_handle(this.lid),'content',-7,0,wd); }
}
l_site = new ly_site();
// Lightbox menu ----------------------------------------------
function ly_lb() {
    this.load=0;this.open=0;this.touched=0;this.outclose=1;
    this.lid='box2';
    this.lid2='lbch2';
    this.which='';
    this.login='';
    this.bindoff=100;
    this.wd=145;
    this.go=function(isl,wh,login) { 
        mtn_touch(this);
        if (this.load==1) { return; }
        if (login!=undefined) { l_lb.login=login; }
        if (wh) { if (this.which!=wh) { if (this.open) {this.go();/*close it properly*/} this.open=0;this.load=0; var n=find_object(this.lid); if (n) { document.body.removeChild(n); } } this.which=wh; }
        if (this.open==1 || this.load==2) {this.show(this.open); return; }
        var bn=find_object(this.which);
        if (bn && bn.parentNode) { if (bn.parentNode.style.width) { this.wd=parseInt(bn.parentNode.style.width); } }
        var addi=this.wd>200?" style='width:207px;'":"";
        var addi2=this.wd>200?" style='width:188px;'":"";
        var create="&gt;<a class='ql l8' onclick=\"l_lb.act(0,0,this)\">"+mtn_lang('layercreate')+"</a>";
        var change="&gt;<a class='ql l8'>"+mtn_lang('change_lb')+"</a>";
        if (isl) {
            create='<input id="addlbn"'+addi+'><div class="newl"><a id="lbmnew" class="ql" onmousedown="l_lb.act(1,0,this);">'+mtn_lang('layercreate')+'</a>';
            change='<div id="lbch1"><div id="lbch1i"'+addi2+'>'+mtn_lang('change_lb')+'</div></div><div style="float:left;"><img src="g/lsel.gif"></div>';
        }
        viewcont='<div id="lbquick" style="display:' + this.quickshow(0) + ';">&gt;<a id="lbmdda" class="ql l8" onmousedown="l_lb.act(1,2,this);">'+mtn_lang('lb_quick')+'</a>';
        this.open=1;this.load=1;var n=document.createElement("DIV");n.id=this.lid;n.innerHTML="<div id='lbwrap' onmouseover='mtn_lbbg(this,1,2)' onmouseout='mtn_lbbg(this,0,2)'>"+bn.innerHTML.replace(/>\+<......../,' id="lbm1" style="visibility:hidden;">x</span><a id="lbm2" style="visibility:hidden;" ').replace('id="lbname1"','id="lbname2"').replace('id="inlbnum1"','id="inlbnum2"')+"<div id='lbopts'><div>"+viewcont+"</div><div>"+create+"</div><div id='lbch0' onclick=\"l_lb.act('"+isl+"',1,this);\">"+change+"</div></div></div>";n.style.zIndex=1300;  
        document.body.appendChild(n); this.load=2; this.show(0); }
    this.bind=function() {
        this.bindoff=this.which=='boxi'?100:70;
        mtn_bind(find_handle(this.lid),this.which,0,-this.bindoff,l_lb.wd); }
    this.show=function(hide) {
        var l=find_handle(this.lid);
        var bn=find_handle(this.which);
        if(hide){
            with(bn){backgroundColor="transparent";paddingRight="7px";borderRight="0";paddingLeft="2px";borderLeft="0";paddingTop="1px";borderTop="0"; }
            l.display='none';
            s=find_handle('lbm1'); if(s) {s.visibility='hidden'; }
            s=find_handle('lbm2'); if(s) {s.visibility='hidden'; }
            l_lb.ddclose();
            this.open=0;
        }
        else {
            with(bn){backgroundColor="#eff2f9";paddingRight="6px";borderRight="1px #ebebeb solid";paddingLeft="1px";borderLeft="1px #ebebeb solid";paddingTop="0";borderTop="1px #ebebeb solid"; }
            this.bind();
            if (this.which=='lbmenufl' && self.pageYOffset/*the floter on non-IE5/6*/) { l.position='fixed'; }
            l.display='block';
            mtn_slide(this.lid,'y',parseInt(l.top),parseInt(l.top),parseInt(l.top)+this.bindoff,this.bindoff+20,0);
            this.open=1;
            this.quickshow(1);
        } }
    this.act=function(l,wi,o) { 
	    var rn=Math.floor(Math.random()*301234);
        if (l!=1) { if(confirm(mtn_lang('lb_notlogged'))){location=l_lb.login;} return;}
        if (wi) { 
            if (l_lb.ddclose()) { return; } 
            var addi=this.wd>200?" style='width:207px;'":"";
            var n=document.createElement("DIV");
            n.id='lbch2';
            n.innerHTML='<div id="lbchwrap"'+addi+'>'+loadingtext(0)+'</div>';
            var ib=find_object(wi==2?'lbquick':'lbch0');
            if (ib) { 
            var le=sg_ofs(ib,"offsetLeft")+1; var to=sg_ofs(ib,"offsetTop")+(wi==2?20:23);
            var pos=(l_lb.which=='lbmenufl' && self.pageYOffset/*the floter on non-IE5/6*/)?'fixed':'absolute';
            with (n.style) {position=pos; left='1043px'; top=to+'px'; visibility='visible'; width='121px'; } document.body.appendChild(n);
            xmlreq('x_lbch.php?lb='+mtn_lb+'&wi='+wi+'&rn='+rn,l_lb.dd); }}
        else { var t='';var n=find_object('addlbn'); if (n){t=n.value;} if (!t.length) { alert(mtn_lang('lightbox_noname')); return; }
            xmlreq('x_lb.php?newlb='+mtn_escape(t)+'&rn='+rn,l_lb.newre);  }
    }
    this.newre=function(rid,o) { 
        if (l_lb.resp(o)) {
        var n=find_object('lbmnew'); if (n) { n.style.textDecoration='none'; n.innerHTML='done'; l_lb.go(); } } }
    this.dd=function(rid,o) { 
        var el=find_object('lbchwrap');if(el){ el.innerHTML=mtn_unescape(o.response); } }
    this.ch=function(id) { 
	    var rn=Math.floor(Math.random()*301234);
        xmlreq('x_lb.php?chlb='+id+'&rn='+rn,l_lb.chre); }
    this.chre=function(rid,o) { 
        if (l_lb.resp(o)) { l_lb.go(); } }
    this.resp=function(o) {
        var msg; var rsp=mtn_unescape(o.response);var re=rsp.split('|'); 
        if (re[0]!='*') { msg='Script error'; }
        if (re[1]=='-0'||re[1]==0) { return false; }
        if(re[1]<0) { re[1]=-re[1] };mtn_lb=re[1];mtn_bsess('lightbox',mtn_lb);
        for (var i=0;i<3;i++) { var name=find_object('lbname'+i); if (name) {name.innerHTML=re[3];} }
        if (re[5]){lb_objnum=re[5];}else{lb_objnum=0;}
        if (re[6]){inlbimg=re[6];}else{inlbimg=0;} mtn_lbnum();
        return true;
    }
    this.ddclose=function() {
        var s=find_object('lbch2'); if(s) {document.body.removeChild(s); return true;} else {return false;} }
    this.quickshow=function(show) { 
        var disp=parseInt(inlbimg)?'block':'none';
        if (show) { var s=find_handle('lbquick'); if(s) {s.display=disp;} } else return(disp); }
    this.layrem=function(im,cds) {
	    var rn=Math.floor(Math.random()*301234);
        xmlreq('x_lb.php?box=1&lb=rm'+mtn_lb+'&image='+cds+mtn_escape(im)+'&rn='+rn,l_lb.layresp); }
    this.layresp=function() { 
        var o=find_object('lbmdda'); if (o) { l_lb.ddclose(); l_lb.act(1,2,o); } }
}
l_lb = new ly_lb();
// Go to page ----------------------------------------------
function ly_nav() {
    this.open=0;this.touched=0;this.outclose=1;
    this.lid='naviglayer';this.lid2='';
    this.nav=false;
    this.floater=0;
    this.go=function(o,spage,page_num,currpage,ohid,fl) {
        mtn_touch(this);
        this.floater=fl;
        if (this.open) { this.open=0; var n=find_object(this.lid); if (n) { document.body.removeChild(n); } }
        if (!o) { return; }
        this.nav=o;
        var n=document.createElement("DIV");n.innerHTML='<form method="get" name="navigform" action="'+spage+'" onsubmit="navfix(\''+page_num+'\',this);"><span>'+mtn_lang('pagech')+'</span><input value="'+currpage+'" name="oo" autocomplete="off"><a class="re" onclick="document.navigform.submit();">&gt;</a>'+ohid+'</form>';n.id=this.lid;
        this.open=1;
        document.body.appendChild(n);this.bind();document.navigform.oo.focus();
    }
    this.bind=function() {
        var ns=find_handle(this.lid);
        var ib=this.nav.parentNode;
        while (ib.nodeName!="TABLE" && ib.parentNode) { if(ib.nodeName=="TD") {td=ib;} ib=ib.parentNode; }
        if (ib.nodeName!="TABLE") { return; }
        var le=sg_ofs(ib,"offsetLeft");
        var p="absolute"; if (this.floater && self.pageYOffset/*the floter on non-IE5/6*/) { p="fixed"; } ns.position=p;
        if (this.floater) { with(ns){left=(le)+"px";top=(sg_ofs(ib,"offsetTop")-1)+"px";}  }
        else {  
            var redge=sg_ofs(td.nextSibling.nextSibling,"offsetLeft")+15; var lwd=300;
            with(ns){left=(redge-lwd)+"px";width=lwd+'px';
            var posy=parseInt(sg_ofs(ib,"offsetTop"))-3;
            var b=find_object('dw'); if (b) { posy-=b.scrollTop; } top=(posy+6)+"px"; } } }
}
l_nav = new ly_nav();
// Search language selector ----------------------------------------------
function ly_lang() {
    this.load=0;this.open=0;this.touched=0;this.outclose=1;
    this.lid='langl';this.lid2='';
    this.state=-1;
    this.value=new Array(2); this.text=new Array(2);
    this.go=function(av,at) { 
        mtn_touch(this);
        if (this.load==1) { return; }
        var lsel=find_object('lsel');
        var lselimg=find_object('lselimg');
        if (this.state==-1) {
            this.value[0]=document.sf.lsok.value; this.text[0]=lsel.innerHTML;
            this.value[1]=av; this.text[1]=at; this.state=0; }
        if (this.open==1 || this.load==2) {this.open=this.open?0:1; var o=find_handle(this.lid); o.display=this.open?'block':'none'; return; }
        this.open=1;this.load=1;var bn=find_object(this.which);var n=document.createElement("DIV");n.id=this.lid;n.innerHTML="<div id='langlin'><a id='langa' class='ql' onclick='l_lang.ch();'>"+mtn_lang('langt_inenglish_title')+" "+this.text[1-this.state]+"</a></div>";var le=sg_ofs(lsel,"offsetLeft")-5;var wd=sg_ofs(lselimg,"offsetLeft")-le+16; with(n.style){position='absolute';top=(sg_ofs(lselimg,"offsetTop")+17)+"px";left=le+'px';width=wd+'px';}
        document.body.appendChild(n); this.load=2; }
    this.ch=function() {
        var astate=1-this.state;
        this.go();
        find_object('langa').innerHTML=mtn_lang('langt_inenglish_title')+" "+this.text[this.state];
        find_object('lsel').innerHTML=this.text[astate];
        document.sf.lsok.value=this.value[astate];
        this.state=astate;
    }
}
l_lang = new ly_lang();
// Handle layers -------------------------------------------------
var mtn_ly=new Array(l_filt,l_faq,l_site,l_lb,l_nav,l_lang,l_offer);
function mtn_click(e) {
    var opened=new Array();
    var t=new Date(); var now=t.getTime();
    for (var i=0;i<mtn_ly.length;i++) {  if (mtn_ly[i].outclose && mtn_ly[i].open && t-mtn_ly[i].touched>500) { opened.push(i); } }
    if (opened.length==0 && !sg) return;
    var p=e.target?e.target:e.srcElement;
    var cids=new Array;
    var layers_closed=0;
    while (p.parentNode) {
        if (p.id) { cids.push(p.id); }
        p=p.parentNode; }
    for (var j=0;j<opened.length;j++) {
        i=opened[j]; var inside=0;
        for (var k=0;k<cids.length;k++) { if (cids[k]==mtn_ly[i].lid || cids[k]==mtn_ly[i].lid2 ) inside=1; }
        if (!inside) { mtn_ly[i].go(); layers_closed++; } }
    //if (layers_closed) { return false; } else { return true; }
    if (sg) { var inside=0; for (var k=0;k<cids.length;k++) { if (cids[k]=='sg_d') inside=1; } if (!inside) sg_k(); }
    return true;
    }
function mtn_touch(o) { 
    var t=new Date(); o.touched=t.getTime(); }
// Layer helper functions -----------------------------------
function mtn_showsw_st(o,on,step) {
    if (mtn_safari) { o.visibility=on==1?'visible':'hidden'; }
    if (on==1) { o.opacity=0.9999; o.filter = 'alpha(opacity=100)'; }
    else if (on==0) { o.opacity=0; o.filter = 'alpha(opacity=0)'; }
    else { o.opacity='0.'+step; o.filter = 'alpha(opacity=' + step*10 + ')'; }
}
function getstyle(ob,s,ref) {
    var o; o=ref?ob:find_object(ob); if (o) {
    if (o.currentStyle)	{ return o.currentStyle[s]; }
	else if (window.getComputedStyle) { return document.defaultView.getComputedStyle(o,null).getPropertyValue(s); } }
}
function mtn_slide(o,dir,from,curr,to,total,step) {
    var s=find_handle(o);
    if (!s) { return; }
    curr+=(to-from)/8;
    if (curr>to) { curr=to; }
    var x=2*(curr-from)/(to-from);
    var fx=Math.round((2-(x*x-3*x+2))/2*to);
    s.top=fx+'px';
    s.clip='rect('+(total-fx+from)+'px auto auto auto)';
    if (o=='filters' && fx-from>0) {
        var co=find_handle('content'); co.top=(fx-from)+'px';
        var co=find_handle('flinks'); co.top=(fx-from)+'px';
    }
    //alert(curr+' '+x+' '+fx);
    if (curr<to) {
        setTimeout("mtn_slide('"+o+"','"+dir+"',"+from+","+curr+","+to+","+total+")",1);
    }
    else {
        s.clip='rect(auto auto auto auto)';
        if (o=='box2') {
            s=find_handle('lbm1'); if(s) {s.visibility='visible'; }
            s=find_handle('lbm2'); if(s) {s.visibility='visible'; }
        }
    }
}
function mtn_bind(n,to,ox,oy,wd) { 
    var ib = find_object(to); if (ib) { with(n){position="absolute";top=(sg_ofs(ib,"offsetTop")+oy)+"px";left=(sg_ofs(ib,"offsetLeft")+ox)+"px"; } if (wd!=-1) { n.width=wd?wd+"px":"985px"; n.padding="0"; } } }
function hide_maincontent(on) {
    var c=find_handle('content'); 
    if (c) { c.visibility=on?'hidden':'visible'; } }
function loadingtext (ox) {
    return "<div style='margin-left:"+ox+"px;'>"+mtn_lang('langt_loading_1')+"..."+"</div>";
}
function mtn_hisk() {
    var el=find_object('hiss');if(el){for(var j=el.options.length;j>0;j--){el.remove(j);}mtn_bsess('sought','');alert(mtn_lang('hist_cleared'));}}

function mtn_ss() { 
    var ind=find_handle('loading'); if (ind){ind.visibility='visible';} return true; /*location=baseurl+url; return false; }*/ }

function mtn_lbbg(box,on,t) { 
    var b=box.style; if (b || t) { 
//    	var fb=find_handle('fixbar');
//    	fb.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=90);";
        if (t) { var ln=find_handle('lbname'+t); if (ln) {
                if (on && mtn_drag.length && mtn_nodrop==0) { ln.color='#ff8200'; } 
                else { ln.color='#888'; } } }
        else { if (on && mtn_drag.length) { b.backgroundColor="#eff2f9"; mtn_boxtext(0,mtn_lang('drop_image'),0,1); } 
               else { b.backgroundColor='#f9f9f9'; mtn_boxtext(0,mtn_lang('search_dd'),0,0); } }
    }}

function mtn_boxtext(b,t,rec,col) { if (b==1 && rec==1) { mtn_boxtext(0,t,1); mtn_boxtext(2,t,1); } 
    var obt;var bt='bt'+b; if (obt=find_object(bt)) { obt.style.color=col?"#ff8200":"#9f9f9f"; obt.innerHTML=t; if (rec) { var orec=lb_objnum>=300?'lb_full':'search_dd'; var old=mtn_insearch==1?mtn_lang(orec):'&nbsp;'; setTimeout("mtn_boxtext('"+b+"','"+old+"',0,0)",3500); } } }
function mtn_lbnum() {
    for (var i=0;i<4;i++) { var zz=find_object('inlbnum'+i); if (zz) {  zz.innerHTML=lb_objnum; } } l_lb.quickshow(1); }
// suggest --------------------------------------------------------------
sg=false;sgs=false;sgi='';sgo=new Array();sgx=false;sgb=false;sgc=0;sgp=-1;sgobj='';sg_wd=502;sg_dontshow=false;
function sg_w() {
    if (l_filt.open || sg_dontshow) { return; }
    if (!sg) {sgobj=document.sf.obj.value; if(sgobj=='cd'||sgobj=='font') { sg=sg_m(); sgs=find_handle('sg_d'); }} if (!sg) { return; }
    if (sg) { if (sgi!=sgb.value) { if (sgb.value) { sgi=sgb.value; if (sgo[sgi]) {sg_p(sgi)} else {sg_x(sgi);} } else { sgs.visibility='hidden'; } } setTimeout("sg_w()",250); } }
function sg_x(x) {
    //if(sgx && sgx.readyState!=0){sgx.abort()}
    sgx = new xmlhttp_request('x_suggest.php?obj='+sgobj+'&s='+mtn_escape(x),sg_r,'sgy'); }
function sg_r(x) {
    if (sgx) { 
        if (sgx.response) { 
            var y=sgx.response.split('|'); if (y.length>1) { var z=y[0];var q='';for(var i=1;i<y.length;i++){q+=y[i]+'|';}sgo[z]=q;sg_p(z); } else sg_k(); } } }
function sg_p(z) {
    var o=sgo[z].split('|');sgc=0;sgp=-1; var po=1;
    if (sg) { while(sg.childNodes.length>0) { sg.removeChild(sg.childNodes[0]); } }
    sg_row(sgc++,sgobj=='img'?mtn_lang('predictive_trans'):(sgobj=='font'?mtn_lang('predictive_fonts'):mtn_lang('predictive_cd_titles')),' ',false,true); 
    for(var i=0;i<o.length;i++){if(o[i].length){ var t=o[i].split(':');
        if (t[0]=='-tr-') { sg_row(sgc++,t[1],t[1],'',false); }
        //else if (t[0].length) { sg_row(sgc++,mtn_lang('predictive_fonts_in_title')+' '+t[0]+' <span class="re">('+t[1]+''+(sgobj=='font'?mtn_lang('suggest_fonts'):mtn_lang('suggest_cds'))+')</span>',t[2],false,false); }        
        else if (t[0].length) { sg_row(sgc++,mtn_lang('predictive_fonts_in_title')+' '+t[0]+' <span class="re">('+t[1]+')</span>',t[2],false,false); }
        else { sg_row(sgc++,'CD '+t[1]+' <span class="re">('+t[3]+' images)</span> '+t[4],t[1],t[2],false); }}}
    sgs.visibility=sgc?'visible':'hidden'; if (sgc) { sg.style.height=Math.min(200,sgc*18+5)+'px'; } }
function sg_row(i,ih,t,p,bo) {
    var n=document.createElement("DIV");var sn=n.style; n.onmousedown=sg_md; n.onmouseover=sg_mi; n.onmouseout=sg_mo;
    /*sn.width=(sg_wd-25)+'px';sn.overflow='hidden';*/sn.marginRight='3px';sn.height='18px';sn.padding='0';sn.cursor='pointer';n.id='sg'+i;ih='&nbsp;'+ih;
    if (bo) { sn.borderBottom='1px #f3f3f3 dotted'; ih='<div style="float:right;cursor:pointer;"><a class="ql" onclick="sg_k(1)">'+mtn_lang('hide')+'</a></div>'+ih;}
    n.innerHTML=ih;n.t=t;n.prdc=p; sg.appendChild(n); }
function sg_m() {
    if (!sgb) { sgb=document.sf.sok; /*sgb.onblur=sg_k;*/ sgb.onkeydown=sg_t;
        var ibb = find_object('ssbutt'); var ib = find_object('ehs'); if(!ib) { var ib=find_object('fehs'); } var d=document.createElement("DIV"); d.id="sg_d"; var t=sg_ofs(ib,"offsetTop")-2; var l=sg_ofs(ib,"offsetLeft"); var bul=sg_ofs(ibb,"offsetLeft"); if (bul && bul-l-2>sg_wd) {sg_wd=bul-l-2;} with (d.style) { border="#e8e8e8 1px solid"; zIndex="1"; padding="0"; top="228px"; left=l+"px"; width=sg_wd+'px'; visibility="hidden"; position="absolute"; backgroundColor="#f9f9f9"; height='200px'; overflow='auto'; } document.body.appendChild(d);  } 
    return find_object('sg_d'); }
function sg_ofs(r,attr) {
    var o=0; while(r) {o+=r[attr]; r=r.offsetParent; } return o;  }
function sg_k(perm) {
    if (typeof(perm)!='undefined') { sg_dontshow=true; } 
    if(sg){if(sgs){sgs.visibility='hidden';}sg=false; } }
function sg_t(e) {
    var k=e?e:event;var c=k.keyCode;
    if(c==40) { sg_bg(sgp,0,false); sgp++;if(sgp>=sgc){sgp=sgc-1;} sg_bg(sgp,1,false);}
    if(c==38) { sg_bg(sgp,0,false); sgp--;if(sgp<-1){sgp=-1} sg_bg(sgp,1,false); }
    if(c==13) { var b=find_object('sg'+sgp); if (b) { sg_su(b,0); } } }
function sg_bg(num,on,b) {
    if (!b) { if (on && sg.style.height=='200px') { sg.scrollTop=Math.max(0,num*18-180); } b=find_handle('sg'+num); } if (b) { b.backgroundColor=on?'#eff2f9':'#f9f9f9'; } }
function sg_mi(e) { var k=e?e:event; sg_mm(k,1); }
function sg_mo(e) { var k=e?e:event; sg_mm(k,0); }
function sg_md(e) { var k=e?e:event; sg_mm(k,-1); }
function sg_mm(k,a) {
    var o=k.srcElement?k.srcElement:k.target; if (!o.t){o=o.parentNode;} if (!o.t){return;}
    if (a==-1){ sg_su(o,1);}else{sg_bg(0,a,o.style); } }
function sg_su(b,cs) {
    var f=document.sf;
    sgb.value=b.t; f.notrel.value='1'; if (b.prdc){ f.inres.value=b.prdc; f.inres.name='cd'; f.action='cd.php'; f.obj.value='1'; f.obj.name='cdmenu'; }
    if (cs) { f.submit();} }
function trimString (str) {str = this != window? this : str;return str.replace(/^\s+/g, '').replace(/\s+$/g, '');}

function mtn_lbclick(im,cds,prid,id) {
    var state='';
    /*var bu=find_object('lbulb_'+im); 
    if (!bu) bu = find_object('lbulb'); 
    if (!bu) { return; }
    var state='';
    if (bu.src && bu.src.search(new RegExp("[0-9s](y?).gif$","gi"))>=0) { state=RegExp.$1; }
    else if (bu.name) { state=bu.name; }*/
    var bu2=find_object(id);
    //if (bu2.style.color == '#0081AF' || bu2.style.color == 'rgb(0, 129, 175)') state = 'y';
    if (bu2.src.indexOf('g/s/8.gif') > -1) state = 'y';
    var rn=Math.floor(Math.random()*301234);
    if (state=='y') {
        xmlreq('x_lb.php?box=1&lb=rm'+mtn_lb+'&image='+cds+mtn_escape(im)+'&rn='+rn+'&prid='+prid,mtn_lbcresp); 
    } 
    else { 
        xmlreq('x_lb.php?box=1&lb='+mtn_lb+'&image='+mtn_escape(im)+'&cdsingle='+cds+'&rn='+rn+'&prid='+prid,mtn_lbcresp); 
    }
}

function mtn_lbcresp(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]; bt=re[2]; lb_objnum=re[5]; inlbimg=re[6]; mtn_lbnum(); var fontnameinfav = '';
    }
    var bu=find_object('lbulb_'+re[3]); 
    if (!bu) bu = find_object('lbulb');
    if (bu.src) {
        //s=new String(bu.src);
        //if (re[1]==-1) { r=new RegExp("/2(s?)y.gif","i"); bu.src=s.replace(r,"/2$1.gif"); }
        //else if (re[1]==0) { r=new RegExp("/2(s?).gif","i"); bu.src=s.replace(r,"/2$1y.gif"); }
        if (re[1]==-1) { bu.src="g/s/9.gif"; }
        else if (re[1]==0) { bu.src="g/s/8.gif"; }
    }
    else {
        if (re[1]==-1) { 
            bu.name=""; 
            if (fontnameinfav != '') bu.innerHTML=fontnameinfav;
            else {
                bu.innerHTML = document.getElementById('oldname_'+re[3]).value; 
            }
            bu.style.color='#c7c7c9'; 
        }
        else if (re[1]==0) { 
            bu.name="y"; 
            fontnameinfav=bu.innerHTML; 
            bu.innerHTML=mtn_lang('tx9'); 
            bu.style.color='#0081af'; 
        }
    }

    if (window.addedtolb) { 
        addedtolb(re[3],msg,1); 
    } 
    else { 
        mtn_boxtext(bt,msg,1); 
    }
}
function mtn_almd(d){var i=document.createElement("DIV");with(i.style){padding='3px 3px 0 4px';whiteSpace='nowrap';backgroundColor="#e8e8e8";textAlign="right";borderRight="1px #e8e8e8 solid";borderLeft="1px #e8e8e8 solid";}if(d){i.innerHTML='&nbsp;';d.appendChild(i);}return i;}
function popwindow(page,same, width, height) {
  if (!width) {width=500;}
  if (!height) {height=200;}
  winopts = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height;
  var w=window.open(baseurl+page, 'pw'+same, winopts); 
  if (!w) { alert(mtn_lang('popblock')); }
  return w;
  }
function popwindowdirect(page,same, width, height) {
  if (!width) {width=500;}
  height=200;
  winopts = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height;
  return window.open(page, 'pw'+same, winopts); }

function mtn_openerlink(url) { if (opener) {opener.location=baseurl+url;} else {window.open(baseurl+url);} }

// explanation is in the 'Search data for pages' page.
mroll=new Object(); 
mroll.S=new Object(); mroll.C=new Object(); mroll.O=new Object(); mroll.U=new Object(); mroll.X=new Object(); 
mroll.A=new Object(); mroll.B=new Object(); mroll.F=new Object(); mroll.T=new Object(); mroll.M=new Object(); mroll.N=new Object(); 

with(mroll) {
A.rs='tx2';
O.r0=O.rs='txsO';
S.rs='txsS'; T.rs='txsT'; C.rs='txsC'; U.rs='txsU'; X.rs='txsX'; B.rs='txsB'; F.rs='txsF'; M.rs='txsM'; N.rs='txsN'; 
X.r0=S.r0='tx0';
T.r0='txsT';
M.r0='txsM';
A.r1=M.r1=U.r0=O.r1=C.r0=S.r1='tx1';
A.r2=B.r2=M.r2=N.r2=T.r2=F.r2=X.r2=U.r2=O.r2=C.r2=S.r2='tx2';
A.r2y=B.r2y=M.r2y=N.r2y=T.r2y=F.r2y=X.r2y=U.r2y=O.r2y=C.r2y=S.r2y='tx9';
A.r6=B.r6=M.r6=N.r6=T.r6=F.r6=X.r6=U.r6=O.r6=C.r6=S.r6='myacc_view_licen_2';
A.r7=B.r7=M.r7=N.r7=T.r7=F.r7=X.r7=U.r7=O.r7=C.r7=S.r7='lightbox_itemcopy';
A.r4=B.r4=M.r4=N.r4=T.r4=F.r4=X.r4=U.r4=O.r4=C.r4=S.r4='lb_addtobasket';
A.r8=B.r8=M.r8=N.r8=T.r8=F.r8=X.r8=U.r8=O.r8=C.r8=S.r8='lightbox_itemremove';
X.r3=U.r3=O.r3=S.r3='tx3';
C.r3='tx3cd';
F.r3='tx3font';
M.r4=N.r4=T.r4=U.r4=C.r4=S.r4=O.r4='tx4';
lrs['lb_addtobasket']='add to basket';
}

function mtn_rollm(obj,cdsingle,butt) {  
    //alert(obj.id+':'+cdsingle+' :'+butt);
    var gr; 
    var tx; 
    var txc=mtn_background=='bl'?'9f9f9f':'4a362f';  
    if(butt=='e') { obj.innerHTML=''; return; } 	
    if(butt=='5' && obj && obj.id.search(new RegExp("o([0-9]+)$","gi"))>=0) { 
        var k=find_object('orno'+RegExp.$1); 
        if (k) { 
            obj.innerHTML=k.alt; 
            obj.style.color='#'+txc; 
        } 
    } 
    butt='r'+butt; 
    if(mroll[cdsingle]) { 
        if(mroll[cdsingle][butt]) {  
        {txc='5186b3';}  
        tx=mroll[cdsingle][butt]; 
        if (butt=='rs') {txc='5186b3';} 
        if (butt=='rs' && cdsingle=='A') 
            if (mtnsp==true) tx='tx1'; 
            else tx=''; 
            if(gr=mtn_lang(tx))
                {
                    if (gr==' ') gr="&nbsp"; 
                    obj.innerHTML=gr; 
                    //alert(gr);
                    obj.style.color='#'+txc;
                }
        }
    }
}

function mtn_rollms(obj,cdsingle,butt,bobj) {
    if (butt=='2'&&bobj) { if(bobj.src.search(new RegExp("([0-9y]+).gif$","gi"))>=0) { butt=RegExp.$1; } }
    //alert(obj+' '+cdsingle+' '+butt);
    var o=find_object(obj);if(o){mtn_rollm(o,cdsingle,butt);} }

function navfix(max,f) {
    if (f.elements){for(var i=0;i<f.elements.length;i++){if(f.elements[i].name=='oo'){if(parseInt(f.elements[i].value)>max)f.elements[i].value=max;}}}}
mtn_unf=0;
function unfaint(inp) {
    if (mtn_unf==0 && inp && inp.style) { mtn_unf=1; inp.value=""; inp.style.color="#666"; } }

//search session data handling functions
allfs=new Array("f","m","b","p","rz","fsp");persec='';filters_set=new Object();fset_init = false;
function isfset() {
    if ((persec=='') || (!fset_init)) { mtn_fsets(); fset_init = true;} var f;
    var fset = false;
    var aset = new Array();
    for (var i=0;i<allfs.length;i++) {  
        eval('f=filters_set.'+allfs[i]); 
        if (f!=''&&f!=0 ) { 
            fset = true; 
            aset.push(allfs[i]+'='+f);
        } 
    }
    if (fset) {
//        alert(aset.join(','));
    }
    return fset;
}
function mtn_fsave(d) {
    if (persec=='') { mtn_fsets(); }
    var fpa=d.split(':');
    for (var i=0;i<fpa.length;i+=2) { eval('filters_set.'+fpa[i]+'="'+fpa[i+1]+'"'); }
    mtn_bsess('filters_'+persec,d);
}
function mtn_fsets() {
    var f=document.fform;
    if (f) { var fpa=f.fd.value.split(':');
        persec=fpa[0];
        if (persec == '') persec = 'image';
        for (var i=1;i<fpa.length;i+=2) { eval('filters_set.'+fpa[i]+'="'+fpa[i+1]+'"'); } }
}
function mtn_fch(w) {
    var wn=w.name;
    if (wn=='b' || wn=='bb') {
        var b=document.fform.b;var bb=document.fform.bb;var ba=new Array();
        for(var i=0;i<b.options.length;i++) {
            if (wn=='bb' && bb.checked) { b.options[i].selected=false; }
            else if (b.options[i].selected) { ba.push(b.options[i].value); } }
        	if (bb != undefined) bb.checked=ba.length?false:true;

        //for(var i=0;i<b.options.length;i++) { b.options[i].style.backgroundColor=ba.length?"#fff":"#eee"; }
        for(var i=0;i<b.options.length;i++) { b.options[i].style.color=b.options[i].selected?"#5186b3":"#9f9f9f"; }
        mtn_fsave('b:'+ba.join(','));
    }
    else if (wn=='p' || wn=='rz' ||  wn=='stp' || wn=='si' || wn=='ftype' || wn=='fenc' || wn == 'platform' || wn == 'theme' || wn == 'category') {
        mtn_fsave(wn+':'+w.value);
    }
}
function mtn_cbfilt() {
    var c=document.fform;var f=0;var m=0;var b0;var b1;
    var cbs=new Array('o','s','i','c','r');
    for (var i=0;i<cbs.length;i++) {
        eval('b0=c.'+cbs[i]+'0'); eval('b1=c.'+cbs[i]+'1');
        if (i==4) i=26;
		if (b0 != undefined) {
        	if (b0.checked==false) { m+=Math.pow(2,i); f+=Math.pow(2,i); }
        	else if (b1.checked==false) { m+=Math.pow(2,i); }
		}
    }
    if (c.a != undefined) {
		if (c.a.selectedIndex) { m+=Math.pow(2,25); }
		if (c.a.selectedIndex) { f+=Math.pow(2,25); }
	}
    mtn_fsave('f:'+f+':m:'+m);    
}
function mtn_clearfilt() {
    mtn_fsave('b::p::rz::f::m::fsp::icons:');
    filters_deleted = false;
}
function mtn_fcb(cb,n,sign) {
    var cb1;var cb2;var f=document.fform;var n2=n?0:1; eval('cb1=f.'+cb+n);eval('cb2=f.'+cb+n2);
    if (cb1.checked==false && cb2.checked==false){ alert(mtn_lang('cb_atl1')+' '+mtn_lang('cb_atl'+cb+sign)+' '+mtn_lang('cb_atl2'));cb2.checked=true;}mtn_cbfilt();}
function mtn_free(e) {
    var p=e.target?e.target:e.srcElement; 
    if (p.nodeName=="IMG" && p.id.search(new RegExp("fs([0-9])","gi"))>=0) { 
        var sw=RegExp.$1; 
        var fsp=0;
        for (var i=0;i<9;i++) {
            p=find_object('fs'+i);
            if (p) {
                if (i==sw) { p.className=p.className==''?'sel':''; }
                if (p.className=='sel') { fsp+=Math.pow(2,i); }
            }
        }
    }
    mtn_fsave('fsp:'+fsp);    
}
function mtn_bgch(e) {
    var p=e.target?e.target:e.srcElement;
    gs=gifs.join("|");
    if (p.nodeName=="IMG" && p.src.search(new RegExp("g/("+gs+").gif$","gi"))>=0) { 
        var bg=RegExp.$1; 
        var pa=p.parentNode; var i; var j;
        for(i=0;i<pa.childNodes.length;i++) { // highlight selected 
            j=pa.childNodes[i];
            if (j.nodeName=="IMG" && j.src.search(new RegExp("g/("+gs+").gif$","gi"))>=0) { 
                j.style.borderColor=bg==RegExp.$1?"#5186b3":"#aaa";
            }
        }
        if (mtn_background!=bg) {
            dri=0;
            if (bg=='w') { dri=-4; } else if (mtn_background=='w') { dri=-3; } // replace buttons if changed from or to white
            mtn_background=bg;
            var ra=find_object('colbgr');
            for (x=0;x<bgcolors.length;x++) { 
                if (gifs[x]==bg) bgc=bgcolors[x];
            }
            if (ra) {  // change background if in search page
                bgcolor=bgc;
                ra.style.backgroundColor=bgc; 
                //if (dri<0) {
                    var xx;
                    if (typeof(mtn_res)=='undefined' || mtn_res<=0) { xx=97; } else { xx=mtn_res; }
                    for (x=0;x<xx;x++) { 
                        c=find_object('s1'+x); if (c && xx!=97) { 
                            mtn_attach(c,dri);
                        } 
                        c=find_object('s4'+x); if (c) {
                            c.style.backgroundColor=bgc; 
                        } 
                    }
                //}
            }
            else
            {
                ra=find_object('stbb');
                if (ra) {  // change background if in lightbox page
                    bgcolor=bgc;
                    mtn_lbbg_lb();
                    ra.style.backgroundColor=bgc; 
                    var xx;
                    if (typeof(mtn_res)=='undefined' || mtn_res<=0) { xx=97; } else { xx=mtn_res; }
                    for (x=0;x<xx;x++) { 
                        c=find_object('s'+x); 
                        if (c) {
                            c.style.backgroundColor=bgc;
                            mtn_attach(c,dri);
                        }
                    }
                    mtn_changethumbs(1);
                }
            }
            mtn_fsave('bg:'+bg);
        }
    }
}
function mtn_bych(s) { 
    var f=document.sf; var v=s.options[s.selectedIndex].value;
    if (typeof(f.by)!='undefined') {
        var l=location+'';
        if (l.indexOf('.php')<0) { l=l+'/by-'+v+'/byh-'+f.by.value; }
        else { uconc=(l.indexOf('?')>0)?'&':'?'; l=l+uconc+'by='+v+'&byh='+f.by.value; } 
        location=l;
    }
    else {
        mtn_fsave('by:'+v);
    }
}
function mtn_pch(s) { mtn_fsave('p:'+s.options[s.selectedIndex].value); return true; }
function mtn_lbch(s) { mtn_fsave('lb:'+s.options[s.selectedIndex].value); return true;    }
function mtn_stpch(s) { mtn_fsave('stp:'+s.options[s.selectedIndex].value); return true;    }
function mtn_extch(s) { mtn_fsave('ext:'+s.options[s.selectedIndex].value);    mtn_ext=s.options[s.selectedIndex].value; }
function mtn_ich(s) {
    mtn_fsave('icons:'+s.options[s.selectedIndex].value);    
    mtn_icons=s.options[s.selectedIndex].value;
    if (mtn_stb) { mtn_stb(-1,1); }
}
mtn_res=-1;mtn_thumbsize=-1;
function mtn_changethumbs(size) {
    mtn_fsave('thsize:'+size);
    if (size==mtn_thumbsize || mtn_thumbsize==-1) {return;}
    if (mtn_res>0) {
        mtn_stb(size);
        for (x=0;x<mtn_res;x++) { c=find_object('s0'+x); if (c) { mtn_attach(c,2+size); } }
        mtn_thumbsize=size;
    }
}
function mtn_debug(data){
    var d=find_object('debug');
    if (d) { d.innerHTML=data; }
}
function promoover(ev) {
    var e = ev ? ev : event;
    var p = e.target ? e.target : e.srcElement;
    while (p && (typeof(p.pobj) == 'undefined')) p = p.parentNode;
    if (p) {
        p.pobj.waitforstop[p.section_id] = true; 
        setTimeout(function() {promostate(p.pobj,p.section_id, true);}, 1000);
    }
}
function promoout(ev) {
    var e = ev ? ev : event;
    var p = e.target ? e.target : e.srcElement;
    while (p && (typeof(p.pobj) == 'undefined')) p = p.parentNode;
    if (p) {
        p.pobj.waitforstop[p.section_id] = false; 
        setTimeout(function() {promostate(p.pobj,p.section_id, false);}, 1000);
    }
}
function promolock(ev) {
    var e = ev ? ev : event;
    var p = e.target ? e.target : e.srcElement;
    while (p && (typeof(p.pobj) == 'undefined')) p = p.parentNode;
    if (p) {
        p.pobj.locked[p.section_id] = !p.pobj.locked[p.section_id];
        p.pobj.waitforstop[p.section_id] = p.pobj.locked[p.section_id]; 
        setTimeout(function() {promostate(p.pobj,p.section_id, p.pobj.locked[p.section_id]);}, 1000);
    }
}
indi=new Array();indi['indicator']=false;indi['moreimages']=false;var indi_stop = new Array(); indi_stop['indicator']=false;indi_stop['moreimages']=false;
function mtn_loa(i,wi) {
    if (!indi_stop[wi]) {
        i++; var ind=find_object(wi); 
        if (ind) { 
            if (!indi[wi]){indi[wi]=ind.innerHTML;}
//         if (i==10) {i=0; ind.innerHTML=indi[wi]; } else { ind.innerHTML=ind.innerHTML+'.'; } 
        }
         setTimeout("mtn_loa("+i+",'"+wi+"')",250); 
    }
}

function mtn_unescape(t) {  // for Safari 1.x and Explorer 5.0
    if (decodeURIComponent) return decodeURIComponent(t);
    return unescape(t); }
function mtn_escape(t) {  // for Safari 1.x and Explorer 5.0
    if (encodeURIComponent) { return encodeURIComponent(t); }
    return escape(t); }

function cdinfo_expand(state) { 
	if (state==1) {
		document.getElementById("cdinfoext").style.display="block";
		document.getElementById("cdinfo").style.display="none";
		document.getElementById("cdinfoshrink").style.display="block";
	}
	else {
		document.getElementById("cdinfoext").style.display="none";
		document.getElementById("cdinfo").style.display="block";		
	}
	
}
function ownToFixed(x, d) {
    if (x == undefined) x=0;
    if (x.toFixed) return x.toFixed(d);
    x = Math.round(x*100).toString();
    x = x.substring(0,x.length-d)+'.' + x.substring(x.length-d,x.length);
    return x;
}
function wdlink(o,go) {
    var a=o.childNodes[0];
    if (go==0) {
        location=a.href;
    }
    else {
        //a.style.textDecoration=go==1?"underline":"none";
        a.childNodes[0].style.borderColor=go==1?"#888":"#fff";
    }
}

function show_tooltip(text,ev) {
    var n=document.getElementById("tooltip_div");
    if (!n) {
        n=document.createElement("DIV");
        n.id="tooltip_div";
        n.style.zIndex=99999;
        n.style.position="absolute";
        n.style.backgroundColor="#fff";
        n.style.padding="3px";   
        n.style.maxWidth="375px";
        document.body.appendChild(n); 
    }        
    n.innerHTML=text;    
    n.style.display="block";
}       

function mtn_move_div(ev,obj,vis) {
    var x;var y;var d=find_handle(obj);
    y=ev.pageY?ev.pageY:ev.y; x=ev.pageX?ev.pageX:ev.x; y=parseInt(y)+1; x=parseInt(x)+10; 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 set_cookie(cookieName,cookieValue,nDays) {
    var today = new Date();
    var expire = new Date();
    if (nDays==null || nDays==0) nDays=1;
    expire.setTime(today.getTime() + 3600000*24*nDays);
    document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}
// * * * * * E U L A   a c c e p t   s c r i p t s * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
function div_scroll_position(id) {
    var valami = document.getElementById('eulabox_'+id).scrollHeight;
    var valami2 = document.getElementById('eulabox_'+id).scrollTop;
    alert (valami+', '+valami2);
}

function check_box(id) {   
    field = document.getElementById('accept_'+id);
    if (field.checked == true) field.checked = false;
    else field.checked = true;
    
    licence_accept(id);
}

function licence_accept(id) {
    if(document.getElementById('accept_'+id).checked) licences[id]=1;
    else licences[id]=0;
}

function licence_submit() {
    var l_go = 1;
    for (var q=0; q<licences.length; ++q) {
        if (licences[q] == 0) {
            l_go = 0;
        }
    }
    if (l_go == 1) {
        document.bform.submit();
    }
    else {
        alert('You must accept all the licences!');
        for (var q=0; q<licences.length; ++q) {
            if (licences[q] == 0) {
                document.getElementById('desc_'+q).setAttribute('class', 'bo re');
            }
        }                                                
    }
}
// * * * * * E U L A   a c c e p t   s c r i p t s * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
