$(function () {
	var $jqlayer = $('#layer50E95956A61094BB9F680E76DEC7073C');

	$jqlayer.triggerHandler("modresize");

	$jqlayer.data("nodemap", {"title":".boxli .imgtitle","img":".imgdiv","imgdiv":".imgdiv","boxli":".boxli"});
});

window.addEventListener('load', function () {
	var isThumb = '1';
	if (isThumb == 2) {
		$('#layer50E95956A61094BB9F680E76DEC7073C .wp-friend_link_content .boxli .images').each(function (i, v) {
			pic_thumb_50E95956A61094BB9F680E76DEC7073C(this);
		});
	}
});

function pic_thumb_50E95956A61094BB9F680E76DEC7073C(img) {
	img = $(img);
	var maxWidth = parseInt(img.css('width')); 
    var maxHeight = parseInt(img.css('height'));
    AutoResizeImage50E95956A61094BB9F680E76DEC7073C(maxWidth,maxHeight,img[0]);  
}

function AutoResizeImage50E95956A61094BB9F680E76DEC7073C(maxWidth, maxHeight, objImg) {
    var img = new Image();
    img.src = objImg.src;
    var hRatio;
    var wRatio;
    var Ratio = 1;
    var w = img.width;
    var h = img.height;
    wRatio = maxWidth / w;
    hRatio = maxHeight / h;
    if (maxWidth == 0 && maxHeight == 0) {
        Ratio = 1;
    } else if (maxWidth == 0) { //
        if (hRatio < 1) Ratio = hRatio;
    } else if (maxHeight == 0) {
        if (wRatio < 1) Ratio = wRatio;
    } else if (wRatio < 1 || hRatio < 1) {
        Ratio = (wRatio <= hRatio ? wRatio : hRatio);
    }
    if (Ratio < 1) {
        w = w * Ratio;
        h = h * Ratio;
    }
    if(h < maxHeight){
        //$(objImg).css({'margin-top':((maxHeight - h) / 2)+'px'});
    }
    if (w < maxWidth) {
    	//$(objImg).css({'margin-left':((maxWidth - w) / 2)+'px'});
    }
    $(objImg).css({'height':h,'width':w});
}