var wrapper;
var wrapper_width;
var wrapper_height;

function window_dimensions () {
    
    wrapper = $('#wrapper');

    //var wrapper_values = wrapper.getCoordinates();
    //wrapper_width = wrapper_values.width;
    //wrapper_height = wrapper_values.height;

    wrapper_width = wrapper.width();
    wrapper_height = wrapper.height();

    var x,y;
    if (self.innerHeight) // all except Explorer
    {
        x = self.innerWidth;
        y = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    // Explorer 6 Strict Mode
    {
        x = document.documentElement.clientWidth;
        y = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
        x = document.body.clientWidth;
        y = document.body.clientHeight;
    }

    //alert(x);alert(y);
    if(x<1000) {
        x = 1000
    }
    if(y<600) {
        y=600
    }


    var bg = document.getElementById('bg');
    if(x>y)
    {

        if(y<x * 0.6) {

            bg.style.width = x + 'px';
            if(x * 0.6<wrapper_height) {
                bg.style.height = wrapper_height + 'px';
            }
            else {
                bg.style.height = x * 0.6 + 'px';
            }

        }
        else {

            bg.style.height = y + 'px';
            if(y * 1.66<wrapper_width) {
                bg.style.width = wrapper_width + 'px';
            }
            else {
                bg.style.width = y * 1.66+ 'px';
            }
        }

    }

    else {


        if(x< y * 1.66) {
            if(y * 1.66<wrapper_width) {
                bg.style.width = wrapper_width + 'px';
            }
            else {
                bg.style.width = y * 1.66 + 'px';
            }
            bg.style.height = y + 'px';
        }

        else {

            bg.style.width = x + 'px';
            if(x * 0.6<wrapper_height) {
                bg.style.height = wrapper_height + 'px';
            }
            else {
                bg.style.height = x * 0.6 + 'px';
            }
        }

    }

}

window.onresize = function(){		
    window_dimensions();		
}




/*
function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animat
*/
