function clientHeightArea(){return (typeof(window.innerHeight)=='number')?window.innerHeight:( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight ) )? document.documentElement.clientHeight:(document.body && (document.body.clientWidth || document.body.clientHeight ) )?document.body.clientHeight:0;}
function clientWidthArea(){return myWidth=(typeof(window.innerWidth)=='number')?window.innerWidth:(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight ) )? document.documentElement.clientWidth:(document.body && (document.body.clientWidth || document.body.clientHeight))?document.body.clientWidth:0;}

function resize(){
    var szerokosc = clientWidthArea();
    var wysokosc = clientHeightArea();
    var content = document.getElementById('content');
    var root = document.getElementById('root');
    var contentRight = document.getElementById('contentRight');
    var navigationLine = document.getElementById('navigationLine');
    var navigationLineLeft = document.getElementById('navigationLineLeft');

    saveWindowSize();

    if(!AUTO_RESIZE){
        return false;
    }

    if(!is(root) || !is(content) || !is(contentRight)){
        return false;
    }
    
    if(szerokosc < MIN_WIDTH){
        szerokosc = MIN_WIDTH;
    }

    
    //lewy prawy margin na body
    szerokosc -= LAYER_ROOT_MARGIN;

    //glowny div
    root.style.width = szerokosc+'px';

    //lewy i prawy border 1px*2
    szerokosc -= LAYER_CONTENT_MARGIN;
    content.style.width = szerokosc+'px';
    
    //200px na menu
    szerokosc -=LAYER_CONTENT_MENU_WIDTH;
    //paddingi warstwy contentRight 10+20
    szerokosc -= LAYER_CONTENT_LEFT_PADDING;//?

    //wolne miejsce z prawej strony za warstwa
    szerokosc -= LAYER_CONTENT_RIGHT_PADDING;
    contentRight.style.width = (szerokosc)+'px';
    //jesli a stronie istnieja taby to policz ponownie ich rozmiary.
    
    if(is(navigationLine) && is(navigationLineLeft)){
        navigationLine.style.width = (szerokosc-LAYER_CONTENT_CONTAINER_BORDER-LAYER_CONTENT_CONTAINER_PADDING)+'px';

        navigationLineLeft.style.width = (szerokosc - LAYER_CONTENT_CONTAINER_BORDER - LAYER_CONTENT_CONTAINER_PADDING-LAYER_NAVIGATION_LINE_RIGHT_WIDTH-LAYER_CONTENT_RIGHT_PADDING-3)+'px';//3piksle 
    }

    if(existTabs){
        tabOptions();
    }
}

function saveWindowSize(){
    var szerokosc = clientWidthArea();
    var wysokosc = clientHeightArea();
    setCookie('width', szerokosc, 31);
    setCookie('height', wysokosc, 31);    
}
