if (typeof(MGI) == "undefined") {
     MGI = {};
}

if(typeof(MGI.GigView) === "undefined"){
    MGI.GigView = {};
}

MGI.GigView.onClickSetFlyer = function(e){
    EUNIT.log("onClickSetFlyer");
    $.fn.nyroModalManual({
        content: $('#setflyer'),
        bgColor: '#111111',
        width: 500,
        height: 600
    });
};

MGI.GigView.scaleFlyer = function(){
    //scale the flyer image so that it fits in the container div while 
    //preserving the aspect ratio
    var dw = $(".flyer").width();
    var dh = $(".flyer").height();
    var img = $(".flyer > a > img");
    var iw = img.width();
    var ih = img.height();
    
    var xscale = dw/iw;
    var yscale = dh/ih;
    
    if(iw <= dw && ih <= dh){
        //don't do anything, just leave the image there!
    }else if(iw * xscale <= dw){
        img.width(Math.round(iw * xscale));
        img.height(ih*xscale);
    }else{
        img.height(Math.round(ih * yscale));
        img.width(iw*yscale);        
    }
    
    img.removeClass("invisible");
};

$(document).ready(function(){
    //$('div.noflyer').click(MGI.GigView.onClickSetFlyer);
    //$("img.flyer").click(MGI.GigView.onClickFlyer())
    // $("a.nyromodal").nyroModal({
    //     width:300,
    //     height:150
    // });
});