var efa_default = 100;                                                                                        //default text size as percentage of user default
var efa_increment = 10;                                                                                        //percentage to increase/decrease font size

var efa_bigger_de = ['<ul><li>',                       //HTML to go before 'bigger' link
                 '<span>Schrift gr&ouml;sser<' + '/span>',            //HTML to go inside 'bigger' anchor tag
                 'Mit einem Klick k&ouml;nnen Sie die Schrift gr&ouml;sser stellen',                                //title attribute
                 'plus',                            //class attribute
                 '',                                //id attribute
                 '',                                //name attribute
                 '',                                //accesskey attribute
                 '',                                //onmouseover attribute
                 '',                                //onmouseout attribute
                 '',                                //onfocus attribute
                 '<' + '/li><' + '/ul>'             //HTML to go after 'bigger' link
                    ]

var efa_bigger_en = ['<ul><li>', '<span>Font larger<' + '/span>', 'Click here to enlarge print', 'plus', '', '', '', '', '', '', '<' + '/li><' + '/ul>']
var efa_bigger_cz = ['<ul><li>', '<span>Zv&#283;tit velikost písma<' + '/span>', 'Kliknutím m&#367;ete zv&#283;tit písmo', 'plus', '', '', '', '', '', '', '<' + '/li><' + '/ul>']
var efa_bigger_it = ['<ul><li>', '<span>Carattere grande<' + '/span>', 'Con un clic puoi ingrandire la grandezza del carattere', 'plus', '', '', '', '', '', '', '<' + '/li><' + '/ul>']
var efa_bigger_hu = ['<ul><li>', '<span>Nagyítás<' + '/span>', 'Egy kattintással felnagyíthatja a bet&#369;méretet', 'plus', '', '', '', '', '', '', '<' + '/li><' + '/ul>']
var efa_bigger_nl = ['<ul><li>', '<span>Grotere letter<' + '/span>', 'U kunt de tekengrootte met één klik vergroten', 'plus', '', '', '', '', '', '', '<' + '/li><' + '/ul>']

var efa_smaller_de = ['<ul><li>',                      //HTML to go before 'smaller' link
                 '<span>Schrift kleiner<' + '/span>',                 //HTML to go inside 'smaller' anchor tag
                 'Mit einem Klick k&ouml;nnen Sie die Schrift kleiner stellen',                                       //title attribute
                 'minus',                           //class attribute
                 '',                                //id attribute
                 '',                                //name attribute
                 '',                                //accesskey attribute
                 '',                                //onmouseover attribute
                 '',                                //onmouseout attribute
                 '',                                //onfocus attribute
                 '<' + '/li><' + '/ul>'             //HTML to go after 'smaller' link
                                  ]
var efa_smaller_en = ['<ul><li>', '<span>Font smaller<' + '/span>', 'Click here to make print smaller','minus','','','','', '','','<' + '/li><' + '/ul>']
var efa_smaller_cz = ['<ul><li>', '<span>Normální velikost písma<' + '/span>', 'Kliknutím m&#367;ete zmenit písmo','minus','','','','', '','','<' + '/li><' + '/ul>']
var efa_smaller_it = ['<ul><li>', '<span>Carattere piccolo<' + '/span>', 'Con un clic puoi rimpicciolire la grandezza del carattere','minus','','','','', '','','<' + '/li><' + '/ul>']
var efa_smaller_hu = ['<ul><li>', '<span>Kicsinyítés<' + '/span>', 'Egy kattintással kicsinyítheti a bet&#369;méretet','minus','','','','', '','','<' + '/li><' + '/ul>']
var efa_smaller_nl = ['<ul><li>', '<span>Kleinere letter<' + '/span>', 'U kunt de tekengrootte met één klik verkleinen','minus','','','','', '','','<' + '/li><' + '/ul>']

var efa_reset_de = ['<ul><li>',                        //HTML to go before 'reset' link
                 '<span>normale Schriftgr&ouml;&szlig;e<' + '/span>', //HTML to go inside 'reset' anchor tag
                 'Mit einem Klick k&ouml;nnen Sie die Ausgangs-Schriftgr&ouml;&szlig;e wieder einstellen',                                //title attribute
                 'gleich',                          //class attribute
                 '',                                //id attribute
                 '',                                //name attribute
                 '',                                //accesskey attribute
                 '',                                //onmouseover attribute
                 '',                                //onmouseout attribute
                 '',                                //onfocus attribute
                 '<' + '/li><' + '/ul>'             //HTML to go after 'reset' link
                                   ]
var efa_reset_en = ['<ul><li>','<span>Normal font size<' + '/span>','Click here to return to original print','gleich','','','','','','','<' + '/li><' + '/ul>' ]
var efa_reset_cz = ['<ul><li>','<span>Zmenit velikost písma<' + '/span>','Kliknutím se vrátíte k p&#367;vodní velikosti písma','gleich','','','','','','','<' + '/li><' + '/ul>' ]
var efa_reset_it = ['<ul><li>','<span>Carattere medio<' + '/span>','Con un clic puoi ristabilire la grandezza originale del carattere','gleich','','','','','','','<' + '/li><' + '/ul>' ]
var efa_reset_hu = ['<ul><li>','<span>Normál szövegméret<' + '/span>','Egy kattintással visszaállíthatja az eredeti bet&#369;méretet','gleich','','','','','','','<' + '/li><' + '/ul>' ]
var efa_reset_nl = ['<ul><li>','<span>Normale lettergrootte<' + '/span>','U kunt de standaardtekengrootte met één klik herstellen','gleich','','','','','','','<' + '/li><' + '/ul>' ]


function Efa_Fontsize(increment,bigger,reset,smaller,def) {
        this.w3c = (document.getElementById);
        this.ms = (document.all);
        this.userAgent = navigator.userAgent.toLowerCase();
        this.isOldOp = ((this.userAgent.indexOf('opera') != -1)&&(parseFloat(this.userAgent.substr(this.userAgent.indexOf('opera')+5)) <= 7));
        if ((this.w3c || this.ms) && !this.isOldOp && !this.isMacIE) {
                this.name = "efa_fontSize";
                this.cookieName = 'efaSize';
                this.increment = increment;
                this.def = def;
                this.defPx = Math.round(16*(def/100))
                this.base = 1;
                this.pref = this.getPref();
                this.testHTML = '<div id="efaTest" style="position:absolute;visibility:hidden;line-height:1em;">&nbsp;</div>';
                this.biggerLink = this.getLinkHtml(1,bigger);
                this.smallerLink = this.getLinkHtml(-1,smaller);
                this.resetLink = this.getLinkHtml(0,reset);
        } else {
                this.biggerLink = '';
                this.smallerLink = '';
                this.resetLink = '';
                this.efaInit = new Function('return true;');
        }

        //this.allLinks = this.biggerLink + this.resetLink + this.smallerLink;
        this.allLinks = this.biggerLink + this.resetLink ;
}

Efa_Fontsize.prototype.efaInit = function() {
                document.writeln(this.testHTML);
                this.body = (this.w3c)?document.getElementsByTagName('body')[0].style:document.all.tags('body')[0].style;
                this.efaTest = (this.w3c)?document.getElementById('efaTest'):document.all['efaTest'];
                var h = (this.efaTest.clientHeight)?parseInt(this.efaTest.clientHeight):(this.efaTest.offsetHeight)?parseInt(this.efaTest.offsetHeight):999;
                if (h < this.defPx) this.base = this.defPx/h;
                this.body.fontSize = Math.round(this.pref*this.base) + '%';
}

Efa_Fontsize.prototype.getLinkHtml = function(direction,properties) {
        var html = properties[0] + '<a href="#" onclick="efa_fontSize.setSize(' + direction + '); return false;"';
        html += (properties[2])?'title="' + properties[2] + '"':'';
        html += (properties[3])?'class="' + properties[3] + '"':'';
        html += (properties[4])?'id="' + properties[4] + '"':'';
        html += (properties[5])?'name="' + properties[5] + '"':'';
        html += (properties[6])?'accesskey="' + properties[6] + '"':'';
        html += (properties[7])?'onmouseover="' + properties[7] + '"':'';
        html += (properties[8])?'onmouseout="' + properties[8] + '"':'';
        html += (properties[9])?'onfocus="' + properties[9] + '"':'';
        return html += '>'+ properties[1] + '<' + '/a>' + properties[10];
}

Efa_Fontsize.prototype.getPref = function() {
        var pref = this.getCookie(this.cookieName);
        if (pref) return parseInt(pref);
        else return this.def;
}

Efa_Fontsize.prototype.setSize = function(direction) {
        this.pref = (direction)?this.pref+(direction*this.increment):this.def;
        this.setCookie(this.cookieName,this.pref);
        this.body.fontSize = Math.round(this.pref*this.base) + '%';
}

Efa_Fontsize.prototype.getCookie = function(cookieName) {
        var cookie = cookieManager.getCookie(cookieName);
        return (cookie)?cookie:false;
}

Efa_Fontsize.prototype.setCookie = function(cookieName,cookieValue) {
        return cookieManager.setCookie(cookieName,cookieValue);
}

var efa_bigger_language = self['efa_bigger_'+lang];
var efa_reset_language = self['efa_reset_'+lang];
var efa_smaller_language = self['efa_smaller_'+lang];

var  efa_fontSize = new Efa_Fontsize(efa_increment,efa_bigger_language,efa_reset_language,efa_smaller_language,efa_default);
