/**
 * @author jonas@startsiden.no
 */

// resize something 
function getCa(intg) {
    switch(intg){
        case 3:
        case 4:
            return 24;
            break;
        case 5:
        case 6:
        case 7:
            return 14;
            break;
        case 8:
        default:
            return 10;
            break;
    }     
}

$().ready(function(){
	// set shadow size to the size of overlaying image + padding + borders
	$("ol.thumbs div.shadow").each(function(i){
	    $(this).width($(this).find("img").width() + 10); 
	});
    $("body").css("min-width", "750px")
   
    thumbs = $("ol.thumbs li");
    s = 195; /* li-thumb width */
    e = getCa(Math.floor($("#results").width() / s));
    $(thumbs).each(function(i){
        if((i > 13) && (e == 14)) {
            $(this).css("width", ""+(e + 2.5)+"%");
        }
        else {
            $(this).css("width", ""+e+"%");
        }
    });

   // $(thumbs).css("width", ""+getCa(Math.floor($("#results").width() / s))+"%");
    
});

    window.onresize = function(){
        if(thumbs.length < 20) return;

        w = $("#results").width();

        m = Math.floor(w / s);
        r = getCa(m);
        //$(thumbs).css("width", ""+getCa(m)+"%");
        $(thumbs).each(function(i){
            if((i > 13) && (r == 14)) {
                $(this).css("width", ""+(r + 2.5)+"%");
            }
            else {
                $(this).css("width", ""+r+"%");
            }
        });
    }