if (Browser.NS4){
        origWidth = innerWidth;
        origHeight = innerHeight;
}

var        useCookie = true;
var blnInitFont = true;
var intStep = 2;
//var intMidFontSize = 10;// for fonts in pt
var intMidFontSize = 13;// for fonts in px
var intMinFontSize = intMidFontSize - (intStep * 2);
var intMaxFontSize = intMidFontSize + (intStep * 2);

var intrest = 0;
var intScrollTextWidth = 397;
var intScreenItemsHeight = 0;
var intScreenItemsHeightCorrection = 4;
if (Browser.NS4 && Browser.Mac){
        intScreenItemsHeightCorrection = 0;
}
var intScreenItemsWidth = 0;

/*-----------------------------------------*/
function fontResize(id,direction){
        if (Browser.IE5 || Browser.IE55 || Browser.IE6){        //leave function if id dosnīt exist (AuthorMode)
                if (!findObj(id)) return;                                                 //if object dosnīt exist (AuthorMode)
        }
        var intFontSize;
        var intNewValue = 0;
        intFontSize = parseInt(readCookie('fontSize'));

        if (direction == "+1"){
                if (intFontSize < intMaxFontSize){
                        intNewValue += intStep;
                }
        }
        if (direction == "-1"){
                if (intFontSize > intMinFontSize){
                        intNewValue -= intStep;
                }
        }
        var myValue = intNewValue;
        if(Browser.IE5){
                var myfont = findObj(id);
                if(Browser.Mac){
                        var curValue = parseInt(readCookie('fontSize'));
                }
                else{
                        var curValue = parseInt(myfont.currentStyle.fontSize.replace('px',''));
                }
                myValue = myValue + curValue;
                setFontSize(id,myValue);
        }
        else if (Browser.NS4){
                intFontSize = parseInt(readCookie('fontSize')) + myValue;
                document.layers['rela'].layers['elMain'].document.open();
                document.layers['rela'].layers['elMain'].document.write('<span class="LongstorySubHead" id="Longstory" style="font-size:' + intFontSize + 'px;FONT-FAMILY: tahoma, Geneva, Arial, Helvetica, sans-serif;">' + ScrollText + '</span>');
                document.layers['rela'].layers['elMain'].document.close();
                setCookie('fontSize',intFontSize);
                initScroll();
        }
        else if (Browser.NS6 || Browser.IE4){
                intFontSize = parseInt(readCookie('fontSize')) + myValue;
                setFontSize('longstory',intFontSize)
                setCookie('fontSize',intFontSize);
                initScroll();
        }
        else if (Browser.Opera){
                intFontSize = parseInt(readCookie('fontSize')) + myValue;
                setFontSize('divContentOP',intFontSize)
                setCookie('fontSize',intFontSize);
//                initScroll();
        }
}
function setFontSize(id,size){
        var myfont;
        if (Browser.NS6){
                myfont = document.getElementById(id);
                myfont.style.fontSize = size + "px";
        }
        else if (Browser.Opera){
                return;
        }
        else{
                myfont = findObj(id);
                if (myfont){
                        if (Browser.Mac){
                                myfont.innerHTML = '<font style="font-size: ' + size + 'px;FONT-FAMILY: tahoma, Geneva, Arial, Helvetica, sans-serif;">' + ScrollText + '</font>';
                        }
                        else{
                                myfont.style.fontSize = size + " px";
                        }
                }
        }
        setCookie('fontSize',size);
}
function setCookie(cookieName,cookieValue) {
        var today = new Date();
        var expire = new Date();
        expire.setTime(today.getTime() + 3600000*24*3000);
        document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString() + ";path=/";
}
function readCookie(cookieName) {
        var theCookie=""+document.cookie;
        var ind = theCookie.indexOf(cookieName);
        if (ind == -1 || cookieName == ""){
                setCookie('fontSize',intMidFontSize);
                return intMidFontSize;
        }
        var ind1 = theCookie.indexOf(';',ind);
        if (ind1 == -1) ind1 = theCookie.length;
        return unescape(theCookie.substring(ind + cookieName.length + 1,ind1));
}
/*----------------------------------------*/
function reDo() {
        //if (innerWidth != origWidth || innerHeight != origHeight)
           // location.reload();
}
onresize = reDo;

/*
arImLoad = ["barBg","barBgBl","bg","bgBl",
            "butBd","butBu","butTd","butTu",
            "tmbBg","tmbBgL","tmbBot","tmbTop"];

arImList = [];
for (counter in arImLoad) {
    arImList[counter] = new Image();
    arImList[counter].src = arImLoad[counter] + ".gif";
}
*/

docIncr = 8;
barWidth = 16;
thumbMinHeight = 10;

origInt = 500;
repeatInt = 50;

initTimer = null;
scrollTimer = null;
bgTimer = null;
thumbTimer = null;

curY = null;
butImage = null;

pageLoaded = false;
onload = initScroll;

function initScroll(){
        if (arguments[0]){
                if (Browser.IE && Browser.Mac){
                        return;
                }
        }
        if (Browser.Opera){
                InitialiseScrollableAreaOpera();
                return;
        }
        if (document.getElementById || Browser.IE4){ // kosher
                // read the cookie to get the proper font size, set to default 12 if a first timer
                fs = parseInt(readCookie('fontSize'));
//                if (!fs > 0) fs = 10;
                if (!fs > 0) fs = intMidFontSize;
                setFontSize('longstory',fs);
        }
        if (Browser.NS4){
                if (blnInitFont && useCookie){
                        blnInitFont = false;
                        fontResize('longstory','0');
                }
                else{
                        makeScroll();
                }
        }
        if (Browser.NS6){
                document.getElementById('longstory').style.height = cmpage.y2 - intScreenItemsHeight  - intScreenOffset;
                document.getElementById('longstory').style.width = intScrollTextWidth;
        }
}
/*----------------------------------------*/
function makeScroll(){
        elCont =  document.rela;
        elMain =  document.rela.document.elMain;
        elScroll = document.rela.document.elScroll;

        var intRest = cmpage.y2 - intScreenItemsHeight - intScreenOffset + intScreenItemsHeightCorrection;
        var positionY = intScreenItemsHeight + intScreenOffset - intMenuBottomHeight;
        if((cmpage.x2 - 796) > 0 ){
                var positionX = parseInt(((cmpage.x2 - 796)/2) + (796 - intScrollTextWidth) + 1);
        }
        else{
                var positionX = parseInt(796 - intScrollTextWidth + 1);
        }

        document.rela.top = positionY;
        document.rela.left = positionX;

        var scrollH = intRest
        elMain.clip.height  = scrollH;
        elScroll.clip.height = scrollH;

        elScroll.document.elBGcol.clip.height = scrollH;
        elScroll.document.elBG.clip.height = scrollH;
        elScroll.document.elButtonBot.top = scrollH - 16;

        elMain.top = 0;

        if (elMain.origTop) elMain.top = elMain.origTop;
        elMain.origTop = elMain.top;
        elMain.clip.top = 0;

        if (elMain.origHeight) elMain.clip.height = elMain.origHeight;
        elMain.origHeight = elMain.clip.height;

        docHeight = elMain.document.height;
        lyrHeight = elMain.clip.height;

        var blnAlert = false;
        var strAlert = 'docHeight : ' + docHeight + '\n';
        strAlert += 'lyrHeight : ' + lyrHeight + '\n';
        strAlert += 'elMain.top : ' + elMain.top + '\n';
        strAlert += 'elMain.document.top : ' + elMain.document.top + '\n';
        strAlert += 'elMain.clip.height : ' + elMain.clip.height + '\n';
        strAlert += 'elScroll.clip.height : ' + elScroll.clip.height + '\n';

        if(blnAlert) alert(strAlert);
        document.rela.visibility = "show";

        if (docHeight <= lyrHeight){
                elScroll.visibility = "hide";
                return;
        }

        elThumb = elScroll.document.elThumb;
        elThumb.top = barWidth;
        elThumbBot = elThumb.document.elThumbBot;

        elvBarHeight = elScroll.clip.height - (barWidth*2);
        thumbHeight = Math.max((lyrHeight*elvBarHeight)/docHeight,thumbMinHeight)
        elThumb.clip.height = thumbHeight;

        elThumbBot.top = thumbHeight - elThumbBot.clip.height;
        thumbMaxTop = (elvBarHeight + barWidth) - thumbHeight;

        docToTravel = docHeight - lyrHeight;
        scrToTravel = elvBarHeight - thumbHeight;
        scrPixels = scrToTravel/docToTravel;
        docPixels = docToTravel/scrToTravel;

        upImage = elScroll.document.images[0];
        elButtonBot = elScroll.document.elButtonBot;
        downImage = elButtonBot.document.images[0];

        upImage.direction = 0;
        downImage.direction = 1;
        upImage.onmousedown = butDown;
        downImage.onmousedown = butDown;

        elThumb.captureEvents(Event.MOUSEDOWN);
        elThumb.onmousedown = thumbDown;

        elBG = elScroll.document.elBG;
        elBGcol = elScroll.document.elBGcol;
        elBG.captureEvents(Event.MOUSEDOWN);
        elBG.onmousedown = bgDown;

        elScroll.visibility="show";
}

function clearTimers() {
        clearTimeout(initTimer);
        clearInterval(scrollTimer);
        initTimer = scrollTimer = null;
        clearTimeout(bgTimer);
        clearInterval(thumbTimer);
        bgTimer = thumbTimer = null;
}

function butDown(e){
        butImage = e.target;
        dir = butImage.direction
        butImage.origSrc = butImage.src;
        butImage.src = (dir) ? "/global/img/common/butBd.gif" : "/global/img/common/butTd.gif";
        butImage.onmouseout = butOut;

        captureEvents(Event.MOUSEUP)
        onmouseup = butUp;

        butMove(dir);
        if(e.type=="mousedown") initTimer = setTimeout("scrollTimer = setInterval(butMove,repeatInt,dir)",origInt);
        else scrollTimer = setInterval(butMove,repeatInt,dir);
        return false;
}

function butMove(dir) {
        if ((dir && elMain.clip.top==docToTravel) || (!dir && elMain.clip.top==0)) {clearTimers();return}
        elMain.top = (dir) ? Math.max(elMain.top-docIncr,elMain.origTop-docToTravel) : Math.min(elMain.top+docIncr,elMain.origTop);
        elMain.clip.top = (dir) ? Math.min(elMain.clip.top+docIncr,docToTravel) : Math.max(elMain.clip.top-docIncr,0) ;
        elMain.clip.height = elMain.origHeight;
        elThumb.top = Math.min(Math.max(barWidth + (scrPixels*elMain.clip.top),barWidth),thumbMaxTop);
}

function butOut(){
        clearTimers();
        butImage.src = butImage.origSrc;
        butImage.onmouseover = butDown;
}

function butUp(){
        clearTimers();
        butImage.src = butImage.origSrc;
        butImage.onmouseout = null;
        butImage.onmouseover = null;
        releaseEvents(Event.MOUSEUP);
        return false;
}

function thumbDown(e) {
        curY = e.pageY;
        captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
        onmousemove = thumbMove;
        onmouseup = thumbUp;
        return false;
}

function thumbMove(e) {
        difY = e.pageY - curY;

        elThumb.top = Math.min(Math.max(elThumb.top+difY,barWidth),thumbMaxTop);
        docAlign();
        curY = e.pageY;
}

function thumbUp() {
        releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}

function docAlign(){
        thumbDiff = elThumb.top - barWidth;
        elMain.top = elMain.origTop - (thumbDiff*docPixels);
        elMain.clip.top = (thumbDiff*docPixels);
        elMain.clip.height = elMain.origHeight;
}

function bgDown(e){
        dir = (e.pageY < elThumb.pageY) ? -1 : 1;
        captureEvents(Event.MOUSEUP);
        onmouseup = bgUp;
        bgMove(e);
        ev = e;
        bgTimer = setTimeout("thumbTimer = setInterval(bgMove,repeatInt,ev)",origInt);
        return false;
}

function bgMove(e){
        if (e.pageY > elThumb.pageY && e.pageY <= elThumb.pageY+elThumb.clip.height) {bgUp();return}

        elThumb.top = Math.min(Math.max(elThumb.top + elThumb.clip.height * dir,barWidth),thumbMaxTop);
        elBGcol.top = (dir==1) ? elThumb.top : barWidth;
        elBGcol.clip.bottom = (dir==1) ? scrToTravel : elThumb.top-barWidth;
        elBGcol.moveAbove(elBG);
        docAlign();
}

function bgUp(){
        clearTimers();
        releaseEvents(Event.MOUSEUP);
        elBG.moveAbove(elBGcol);
        return false;
}

function loadnew(num){
        switch (num) {
                case 0:
                        newFile = "oscar.html";
                        break;
                case 1:
                        newFile = "raven.html";
                        break;
                case 2:
                        newFile = "usher.html";
                        break;
        }

        elMain.load(newFile,376)
}
/*----------------------------------------*/
        function verifyCompatibleBrowserOpera(){
                this.ver=navigator.appVersion
                this.dom=document.getElementById?1:0
                this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
                this.ie4=(document.all && !this.dom)?1:0;
                this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
                this.ns4=(document.layers && !this.dom)?1:0;
                this.bwOpera=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
                return this;
        }

        bwOpera = new verifyCompatibleBrowserOpera();

        var blnInitialisedOpera;
        var intspeedOpera = 50;
        var blnLoop, blnTimer;

        function ConstructObjectOpera(obj,nest){
                nest = (!nest) ? '':'document.'+ nest +'.'
                this.el = bwOpera.dom?document.getElementById(obj):bwOpera.ie4?document.all[obj]:bwOpera.ns4?eval(nest+'document.'+obj):0;
                this.css = bwOpera.dom?document.getElementById(obj).style:bwOpera.ie4?document.all[obj].style:bwOpera.ns4?eval(nest+'document.'+obj):0;
                this.scrollHeight = bwOpera.ns4 ? this.css.document.height : this.el.offsetHeight;
                this.clipHeight = bwOpera.ns4 ? this.css.clip.height : this.el.offsetHeight;
                this.up = MoveAreaUpOpera; this.down = MoveAreaDownOpera;
                this.MoveAreaOpera = MoveAreaOpera; this.x; this.y;
                this.obj = obj + "Object";
                eval(this.obj + "=this");
                return this;
        }

        function MoveAreaOpera(x,y){
                this.x = x;
                this.y = y;
                this.css.le;
                ft = this.x;
                this.css.top = this.y;
        }

function MoveAreaDownOpera(move){
  if(this.y>-this.scrollHeight+objContainerOpera.clipHeight){
    this.MoveAreaOpera(0,this.y-move)
    if(blnLoop) setTimeout(this.obj+".down("+move+")",intspeedOpera)
  }
}

function MoveAreaUpOpera(move){
        if(this.y < 0){
                this.MoveAreaOpera(0,this.y-move);
                if(blnLoop){
                        setTimeout(this.obj+".up("+move+")",intspeedOpera);
                }
        }
}

        function PerformScrollOpera(intSpeed){
                if(blnInitialisedOpera){
                        blnLoop = true;
                        if(intSpeed > 0){
                                objScrollerOpera.down(intSpeed);
                        }
                        else{
                                objScrollerOpera.up(intSpeed)
                        }
                }
        }

function CeaseScrollOpera(){
    blnLoop=false;
    if(blnTimer) clearTimeout(blnTimer)
}

function InitialiseScrollableAreaOpera(){
        preloadImagesOpera('/global/img/common/butTd.gif','/global/img/common/butBd.gif');

        if (Browser.Opera){
                var divCont = document.getElementById('divContainerOP');
                var divText = document.getElementById('divContentOP');
                var butUp = document.getElementById('divUpControlOP');
                var butDown = document.getElementById('divDownControlOP');
                var butBar = document.getElementById('divBarControlOP');
        }

        if (Browser.IE4){
        /*
                var divCont        = document.all['divContainerOP'];
                var divText        = document.all['divContentOP'];
                var butUp        = document.all['divUpControlOP'];
                var butDown        = document.all['divDownControlOP'];
                var butBar        = document.all['divBarControlOP'];

                var strAlert = "";
                strAlert += "divCont: " + divCont + "\n";
                strAlert += "divText: " + divText + "\n";
                strAlert += "butUp: " + butUp + "\n";
                strAlert += "butDown: " + butDown + "\n";
                strAlert += "butBar: " + butBar + "\n";

                strAlert += "divCont.style.top: " + divCont.style.top + "\n";
                strAlert += "divCont.style.left: " + divCont.style.left + "\n";
                strAlert += "divCont.style.height: " + divCont.style.height + "\n";
                strAlert += "butUp.style.top: " + butUp.style.top + "\n";
                strAlert += "butUp.style.left: " + butUp.style.left + "\n";
                //alert(strAlert);
        */
        }

        var intRest = cmpage.y2 - intScreenItemsHeight - intScreenOffset + intScreenItemsHeightCorrection;
        var positionY = intScreenItemsHeight + intScreenOffset - intMenuBottomHeight;

        if((cmpage.x2 - 796) > 0 ){
                var positionX = parseInt(((cmpage.x2 - 796)/2) + (796 - intScrollTextWidth) + 1);
        }
        else{
                var positionX = parseInt(796 - intScrollTextWidth + 1);
        }

        divCont.style.top = positionY;
        divCont.style.left = positionX;
        divCont.style.height = intRest - 2;
        butUp.style.top = divCont.style.top;
        butUp.style.left = eval(divCont.style.left + divCont.style.width - 1);

        butBar.style.top = butUp.style.top;
        butBar.style.left = butUp.style.left;
        butBar.style.height = divCont.style.height;

        butDown.style.top = divCont.style.top + divCont.style.height - butDown.style.height - 2;
        butDown.style.left = divCont.style.left + divCont.style.width - 1;

        if(divText.offsetHeight < divCont.offsetHeight){
                butUp.style.visibility ='hidden';
                butDown.style.visibility ='hidden';
                butBar.style.visibility ='hidden';
        }
        else{
                butUp.style.visibility ='visible';
                butDown.style.visibility ='visible';
                butBar.style.visibility ='visible';
        }

         objContainerOpera = new ConstructObjectOpera('divContainerOP')
    objScrollerOpera = new ConstructObjectOpera('divContentOP','divContainerOP')
    objScrollerOpera.MoveAreaOpera(0,0)
    objContainerOpera.css.visibility='visible'
    blnInitialisedOpera = true;
}
function displayStatusMsgOpera(msgStr) {
  status = msgStr;
  document.returnValue = true;
}

function preloadImagesOpera() {
  var d = document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j = d.p.length,a=preloadImagesOpera.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function swapImgRestoreOpera() {
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObjOpera(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObjOpera(n,d.layers[i].document); return x;
}

function swapImageOpera() {
  var i,j=0,x,a=swapImageOpera.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObjOpera(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*----------------------------------------*/

