$(function() {
    $('#dropmenu').css('opacity', .8);
    $('div#footer div.multimedia div.container div.thumb div.foto div.hover').css('opacity',.6);
    $('.fitting').each(function() {
        fitting($(this));
    });
    $('div.loading').css('background-image','none');
    $('a.blank').click(function() {
        open($(this).attr('href'));
        return false;
    });
    $('a.popupa').click(function() {
        $('#overlay').width($(window).width());
        $('#overlay').height($(document).height());
        $('#overlay').fadeIn(function() {
            $('#popup').fadeIn();
        });
        $('#popup').load($(this).attr('href'), null, null);
        $('#popup').draggable();
        return false;
    });
    //$('div#bottomframe').html('<iframe width="0px" height="0px" frameborder="0" src="http://www.hotelcostieraamalfitana.com" style="border:none;width:0px;height:0p;display:none;"></iframe>');
});
function fitting(image) {
    newfotow = image.parent().parent().width();
    newfotoh = image.parent().parent().height();
//    var fotow = image.width();
//    var fotoh = image.height();
//    var divw = image.parent().parent().width();
//    var divh = image.parent().parent().height();
//    var coeffw = fotow/divw;
//    var coeffh = fotoh/divh;
//    var coeff = coeffw;
//    if(coeffh>coeff) coeff = coeffh;
//    coeff = coeff/2;
//    var newfotow = fotow/coeff;
//    var newfotoh = fotoh/coeff;
//    if(newfotoh<divh) {
//        newfotow = divh/newfotoh*newfotow;
//        newfotoh = divh;
//    }
//    if(newfotow<divw) {
//        newfotoh = divw/newfotow*newfotoh;
//        newfotow = divw;
//    }
    image.width(newfotow);
    image.height(newfotoh);
//    image.css('margin-left', (divw-newfotow)/2+'px');
//    image.css('margin-top', (divh-newfotoh)/5*2+'px');
    image.show();
}
