/*  Pixy DOM DHTML Lib 1.2.1
    ------------------------
    Knihovna JS funkci pro snazsi dynamickou manipulaci s HTML dokumenty
    
    Copyright (C) 2001 Petr Stanicek (aka -pixy-), mailto:stanicek@mac.com
    Info, licence, download, kontakt: http://web.iol.cz/pixy/dhtmllib.html
    * GNU/GPL 2.CZE *
    Tato knihovna a jeji soucasti jsou volne programove vybaveni;
    muzete jej sirit a modifikovat podle ustanoveni Obecne verejne licence GNU
    pro Ceskou republiku, vydavane Free Software Foundation a obcanskym sdruzenim
    zastudena.cz, ve verzi 2.CZE teto licence.
    Tento program je rozsirovan v nadeji, ze bude uzitecny, avsak BEZ JAKEKOLI ZARUKY;
    neposkytuji se ani odvozene zaruky PRODEJNOSTI anebo VHODNOSTI PRO URCITY UCEL.
    Dalsi podrobnosti hledejte v Obecne verejne licenci GNU pro Ceskou republiku,
    ktera je soucasti teto knihovny - http://web.iol.cz/pixy/dhtmllib.html
*/

var jsDOM0 = (document.all);
var jsDOM1 = (document.getElementById);
var jsDOM = jsDOM0 || jsDOM1;
var jsDebug = 0;

function getObj (name) {
    if (typeof name == "object") return name;
    if (jsDOM1) return document.getElementById(name);
    if (jsDOM0) return eval('document.all.'+name);
    else return null;
    }

function getObjX(name) {
    var n,x,obj=getObj(name);
    n = ( (x=obj.style.pixelLeft) || (x=obj.offsetLeft) || (x=parseInt(obj.style.left)) ) ? x:null;
    if (jsDebug) doDebug(n);
    return n;
    }
function getObjY(name) {
    var n,x,obj=getObj(name);
    n = ( (x=obj.style.pixelTop) || (x=obj.offsetTop) || (x=parseInt(obj.style.top)) ) ? x:null;
    if (jsDebug) doDebug(n);
    return n;
    }
function getObjW(name) {
    var n,x,obj=getObj(name);
    if (!obj) return;
    n = ( (x=obj.style.pixelWidth) || (x=obj.clientWidth) || (x=obj.offsetWidth) || (x=parseInt(obj.style.width)) ) ? x:null;
    if (jsDebug) doDebug(n);
    return n;
    }
function getObjH(name) {
    var n,x,obj=getObj(name);
    if (!obj) return;
    n = ( (x=obj.style.pixelHeight) || (x=obj.clientHeight) || (x=obj.offsetHeight) || 
    (x=parseInt(obj.style.height)) ) ? x:null;
    if (jsDebug) doDebug(n);
    return n;
    }

function getWinW() {
    if (window.innerWidth) x=window.innerWidth;
    else if (document.body.clientWidth) x=document.body.clientWidth;
    if (jsDebug) doDebug(x);
    return x;
    }
function getWinH() {
    if (window.innerHeight) x=window.innerHeight;
    else if (document.body.clientHeight) x=document.body.clientHeight;
    if (jsDebug) doDebug(x);
    return x;
    }

function moveObjTo(name,x,y) {
    if (jsDebug) doDebug();
    var x,obj = getObj(name);
    if (!obj) return;
    if (x!=null) obj.style.left = x+'px'; if (y!=null) obj.style.top = y+'px';
    return obj;
    }
function moveObjBy(name,dx,dy) {
    if (jsDebug) doDebug();
    var x = getObjX(name)+dx; var y = getObjY(name)+dy;
    moveObjTo(name,x,y);
    }
function resizeObjTo(name,w,h) {
    if (jsDebug) doDebug();
    var x,obj = getObj(name);
    if (w!=null) obj.style.width = w+'px'; if (h!=null) obj.style.height = h+'px';
    return obj;
    }
function resizeObjBy(name,wk,hk) {
    if (jsDebug) doDebug();
    var w = getObjW(name)*wk; var h = getObjH(name)*hk;
    resizeObjTo(name,w,h);
    }

function getObjCSSProp(name,prop) {
    var x,obj=getObj(name);
    if (obj.style) x=eval("obj.style."+prop); else x=null;
    if (jsDebug) doDebug(x);
    return x;
    }
function setObjCSSProp(name,prop,val) {
    if (jsDebug) doDebug();
    var obj=getObj(name); eval("obj.style."+prop+"='"+val+"'");
    return obj;
    }
function getObjContent(name) {
    var x,obj = getObj(name);
    if(!(x=obj.innerHTML)) x='';
    if (jsDebug) doDebug(x);
    return x;
    }
function setObjContent(name,html) {
    if (jsDebug) doDebug();
    var obj = getObj(name);
    if(obj.innerHTML) obj.innerHTML=html;
    return obj;
    }

function getObjVisible(name) {
    var x = getObjCSSProp(name,'visibility'); x=(x!='hidden');
    if (jsDebug) doDebug(getObjVisible.caller, x);
    return x;
    }
function setObjVisible(name,show) {
    if (jsDebug) doDebug();
    return setObjCSSProp(name,'visibility',(show)?'visible':'hidden');
    }
function getObjDisplayed(name) {
    var x = getObjCSSProp(name,'display'); x=(x!='none');
    if (jsDebug) doDebug(x);
    return x;
    }
function setObjDisplayed(name,show) {
    if (jsDebug) doDebug();
    return setObjCSSProp(name,'display',(show)?'block':'none');
    }

function getObjClip(name) {
    var str = getObjCSSProp(name,"clip");
    if (str) {
        var cl = new Array();
        var i = str.indexOf("(");
        cl[0] = parseInt(str.substring(i + 1, str.length), 10);
        i = str.indexOf(" ", i + 1);
        cl[1] = parseInt(str.substring(i + 1, str.length), 10);
        i = str.indexOf(" ", i + 1);
        cl[2] = parseInt(str.substring(i + 1, str.length), 10);
        i = str.indexOf(" ", i + 1);
        cl[3] = parseInt(str.substring(i + 1, str.length), 10);
        return cl;
        }
    else var cl = false;
    if (jsDebug) doDebug(cl);
    return cl;
    }
function setObjClip(name,t,r,b,l) {
    if ( (t==null) || (r==null) || (b==null) || (l==null) ) {
        var cl = getObjClip(name);
        if (t==null) t = cl[0];
        if (r==null) r = cl[1];
        if (b==null) b = cl[2];
        if (l==null) l = cl[3];
        }
    var obj = getObj(name);
    var str = 'rect(' + t+'px ' +  r+'px ' + b+'px ' + l+'px)';
    obj.style.clip = str;
    if (jsDebug) doDebug(str);
    return obj;
    }

function getObjDepth(name) {
    var x = getObjCSSProp(name,'zIndex');
    if (jsDebug) doDebug(x);
    return x;
    }
function setObjDepth(name,z) {
    if (jsDebug) doDebug();
    return setObjCSSProp(name,'zIndex',z);
    }

function setObjBkgr(name,color,src) {
    var obj=getObj(name);
    if (jsDebug) doDebug();
    if (color!=null) setObjCSSProp(obj,'backgroundColor',color);
    if (src!=null) setObjCSSProp(obj,'backgroundImage','url('+src+')');
    return obj;
    }
function setObjFont(name,family,size,color,weight,style) {
    var obj=getObj(name);
    if (jsDebug) doDebug();
    if (family!=null) setObjCSSProp(obj,'fontFamily',family);
    if (size!=null) setObjCSSProp(obj,'fontSize',size);
    if (color!=null) setObjCSSProp(obj,'color',color);
    if (weight!=null) setObjCSSProp(obj,'fontWeight',weight);
    if (style!=null) setObjCSSProp(obj,'fontStyle',style);
    return obj;
    }
function setObjBorder(name,style,width,color) {
    var obj=getObj(name);
    if (jsDebug) doDebug();
    if (style!=null) setObjCSSProp(obj,'borderStyle',style);
    if (width!=null) setObjCSSProp(obj,'borderWidth',width);
    if (color!=null) setObjCSSProp(obj,'borderColor',color);
    return obj;
    }

function addStylesheet(url) {
    if (jsDebug) doDebug();
    document.write("<LINK rel='stylesheet' href='"+url+"' type='text/css'>");
    }
function activateStylesheet(n,active) {
    if (jsDebug) doDebug(activateStylesheet.caller);
    if(document.styleSheets) document.styleSheets[n].disabled=!active;
    }

// Browser Check

function getBrowser() {
    var app = navigator.appName;
    if (app=="Microsoft Internet Explorer") this.br = "IE"; else if (app=="Netscape") this.br = "NN"; else this.br = app;
    this.v = navigator.appVersion; this.vmaj = parseInt(this.v); this.vmin = parseFloat(this.v);
    this.NN = (this.br=="NN");
    this.NN4 = (this.br=="NN" && this.vmaj==4);
    this.NNmin4 = (this.br=="NN" && this.vmaj>=4);
    this.NN6 = (this.br=="NN" && this.vmaj>=5);
    this.IE = (this.br=="IE");
    this.IEmin4 = (this.br=="IE" && this.vmaj>=4);
    this.IE4 = (this.v.indexOf('MSIE 4')>-1);
    this.Mac = (this.v.indexOf('Mac')>-1);
    this.IE4Mac = (this.IE4 && this.Mac);
    this.IE5 = (this.v.indexOf('MSIE 5')>-1);
    this.IE55 = (this.v.indexOf('MSIE 5.5')>-1);
    this.IE6 = (this.v.indexOf('MSIE 6')>-1);
    this.IEmin5 = (this.br=="IE" && (this.IE5 || this.IE6 || this.vmaj>=5));
    this.ua = navigator.userAgent.toLowerCase();
    this.OP = (this.ua.indexOf('opera')>-1);
    this.OPMac = (this.OP && this.OP);
    this.IEnotOP = (this.IE && !this.OP)
    this.GEC = (this.ua.indexOf('gecko')>-1);
    }
var BrIs = new getBrowser();

function testBadWidths() {
    var name = "testbadwidthslayer";
    if (document.body.insertAdjacentHTML) {
        s = '<div id="'+name+'"></div>';
        document.body.insertAdjacentHTML("beforeEnd", s);
        }
    else {
        var test = document.createElement('div');
        test.setAttribute("id",name);
        document.body.appendChild(test);
        }
    setObjCSSProp(name,'margin',0+'px');
    setObjCSSProp(name,'padding',0+'px');
    resizeObjTo(name,null,100);
    var x, obj = getObj(name);
    var x1 = (x=obj.offsetHeight) || (x=obj.clientHeight) || (x=obj.style.pixelHeight);
    setObjCSSProp(name,'padding',10+'px');
    resizeObjTo(name,null,100);
    var x2 = (x=obj.offsetHeight) || (x=obj.clientHeight) || (x=obj.style.pixelHeight);
    setObjDisplayed(name,0);
    return (x1==x2);
    }

// Debugging section

var DebugWin;

function doDebug(result) {
    if (jsDebug) {
        if (jsDebug>0) jsDebug--;
        var i, n, call = doDebug.caller;
        var buff = "", fstr = "";
        while (call) {
            func = call.toString();
            n=func.indexOf('(');
            if(n>-1) fstr=func.substring(0,n); else fstr=func.toString();
            par='('; n=call.arguments.length;
            for (i=0; i<n; i++) par += call.arguments[i] + ((i<n-1)?', ':'');
            par += ")";
            buff = fstr + par + " =&gt;<br>" + buff;
            call = call.caller;
            }
        if (!fstr) fstr = "unknown =&gt;<br>";
        if (!result) buff += '<b>&lt;no result&gt;</b>';
        else buff += "<b>result:</b> "+result;
        PrintDebug(buff);
        }
    }

function Dump() {
    func = Dump.caller;
    if (func) { funcname=func.toString(); n=funcname.indexOf('('); if(n>-1) funcname=funcname.substring(0,n); }
    else { funcname = "unknown"; par = ""; }
    var acnt = Dump.arguments.length;
    var str=''; for (var i=0;i<acnt; i++) str += ((str)?', ':'') + Dump.arguments[i];
    PrintDebug('Dump from '+funcname+': '+str); }

function PrintDebug(s) {
    if (!DebugWin || DebugWin.closed) {
        DebugWin = window.open('','Debugger','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=440');
        DebugWin.document.writeln('<html><head><TITLE>Debugger</TITLE></head><body>\n');
        dom=(jsDOM1)?'DOM':(jsDOM0)?'document.all':'';
        DebugWin.document.writeln('<h4>Model: '+dom+'</h4>\n');
        }
    DebugWin.document.writeln(s+'<hr>');
    }
