// global var that keeps track of current width to use with animDivOpen()
var gWidthOpen = 0;
// global var that keeps track of current height to use with animDivOpen()
var gHeightOpen = 0;

// global var that keeps track of current width to use with animDivClose()
var gWidthClose = 0;
// global var that keeps track of current height to use with animDivClose()
var gHeightClose = 0;

var isFlashFolded = false;
var isFrameClosed = false;

window.onload = function(){

    left = 0;

    switch( screen.width ) {

        case 1024:
            left = '0%';
            break;

        case 1280:
            left = '10%';
            break;

        case 1440:
            left = '13%';
            break;

        default:

    }

    if( document.getElementById("Table_01") )
        document.getElementById("Table_01").style.left = left;

}

function flashFold( ){
    setWidth( "banner", 370 );
    setHeight( "banner", 519 );
    
    document.getElementById( "qFrame" ).innerHTML =
        '<iframe frameborder="0" id="qwertyFrame" />';
        
    isFlashFolded = true;
}

function animDivOpen( id, width, height, Interval ){
    
    resize = false;
    
//    if( !gWidthOpen ) {
//        gWidthOpen  = width;
//        width = 0
//    }

    if( !gHeightOpen ) {
        gHeightOpen = height;
        height = 0
    }
    
//    if( gWidthOpen > width ) {
//        width += 10;
//        resize |= true;
//    }

    if( gHeightOpen > height ) {
        height += 10;
        resize |= true;
    }


    if( resize ) {
//        setWidth( id, width );
        setHeight( id, height );
    } else {
        gHeightOpen = 0
        gWidthOpen = 0
        return;
    }
    
    setTimeout( "animDivOpen( '" + id + "', " + width + ", " + height + 
                ',' + Interval + ");", Interval );
    
}

function animDivClose( id, width, height, Interval ){
    
    resize = false;
    
//    if( !gWidthClose ) {
//        gWidth  = width;
//        width = 0
//    }

    if( !gHeightClose ) {
        gHeightClose = height;
        height = getHeight( id );
    }
    
//    if( gWidthClose < width ) {
//        width -= 10;
//        resize |= true;
//    }

    if( gHeightClose < height ) {
        height -= 10;
        resize |= true;
    }
    
    alert( resize + ' :: ' + gHeightClose + ' :: ' + height );
    if( resize ) {
//        setWidth( id, width );
        setHeight( id, height );
    } else {
        isFrameClosed = true;
        return;
    }
            
    setTimeout( "animDivClose( '" + id + "', " + width + ", " + height + 
                ',' + Interval + ");", Interval );
    
}

function setWidth( id, width ){
    document.getElementById( id ).style.width = width + 'px';
}

function getWidth( id ){
    return (document.getElementById( id ).style.width).replace( /px/i, '' );
}

function setHeight( id, height ){
    document.getElementById( id ).style.height = height + 'px';
}

function getHeight( id ){
    return (document.getElementById( id ).style.height).replace( /px/i, '' );
}

function switchFrame( btnName ) {
    
    if( !isFlashFolded )
        flashFold();
    
    switch( btnName ) {
        case 1:
            url = "whois.html";
            break;

        case 5:
            url = "contact.html";
            break;

        case 6:
            url = "map.html";
            break;

        case 3:
            url = "gallery/index.html";
            break;

        case 4:
            url = "absolut/index.php";
            break;

        case 2:
            url = "service.html";
            break;

        default:
            url = "default.html";
            break;
    }
    
//    animDivClose( "qwertyFrame", 1, 1, 1 );

    document.getElementById("qwertyFrame").src = url;
    
    animDivOpen( "qwertyFrame", 463, 520, 30 );
    
}
