function resizeback() {
    var window_width = jQuery(window).width();
    var window_height = jQuery(window).height();
    var window_rapp = window_width / window_height;

    jQuery('#myvideo').css('height', window_height - 100);
    jQuery('#myvideo').css('width', window_width - jQuery('#BoxSx').offset().left-290);
    

    var image_width = parseInt(jQuery('#back').width());
    if (image_width < 200) return;
    if (image_width == 0) return;
    var image_height = parseInt(jQuery('#back').height());
    var image_rapp = image_width / image_height;


  
    
    if (image_rapp > window_rapp) {
        var scale_rapp = image_height / window_height;
        var new_height = image_height / scale_rapp;
        var new_width = image_width / scale_rapp;
        jQuery('#back').css('height', new_height);
        jQuery('#back').css('width', new_width);

        jQuery('#back').css('left', '0');
        jQuery('#back').css('top', '0');
        if (new_width > window_width) {
            var half = (new_width - window_width) / 2;
            jQuery('#back').css('left', -half);
        }


    }
    else {
        //alert(image_rapp + ' ' + window_rapp);
        var scale_rapp = image_width / window_width;
        var new_height = image_height / scale_rapp;
        var new_width = image_width / scale_rapp;
        jQuery('#back').css('height', new_height);
        jQuery('#back').css('width', new_width);

        jQuery('#back').css('left', '0');
        jQuery('#back').css('top', '0');
        if (new_height > window_height) {
            var half = (new_height - window_height) / 2;
            jQuery('#back').css('top', -half);
        }



    }

    if (jQuery('#SpazioArticoli') != null) {
        var window_height = jQuery(window).height()-180;
        jQuery('#SpazioArticoli').css('height', window_height);
    }

    return;
}
jQuery(document).ready(function() {
    resizeback();
    //jQuery('#back').mouseover(function() { alert('ciao'); });
    var items = jQuery('.DivStripGray a');

    for (var i = 0; i < items.length; i++) {
        var a = items[i];
        jQuery(a).mouseover(function() {
            var path = jQuery(this).find('img').attr('src');
            var newpath = path.replace('/gray/', '/high/');
            jQuery(this).find('img').attr('src', newpath);
        });
        jQuery(a).mouseout(function() {

        var path = jQuery(this).find('img').attr('src');
        var newpath = path.replace('/high/', '/gray/');
        jQuery(this).find('img').attr('src', newpath);
        
        });

    }

});

jQuery(window).resize(function() {
    resizeback();
});

function Altezza() {
    screenHeight = document.body.parentNode.clientHeight - 80 + "px";
    if (document.getElementById("BoxSx") != null)
    document.getElementById("BoxSx").style.height = screenHeight;

    screenHeight = document.body.parentNode.clientHeight - 580 + "px";
    if (document.getElementById("SpcNews") != null)
    document.getElementById("SpcNews").style.height = screenHeight;

    resizeback();
    return;
}
