var timer;
var match_rule;
var enableSiteRule;

function setPPos(state)
{
        loc  = new Array();

        // OPTIONS:
        // this variables manage the reversed (starting from right-bottom)
        // relative positions
        if(document.all){
                // for the early microsoft internet explorer 4 versions
                theight = 35;
                twidth  = 130;
        }else if(document.layers){
                // for the good old netscape 4 family
                theight = 35;
                twidth  = 130;
        }else if(document.getElementById){
                // and finally for modern browsers that include
                // the newer dom (Netscape6, mozilla, ie)
                theight = 35;
                twidth  = 130;
        }

        // define wether the layer hast to disappear at a specific resolution
        // true = enable, false = do not enable
        enableSiteRule = false;

        // define here at which (inner) non-reversed resolution (top-left) the layer has to disappear
        // only if you have enabled thw site rule
        rule_width  = 750;
        rule_height = 300;

        // this array contains the sites where the resolution rules above will be affected
        // you can simply add a file where the rule has to be affected (no url, just the filename!)
        // if you want to define rules, uncomment this block out


        // get the (crossbrowser)heights ...
        if(document.all){
                inner_height = document.body.clientHeight - theight;
                inner_width  = document.body.clientWidth  - twidth;
        }else if(document.layers || document.getElementById){
                inner_height = window.innerHeight - theight;
                inner_width  = window.innerWidth  - twidth;
        }

        // rules for sites which contain e.g. flash-movies, inputs etc.
        if(enableSiteRule){
                locl = loc.length;
                for(i=0;i<locl;i++){
                        if(document.location.href.indexOf(loc[i])!=-1){
                                if(inner_width < rule_width || inner_height < rule_height){
                                        match_rule = true;
                                }else{
                                        match_rule = false;
                                }
                        }
                }
        }else{
                match_rule = false;
        }

        // crossbrowser starts here ...
        if(document.all){
                if(state=='onload'){
                        Layer1.style.pixelTop   = inner_height;
                        Layer1.style.pixelLeft  = inner_width;
                }
                if(match_rule==true){
                        Layer1.style.visibility = "hidden";
                }else{
                        Layer1.style.visibility = "visible";
                }
        }else if(document.layers){
                if(state=='onload'){
                        document.Layer1.pageY = inner_height;
                        document.Layer1.pageX = inner_width;
                }
                if(match_rule==true){
                        document.Layer1.visibility = "hide";
                }else{
                        document.Layer1.visibility = "show";
                }
        }else if(document.getElementById){
                if(state=='onload'){
                        //alert(document.getElementById('Layer1'));
                        document.getElementById('Layer1').style.top  = inner_height;
                        document.getElementById('Layer1').style.left = inner_width;
                }
                if(match_rule==true){
                        document.getElementById('Layer1').style.visibility = "hidden";
                }else{
                        document.getElementById('Layer1').style.visibility = "visible";
                }
        }

        // return the heights of inner window
        positions = inner_width+"#"+inner_height;
        return positions;
}

function scrollPPos(){
        // get return value of setPPos where the window heights are defined
        positions      = setPPos("xxx");
        positionsArray = positions.split("#");
        inner_width    = positionsArray[0];
        inner_height   = positionsArray[1];

        // crossbrowser starts here ... discovering new ways of mathmatics
        if(document.all){
                Layer1.style.pixelTop  = document.body.scrollTop  + inner_height * 0.999;
                Layer1.style.pixelLeft = document.body.scrollLeft + inner_width  * 0.999;
        }else if(document.layers){
                document.Layer1.pageY = pageYOffset + inner_height * 0.997;
                document.Layer1.pageX = pageXOffset + inner_width  * 0.997;
        }else if(document.getElementById){
                document.getElementById('Layer1').style.top  = pageYOffset + inner_height * 0.997;
                document.getElementById('Layer1').style.left = pageXOffset + inner_width  * 0.997;
        }

        timer = setTimeout("scrollPPos();",1);
}